Ejemplo n.º 1
0
        private void tsmiLanguage_Click(object sender, EventArgs e)
        {
            CustomMessageBoxReturnValue exit = CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ExitToChangeLanguage"), CustomMessageBoxMessageType.Warning, CustomMessageBoxButtonType.YesNo);

            if (exit == CustomMessageBoxReturnValue.Ok)
            {
                string      culture        = ((ToolStripMenuItem)sender).Tag.ToString();
                XmlDocument doc            = new XmlDocument();
                String      configFileName = DirectoryAndFileHelper.LanguageConfigurationFile;

                if (File.Exists(configFileName))
                {
                    doc.Load(configFileName);
                    doc.DocumentElement.Attributes["culture"].Value = culture;
                }
                else
                {
                    doc.LoadXml("<Language culture=\"" + culture + "\" />");
                }

                doc.Save(configFileName);
                try
                {
                    Process.Start(Application.ExecutablePath);
                    Process.GetCurrentProcess().Kill();
                }
                catch
                { }
            }
        }
Ejemplo n.º 2
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     _returnValue = CustomMessageBoxReturnValue.Cancel;
     _newMessageBox.Dispose();
 }
Ejemplo n.º 3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool restoreDataBase   = chkRestoreDataBase.Checked;
            bool restoreFiles      = chkRestoreFiles.Checked;
            bool restoreShapefiles = chkRestoreShapefiles.Checked;

            if (restoreDataBase == false && restoreFiles == false && restoreShapefiles == false)
            {
                CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("MustSelectAtLeastOneOption"));
                return;
            }

            if (Environment.OSVersion.Version.Major == 6)
            {
                if (!IsAdministrator())
                {
                    CustomMessageBoxReturnValue customMessageBoxReturnValue1 = CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("RestoreAsAdministratorWarning"),
                                                                                                            CustomMessageBoxMessageType.Information, CustomMessageBoxButtonType.YesNo);
                    if (customMessageBoxReturnValue1 == CustomMessageBoxReturnValue.Ok)
                    {
                        // it's windows Vista / 7. UAC requires the user to run as an ADMINISTRATOR to restart the Windows Service.
                        ProcessStartInfo info = new ProcessStartInfo();
                        info.FileName        = Assembly.GetEntryAssembly().Location;
                        info.UseShellExecute = true;
                        info.Verb            = "runas"; // Provides Run as Administrator

                        if (Process.Start(info) != null)
                        {
                            // The user accepted the UAC prompt.
                            Application.Exit();
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }

            CustomMessageBoxReturnValue customMessageBoxReturnValue2 = CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("RestoreTimeWarning"),
                                                                                                    CustomMessageBoxMessageType.Information, CustomMessageBoxButtonType.YesNo);

            if (customMessageBoxReturnValue2 == CustomMessageBoxReturnValue.Cancel)
            {
                return;
            }

            OpenFileDialog ofd = new OpenFileDialog()
            {
                Filter = "Gzipped restore files(*.gz)|*.gz", Title = "Restore backup from..."
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                Boolean backupFailed = false;
                try
                {
                    string noCorrespondingRestorations = DocumentHelper.Restore(Convert.ToBase64String(File.ReadAllBytes(ofd.FileName)), restoreDataBase, restoreFiles, restoreShapefiles);
                    RestartService("IDEA Geo Host Service");
                    if (noCorrespondingRestorations != string.Empty)
                    {
                        if (noCorrespondingRestorations.Contains("invaliddbversion"))
                        {
                            CustomMessageBox.ShowError(ResourceHelper.GetResourceText("DataRestoreInvalidDBVersion"));
                            backupFailed = true;
                        }

                        if (noCorrespondingRestorations.Contains("errorrestoringdb"))
                        {
                            CustomMessageBox.ShowError(ResourceHelper.GetResourceText("DataRestoreError"));
                            backupFailed = true;
                        }

                        noCorrespondingRestorations = noCorrespondingRestorations.Substring(0, noCorrespondingRestorations.Length - 3);
                        noCorrespondingRestorations = " " + ResourceHelper.GetResourceText("SelectedRestoreOptionsWereNotBackupFile") + ": " + noCorrespondingRestorations + ".";
                    }

                    if (!backupFailed)
                    {
                        CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("DataRestored") + noCorrespondingRestorations);
                        Application.Exit();
                    }
                }
                catch (Exception ex)
                {
                    CustomMessageBox.ShowMessage(ex.Message, CustomMessageBoxMessageType.Error, CustomMessageBoxButtonType.OKOnly);
                }
            }
        }
Ejemplo n.º 4
0
        private void tsmiImportModel_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                StreamReader sr  = File.OpenText(openFileDialog.FileName);
                Document     doc = new Document {
                    Content = sr.ReadToEnd()
                };

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(doc.Content);

                int     importVersion = 0;
                XmlNode versionNode   = xmlDoc.SelectSingleNode("data/Version");
                if (versionNode != null)
                {
                    importVersion = int.Parse(versionNode.Attributes["Number"].Value.Substring(0, 1));
                }

                if (importVersion == 0 || importVersion < 7)
                {
                    CustomMessageBoxReturnValue customMessageBoxReturnValue = CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("RegionsMustBeLoadedBeforeImport"),
                                                                                                           CustomMessageBoxMessageType.Information, CustomMessageBoxButtonType.YesNo);
                    if (customMessageBoxReturnValue == CustomMessageBoxReturnValue.Cancel)
                    {
                        return;
                    }
                }

                List <string> message = DocumentHelper.Import(doc);

                if (message[0] == "true")
                {
                    //import successfull.
                    if (message.Count > 2)
                    {
                        if (message[1] == "SomeRegionsWereNotImported")
                        {
                            CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportOk") + " " +
                                                         ResourceHelper.GetResourceText("SomeRegionsWereNotImported") + ": " +
                                                         message[2]);
                        }
                    }
                    else
                    {
                        CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportOk"));
                    }
                    ViewManager.ShowStart();
                    ViewManager.LoadModelsMenu();
                }
                else
                {
                    //import failed.
                    if (message.Count == 1)
                    {
                        //it was an exception
                        CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportNotOk"));
                        return;
                    }

                    if (message[1] == "ModelImportNoExistsRegionsInLocalDB")
                    {
                        CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportNoExistsRegionsInLocalDB") + " " +
                                                     ResourceHelper.GetResourceText("ModelImportNotOk"));
                    }
                    else if (message[1] == "ModelImportNoExistsParentRegionInLocalDB")
                    {
                        CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportNoExistsParentRegionInLocalDB") + " " +
                                                     ResourceHelper.GetResourceText("ModelImportNotOk"));
                    }
                    else if (message[1] == "ModelImportMainRegionDoesNotExits")
                    {
                        CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportMainRegionDoesNotExits") + " " +
                                                     ResourceHelper.GetResourceText("ModelImportNotOk"));
                    }
                    else if (message[1] == "ModelImportErrorVersionUsesDundasAndWrongParent")
                    {
                        CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportErrorVersionUsesDundasAndWrongParent") + " " +
                                                     ResourceHelper.GetResourceText("ModelImportNotOk"));
                    }
                    else
                    {
                        CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportNotOk"));
                    }
                }
            }
        }