Exemplo n.º 1
0
        private void FormMain_Shown(object sender, EventArgs e)
        {
            System.Timers.Timer Timer = new System.Timers.Timer(300000);

            Timer.Elapsed  += new System.Timers.ElapsedEventHandler(LoginKeep);
            Timer.AutoReset = true;
            Timer.Start();

            ListViewDataLoad();

            AppCommon.ProcessExecute(AppCommon.PathCombine(AppConfig.AppPath, "dboxSyncer.Task.exe"), "", -1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 同步设置按钮点击事件
        /// </summary>
        private void ButtonSetting_Click(object sender, EventArgs e)
        {
            XmlDocument XDocument     = new XmlDocument();
            XmlNode     XNode         = default(XmlNode);
            string      XPath         = "/configuration/appSettings/add[@key=\"{key}\"]";
            string      ConfigPath    = AppCommon.PathCombine(AppConfig.AppPath, "dboxSyncer.exe.config");
            string      IntervalTime  = listBoxIntervalTime.Text;
            string      UploadSpeed   = textBoxUploadSpeed.Text;
            string      DownloadSpeed = textBoxDownloadSpeed.Text;

            if (UploadSpeed.TypeInt() < 0 || UploadSpeed.TypeInt() > 1000)
            {
                MessageBox.Show(LangTable["tipsUploadSpeedError"].TypeString());
                return;
            }

            if (DownloadSpeed.TypeInt() < 0 || DownloadSpeed.TypeInt() > 1000)
            {
                MessageBox.Show(LangTable["tipsDownloadSpeedError"].TypeString());
                return;
            }

            XDocument.Load(ConfigPath);

            XNode = (XmlNode)XDocument.SelectSingleNode(XPath.Replace("{key}", "IntervalTime"));

            if (AppCommon.IsNothing(XNode) == false)
            {
                XNode.Attributes["value"].InnerText = IntervalTime;
            }

            XNode = (XmlNode)XDocument.SelectSingleNode(XPath.Replace("{key}", "UploadSpeed"));

            if (AppCommon.IsNothing(XNode) == false)
            {
                XNode.Attributes["value"].InnerText = UploadSpeed;
            }

            XNode = (XmlNode)XDocument.SelectSingleNode(XPath.Replace("{key}", "DownloadSpeed"));

            if (AppCommon.IsNothing(XNode) == false)
            {
                XNode.Attributes["value"].InnerText = DownloadSpeed;
            }

            XDocument.Save(ConfigPath);

            AppCommon.ProcessExit("dboxSyncer.Task");
            AppCommon.ProcessExecute(AppCommon.PathCombine(AppConfig.AppPath, "dboxSyncer.Task.exe"), "", -1);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 手工同步菜单点击事件
        /// </summary>
        private void ToolStripMenuItemSync_Click(object sender, EventArgs e)
        {
            if (AppCommon.ProcessExist("dboxSyncer.Process") == true)
            {
                MessageBox.Show(LangTable["tipsProcessing"].TypeString());
            }
            else
            {
                buttonSync.Enabled = false;
                buttonSync.Text    = LangTable["buttonProcessing"].TypeString();

                AppCommon.ProcessExecute(AppCommon.PathCombine(AppConfig.AppPath, "dboxSyncer.Process.exe"), "", -1);

                buttonSync.Enabled = true;
                buttonSync.Text    = LangTable["buttonSync"].TypeString();
            }
        }
Exemplo n.º 4
0
        public static void Main()
        {
            if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length - 1 > 0)
            {
                Application.Exit();
            }

            TimeSpan TS = new TimeSpan();

            try
            {
                do
                {
                    TS = DateTime.Now.AddMinutes(AppConfig.IntervalTime.TypeInt()) - DateTime.Now;

                    Thread.Sleep((int)TS.TotalMilliseconds);

                    if (AppCommon.ProcessExist("dboxSyncer") == false)
                    {
                        Application.Exit();
                    }

                    if (AppCommon.ProcessExist("dboxSyncer.Process") == false)
                    {
                        AppCommon.ProcessExecute(AppCommon.PathCombine(AppConfig.AppPath, "dboxSyncer.Process.exe"), "", 0);
                    }
                } while (true);
            }
            catch (Exception ex)
            {
                File.AppendAllText(AppCommon.PathCombine(AppConfig.AppPath, "error.log"), "" + DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n");
            }
            finally
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }