public SettingsValue GetSetting(string key) { //Path to the settings.config file var configPath = HostingEnvironment.MapPath(ConfigPath); //Load settings.config XML file XmlDocument settingsXml = new XmlDocument(); settingsXml.Load(configPath); //Get specific node XmlNode settingNode = settingsXml.SelectSingleNode("//Analytics/" + key); if (settingNode != null) { //Go & populate our model var setting = new SettingsValue(); setting.Key = settingNode.Name; setting.Label = settingNode.Attributes["label"].Value; setting.Description = settingNode.Attributes["description"].Value; setting.Value = settingNode.InnerText; return(setting); } return(null); }
public SettingsValue PostSetting(SettingsValue setting) { //Update the XML config file on disk //Path to the settings.config file var configPath = HostingEnvironment.MapPath(ConfigPath); //Load settings.config XML file XmlDocument settingsXml = new XmlDocument(); settingsXml.Load(configPath); //Get all child nodes of <Analytics> node XmlNode settingNode = settingsXml.SelectSingleNode("//Analytics/" + setting.Key); //Go & update the value if (settingNode != null) { settingNode.InnerText = setting.Value; } //Save the XML file back down to disk settingsXml.Save(configPath); //Return the same setting that passed in return(setting); }
/// <summary> /// Returns all tags for settings in which the value equals the search string /// </summary> /// <param name="partial"></param> /// <returns></returns> public static string[] FindValues(string searchString) { GetSingleton(); List <string> results = new List <string>(); lock (m_singleton) { string inputString; string[] inputFields; string UserSettingsFileName; UserSettingsFileName = GetAppPath(); if (File.Exists(UserSettingsFileName)) { // load the records into memory // open the file for reading try { StreamReader fileReader; string SettingsName; string SettingsValue; fileReader = new StreamReader(UserSettingsFileName); while ((inputString = fileReader.ReadLine()) != null) { if (!inputString.Contains(",")) { continue; } inputFields = inputString.Split(','); SettingsName = inputFields[0]; SettingsValue = inputFields[1]; if (SettingsValue.Equals(searchString)) { results.Add(SettingsName); } } // end while fileReader.Close(); } catch (Exception ex) { FileLogging.Set("GetCountByPartial exception : " + ex.Message); return(null); } // end try } // end if file exists else // the files has not been created, so this is an error { // MessageBox.Show("could not open user.config file"); return(null); } return(results.ToArray()); } }
/* ----------------------------------------------------------------- */ /// /// TagSettings /// /// <summary> /// タグ設定用ダイアログを生成します。 /// </summary> /// /* ----------------------------------------------------------------- */ public static TagForm TagSettings(Form owner, TagCollection model, SettingsValue settings) { var dest = new TagForm(model); dest.StartPosition = FormStartPosition.Manual; dest.Location = CreateLocation(owner); dest.FormClosing += (s, e) => { e.Cancel = CancelTagRemoving(s, settings.TagRemoveWarning); }; return(dest); }
/* ----------------------------------------------------------------- */ /// /// SettingsForm /// /// <summary> /// オブジェクトを初期化します。 /// </summary> /// /* ----------------------------------------------------------------- */ public SettingsForm(SettingsValue settings, int index = 0) { InitializeComponent(); UpdateLayout(Dpi / BaseDpi); Update(settings); InitializeEvents(); Caption = TitleControl; Caption.MinimizeControl.Visible = false; SettingsControl.OKButton = ApplyButton; SettingsControl.CancelButton = ExitButton; TabControl.SelectTab(index); DataFolderButton.Click += DataFolderButton_Click; }
/// <summary> /// Gets Settings from the XML settings.config /// </summary> /// <returns>Serializes settings from XML file into a nice list of objects</returns> public List <SettingsValue> GetSettings() { //A list to store our settings var settings = new List <SettingsValue>(); //Path to the settings.config file var configPath = HostingEnvironment.MapPath(ConfigPath); //Load settings.config XML file XmlDocument settingsXml = new XmlDocument(); settingsXml.Load(configPath); //Get all child nodes of <Analytics> node XmlNodeList analayticsNode = settingsXml.SelectNodes("//Analytics"); //Ensure we found the <Analytics> node in the config if (analayticsNode != null) { //Loop over child nodes inside <Analytics> node foreach (XmlNode settingNode in analayticsNode) { foreach (XmlNode setting in settingNode.ChildNodes) { //Go & populate our model from each item in the XML file var settingToAdd = new SettingsValue(); settingToAdd.Key = setting.Name; settingToAdd.Label = setting.Attributes["label"].Value; settingToAdd.Description = setting.Attributes["description"].Value; settingToAdd.Value = setting.InnerText; //Add the item to the list settings.Add(settingToAdd); } } } //Return the list return(settings); }
//Never did get around to tagging films to test this. //[Route("Suggestion")] //[HttpGet] //public HttpResponseMessage Suggestion() //{ // var tags = // _rentalHistoryService.GetByUserId(RequestContext.Principal.Identity.GetUserId()) // .SelectMany(x => x.Title.TitleMetaValues) // .Where(x=> x.ValueTypeId == 8) //Only get Genre Meta Tags // .GroupBy(x => x.Value) // .Select(x => new {Key = x.Key, Value = x.Distinct().Count()}).OrderByDescending(x=> x.Value); // //TODO: Be less random about how the meta tags are used to suggest a title // var titles = new List<Title>(); // var e = tags.GetEnumerator(); // if (e.MoveNext()) // { // titles.AddRange(_titleService.GetTitlesByGenreMetaTag(e.Current.Key)); // if (e.MoveNext()) // { // titles.AddRange(_titleService.GetTitlesByGenreMetaTag(e.Current.Key)); // } // var result = titles.ToArray(); // FisherYatesShuffle.Shuffle(result); // var response = Request.CreateResponse(HttpStatusCode.OK, result); // return response; // } // else // { // var result = _titleService.GetAll().ToArray(); // FisherYatesShuffle.Shuffle(result); // var response = Request.CreateResponse(HttpStatusCode.OK, result); // return response; // } //} private static bool ProcessPayment(SettingsValue paymentMethod) { //TODO return(true); }
protected void SetValue(string key, string value) { if (!dictionary.ContainsKey(key)) dictionary.Add(key, new SettingsValue(value)); else dictionary[key] = new SettingsValue(value); }
public static void Initialize(AppDbContext context, UserManager <AppUser> um) { if (context.Authors.Any()) { return; } var users = new Author[] { new Author { Fullname = "admin", Email = "*****@*****.**", Slug = "admin-page", CreatedAt = DateTime.Now, CreatedBy = 1, IsAdmin = true, IdentityId = um.Users.Single(u => u.Email.Equals("*****@*****.**")).Id, UserName = um.Users.Single(u => u.Email.Equals("*****@*****.**")).UserName }, new Author { Fullname = "user", Email = "*****@*****.**", Slug = "user-page", CreatedAt = DateTime.Now, CreatedBy = 1, IdentityId = um.Users.Single(u => u.Email.Equals("*****@*****.**")).Id, UserName = um.Users.Single(u => u.Email.Equals("*****@*****.**")).UserName } }; foreach (Author u in users) { context.Authors.Add(u); } context.SaveChanges(); var settings = new SettingsValue[] { new SettingsValue { Key = "Title", Value = "lrndr.pub", Type = SettingType.Blog, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("admin")).AuthorId }, new SettingsValue { Key = "Description", Value = "asp.net core blogging platform", Type = SettingType.Blog, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("admin")).AuthorId }, new SettingsValue { Key = "PostsPerPage", Value = "5", Type = SettingType.Blog, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("admin")).AuthorId }, new SettingsValue { Key = "EnableComments", Value = "true", Type = SettingType.Blog, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("admin")).AuthorId }, new SettingsValue { Key = "DaysToComment", Value = "90", Type = SettingType.Blog, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("admin")).AuthorId }, new SettingsValue { Key = "ModerateComments", Value = "true", Type = SettingType.Blog, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("admin")).AuthorId }, new SettingsValue { Key = "Theme", Value = "Standard", Type = SettingType.Blog, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("admin")).AuthorId } }; foreach (SettingsValue s in settings) { context.Settings.Add(s); } context.SaveChanges(); var posts = new Post[] { new Post { Title = "First post", Slug = "first-post", Content = "test content is going here.<p>testing paragrapg</p>", IsPublished = true, PublishedAt = DateTime.Now, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("admin")).AuthorId }, new Post { Title = "Second post", Slug = "second-post", Content = "test content is going here.<p>testing paragrapg</p>", IsPublished = true, PublishedAt = DateTime.Now, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("user")).AuthorId }, new Post { Title = "Third post", Slug = "third-post", Content = "test content is going here.<p>testing paragrapg</p>", IsPublished = true, PublishedAt = DateTime.Now, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("admin")).AuthorId }, new Post { Title = "Page One", Slug = "page1", Content = "test content is going here.<p>testing paragrapg</p>", IsPage = true, IsPublished = true, PublishedAt = DateTime.Now, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("admin")).AuthorId }, new Post { Title = "This is me", Slug = "this-is-me", Content = "test content is going here.<p>testing paragrapg</p>", IsPage = true, IsPublished = true, PublishedAt = DateTime.Now, CreatedAt = DateTime.Now, CreatedBy = context.Authors.FirstOrDefault(u => u.Fullname.Equals("admin")).AuthorId } }; foreach (Post p in posts) { context.Posts.Add(p); } context.SaveChanges(); var comments = new Comment[] { new Comment { Author = "Demo89", Content = "hej hej", Email = "*****@*****.**", IsOwner = false, IsPublished = true, PublishedAt = DateTime.Now, CreatedAt = DateTime.Now, PostId = 1 } }; foreach (Comment c in comments) { context.Comments.Add(c); } context.SaveChanges(); }
public HttpResponseMessage UpdateUserAddress(AddressModel addressModel) { var user = _userService.GetById(RequestContext.Principal.Identity.GetUserId()); if (user.SettingsValues.Any(x => x.ValueTypeId == 1)) { if (addressModel.Address1 != null) { var address1 = user.SettingsValues.First(x => x.ValueTypeId == 1); address1.Value = addressModel.Address1; _settingsValueService.Update(address1); } if (addressModel.Address2 != null) { var address2 = user.SettingsValues.First(x => x.ValueTypeId == 2); address2.Value = addressModel.Address2; _settingsValueService.Update(address2); } if (addressModel.City != null) { var city = user.SettingsValues.First(x => x.ValueTypeId == 3); city.Value = addressModel.City; _settingsValueService.Update(city); } if (addressModel.State != null) { var state = user.SettingsValues.First(x => x.ValueTypeId == 4); state.Value = addressModel.State; _settingsValueService.Update(state); } if (addressModel.Zip != null) { var zip = user.SettingsValues.First(x => x.ValueTypeId == 6); zip.Value = addressModel.Zip; _settingsValueService.Update(zip); } } else { var address1 = new SettingsValue { UserId = user.Id, ValueTypeId = 1, Value = addressModel.Address1 ?? "" }; _settingsValueService.Create(address1); var address2 = new SettingsValue { UserId = user.Id, ValueTypeId = 2, Value = addressModel.Address2 ?? "" }; _settingsValueService.Create(address2); var city = new SettingsValue { UserId = user.Id, ValueTypeId = 3, Value = addressModel.City ?? "" }; _settingsValueService.Create(city); var state = new SettingsValue { UserId = user.Id, ValueTypeId = 4, Value = addressModel.State ?? "" }; _settingsValueService.Create(state); var zip = new SettingsValue { UserId = user.Id, ValueTypeId = 6, Value = addressModel.Zip ?? "" }; _settingsValueService.Create(zip); } return(Request.CreateResponse(HttpStatusCode.NoContent)); }
/// <summary> /// Initialize this <c>Adapter</c>'s settings list. /// </summary> /// <returns>An <c>IList</c> of <c>SettingsValue</c> objects.</returns> protected override IList <SettingsValue> InitializeSettings() { // CRM 2011 will just use a deiscovery service URL provided by the user rather than piecing it together var list = base.InitializeSettings(); var setting = new SettingsValue(); var propertyChangedSettings = new List <SettingsValue>(); setting.FieldDefinition = GetCompanyDefField(); setting.Attributes = SettingsValueAttributes.Site | SettingsValueAttributes.SupportsValueList; setting.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.OrganizationNamePropertyChanged); list.Add(setting); setting = new SettingsValue(); setting.FieldDefinition = GetUserNameDefField(); setting.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.UserNameOrPasswordPropertyChanged); list.Add(setting); setting = new SettingsValue(); setting.FieldDefinition = GetUserPasswordDefField(); setting.Attributes = SettingsValueAttributes.Password; setting.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.UserNameOrPasswordPropertyChanged); list.Add(setting); setting = new SettingsValue(); setting.Value = true.ToString(); setting.FieldDefinition = GetImpersonateIntegrationUserDefField(); setting.Attributes = SettingsValueAttributes.HiddenFromUI; setting.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.ImpersonateIntegrationUserPropertyChanged); list.Add(setting); setting = new SettingsValue(); setting.FieldDefinition = GetProxyServerName(); setting.Attributes = SettingsValueAttributes.HiddenFromUI; setting.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.MetadataTimestampPropertyChanged); list.Add(setting); setting = new SettingsValue(); setting.FieldDefinition = GetMetadataTimestamp(); setting.Attributes = SettingsValueAttributes.HiddenFromUI; setting.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.MetadataTimestampPropertyChanged); list.Add(setting); setting = new SettingsValue(); setting.FieldDefinition = GetDiscoveryServiceUrlSetting(); setting.Value = @"https://<host>:<port>/XRMServices/2011/Discovery.svc"; propertyChangedSettings.Add(setting); list.Add(setting); setting = new SettingsValue(); setting.FieldDefinition = GetConfigUtilityLocationSetting(); setting.Attributes = SettingsValueAttributes.Informational; setting.Value = ConfigUtilityDefaultFilePath; propertyChangedSettings.Add(setting); list.Add(setting); var userNameSetting = list.FirstOrDefault(s => s.FieldDefinition.Name == "UserName"); if (userNameSetting != null) { userNameSetting.FieldDefinition.Description = Resources.CRMAdapterSettingsUserNameDesc; propertyChangedSettings.Add(userNameSetting); } foreach (var s in propertyChangedSettings) { s.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.setting_PropertyChanged); } return(list); }
private void Initialize() { SettingsValue = new SettingsValue(); }