Exemplo n.º 1
0
        public void OnObjectChanged(object sender, EventArgs e)
        {
            _instance = sender as ChoGlobalApplicationSettings;
            ChoApplication.Refresh();

            ChoEventManager.GetValue(GetType()).OnObjectChanged(sender, e);
        }
Exemplo n.º 2
0
        static ChoAppDomain()
        {
            //ChoApplication.Initialize();
            RegisterAppDomainEvents();
            string envPath = ChoEnvironmentSettings.GetConfigFilePath();
            ChoGlobalApplicationSettings x = ChoGlobalApplicationSettings.Me;

            ChoApplication.Refresh();
            ChoTypesManager.Initialize();
            ChoAbortableQueuedExecutionService asyncExecutionService = ChoAbortableQueuedExecutionService.Global;

            _Load();
        }
Exemplo n.º 3
0
        public ChoApplicationHost()
        {
            ChoApplication.ApplyFrxParamsOverrides += ((sender, e) =>
            {
                ApplyFrxParamsOverrides(e.GlobalApplicationSettings, e.MetaDataFilePathSettings);

                using (ChoCommandLineArgParser parser = new ChoCommandLineArgParser())
                {
                    parser.Parse();
                    foreach (KeyValuePair <string, string> keyValuePair in parser)
                    {
                        if (keyValuePair.Key.ToUpper() == "I")
                        {
                            ChoApplication.ServiceInstallation = true;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.HideWindow = false;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.SingleInstanceApp = false;
                            e.GlobalApplicationSettings.DoAppendProcessIdToLogDir = false;
                            e.GlobalApplicationSettings.ApplicationName = "{0}.InstallService".FormatString(e.GlobalApplicationSettings.ApplicationNameWithoutExtension);
                            e.GlobalApplicationSettings.EventLogSourceName = "{0}.InstallService".FormatString(e.GlobalApplicationSettings.EventLogSourceName);
                            e.GlobalApplicationSettings.LogSettings.LogFileName = "{0}.InstallService".FormatString(e.GlobalApplicationSettings.LogSettings.LogFileName);
                            break;
                        }
                        else if (keyValuePair.Key.ToUpper() == "U")
                        {
                            ChoApplication.ServiceInstallation = true;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.HideWindow = false;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.SingleInstanceApp = false;
                            e.GlobalApplicationSettings.DoAppendProcessIdToLogDir = false;
                            e.GlobalApplicationSettings.ApplicationName = "{0}.UninstallService".FormatString(e.GlobalApplicationSettings.ApplicationNameWithoutExtension);
                            e.GlobalApplicationSettings.EventLogSourceName = "{0}.UninstallService".FormatString(e.GlobalApplicationSettings.EventLogSourceName);
                            e.GlobalApplicationSettings.LogSettings.LogFileName = "{0}.UninstallService".FormatString(e.GlobalApplicationSettings.LogSettings.LogFileName);
                            break;
                        }
                        else if (keyValuePair.Key.ToUpper() == "S")
                        {
                            ChoApplication.ServiceInstallation = true;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.HideWindow = false;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.SingleInstanceApp = false;
                            e.GlobalApplicationSettings.DoAppendProcessIdToLogDir = false;
                            e.GlobalApplicationSettings.ApplicationName = "{0}.StartService".FormatString(e.GlobalApplicationSettings.ApplicationNameWithoutExtension);
                            e.GlobalApplicationSettings.EventLogSourceName = "{0}.StartService".FormatString(e.GlobalApplicationSettings.EventLogSourceName);
                            e.GlobalApplicationSettings.LogSettings.LogFileName = "{0}.StartService".FormatString(e.GlobalApplicationSettings.LogSettings.LogFileName);
                            break;
                        }
                        else if (keyValuePair.Key.ToUpper() == "T")
                        {
                            ChoApplication.ServiceInstallation = true;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.HideWindow = false;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.SingleInstanceApp = false;
                            e.GlobalApplicationSettings.DoAppendProcessIdToLogDir = false;
                            e.GlobalApplicationSettings.ApplicationName = "{0}.StopService".FormatString(e.GlobalApplicationSettings.ApplicationNameWithoutExtension);
                            e.GlobalApplicationSettings.EventLogSourceName = "{0}.StopService".FormatString(e.GlobalApplicationSettings.EventLogSourceName);
                            e.GlobalApplicationSettings.LogSettings.LogFileName = "{0}.StopService".FormatString(e.GlobalApplicationSettings.LogSettings.LogFileName);
                            break;
                        }
                        else if (keyValuePair.Key.ToUpper() == "P")
                        {
                            ChoApplication.ServiceInstallation = true;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.HideWindow = false;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.SingleInstanceApp = false;
                            e.GlobalApplicationSettings.DoAppendProcessIdToLogDir = false;
                            e.GlobalApplicationSettings.ApplicationName = "{0}.PauseService".FormatString(e.GlobalApplicationSettings.ApplicationNameWithoutExtension);
                            e.GlobalApplicationSettings.EventLogSourceName = "{0}.PauseService".FormatString(e.GlobalApplicationSettings.EventLogSourceName);
                            e.GlobalApplicationSettings.LogSettings.LogFileName = "{0}.PauseService".FormatString(e.GlobalApplicationSettings.LogSettings.LogFileName);
                            break;
                        }
                        else if (keyValuePair.Key.ToUpper() == "C")
                        {
                            ChoApplication.ServiceInstallation = true;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.HideWindow = false;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.SingleInstanceApp = false;
                            e.GlobalApplicationSettings.DoAppendProcessIdToLogDir = false;
                            e.GlobalApplicationSettings.ApplicationName = "{0}.ContinueService".FormatString(e.GlobalApplicationSettings.ApplicationNameWithoutExtension);
                            e.GlobalApplicationSettings.EventLogSourceName = "{0}.ContinueService".FormatString(e.GlobalApplicationSettings.EventLogSourceName);
                            e.GlobalApplicationSettings.LogSettings.LogFileName = "{0}.ContinueService".FormatString(e.GlobalApplicationSettings.LogSettings.LogFileName);
                            break;
                        }
                        else if (keyValuePair.Key.ToUpper() == "E")
                        {
                            ChoApplication.ServiceInstallation = true;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.HideWindow = false;
                            e.GlobalApplicationSettings.ApplicationBehaviourSettings.SingleInstanceApp = false;
                            e.GlobalApplicationSettings.DoAppendProcessIdToLogDir = false;
                            e.GlobalApplicationSettings.ApplicationName = "{0}.ExecuteCommand".FormatString(e.GlobalApplicationSettings.ApplicationNameWithoutExtension);
                            e.GlobalApplicationSettings.EventLogSourceName = "{0}.ExecuteCommand".FormatString(e.GlobalApplicationSettings.EventLogSourceName);
                            e.GlobalApplicationSettings.LogSettings.LogFileName = "{0}.ExecuteCommand".FormatString(e.GlobalApplicationSettings.LogSettings.LogFileName);
                            break;
                        }
                    }
                }
            });

            ChoApplication.FatalApplicationException += FatalApplicationException;

            //ChoApplication.Initialize();
            ChoGlobalApplicationSettings x = ChoGlobalApplicationSettings.Me;

            ApplyServiceInstallParamsOverrides(ChoServiceProcessInstallerSettings.Me, ChoServiceInstallerSettings.Me);
            ServiceProcessInstaller processInstaller = new ServiceProcessInstaller();

            ChoApplication.WriteToEventLog(ChoServiceProcessInstallerSettings.Me.ToString());
            processInstaller.Account  = ChoServiceProcessInstallerSettings.Me.Account;
            processInstaller.Username = ChoServiceProcessInstallerSettings.Me.UserName;
            processInstaller.Password = ChoServiceProcessInstallerSettings.Me.Password;

            ChoApplication.WriteToEventLog(ChoServiceInstallerSettings.Me.ToString());
            ServiceInstaller serviceInstaller = new ServiceInstaller();

            serviceInstaller.DisplayName = ChoServiceInstallerSettings.Me.DisplayName.IsNullOrWhiteSpace() ? ChoGlobalApplicationSettings.Me.ApplicationNameWithoutExtension : ChoServiceInstallerSettings.Me.DisplayName;
            ServiceName = serviceInstaller.ServiceName = ChoServiceInstallerSettings.Me.ServiceName.IsNullOrWhiteSpace() ? ChoGlobalApplicationSettings.Me.ApplicationNameWithoutExtension : ChoServiceInstallerSettings.Me.ServiceName;
            serviceInstaller.StartType        = ChoServiceInstallerSettings.Me.ServiceStartMode;
            serviceInstaller.DelayedAutoStart = ChoServiceInstallerSettings.Me.DelayedAutoStart;
            serviceInstaller.Description      = ChoServiceInstallerSettings.Me.Description;

            this.Installers.Add(processInstaller);
            this.Installers.Add(serviceInstaller);
        }
Exemplo n.º 4
0
 protected virtual void ApplyFrxParamsOverrides(ChoGlobalApplicationSettings globalApplicationSettings, ChoMetaDataFilePathSettings metaDataFilePathSettings)
 {
 }
 protected override void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
 {
     obj.TrayApplicationBehaviourSettings.TurnOn = true;
 }
Exemplo n.º 6
0
        public ChoApplicationHost()
        {
            Instance = this;
            //if (ChoApplication.ApplicationMode == ChoApplicationMode.NA)
            //if (!ChoApplication.IsInitialized)
            //{
            if (!ChoApplication.InternalEventsSubscriped)
            {
                ChoApplication.InternalEventsSubscriped = true;
                ChoApplication.ApplyGlobalApplicationSettingsOverridesInternal += ((sender, e) =>
                {
                    ChoServiceCommandLineArgs.OverrideFrxParams(e.Value);
                    ApplyGlobalApplicationSettingsOverrides(e.Value);
                }
                                                                                   );
                ChoApplication.AfterAppFrxSettingsLoadedInternal += ((sender, e) =>
                {
                    if (e.Value is ChoServiceInstallerSettings)
                    {
                        ChoServiceInstallerSettings o = (ChoServiceInstallerSettings)e.Value;
                        o.BeforeInstall(() => BeforeInstall());
                        o.AfterInstall(() => AfterInstall());
                        o.BeforeUninstall(() => BeforeUninstall());
                        o.AfterUninstall(() => AfterUninstall());
                    }

                    AfterAppFrxSettingsLoaded(e.Value);
                }
                                                                     );
                ChoApplication.ApplyMetaDataFilePathSettingsOverridesInternal += ((sender, e) =>
                {
                    ApplyMetaDataFilePathSettingsOverrides(e.Value);
                }
                                                                                  );
                ChoApplication.AfterNotifyIconConstructedInternal += ((sender, e) =>
                {
                    AfterNotifyIconConstructed(e.Value);
                }
                                                                      );
            }
            //ChoApplication.ApplyFrxParamsOverridesInternal += ((sender, e) =>
            //{
            //    ApplyFrxParamsOverrides(e.GlobalApplicationSettings, e.MetaDataFilePathSettings);

            //    if (_initialized) return;
            //    _initialized = true;

            //    ChoServiceCommandLineArgs.OverrideFrxParams(e);
            //});

            if (Environment.UserInteractive)
            {
                if (this.GetMainWindowObject() != null)
                {
                    if (ChoApplication.ApplicationMode == ChoApplicationMode.NA)
                    {
                        if (GetMainWindowObject() is Window ||
                            GetMainWindowObject() is Form)
                        {
                            ChoApplication.ApplicationMode = ChoApplicationMode.Windows;
                            if (GetMainWindowObject() is Window)
                            {
                                ChoApplication.WindowsAppType = ChoWindowsAppType.WPF;
                            }
                            else
                            {
                                ChoApplication.WindowsAppType = ChoWindowsAppType.WinForms;
                            }
                        }
                        else
                        {
                            ChoApplication.ApplicationMode = ChoApplicationMode.Console;
                        }
                    }
                    //if (!(this is IChoWindowApp))
                    //    throw new ChoApplicationException("ApplicationHost must derive from IChoWindowApp for Windows application.");
                }

                //ChoApplicationMode? applicationMode = ChoFrameworkCmdLineArgs.GetApplicationMode();
                //if (applicationMode != null)
                //    ChoApplication.ApplicationMode = applicationMode.Value;

                if (ChoApplication.ApplicationMode == ChoApplicationMode.Windows)
                {
                    //if (ChoApplication.WindowsAppType == ChoWindowsAppType.NA)
                    //    ChoApplication.ApplicationMode = ChoApplicationMode.Console;
                }
            }


            ChoApplication.FatalApplicationException += FatalApplicationException;

            //if (Environment.UserInteractive)
            //{
            //    if (!ChoServiceCommandLineArgs.HasServiceParams())
            //    {
            //        if (ChoApplication.ApplicationMode == ChoApplicationMode.Windows)
            //        {
            //            if (!ChoAppFrxSettings.Me.DoNotShowEnvSelectionWnd)
            //            {
            //                ChoChooseEnvironmentFrm.Show();
            //                //frm1 = new ChoChooseEnvironmentFrm();
            //                //if (frm1.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
            //                //    Environment.Exit(-101);
            //            }
            //        }
            //    }
            //}
            //}
            //else
            //    ApplyFrxParamsOverrides(ChoGlobalApplicationSettings.Me, ChoMetaDataFilePathSettings.Me);

            //ChoApplication.Initialize();
            ChoGlobalApplicationSettings x = ChoGlobalApplicationSettings.Me;

            ChoApplication.WriteToEventLog(ChoServiceInstallerSettings.Me.ToString());
        }
Exemplo n.º 7
0
 protected virtual void ApplyGlobalApplicationSettingsOverrides(ChoGlobalApplicationSettings obj)
 {
 }
Exemplo n.º 8
0
 public ChoFrxParamsEventArgs(ChoGlobalApplicationSettings globalApplicationSettings, ChoMetaDataFilePathSettings metaDataFilePathSettings)
 {
     GlobalApplicationSettings = globalApplicationSettings;
     MetaDataFilePathSettings  = metaDataFilePathSettings;
 }