コード例 #1
0
        public Updater()
        {
            inputSetting = (Settings)xobj;
            //Kill the process
            Process[] processes = Process.GetProcessesByName("SummaryToolForm");
            if (processes.Length > 0)
                processes[0].Kill();

            // Get current time zone.
            TimeZone zone = TimeZone.CurrentTimeZone;
            string standard = zone.StandardName;
            ServerDir = inputSetting.ITCDirectory;
            if (standard != "India Standard Time") { ServerDir = inputSetting.AustinDirectory; }

            string LocalDir = System.IO.Directory.GetCurrentDirectory();

            //Check the program is running as updater or Installer
            if (System.IO.Path.GetFileNameWithoutExtension(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) == "Update")
            {
                //Skip the development copy
                if (!System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName).Contains("bin\\Debug")) CopyDir(ServerDir, LocalDir);
            }
            else //runs as installer
            {
                InstallerForm f = new InstallerForm(FolderStructure + Production + "\\Summary Tool.exe");
                LocalDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),"Summary Tool");
                if (!System.IO.Directory.Exists(LocalDir)) System.IO.Directory.CreateDirectory(LocalDir);
                DirectoryCopy(ServerDir, LocalDir);
                appShortcutToDesktop("test"); //***cb*******
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            string path = ConfigurationManager.AppSettings["binarypath"];
            string exePath = Path.Combine(path, "Update.exe");

            string connection = ConfigurationManager.ConnectionStrings["default"].ConnectionString;
            string localpath = ConfigurationManager.AppSettings["localfolder"];
            bool isEC2 = Convert.ToBoolean(ConfigurationManager.AppSettings["isEC2"]);

            /*
            string ftpHost = ConfigurationManager.AppSettings["ftp-host"];
            string ftpUsername = ConfigurationManager.AppSettings["ftp-username"];
            string ftpPassword = ConfigurationManager.AppSettings["ftp-password"];
             */

            Settings settings = new Settings(5, connection, "", "", "",false, localpath);

            FeedUpdater updater = new FeedUpdater(settings);
            updater.ClearOldItems();
            updater.Update();

            // Shutdown the PC
            if (isEC2)
            {
                Process.Start("shutdown", "/s");
            }
        }
コード例 #3
0
        public Updater()
        {
            inputSetting = (Settings)xobj;
            //Kill the process
            Process[] processes = Process.GetProcessesByName("SummaryToolForm");
            if (processes.Length > 0)
                processes[0].Kill();

            // Get current time zone.
            TimeZone zone = TimeZone.CurrentTimeZone;
            string standard = zone.StandardName;
            ServerDir = inputSetting.ITCDirectory;
            if (standard != "India Standard Time") { ServerDir = inputSetting.AustinDirectory; }

            string Base = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;

            string LocalDir = System.IO.Path.GetDirectoryName(Base).Replace("file:\\", "");
            //Copies the files from server
            InstallerForm f = new InstallerForm(FolderStructure + Production + "\\SummaryToolForm.exe");
               //Check the program is running as updater or Installer
            if (System.IO.Path.GetFileNameWithoutExtension(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) == "Update")
            {
                //Skip the development copy
                if (!System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName).Contains("bin\\Debug"))
                {
                    //DirectoryCopy(ServerDir, LocalDir,true,true);
                    MessageBox.Show("Updated Successfully.!");

                    //To get the location the assembly normally resides on disk or the install directory
                    Base = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;

                    LocalDir = System.IO.Path.GetDirectoryName(Base).Replace("file:\\", "");

                    System.Diagnostics.Process.Start(System.IO.Path.Combine(LocalDir, "SummaryToolForm.exe"));
                }
            }
            else //runs as installer
            {
                MessageBox.Show("Installed, use the shortcut created in your desktop (Ctrl+Alt+C)!");
            }
        }