예제 #1
0
        public ApplicationOptions()
        {
            this.log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            this.appKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\" + Branding.RegistryKeyName);
            this.runKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            this.isFirstStart = (!File.Exists(NetworkDriveCollection.GetDefaultDrivesStoragePath()) && !File.Exists(Path.Combine(Branding.AppDataPath, ConfigFileName)));
            this.log.Info("Is first start = " + this.isFirstStart);
            this.log.Info("Drives configured = " + NetworkDriveCollection.DrivesConfigured());

            ReadConfiguration();

            //TODO (SD-112) re-enable system notifications (temporary fix, takes long time but has almost no effect)
            this.SendSystemUpdateNotifications = false;
        }
예제 #2
0
        private bool InitApplication(string systemLangName)
        {
            try
            {
                // init pipe stream for ipc receiver
                try
                {
                    //TODO (SD-184) rework single instance application IPC
                    // https://stackoverflow.com/questions/19147/what-is-the-correct-way-to-create-a-single-instance-application
                    this.ipcServer = new NamedPipeServerStream(IpcChannelName, PipeDirection.In, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
                    this.ipcServer.BeginWaitForConnection(new AsyncCallback(IpcProcessConnection), null);
                }
                catch (Exception ex)
                {
                    this.ipcServer = null;
                    log.Error("Could not listen on Ipc Channel: " + ex.Message + " (" + ex.GetType().Name + ")", ex);
                }

                // only the first instance should delete log files
                DeleteOldLogFiles(MaxLogFileRetentionDays);

                if (!NetworkDriveCollection.DrivesConfigured())
                {
                    LoadConfigurationSuffix();
                }

                // initialize licenser silent
                //this.serverAuthorization = new ServerAuthorization(systemLangName);

                // load drives
                try
                {
                    this.driveCollection = new NetworkDriveCollection();
                    this.driveCollection.LoadDrives();
                }
                catch (Exception ex)
                {
                    this.log.Error(ex.GetType().Name + " while loading network drive storage: " + ex.Message, ex);
                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        MessageBox.Show(Strings.MessageNetworkDriveStorageCorrupted, Branding.ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error);
                    }));
                }

                // init background manager and start activity for automatic mounting
                this.backgroundManager = new BackgroundDriveManager(this.driveCollection);
                this.backgroundManager.BeginBackgroundActivity();

                // check for updates
                this.updater = new AutoUpdater(this.appOptions);

                this.officeConfiguration = new MicrosoftOfficeConfiguration();

                return(true);
            }
            catch (Exception ex)
            {
                this.log.Error("Unhandled Exception in App.InitApplication: " + ex.Message + " (" + ex.GetType().Name + ")", ex);
                this.Dispatcher.Invoke(new Action(() =>
                {
                    MessageBox.Show(string.Format(Strings.MessageFatalError, ex.GetType().Name, ex.Message, ex.StackTrace), Branding.ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error);
                }));
                return(false);
            }
        }