public static SettingFRS CreateMessageFromJSON(string json) { SettingFRS msg = null; try { msg = (SettingFRS)JsonConvert.DeserializeObject(json, typeof(SettingFRS)); } catch { } return(msg); }
/// <summary> /// 保存设置 /// </summary> /// <param name="setting"></param> /// <returns></returns> public static int Save(SettingFRS setting) { try { Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); //写入元素的Value //config.AppSettings.Settings["ConnectionStringMySQL"].Value = setting.ConnectionStringMySQL.ToString(); config.AppSettings.Settings["ChannelNum"].Value = setting.ChannelNum.ToString(); config.AppSettings.Settings["Interval"].Value = setting.Interval.ToString(); config.AppSettings.Settings["SearchFaceWidthThresh"].Value = setting.SearchFaceWidthThresh.ToString(); config.AppSettings.Settings["SearchFaceHeightThresh"].Value = setting.SearchFaceHeightThresh.ToString(); config.AppSettings.Settings["SearchFaceYawThresh"].Value = setting.SearchFaceYawThresh.ToString(); config.AppSettings.Settings["SearchFaceRollThresh"].Value = setting.SearchFaceRollThresh.ToString(); config.AppSettings.Settings["SearchFacePitchThresh"].Value = setting.SearchFacePitchThresh.ToString(); config.AppSettings.Settings["TopK"].Value = setting.TopK.ToString(); config.AppSettings.Settings["MaxPersonNum"].Value = setting.MaxPersonNum.ToString(); config.AppSettings.Settings["SearchFaceQualityThresh"].Value = setting.SearchFaceQualityThresh.ToString(); config.AppSettings.Settings["RegisterFaceWidthThresh"].Value = setting.RegisterFaceWidthThresh.ToString(); config.AppSettings.Settings["RegisterFaceYawThresh"].Value = setting.RegisterFaceYawThresh.ToString(); config.AppSettings.Settings["RegisterFaceRollThresh"].Value = setting.RegisterFaceRollThresh.ToString(); config.AppSettings.Settings["RegisterFacePitchThresh"].Value = setting.RegisterFacePitchThresh.ToString(); config.AppSettings.Settings["RegisterFaceQualityThresh"].Value = setting.RegisterFaceQualityThresh.ToString(); //一定要记得保存,写不带参数的config.Save()也可以 config.Save(ConfigurationSaveMode.Modified); } catch { return(ReturnCode.FAIL); } return(ReturnCode.SUCCESS); }