private static void Initialize(ChickenDataContext context) { var proxy = new Setting { Type = SettingType.ProxySetting, IsEnabled = true, Name = Const.BASETWEETSERVICENAME, }; context.Settings.InsertOnSubmit(proxy); var twip = new Setting { Type = SettingType.ProxySetting, IsEnabled = true, IsInUsed = true, Name = Const.TWIPTWEETSERVICENAME, Data = "https://wxt2005.org/tapi/o/6Z66RF" }; context.Settings.InsertOnSubmit(twip); context.SubmitChanges(); }
public void UpdateCurrentUser(User user) { var account = context.Settings.FirstOrDefault(s => s.Type == SettingType.CurrentUser && s.IsEnabled && s.IsInUsed); if (account == null) { account = new Setting { Type = SettingType.CurrentUser, IsEnabled = true, IsInUsed = true, }; context.Settings.InsertOnSubmit(account); } account.Name = user.Name; account.Data = JsonConvert.SerializeObject(user); context.SubmitChanges(); }
public void UpdateLanguage(string name) { var setting = context.Settings.FirstOrDefault(s => s.Type == SettingType.LanguageSetting && s.IsEnabled && s.IsInUsed); if (setting == null) { setting = new Setting { Type = SettingType.LanguageSetting, Name = name, }; context.Settings.InsertOnSubmit(setting); } setting.IsEnabled = setting.IsInUsed = true; setting.Name = name; context.SubmitChanges(); }
public void UpdageProxySetting(Setting setting) { var old = context.Settings.SingleOrDefault(s => s.Type == SettingType.ProxySetting && s.IsInUsed); if (old != null) old.IsInUsed = false; var @new = context.Settings.SingleOrDefault(s => s.Type == setting.Type && s.IsEnabled && s.Name == setting.Name); if (@new == null) { @new = new Setting { Type = SettingType.ProxySetting, Name = setting.Name, Data = setting.Data }; context.Settings.InsertOnSubmit(@new); } @new.IsInUsed = @new.IsEnabled = true; @new.Data = setting.Data; context.SubmitChanges(); }