Exemplo n.º 1
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textKey1.Text != "" &&
                !Regex.IsMatch(textKey1.Text, @"^[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$") &&
                !Regex.IsMatch(textKey1.Text, @"^[A-Z0-9]{16}$"))
            {
                MsgBox.Show(this, "Invalid registration key format.");
                return;
            }
            string regkey = "";

            if (Regex.IsMatch(textKey1.Text, @"^[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$"))
            {
                regkey = textKey1.Text.Substring(0, 4) + textKey1.Text.Substring(5, 4) + textKey1.Text.Substring(10, 4) + textKey1.Text.Substring(15, 4);
            }
            else if (Regex.IsMatch(textKey1.Text, @"^[A-Z0-9]{16}$"))
            {
                regkey = textKey1.Text;
            }
            if (!ValidateKey(regkey))            //a blank registration key will only be valid if the CDT.dll is foreign
            {
                MsgBox.Show(this, "Invalid registration key.");
                return;
            }
            Prefs.UpdateString(PrefName.RegistrationKey, regkey);
            FormOpenDental.RegKeyIsForTesting = PrefL.IsRegKeyForTesting();
            //prefs refresh automatically in the calling class anyway.
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 2
0
        private void butValidate_Click(object sender, EventArgs e)
        {
            if (!PrefC.UsingAtoZfolder)
            {
                MsgBox.Show(this, "Not using AtoZ folders, so UpdateFiles folder does not exist.");
                return;
            }
            string  folderUpdate   = ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "UpdateFiles");
            Version currentVersion = new Version(Application.ProductVersion);

            //identify the ideal situation where everything is already in place and no copy is needed.
            if (Directory.Exists(folderUpdate))
            {
                string filePath = ODFileUtils.CombinePaths(folderUpdate, "Manifest.txt");
                if (File.Exists(filePath))
                {
                    string fileText = File.ReadAllText(filePath);
                    if (fileText == currentVersion.ToString(3))
                    {
                        if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "According to the information in UpdateFiles\\Manifest.txt, the UpdateFiles folder is current.  Recopy anyway?"))
                        {
                            return;
                        }
                    }
                }
            }
            Cursor = Cursors.WaitCursor;
            if (!PrefL.CopyFromHereToUpdateFiles(currentVersion))
            {
                Cursor = Cursors.Default;
                return;
            }
            Cursor = Cursors.Default;
            MsgBox.Show(this, "Recopied.");
        }
Exemplo n.º 3
0
        private void butInstallEConnector_Click(object sender, EventArgs e)
        {
            DialogResult result;
            //Check to see if the update server preference is set.
            //If set, make sure that this is set to the computer currently logged on.
            string updateServerName = PrefC.GetString(PrefName.WebServiceServerName);

            if (!string.IsNullOrEmpty(updateServerName) && !ODEnvironment.IdIsThisComputer(updateServerName.ToLower()))
            {
                result = MessageBox.Show(Lan.g(this, "The eConnector service should be installed on the Update Server") + ": " + updateServerName + "\r\n"
                                         + Lan.g(this, "Are you trying to install the eConnector on a different computer by accident?"), "", MessageBoxButtons.YesNoCancel);
                //Only saying No to this message box pop up will allow the user to continue (meaning they fully understand what they are getting into).
                if (result != DialogResult.No)
                {
                    return;
                }
            }
            //Only ask the user if they want to set the Update Server Name preference if it is not already set.
            if (string.IsNullOrEmpty(updateServerName))
            {
                result = MessageBox.Show(Lan.g(this, "The computer that has the eConnector service installed should be set as the Update Server.") + "\r\n"
                                         + Lan.g(this, "Would you like to make this computer the Update Server?"), "", MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Cancel)
                {
                    return;
                }
                else if (result == DialogResult.Yes)
                {
                    Prefs.UpdateString(PrefName.WebServiceServerName, Dns.GetHostName());
                }
                try {
                    WebServiceMainHQProxy.SetEConnectorOn();
                }
                catch {
                    MsgBox.Show(this, "The eConnector was disabled.  Please contact support.");
                    return;
                }
            }
            //At this point the user wants to install the eConnector service (or upgrade the old cust listener to the eConnector).
            bool isListening;

            if (!PrefL.UpgradeOrInstallEConnector(false, out isListening))
            {
                //Warning messages would have already been shown to the user, simply return.
                return;
            }
            //The eConnector service was successfully installed and is running, set the EConnectorEnabled flag true if false.
            Prefs.UpdateBool(PrefName.EConnectorEnabled, true);
            MsgBox.Show(this, "eConnector successfully installed");
            butInstallEConnector.Enabled = false;
            FillTextListenerServiceStatus();
            FillGridListenerService();
        }
