コード例 #1
0
        public void GetSettingsFromRegistry()
        {
            //SMTP
            EMail        = (string)FFunc.GetRegKey("EMail");
            Password     = (string)FFunc.GetRegKey("Password");
            IMAPServerIP = (string)FFunc.GetRegKey("IMAPServerIp");
            SMTPServerIP = (string)FFunc.GetRegKey("SmtpServerIp");
            WebServiceIP = (string)FFunc.GetRegKey("WebService");
            SMTPLogLevel = (string)FFunc.GetRegKey("SMTPLogLevel");

            //DMS
            object obj = FFunc.GetRegKey("DMSEnable"); //處理一開始GetRegKey return null

            DMS_Enable = (obj == null) ? false : Convert.ToBoolean(obj);

            obj            = FFunc.GetRegKey("DMS_TriggerAt");
            DMS_TriggerAt  = (obj == null) ? new DateTime(2018, 12, 25, 12, 0, 0) : Convert.ToDateTime(obj);
            obj            = FFunc.GetRegKey("DMS_LastUpdate");
            DMS_LastUpdate = (obj == null) ? new DateTime(2018, 1, 1, 12, 0, 0) : Convert.ToDateTime(obj);

            if (File.Exists(_DMSConfigFilePath))
            {
                DMS_Setting = JsonConvert.DeserializeObject <DMSSetting>(File.ReadAllText(_DMSConfigFilePath));
            }

            //Advanced
            LogLevel            = (FConstants.FreyaLogLevel)Convert.ToInt16(FFunc.GetRegKey("LogLevel"));
            FeatureByte         = (FConstants.FeatureByte)Convert.ToInt32(FFunc.GetRegKey("FeatureByte"));
            obj                 = FFunc.GetRegKey("SMTPLogWriterEnable"); //處理一開始GetRegKey return null
            SMTPLogWriterEnable = (obj == null) ? false : Convert.ToBoolean(obj);
        }
コード例 #2
0
        /// <summary>
        /// 從Json導入資料,並且寫入registry
        /// </summary>
        /// <param name="regJSON"></param>
        public void SetSettingsToRegisry(string regJSON)
        {
            FRegSetting r = new FRegSetting();

            r = JsonConvert.DeserializeObject <FRegSetting>(regJSON);

            EMail        = r.EMail;
            Password     = r.Password;
            IMAPServerIP = r.IMAPServerIP;
            SMTPServerIP = r.SMTPServerIP;
            SMTPLogLevel = r.SMTPLogLevel;
            WebServiceIP = r.WebServiceIP;

            DMS_Enable     = r.DMS_Enable;
            DMS_TriggerAt  = r.DMS_TriggerAt;
            DMS_LastUpdate = r.DMS_LastUpdate;
            DMS_Setting    = r.DMS_Setting;

            LogLevel            = r.LogLevel;
            FeatureByte         = r.FeatureByte;
            SMTPLogWriterEnable = r.SMTPLogWriterEnable;

            SetSettingsToRegisry();
        }
コード例 #3
0
 public FRegSetting()
 {
     DMS_Setting = new DMSSetting();
     GetSettingsFromRegistry();
 }