Esempio n. 1
0
        private static void WebAdmin_Project_BeforeInstall(SetupEventArgs e)
        {
            string backupConfigPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "Web.config");

            Version installedVersion = AppSearch.GetProductVersionFromUpgradeCode(e.UpgradeCode);

            if (installedVersion != null && e.IsModifying && !e.IsUninstalling)
            {
                try
                {
                    string configPath = $"{e.Session["INSTALLDIR"]}Web.config";
                    System.IO.File.Copy(configPath, backupConfigPath);
                }
                catch (Exception ex)
                {
                    e.Session.Log($"ERROR : {ex.Message}");
                }
            }
            else if (e.IsUpgrading && System.IO.File.Exists(backupConfigPath))
            {
                e.Session.Log($"Load {backupConfigPath}");
                var doc = XDocument.Load(backupConfigPath);

                var elt = doc.Root.Element("connectionStrings").Elements("add").Single(x => x.Attribute("name").Value == "KsmedEntities");
                e.Session["DATASOURCE"] = elt.Attribute("connectionString").Value.Split(';')
                                          .Single(_ => _.StartsWith("Data Source")).Split('=')[1];

                elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri");
                e.Session["API_LOCATION"] = elt.Attribute("value").Value;

                elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileServerUri");
                e.Session["FILESERVER_LOCATION"] = elt.Attribute("value").Value;

                System.IO.File.Delete(backupConfigPath);
            }
        }
Esempio n. 2
0
 static void project_BeforeInstall(SetupEventArgs e)
 {
     MessageBox.Show(e.ToString(), "BeforeInstall " + AppSearch.GetProductVersionFromUpgradeCode(e.UpgradeCode));
 }
Esempio n. 3
0
        private static void Project_BeforeInstall(SetupEventArgs e)
        {
            string backupConfigPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "KL².exe.config");

            Version installedVersion = AppSearch.GetProductVersionFromUpgradeCode(e.UpgradeCode);

            e.Session.Log($"Installed version : {installedVersion}");
            if (installedVersion != null && e.IsModifying && !e.IsUninstalling)
            {
                try
                {
                    string configPath = $"{e.Session["INSTALLDIR"]}KL².exe.config";
                    e.Session.Log($"Load {configPath}");
                    var doc = XDocument.Load(configPath);

                    e.Session.Log($"Get API_LOCATION");
                    var elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri");
                    e.Session.Log($"API_LOCATION : {elt.Attribute("value").Value}");

                    e.Session.Log($"Get FILESERVER_LOCATION");
                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileServerUri");
                    e.Session.Log($"FILESERVER_LOCATION : {elt.Attribute("value").Value}");

                    e.Session.Log($"Get SYNCPATH");
                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath");
                    e.Session.Log($"SYNCPATH : {elt.Attribute("value").Value}");

                    e.Session.Log($"Get SENDREPORT");
                    elt = doc.Root.Element("userSettings").Element("KProcess.Ksmed.Presentation.Shell.Settings").Elements("setting").Single(x => x.Attribute("name").Value == "SendReport");
                    e.Session.Log($"SENDREPORT : {(elt.Element("value").Value == "True" ? "yes" : "no")}");

                    e.Session.Log($"Get MUTE");
                    elt = doc.Root.Element("userSettings").Element("KProcess.Ksmed.Presentation.Shell.Settings").Elements("setting").Single(x => x.Attribute("name").Value == "Mute");
                    e.Session.Log($"MUTE : {(elt.Element("value").Value == "True" ? "yes" : "no")}");

                    System.IO.File.Copy(configPath, backupConfigPath);
                }
                catch (Exception ex)
                {
                    e.Session.Log($"ERROR : {ex.Message}");
                }
            }
            else if (e.IsUpgrading && System.IO.File.Exists(backupConfigPath))
            {
                e.Session.Log($"Load {backupConfigPath}");
                var doc = XDocument.Load(backupConfigPath);

                e.Session.Log($"Get API_LOCATION");
                var elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri");
                e.Session["API_LOCATION"] = elt.Attribute("value").Value;
                e.Session.Log($"API_LOCATION : {e.Session["API_LOCATION"]}");

                e.Session.Log($"Get FILESERVER_LOCATION");
                elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileServerUri");
                e.Session["FILESERVER_LOCATION"] = elt.Attribute("value").Value;
                e.Session.Log($"FILESERVER_LOCATION : {e.Session["FILESERVER_LOCATION"]}");

                e.Session.Log($"Get SYNCPATH");
                elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath");
                e.Session["SYNCPATH"] = elt.Attribute("value").Value;
                e.Session.Log($"SYNCPATH : {e.Session["SYNCPATH"]}");

                e.Session.Log($"Get SENDREPORT");
                elt = doc.Root.Element("userSettings").Element("KProcess.Ksmed.Presentation.Shell.Settings").Elements("setting").Single(x => x.Attribute("name").Value == "SendReport");
                e.Session["SENDREPORT"] = elt.Element("value").Value == "True" ? "yes" : "no";
                e.Session.Log($"SENDREPORT : {e.Session["SENDREPORT"]}");

                e.Session.Log($"Get MUTE");
                elt = doc.Root.Element("userSettings").Element("KProcess.Ksmed.Presentation.Shell.Settings").Elements("setting").Single(x => x.Attribute("name").Value == "Mute");
                e.Session["MUTE"] = elt.Element("value").Value == "True" ? "yes" : "no";
                e.Session.Log($"MUTE : {e.Session["MUTE"]}");

                System.IO.File.Delete(backupConfigPath);
            }
        }
