/// <summary> /// Saves the data for this instance of the PreValue Editor. /// </summary> public override void Save() { this.m_DataType.DBType = umbraco.cms.businesslogic.datatype.DBTypes.Ntext; lock (m_Locker) { var vals = PreValues.GetPreValues(this.m_DataType.DataTypeDefinitionId); if (vals.Count >= 1) { // update ((PreValue)vals[0]).Value = this._pickerType.SelectedValue; ((PreValue)vals[0]).Save(); } else { // insert PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, this._pickerType.SelectedValue); } // store the xpath if (vals.Count >= 2) { // update ((PreValue)vals[1]).Value = this._chooseTextBox.Text; ((PreValue)vals[1]).Save(); } else { // insert PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, this._chooseTextBox.Text); } } }
/// <summary> /// Add new value to a existing PreValue /// </summary> /// <param name="parameter">UmbracoType</param> /// <param name="value">value as a string</param> public static void SetPreValue(UmbracoType parameter, string value) { int id = Convert.ToInt32(GetParameterValue(parameter)); IEnumerable <PreValue> preValues = DataTypeValue(id); PreValue preValue = PreValue.MakeNew(id, value); preValue.DataTypeId = id; preValue.SortOrder = preValues.Max(pv => pv.SortOrder) + 1; preValue.Save(); }
/// <summary> /// Saves this instance. /// </summary> public void Save() { m_DataType.DBType = umbraco.cms.businesslogic.datatype.DBTypes.Ntext; if (UploadControl.HasFile) { Settings.BaseDir.CreateSubdirectory("MultiImageUploadPrevalues").CreateSubdirectory(m_DataType.DataTypeDefinitionId.ToString()); string savePath = string.Format("{0}\\MultiImageUploadPrevalues\\{1}\\{2}", Settings.BaseDir.FullName, m_DataType.DataTypeDefinitionId, UploadControl.FileName); string virtualPath = string.Format("{0}/MultiImageUploadPrevalues/{1}/{2}", Settings.BaseDirName, m_DataType.DataTypeDefinitionId, UploadControl.FileName); UploadControl.SaveAs(savePath); PreValue.MakeNew(m_DataType.DataTypeDefinitionId, TextControl.Text + "|" + VirtualPathUtility.ToAbsolute(virtualPath)); } return; }
/// <summary> /// Helper method to save/create pre value values in the db /// </summary> /// <param name="propIndex"></param> /// <param name="value"></param> /// <param name="currentVals"></param> private void SavePreValue(PropertyIndex propIndex, string value, SortedList currentVals) { var index = (int)propIndex; if (currentVals.Count >= ((int)propIndex + 1)) { //update ((PreValue)currentVals[index]).Value = value; ((PreValue)currentVals[index]).Save(); } else { //insert PreValue.MakeNew(m_DataType.DataTypeDefinitionId, value); } }
/// <summary> /// Inserts the value. /// </summary> /// <param name = "index">The index.</param> /// <param name = "value">The value.</param> /// <returns></returns> private void UpdatePreValue(int index, string value) { if (EditorPreValues.Count >= index + 1) { //update var preValue = (PreValue)EditorPreValues[index]; preValue.Value = value; preValue.Save(); } else { //insert var preValue = PreValue.MakeNew(_dataType.DataTypeDefinitionId, value); preValue.Save(); } }
public void SavePreValue(PropertyIndex propIndex, string value, SortedList currentVals) { var index = (int)propIndex; if (currentVals.Count >= (index + 1)) { ((PreValue)currentVals[index]).Value = value; ((PreValue)currentVals[index]).SortOrder = index + 1; ((PreValue)currentVals[index]).Save(); } else { PreValue preValue = PreValue.MakeNew(_dataType.DataTypeDefinitionId, value); preValue.SortOrder = index + 1; preValue.Save(); } }
/// <summary> /// Saves this instance. /// </summary> public override void Save() { // it will always be text since people may save a huge amount of selected nodes and serializing to xml could be large. this.m_DataType.DBType = umbraco.cms.businesslogic.datatype.DBTypes.Ntext; // need to lock this operation since multiple inserts are happening and if 2 threads reach here at the same time, there could be issues. lock (m_Locker) { var vals = PreValues.GetPreValues(this.m_DataType.DataTypeDefinitionId); if (vals.Count > 0) { // update ((PreValue)vals[0]).Value = this.MinValueTextBox.Text; ((PreValue)vals[0]).Save(); } else { // insert PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, this.MinValueTextBox.Text); } if (vals.Count > 1) { // update ((PreValue)vals[1]).Value = this.MaxValueTextBox.Text; ((PreValue)vals[1]).Save(); } else { // insert PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, this.MaxValueTextBox.Text); } if (vals.Count > 2) { // update ((PreValue)vals[2]).Value = this.IncrementValueTextBox.Text; ((PreValue)vals[2]).Save(); } else { // insert PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, this.IncrementValueTextBox.Text); } } }
/// <summary> /// /// </summary> public void Save() { this.m_DataType.DBType = umbraco.cms.businesslogic.datatype.DBTypes.Ntext; lock (m_Locker) { var vals = PreValues.GetPreValues(this.m_DataType.DataTypeDefinitionId); string selectedValuesAsCsv = GetSelectedPropertyAliases(); if (vals.Count >= 1) { // update ((PreValue)vals[0]).Value = selectedValuesAsCsv; ((PreValue)vals[0]).Save(); } else { // insert PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, selectedValuesAsCsv); } if (vals.Count >= 2) { //update ((PreValue)vals[1]).Value = _txtMaxResults.Text; ((PreValue)vals[1]).Save(); } else { //insert PreValue.MakeNew(m_DataType.DataTypeDefinitionId, _txtMaxResults.Text); } if (vals.Count >= 3) { //update ((PreValue)vals[2]).Value = _indexToSearch.SelectedValue; ((PreValue)vals[2]).Save(); } else { //insert PreValue.MakeNew(m_DataType.DataTypeDefinitionId, _indexToSearch.SelectedValue); } } }
/// <summary> /// Saves the data for this instance of the PreValue Editor. /// </summary> public override void Save() { this.m_DataType.DBType = umbraco.cms.businesslogic.datatype.DBTypes.Nvarchar; lock (m_Locker) { var vals = PreValues.GetPreValues(this.m_DataType.DataTypeDefinitionId); if (vals.Count >= 1) { // update ((PreValue)vals[0]).Value = this.RootDirectory.Text; ((PreValue)vals[0]).Save(); } else { // insert PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, this.RootDirectory.Text); } } }
/// <summary> /// Saves the data-type PreValue options. /// </summary> public void SaveAsJson(object options) { // serialize the options into JSON var serializer = new JavaScriptSerializer(); var json = serializer.Serialize(options); lock (m_Locker) { var prevalues = PreValues.GetPreValues(this.m_DataType.DataTypeDefinitionId); if (prevalues.Count > 0) { PreValue prevalue = (PreValue)prevalues[0]; // update prevalue.Value = json; prevalue.Save(); } else { // insert PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, json); } } }
/// <summary> /// Saves this instance. /// </summary> public void Save() { this.m_DataType.DBType = umbraco.cms.businesslogic.datatype.DBTypes.Nvarchar; lock (m_Locker) { var vals = PreValues.GetPreValues(this.m_DataType.DataTypeDefinitionId); var data = string.Concat(this.WidthTextBox.Text, Constants.Common.COMMA, this.StyleTextBox.Text); if (vals.Count >= 1) { // update ((PreValue)vals[0]).Value = data; ((PreValue)vals[0]).Save(); } else { // insert PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, data); } } this.SetPreviewTextbox(); }
/// <summary> /// Saves this instance. /// </summary> public override void Save() { PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, this.TextControl.Text); }
/// <summary> /// Saves this instance. /// </summary> public void Save() { if (this.Page.IsValid) { if (DataFormatDropDown == null || DefaultModeDropDown == null || ModeSelector == null || EnableTitleCheckbox == null || EnableNewWindowCheckbox == null) { return; } DataType.DBType = umbraco.cms.businesslogic.datatype.DBTypes.Ntext; // If none are selected that's no good - you need to have at least one. So // we shall select all of the modes in this case. if (!ModeSelector.Items.Cast <ListItem>().Any(x => x.Selected)) { ModeSelector.Items.Cast <ListItem>().ToList().ForEach(x => x.Selected = true); } // Get selected items var allowedModesDataSet = ModeSelector.Items.Cast <ListItem>() .Where(x => x.Selected) .Select(y => y.Text) .ToList(); // Generate "AllowedModes" data string to save - this needs to be the same format as the config above var allowedModesDataString = string.Join("|", allowedModesDataSet.ToArray()); // Validate Default Mode, set to the first allowed mode if it's not allowed if (!allowedModesDataSet.Contains(DefaultModeDropDown.SelectedItem.Text)) { // Set selected default mode var selectedDefaultModeItem = DefaultModeDropDown.Items.FindByText(allowedModesDataSet.First()); if (selectedDefaultModeItem != null) { DefaultModeDropDown.ClearSelection(); selectedDefaultModeItem.Selected = true; } } // I guess I'd better lock this? or something? should I? better safe than sorry. lock (m_Locker) { var vals = GetPreValues(); // Only save if one or more items were selected - otherwise this control doesn't make sense! if (!string.IsNullOrEmpty(allowedModesDataString)) { if (vals.Count >= 1) { //update ((PreValue)vals[0]).Value = allowedModesDataString; ((PreValue)vals[0]).Save(); } else { //insert PreValue.MakeNew(DataType.DataTypeDefinitionId, allowedModesDataString); } } if (vals.Count >= 2) { //update ((PreValue)vals[1]).Value = DataFormatDropDown.SelectedItem.Text; ((PreValue)vals[1]).Save(); } else { //insert PreValue.MakeNew(DataType.DataTypeDefinitionId, DataFormatDropDown.SelectedItem.Text); } if (vals.Count >= 3) { //update ((PreValue)vals[2]).Value = EnableTitleCheckbox.Checked.ToString(); ((PreValue)vals[2]).Save(); } else { //insert PreValue.MakeNew(DataType.DataTypeDefinitionId, EnableTitleCheckbox.Checked.ToString()); } if (vals.Count >= 4) { //update ((PreValue)vals[3]).Value = EnableNewWindowCheckbox.Checked.ToString(); ((PreValue)vals[3]).Save(); } else { //insert PreValue.MakeNew(DataType.DataTypeDefinitionId, EnableNewWindowCheckbox.Checked.ToString()); } if (vals.Count >= 5) { //update ((PreValue)vals[4]).Value = DefaultModeDropDown.SelectedItem.Text; ((PreValue)vals[4]).Save(); } else { //insert PreValue.MakeNew(DataType.DataTypeDefinitionId, DefaultModeDropDown.SelectedItem.Text); } } } }