Exemplo n.º 4
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textRegKey.Text != "" &&
                !Regex.IsMatch(textRegKey.Text, @"^[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$") &&
                !Regex.IsMatch(textRegKey.Text, @"^[A-Z0-9]{16}$"))
            {
                MsgBox.Show(this, "Invalid registration key format.");
                return;
            }
            if (textMultiple.Text.Contains(" "))
            {
                MsgBox.Show(this, "No spaces allowed in the database list.");
                return;
            }
            string regkey = "";

            if (Regex.IsMatch(textRegKey.Text, @"^[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$"))
            {
                regkey = textRegKey.Text.Substring(0, 4) + textRegKey.Text.Substring(5, 4)
                         + textRegKey.Text.Substring(10, 4) + textRegKey.Text.Substring(15, 4);
            }
            else if (Regex.IsMatch(textRegKey.Text, @"^[A-Z0-9]{16}$"))
            {
                regkey = textRegKey.Text;
            }
            bool refreshCache = false;

            if (Prefs.UpdateString(PrefName.UpdateServerAddress, textUpdateServerAddress.Text)
                | Prefs.UpdateBool(PrefName.UpdateShowMsiButtons, checkShowMsi.Checked)
                | Prefs.UpdateString(PrefName.UpdateWebsitePath, textWebsitePath.Text)
                | Prefs.UpdateString(PrefName.UpdateWebProxyAddress, textWebProxyAddress.Text)
                | Prefs.UpdateString(PrefName.UpdateWebProxyUserName, textWebProxyUserName.Text)
                | Prefs.UpdateString(PrefName.UpdateWebProxyPassword, textWebProxyPassword.Text)
                | Prefs.UpdateString(PrefName.UpdateMultipleDatabases, textMultiple.Text)
                | Prefs.UpdateDateT(PrefName.UpdateDateTime, _updateTime))
            {
                refreshCache = true;
            }
            if (Prefs.UpdateString(PrefName.RegistrationKey, regkey))
            {
                FormOpenDental.RegKeyIsForTesting = PrefL.IsRegKeyForTesting();
                refreshCache = true;
            }
            if (refreshCache)
            {
                Cursor = Cursors.WaitCursor;
                DataValid.SetInvalid(InvalidType.Prefs);
                Cursor = Cursors.Default;
            }
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 5
0
        private void butRecopy_Click(object sender, EventArgs e)
        {
            Version versionCurrent = new Version(Application.ProductVersion);
            string  folderUpdate   = "";

            if (PrefC.AtoZfolderUsed)
            {
                folderUpdate = ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "UpdateFiles");
            }
            else             //db
            {
                folderUpdate = ODFileUtils.CombinePaths(Path.GetTempPath(), "UpdateFiles");
                if (Directory.Exists(folderUpdate))
                {
                    Directory.Delete(folderUpdate, true);
                }
                DocumentMisc docmisc = DocumentMiscs.GetUpdateFilesZip();
                if (docmisc != null)
                {
                    byte[] rawBytes = Convert.FromBase64String(docmisc.RawBase64);
                    using (ZipFile unzipped = ZipFile.Read(rawBytes)) {
                        unzipped.ExtractAll(folderUpdate);
                    }
                }
            }
            //identify the ideal situation where everything is already in place and no copy is needed.
            if (Directory.Exists(folderUpdate))
            {
                string filePath = ODFileUtils.CombinePaths(folderUpdate, "Manifest.txt");
                if (File.Exists(filePath))
                {
                    string fileText = File.ReadAllText(filePath);
                    if (fileText == versionCurrent.ToString(3))
                    {
                        if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "According to the information in UpdateFiles\\Manifest.txt, the UpdateFiles folder is current.  Recopy anyway?"))
                        {
                            return;
                        }
                    }
                }
            }
            Cursor = Cursors.WaitCursor;
            if (!PrefL.CopyFromHereToUpdateFiles(versionCurrent))
            {
                Cursor = Cursors.Default;
                return;
            }
            Cursor = Cursors.Default;
            MsgBox.Show(this, "Recopied.");
        }
Exemplo n.º 6
0
        private void butDownload_Click(object sender, System.EventArgs e)
        {
            if (IsDynamicMode())
            {
                return;
            }
            string patchName = "Setup.exe";
            string destDir   = ImageStore.GetPreferredAtoZpath();

            if (destDir == null || CloudStorage.IsCloudStorage)
            {
                destDir = PrefC.GetTempFolderPath();
            }
            PrefL.DownloadInstallPatchFromURI(textWebsitePath.Text + textUpdateCode.Text + "/" + patchName,     //Source URI
                                              ODFileUtils.CombinePaths(destDir, patchName), true, false, null); //Local destination file.
        }
Exemplo n.º 7
0
        private void CheckMain()
        {
            butDownload.Enabled = false;
            textResult.Text     = "";
            textResult2.Text    = "";
            if (textUpdateCode.Text.Length == 0)
            {
                textResult.Text += Lan.g(this, "Registration number not valid.");
                return;
            }
            string updateInfoMajor = "";
            string updateInfoMinor = "";

            butDownload.Enabled = PrefL.ShouldDownloadUpdate(textWebsitePath.Text, textUpdateCode.Text, out updateInfoMajor, out updateInfoMinor);
            textResult.Text     = updateInfoMajor;
            textResult2.Text    = updateInfoMinor;
        }
Exemplo n.º 8
0
        private void DownloadInstallPatchForVersion(string version, string updateCode, bool showFormUpdateInstallMsg)
        {
            if (IsDynamicMode())
            {
                return;
            }
            if (showFormUpdateInstallMsg)
            {
                FormUpdateInstallMsg FormUIM = new FormUpdateInstallMsg();
                FormUIM.ShowDialog();
                if (FormUIM.DialogResult != DialogResult.OK)
                {
                    return;
                }
            }
            string patchName        = "Setup.exe";
            string fileNameWithVers = version;                       //6.9.23F

            fileNameWithVers = fileNameWithVers.Replace("F", "");    //6.9.23
            fileNameWithVers = fileNameWithVers.Replace(".", "_");   //6_9_23
            fileNameWithVers = "Setup_" + fileNameWithVers + ".exe"; //Setup_6_9_23.exe
            string destDir   = ImageStore.GetPreferredAtoZpath();
            string destPath2 = null;

            if (destDir == null)           //Not using A to Z folders?
            {
                destDir = PrefC.GetTempFolderPath();
            }
            else              //using A to Z folders.
            {
                destPath2 = ODFileUtils.CombinePaths(destDir, "SetupFiles");
                if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ && !Directory.Exists(destPath2))
                {
                    Directory.CreateDirectory(destPath2);
                }
                else if (CloudStorage.IsCloudStorage)
                {
                    destDir = PrefC.GetTempFolderPath();                  //Cloud needs it to be downloaded to a local temp folder
                }
                destPath2 = ODFileUtils.CombinePaths(destPath2, fileNameWithVers);
            }
            PrefL.DownloadInstallPatchFromURI(PrefC.GetString(PrefName.UpdateWebsitePath) + updateCode + "/" + patchName, //Source URI
                                              ODFileUtils.CombinePaths(destDir, patchName),                               //Local destination file.
                                              true, true,
                                              destPath2);                                                                 //second destination file.  Might be null.
        }
Exemplo n.º 9
0
        private void butRecopy_Click(object sender, EventArgs e)
        {
            Version versionCurrent = new Version(Application.ProductVersion);
            string  folderUpdate   = ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), "UpdateFiles");

            if (Directory.Exists(folderUpdate))
            {
                try {
                    Directory.Delete(folderUpdate, true);
                }
                catch {
                    MsgBox.Show(this, "Recopy failed.  Please run as administrator then try again.");
                    return;
                }
            }
            Cursor = Cursors.WaitCursor;
            if (!PrefL.CopyFromHereToUpdateFiles(versionCurrent, false, true, true, this))
            {
                Cursor = Cursors.Default;
                return;
            }
            Cursor = Cursors.Default;
            MsgBox.Show(this, "Recopied.");
        }