Esempio n. 4
0
        private static void FileServer_Project_BeforeInstall(SetupEventArgs e)
        {
            string backupConfigPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "Kprocess.KL2.FileServer.exe.config");

            Version installedVersion = AppSearch.GetProductVersionFromUpgradeCode(e.UpgradeCode);

            if (installedVersion != null && e.IsModifying && !e.IsUninstalling)
            {
                try
                {
                    string configPath = $"{e.Session["INSTALLDIR"]}Kprocess.KL2.FileServer.exe.config";
                    System.IO.File.Copy(configPath, backupConfigPath);
                }
                catch (Exception ex)
                {
                    e.Session.Log($"ERROR : {ex.Message}");
                }
            }
            else if (e.IsUpgrading && System.IO.File.Exists(backupConfigPath))
            {
                e.Session.Log($"Load {backupConfigPath}");
                var doc = XDocument.Load(backupConfigPath);

                var elt = doc.Root.Element("connectionStrings").Elements("add").Single(x => x.Attribute("name").Value == "KsmedEntities");
                e.Session["DATASOURCE"] = elt.Attribute("connectionString").Value.Split(';')
                                          .Single(_ => _.StartsWith("Data Source")).Split('=')[1];

                elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApplicationUrl");
                e.Session["APPLICATION_URL"] = elt.Attribute("value").Value;

                elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileProvider");
                e.Session["FILE_PROVIDER"] = elt.Attribute("value").Value;

                if (e.Session["FILE_PROVIDER"] == "SFtp")
                {
                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_Server");
                    e.Session["SERVER"] = elt.Attribute("value").Value;

                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_Port");
                    e.Session["PORT"] = elt.Attribute("value").Value;

                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_User");
                    e.Session["USER"] = elt.Attribute("value").Value;

                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_Password");
                    e.Session["PASSWORD"] = elt.Attribute("value").Value;

                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_PublishedFilesDirectory");
                    e.Session["PUBLISHED_DIR"] = elt.Attribute("value").Value;

                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_UploadedFilesDirectory");
                    e.Session["UPLOADED_DIR"] = elt.Attribute("value").Value;
                }
                else if (e.Session["FILE_PROVIDER"] == "Local")
                {
                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "Local_PublishedFilesDirectory");
                    e.Session["PUBLISHED_DIR"] = elt.Attribute("value").Value;

                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "Local_UploadedFilesDirectory");
                    e.Session["UPLOADED_DIR"] = elt.Attribute("value").Value;
                }

                System.IO.File.Delete(backupConfigPath);
            }
        }
