Ejemplo n.º 1
0
        private void Btn_Options_Click(object sender, EventArgs e)
        {
            FormSetting f = new FormSetting();

            f.radioClient = radioClient;
            f.ShowDialog(this);

            if (f.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                if (f.restartProxy) // 改動proxy相關資料需要重新啟動proxy
                {
                    /*
                     * new FormWait(() =>
                     * {
                     *  string response = radioClient.Send(JsonConvert.SerializeObject(new FMsg { Type = "CMD", Data = "StopProxy" }));
                     *  if (response.Equals("OK"))
                     *  {
                     *      UpdateMSGtoUI("SMTP/IMAP Service Stopped.");
                     *      response = radioClient.Send(JsonConvert.SerializeObject(new FMsg { Type = "CMD", Data = "StartProxy" }));
                     *      if (response.Equals("OK"))
                     *          UpdateMSGtoUI("SMTP/IMAP Service Re-Started.");
                     *  }
                     *  else
                     *      UpdateMSGtoUI("SMTP/IMAP Service Stop fail. Response:" + response);
                     *
                     *
                     * }).SetMessage("ReStarting SMTP/IMAP Service ...").ShowDialog();
                     */
                    MessageBox.Show("Mail Setting changed, need system reboot to take effect.");
                }
            }

            RegSetting.GetSettingsFromRegistry();
            getStatus();
            alwaysActiveToolStripMenuItem.Checked = RegSetting.hasRight(FConstants.FeatureByte.AlwaysRun) ? true : false;

            if (m_DMSCancellationSource != null)
            {
                m_DMSCancellationSource.Cancel();
                m_DMSCancellationSource = null;
            }

            if (RegSetting.DMS_Enable)
            {
                var dateNow = DateTime.Now;
                var date    = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, RegSetting.DMS_TriggerAt.Hour, RegSetting.DMS_TriggerAt.Minute, 0);
                updateDMSAt(getNextDate(date));
            }


            /*
             * if (f.DialogResult == System.Windows.Forms.DialogResult.OK)
             * {
             *  //若使用者在Form2按下了OK,則進入這個判斷式
             *  //textBox1.Text = "按下了" + f.DialogResult.ToString();
             * }
             * else if (f.DialogResult == System.Windows.Forms.DialogResult.Cancel)
             * {
             *  //若使用者在Form2按下了Cancel或者直接點選X關閉視窗,都會進入這個判斷式
             *  //textBox1.Text = "按下了" + f.DialogResult.ToString();
             * }
             * else
             * {
             *  //textBox1.Text = "按下了" + f.DialogResult.ToString();
             * }
             */
        }
Ejemplo n.º 2
0
        private bool InitializeFreyaEnvironment()
        {
            ///
            ///[確認Service存在並啟動]
            string serviceStatus = GetServiceStatus();

            if (serviceStatus.Equals("NotExist"))
            {
                if (FFunc.Heimdallr("install") == false)
                {
                    ExitFreya();
                    return(false);
                }
            }
            else
            {
                string FreyaDirectory = (string)FFunc.GetRegKey("FreyaDirectory");
                if (FreyaDirectory == null || !FreyaDirectory.Equals(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase))
                {
                    if (FFunc.Heimdallr("reinstall") == false)
                    {
                        ExitFreya();
                        return(false);
                    }
                }
            }
            //StartService();

            RegSetting.GetSettingsFromRegistry();
            ///
            /// [Registry]
            /// 確認 Email/WebService/SMTPServer有值,若無,則跳出Option視窗要求填寫
            while (RegSetting.EMail == null || RegSetting.Password == null || RegSetting.SMTPServerIP == null || RegSetting.WebServiceIP == null)
            {
                if (!RegSetting.hasRight(FConstants.FeatureByte.Hide))
                {
                    FormSetting f = new FormSetting();
                    f.radioClient = radioClient;
                    f.TopMost     = true;
                    f.TopLevel    = true;
                    f.ShowDialog(this);

                    //如果按下Cancel,直接結束程式
                    if (f.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                    {
                        this.Close();
                        ExitFreya();
                        return(false);
                    }
                    else if (f.DialogResult == System.Windows.Forms.DialogResult.OK)
                    {
                        radioClient.Send(JsonConvert.SerializeObject(new FMsg {
                            Type = "CMD", Data = "StartProxy"
                        }));
                        logger.WriteLine("[FreyaUI] Send options to service.");
                        RegSetting.GetSettingsFromRegistry();
                    }
                }
                else
                {
                    break;
                }
            }
            RegSetting.GetSettingsFromRegistry();
            getStatus();
            alwaysActiveToolStripMenuItem.Checked = RegSetting.hasRight(FConstants.FeatureByte.AlwaysRun) ? true : false;
            return(true);
        }