mirror of
				https://github.com/Kopano-dev/kopano-ol-extension.git
				synced 2023-10-10 11:37:40 +00:00 
			
		
		
		
	[KOE-113] Removed old debug code from restarter, added logging. Also now including version numbers in OutlookRestarter and PluginDebugger.
This commit is contained in:
		@@ -1,4 +1,6 @@
 | 
			
		||||
/// Copyright 2017 Kopano b.v.
 | 
			
		||||
 | 
			
		||||
using Acacia;
 | 
			
		||||
/// Copyright 2017 Kopano b.v.
 | 
			
		||||
/// 
 | 
			
		||||
/// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
/// it under the terms of the GNU Affero General Public License, version 3,
 | 
			
		||||
@@ -13,7 +15,6 @@
 | 
			
		||||
/// along with this program.If not, see<http://www.gnu.org/licenses/>.
 | 
			
		||||
/// 
 | 
			
		||||
/// Consult LICENSE file for details
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
@@ -25,7 +26,7 @@ using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace OutlookRestarter
 | 
			
		||||
{
 | 
			
		||||
    class Program
 | 
			
		||||
    class OutlookRestarter
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
@@ -40,6 +41,8 @@ namespace OutlookRestarter
 | 
			
		||||
        [STAThread]
 | 
			
		||||
        static void Main(string[] args)
 | 
			
		||||
        {
 | 
			
		||||
            Logger.Instance.Debug(typeof(OutlookRestarter), "Restarting: {0}", string.Join(", ", args));
 | 
			
		||||
 | 
			
		||||
            string procPath = args[1];
 | 
			
		||||
            List<string> procArgs = args.Skip(2).ToList();
 | 
			
		||||
            try
 | 
			
		||||
@@ -47,10 +50,13 @@ namespace OutlookRestarter
 | 
			
		||||
                // Attempt waiting for the process to finish
 | 
			
		||||
                int procId = int.Parse(args[0]);
 | 
			
		||||
                Process proc = Process.GetProcessById(procId);
 | 
			
		||||
                proc.WaitForExit(15000);
 | 
			
		||||
                Logger.Instance.Debug(typeof(OutlookRestarter), "Waiting for process to exit: {0}: {1}", procId, proc);
 | 
			
		||||
                bool finished = proc.WaitForExit(15000);
 | 
			
		||||
                Logger.Instance.Debug(typeof(OutlookRestarter), "Waited for process to exit: {0}: {1}", procId, finished);
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            {
 | 
			
		||||
                Logger.Instance.Debug(typeof(OutlookRestarter), "Parsing arguments");
 | 
			
		||||
                List<string> useArgs = new List<string>();
 | 
			
		||||
                for (int i = 0; i < procArgs.Count; ++i)
 | 
			
		||||
                {
 | 
			
		||||
@@ -58,14 +64,19 @@ namespace OutlookRestarter
 | 
			
		||||
                    {
 | 
			
		||||
                        ++i;
 | 
			
		||||
                        string path = procArgs[i];
 | 
			
		||||
                        Logger.Instance.Debug(typeof(OutlookRestarter), "Request to remove store: {0}", path);
 | 
			
		||||
                        if (System.IO.Path.GetExtension(path) == ".ost")
 | 
			
		||||
                        {
 | 
			
		||||
                            Logger.Instance.Info(typeof(OutlookRestarter), "Removing store: {0}", path);
 | 
			
		||||
                            // Delete it
 | 
			
		||||
                            try
 | 
			
		||||
                            {
 | 
			
		||||
                                System.IO.File.Delete(path);
 | 
			
		||||
                            }
 | 
			
		||||
                            catch (Exception) { }
 | 
			
		||||
                            catch (Exception e)
 | 
			
		||||
                            {
 | 
			
		||||
                                Logger.Instance.Error(typeof(OutlookRestarter), "Exception removing store: {0}: {1}", path, e);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
@@ -73,12 +84,14 @@ namespace OutlookRestarter
 | 
			
		||||
                        useArgs.Add(procArgs[i]);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                File.WriteAllLines("c:\\temp\\ol.txt", useArgs);
 | 
			
		||||
                string argsString = string.Join(" ", useArgs);
 | 
			
		||||
                Logger.Instance.Debug(typeof(OutlookRestarter), "Parsed arguments: {0}", argsString);
 | 
			
		||||
                // Start the process
 | 
			
		||||
                Process process = new Process();
 | 
			
		||||
                process.StartInfo = new ProcessStartInfo(procPath, argsString);
 | 
			
		||||
                Logger.Instance.Debug(typeof(OutlookRestarter), "Starting process: {0}", process);
 | 
			
		||||
                process.Start();
 | 
			
		||||
                Logger.Instance.Debug(typeof(OutlookRestarter), "Started process: {0}", process);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -49,8 +49,9 @@
 | 
			
		||||
    <Reference Include="System.Xml" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Compile Include="Program.cs" />
 | 
			
		||||
    <Compile Include="OutlookRestarter.cs" />
 | 
			
		||||
    <Compile Include="Properties\AssemblyInfo.cs" />
 | 
			
		||||
    <Compile Include="Version.cs" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <None Include="App.config" />
 | 
			
		||||
@@ -58,6 +59,12 @@
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Content Include="Kopano.ico" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <ProjectReference Include="..\AcaciaZPushPlugin\AcaciaZPushPlugin.csproj">
 | 
			
		||||
      <Project>{1a7427a5-f814-4b07-98b2-c67d758b65d6}</Project>
 | 
			
		||||
      <Name>AcaciaZPushPlugin</Name>
 | 
			
		||||
    </ProjectReference>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 | 
			
		||||
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
 | 
			
		||||
       Other similar extension points exist, see Microsoft.Common.targets.
 | 
			
		||||
 
 | 
			
		||||
@@ -37,16 +37,3 @@ using System.Runtime.InteropServices;
 | 
			
		||||
 | 
			
		||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
 | 
			
		||||
[assembly: Guid("222c4da5-fa31-471a-b127-5e0c6ad2cb3c")]
 | 
			
		||||
 | 
			
		||||
// Version information for an assembly consists of the following four values:
 | 
			
		||||
//
 | 
			
		||||
//      Major Version
 | 
			
		||||
//      Minor Version 
 | 
			
		||||
//      Build Number
 | 
			
		||||
//      Revision
 | 
			
		||||
//
 | 
			
		||||
// You can specify all the values or you can default the Build and Revision Numbers 
 | 
			
		||||
// by using the '*' as shown below:
 | 
			
		||||
// [assembly: AssemblyVersion("1.0.*")]
 | 
			
		||||
[assembly: AssemblyVersion("1.0.0.0")]
 | 
			
		||||
[assembly: AssemblyFileVersion("1.0.0.0")]
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								src/AcaciaZPushPlugin/OutlookRestarter/Version.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/AcaciaZPushPlugin/OutlookRestarter/Version.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
/// Copyright 2016 Kopano b.v.
 | 
			
		||||
/// 
 | 
			
		||||
/// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
/// it under the terms of the GNU Affero General Public License, version 3,
 | 
			
		||||
/// as published by the Free Software Foundation.
 | 
			
		||||
/// 
 | 
			
		||||
/// This program is distributed in the hope that it will be useful,
 | 
			
		||||
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
 | 
			
		||||
/// GNU Affero General Public License for more details.
 | 
			
		||||
/// 
 | 
			
		||||
/// You should have received a copy of the GNU Affero General Public License
 | 
			
		||||
/// along with this program.If not, see<http://www.gnu.org/licenses/>.
 | 
			
		||||
/// 
 | 
			
		||||
/// Consult LICENSE file for details
 | 
			
		||||
 | 
			
		||||
using System.Reflection; 
 | 
			
		||||
[assembly: AssemblyVersion("0.1")] 
 | 
			
		||||
[assembly: AssemblyFileVersion("0.1")] 
 | 
			
		||||
public static class BuildVersions 
 | 
			
		||||
{ 
 | 
			
		||||
    public const string VERSION = "0.1"; 
 | 
			
		||||
    public const string REVISION = "abcdef0123456789abcdef0123456789abcdef01"; 
 | 
			
		||||
} 
 | 
			
		||||
		Reference in New Issue
	
	Block a user