Esempio n. 5
0
        private static void Project_BeforeInstall(SetupEventArgs e)
        {
            string backupConfigPath        = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "Kprocess.KL2.TabletClient.exe.config");
            string serviceBackupConfigPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "Kprocess.KL2.SyncService.exe.config");

            Version installedVersion = AppSearch.GetProductVersionFromUpgradeCode(e.UpgradeCode);

            if (installedVersion != null && e.IsModifying && !e.IsUninstalling)
            {
                try
                {
                    // Tablet
                    string configPath = $"{e.Session["INSTALLDIR"]}Kprocess.KL2.TabletClient.exe.config";
                    e.Session.Log($"Load {configPath}");
                    var doc = XDocument.Load(configPath);

                    e.Session.Log($"Get API_LOCATION");
                    var elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri");
                    e.Session.Log($"API_LOCATION : {elt.Attribute("value").Value}");

                    e.Session.Log($"Get FILESERVER_LOCATION");
                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileServerUri");
                    e.Session.Log($"FILESERVER_LOCATION : {elt.Attribute("value").Value}");

                    e.Session.Log($"Get SYNCPATH");
                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath");
                    e.Session.Log($"SYNCPATH : {elt.Attribute("value").Value}");

                    System.IO.File.Copy(configPath, backupConfigPath);

                    // SyncService
                    configPath = $"{e.Session["INSTALLDIR"]}Kprocess.KL2.SyncService.exe.config";
                    e.Session.Log($"Load {configPath}");
                    doc = XDocument.Load(configPath);

                    e.Session.Log($"Get API_LOCATION");
                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri");
                    e.Session.Log($"API_LOCATION : {elt.Attribute("value").Value}");

                    e.Session.Log($"Get SYNCPATH");
                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath");
                    e.Session.Log($"SYNCPATH : {elt.Attribute("value").Value}");

                    e.Session.Log($"Get SYNC_INTERVAL");
                    elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncInterval");
                    e.Session.Log($"SYNC_INTERVAL : {elt.Attribute("value").Value}");

                    System.IO.File.Copy(configPath, serviceBackupConfigPath);
                }
                catch (Exception ex)
                {
                    e.Session.Log($"ERROR : {ex.Message}");
                }
            }
            else if (e.IsUpgrading && System.IO.File.Exists(backupConfigPath) && System.IO.File.Exists(serviceBackupConfigPath))
            {
                // Tablet
                e.Session.Log($"Load {backupConfigPath}");
                var doc = XDocument.Load(backupConfigPath);

                e.Session.Log($"Get API_LOCATION");
                var elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri");
                e.Session["API_LOCATION"] = elt.Attribute("value").Value;
                e.Session.Log($"API_LOCATION : {e.Session["API_LOCATION"]}");

                e.Session.Log($"Get FILESERVER_LOCATION");
                elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileServerUri");
                e.Session["FILESERVER_LOCATION"] = elt.Attribute("value").Value;
                e.Session.Log($"FILESERVER_LOCATION : {e.Session["FILESERVER_LOCATION"]}");

                e.Session.Log($"Get SYNCPATH");
                elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath");
                e.Session["SYNCPATH"] = elt.Attribute("value").Value;
                e.Session.Log($"SYNCPATH : {e.Session["SYNCPATH"]}");

                System.IO.File.Delete(backupConfigPath);

                // SyncService
                e.Session.Log($"Load {serviceBackupConfigPath}");
                doc = XDocument.Load(serviceBackupConfigPath);

                e.Session.Log($"Get API_LOCATION");
                elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri");
                e.Session["API_LOCATION"] = elt.Attribute("value").Value;
                e.Session.Log($"API_LOCATION : {e.Session["API_LOCATION"]}");

                e.Session.Log($"Get SYNCPATH");
                elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath");
                e.Session["SYNCPATH"] = elt.Attribute("value").Value;
                e.Session.Log($"SYNCPATH : {e.Session["SYNCPATH"]}");

                e.Session.Log($"Get SYNC_INTERVAL");
                elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncInterval");
                e.Session["SYNC_INTERVAL"] = elt.Attribute("value").Value;
                e.Session.Log($"SYNC_INTERVAL : {e.Session["SYNC_INTERVAL"]}");

                System.IO.File.Delete(serviceBackupConfigPath);
            }
        }