public ActionResult Index(FormCollection collection) { var serviceController = new Service.Library.Controllers.Settings(); var results = serviceController.Search(o => o.Viewable); if (results.Failed || results.Entity == null || !results.Entity.Any()) { throw new ApplicationException(results.Message); } foreach (var setting in results.Entity.Select(x => new SettingModel(x))) { if (!collection.AllKeys.Contains(setting.FullName)) { continue; } var value = collection[setting.FullName]; if (string.IsNullOrWhiteSpace(value)) { if (setting.InputType != InputTypes.Checkbox && setting.InputType != InputTypes.Password) { ModelState.AddModelError(setting.FullName, setting.ValidationMessage); } continue; } else { if (setting.InputType == InputTypes.Password) { var crypt = new QuickAES(); value = crypt.EncryptToString(value); } } if (setting.InputType == InputTypes.Checkbox) { value = collection.Get(setting.FullName).ToLower().Contains("t") ? "true" : "false"; } if (!setting.Value.Equals(value)) { serviceController.Set(setting.Id, value); } } if (ModelState.IsValid) { return(RedirectToAction("Index")); } return(Index()); }
public void LubrizolOutSettings(string validationKey) { const string prefix = "LubrizolOut"; var system = Context.ExternalSystems.FirstOrDefault(x => x.Id == ExternalSystems.LubrizolOut.Id); if (system == null) { return; } var factory = new Factory(Context); /* * Available = Factory.CreateSetting("Available", "Is the Lubrizol export available.", "true", 0, true, InputTypes.Checkbox, ExternalSystems.LubrizolOut); * Repeat = Factory.CreateSetting("Repeat", "Allow export task to repeat.", "true", 0, true, InputTypes.Checkbox, ExternalSystems.LubrizolOut); * RepeatInterval = Factory.CreateSetting("RepeatInterval", "Export repeat interval in minutes.", "3", 0, true, InputTypes.Text, ExternalSystems.LubrizolOut); * ServiceAddress = Factory.CreateSetting("ServiceAddress", "Service Address", "http://localhost", 2, true, InputTypes.Text, ExternalSystems.LubrizolOut); * Account = Factory.CreateSetting("ServiceAccount", "Service User Id", "admin", 3, true, InputTypes.Text, ExternalSystems.LubrizolOut); * Password = Factory.CreateSetting("ServicePassword", "Service Password", "admin", 4, true, InputTypes.Password, ExternalSystems.LubrizolOut); * LastUpdated = Factory.CreateSetting("LastUpdated", "Last updated timestamp on last person record exported.", "", 0, false, InputTypes.Text, ExternalSystems.LubrizolOut); * SourceSystem = Factory.CreateSetting("SourceSystem", "System whose data will be exported.", ExternalSystems.S2In.Id.ToString(), 0, false, InputTypes.Text, ExternalSystems.LubrizolOut); * ActiveEmployeeLibrary = Factory.CreateSetting("ActiveEmployeeLibrary", "Active Employees Library Url", "http://localhost", 7, true, InputTypes.Text, ExternalSystems.LubrizolOut); * InactiveEmployeeLibrary = Factory.CreateSetting("InactiveEmployeeLibrary", "Inactive Employees Library Url", "http://localhost", 7, true, InputTypes.Text, ExternalSystems.LubrizolOut); */ var crypt = new QuickAES(); factory.createSetting(system, prefix, LubrizolExport.Available); factory.createSetting(system, prefix, LubrizolExport.Repeat); factory.createSetting(system, prefix, LubrizolExport.RepeatInterval, "1"); factory.createSetting(system, prefix, LubrizolExport.ServiceAddress, "http://cencle06/_vti_bin/copy.asmx"); factory.createSetting(system, prefix, LubrizolExport.Account, "cencle06\\administrator"); factory.createSetting(system, prefix, LubrizolExport.Password, crypt.EncryptToString("T@ipan11")); factory.createSetting(system, prefix, LubrizolExport.LastUpdated); factory.createSetting(system, prefix, LubrizolExport.SourceSystem); factory.createSetting(system, prefix, LubrizolExport.ActiveEmployeeLibrary, "http://cencle06:10807/Active Employees"); factory.createSetting(system, prefix, LubrizolExport.InactiveEmployeeLibrary, "http://cencle06:10807/Inactive Employees"); factory.createSetting(system, prefix, LubrizolExport.SqlConnection, "Integrated Security=SSPI;Persist Security Info=False;User ID=r1sm;Initial Catalog=LubrizolConnector;Data Source=."); Context.SubmitChanges(); }