Beispiel #1
0
 /// <summary>
 /// Creates a new blog category / tag.
 /// </summary>
 /// <param name="blogid">The blogid.</param>
 /// <param name="username">The username.</param>
 /// <param name="password">The password.</param>
 /// <param name="category">The category.</param>
 /// <returns></returns>
 public string newCategory(
     string blogid,
     string username,
     string password,
     wpCategory category)
 {
     if (User.validateCredentials(username, password, false))
     {
         Channel userChannel = new Channel(username);
         if (userChannel.FieldCategoriesAlias != null && userChannel.FieldCategoriesAlias != "")
         {
             // Find the propertytype via the document type
             ContentType         blogPostType = ContentType.GetByAlias(userChannel.DocumentTypeAlias);
             PropertyType        categoryType = blogPostType.getPropertyType(userChannel.FieldCategoriesAlias);
             interfaces.IUseTags tags         = UseTags(categoryType);
             if (tags != null)
             {
                 tags.AddTag(category.name);
             }
             else
             {
                 PreValue pv = new PreValue();
                 pv.DataTypeId = categoryType.DataTypeDefinition.Id;
                 pv.Value      = category.name;
                 pv.Save();
             }
         }
     }
     return("");
 }
        private List <UmbracoDropdownListNtextDataType> GetAvailableValues(string dataTypeName)
        {
            // Get a sorted list of all prevalues
            SortedList typeTypes = GetPreValues(dataTypeName);

            // Get the datatype enumerator (to sort as in Backoffice)
            IDictionaryEnumerator i = typeTypes.GetEnumerator();

            // Create the list which will hold the values
            var ret = new List <UmbracoDropdownListNtextDataType>();

            // Counter for sort order in return list
            int sortOrder = 0;

            // Move trough the enumerator
            while (i.MoveNext())
            {
                // Get the prevalue (text) using umbraco.cms.businesslogic.datatype
                PreValue statusType = (PreValue)i.Value;
                var      r          = new UmbracoDropdownListNtextDataType();

                // Add to the instanced model OrderItemStatusModel
                r.Id    = statusType.Id;
                r.Order = sortOrder;

                // If we have "08:Something" then just return last part
                r.Value = statusType.Value.Split(':').Last();

                // Add to our statusList
                ret.Add(r);
                sortOrder++;
            }

            return(ret);
        }
        /// <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>
        /// Gets the alias of the specified PreValue
        /// </summary>
        /// <param name="preValue">The PreValue.</param>
        /// <returns>The alias</returns>
        public static string GetAlias(this PreValue preValue)
        {
            using (var sqlHelper = Application.SqlHelper)
                using (var reader = sqlHelper.ExecuteReader(
                           "SELECT alias FROM cmsDataTypePreValues WHERE id = @id",
                           sqlHelper.CreateParameter("@id", preValue.Id)))
                {
                    var hasRows = reader.Read();

                    if (!hasRows)
                    {
                        return(null);
                    }

                    var alias = string.Empty;

                    while (hasRows)
                    {
                        if (reader.ContainsField("alias") && !reader.IsNull("alias"))
                        {
                            alias = reader.GetString("alias");
                        }

                        hasRows = reader.Read();
                    }

                    return(alias);
                }
        }
Beispiel #5
0
        public CategoryInfo[] getCategories(
            string blogid,
            string username,
            string password)
        {
            if (validateUser(username, password))
            {
                Channel userChannel = new Channel(username);
                if (userChannel.FieldCategoriesAlias != null && userChannel.FieldCategoriesAlias != "")
                {
                    // Find the propertytype via the document type
                    ContentType  blogPostType = ContentType.GetByAlias(userChannel.DocumentTypeAlias);
                    PropertyType categoryType = blogPostType.getPropertyType(userChannel.FieldCategoriesAlias);

                    // check if the datatype uses tags or prevalues
                    CategoryInfo[]      returnedCategories = null;
                    interfaces.IUseTags tags = UseTags(categoryType);
                    if (tags != null)
                    {
                        List <interfaces.ITag> alltags = tags.GetAllTags();
                        returnedCategories = new CategoryInfo[alltags.Count];
                        int counter = 0;
                        foreach (interfaces.ITag t in alltags)
                        {
                            CategoryInfo ci = new CategoryInfo();
                            ci.title       = t.TagCaption;
                            ci.categoryid  = t.Id.ToString();
                            ci.description = "";
                            ci.rssUrl      = "";
                            ci.htmlUrl     = "";
                            returnedCategories[counter] = ci;
                            counter++;
                        }
                    }
                    else
                    {
                        SortedList categories = PreValues.GetPreValues(categoryType.DataTypeDefinition.Id);
                        returnedCategories = new CategoryInfo[categories.Count];
                        IDictionaryEnumerator ide = categories.GetEnumerator();
                        int counter = 0;
                        while (ide.MoveNext())
                        {
                            PreValue     category = (PreValue)ide.Value;
                            CategoryInfo ci       = new CategoryInfo();
                            ci.title       = category.Value;
                            ci.categoryid  = category.Id.ToString();
                            ci.description = "";
                            ci.rssUrl      = "";
                            ci.htmlUrl     = "";
                            returnedCategories[counter] = ci;
                            counter++;
                        }
                    }

                    return(returnedCategories);
                }
            }

            throw new ArgumentException("Categories doesn't work for this channel, they might not have been activated. Contact your umbraco administrator.");
        }
Beispiel #6
0
        public override List <PreValue> GetPreValues(Field field)
        {
            List <PreValue> list = new List <PreValue>();

            string[]    selectedLists = ListsToInclude.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            Api         api           = new Api();
            List <List> lists         = api.GetLists();

            foreach (string selectedList in selectedLists)
            {
                List mailingList = lists.SingleOrDefault(l => l.ListID == selectedList);
                if (mailingList != null)
                {
                    PreValue pv = new PreValue();
                    pv.Id    = mailingList.ListID;
                    pv.Value = mailingList.Name;
                    if (field != null)
                    {
                        pv.Field = field.Id;
                    }
                    list.Add(pv);
                }
            }
            return(list);
        }
Beispiel #7
0
        /// <summary>
        /// Gets the alias of the specified PreValue
        /// </summary>
        /// <param name="preValue">The PreValue.</param>
        /// <returns>The alias</returns>
        public static string GetAlias(this PreValue preValue)
        {
            using (var reader = uQuery.SqlHelper.ExecuteReader(
                       "SELECT alias FROM cmsDataTypePreValues WHERE id = @id",
                       uQuery.SqlHelper.CreateParameter("@id", preValue.Id)))
            {
                var hasRows = reader.Read();

                if (!hasRows)
                {
                    return(null);
                }

                var alias = string.Empty;

                while (hasRows)
                {
                    var tmpStr = string.Empty;

                    if (reader.TryGetColumnValue("alias", out tmpStr))
                    {
                        alias = tmpStr;
                    }

                    hasRows = reader.Read();
                }

                return(alias);
            }
        }
Beispiel #8
0
        private void updateCategories(Document doc, Post post, Channel userChannel)
        {
            if (userChannel.FieldCategoriesAlias != null && userChannel.FieldCategoriesAlias != "")
            {
                ContentType  blogPostType = ContentType.GetByAlias(userChannel.DocumentTypeAlias);
                PropertyType categoryType = blogPostType.getPropertyType(userChannel.FieldCategoriesAlias);

                String[]            categories    = post.categories;
                string              categoryValue = "";
                interfaces.IUseTags tags          = UseTags(categoryType);
                if (tags != null)
                {
                    tags.RemoveTagsFromNode(doc.Id);
                    for (int i = 0; i < categories.Length; i++)
                    {
                        tags.AddTagToNode(doc.Id, categories[i]);
                    }
                }
                else
                {
                    for (int i = 0; i < categories.Length; i++)
                    {
                        PreValue pv = new PreValue(categoryType.DataTypeDefinition.Id, categories[i]);
                        categoryValue += pv.Id + ",";
                    }
                }
                if (categoryValue.Length > 0)
                {
                    categoryValue = categoryValue.Substring(0, categoryValue.Length - 1);
                }

                doc.getProperty(userChannel.FieldCategoriesAlias).Value = categoryValue;
            }
        }
Beispiel #9
0
        /// <summary>
        /// get all picked items as a collection of Enum
        /// </summary>
        /// <returns>a collection of Enums, or empty collection</returns>
        public IEnumerable <Enum> AsEnums()
        {
            List <Enum> enums          = new List <Enum>();
            PreValue    dataSourceJson = this.GetDataTypePreValue("dataSource");

            if (dataSourceJson != null)
            {
                EnumDataSource enumDataSouce = JsonConvert.DeserializeObject <EnumDataSource>(dataSourceJson.Value);

                Type enumType = Helper.GetAssembly(enumDataSouce.AssemblyName).GetType(enumDataSouce.EnumName);

                foreach (string pickedKey in this.PickedKeys)
                {
                    foreach (Enum enumItem in Enum.GetValues(enumType))
                    {
                        if (pickedKey == enumItem.GetKey())
                        {
                            enums.Add(enumItem);
                        }
                    }
                }
            }

            return(enums);
        }
 /// <summary>
 /// Formats the prevalue as a dictionary (as we need to return not just the value, but also the sort-order, to the client)
 /// </summary>
 /// <param name="preValue">The prevalue to format</param>
 /// <returns>Dictionary object containing the prevalue formatted with the field names as keys and the value of those fields as the values</returns>
 private IDictionary <string, object> PreValueAsDictionary(PreValue preValue)
 {
     return(new Dictionary <string, object>()
     {
         { "value", preValue.Value }, { "sortOrder", preValue.SortOrder }
     });
 }
        public bool DeletePreValue(PreValue prevalue)
        {
            string sql = "DELETE from UFprevalues where id = @id";

            sqlHelper.ExecuteNonQuery(sql, sqlHelper.CreateParameter("@id", prevalue.Id));

            return(true);
        }
Beispiel #12
0
    /// <summary>
    /// Return Id of a PreValue
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <param name="value">value as a string</param>
    /// <returns>Returns the id of the Property if exists, if not returns 0</returns>
    public static int PropertyId(UmbracoType parameter, string value)
    {
        int id = Convert.ToInt32(GetParameterValue(parameter));
        IEnumerable <PreValue> data = DataTypeValue(id);
        PreValue preValue           = data.SingleOrDefault(dt => dt.Value.ToLower() == value.ToLower());

        return((preValue != null) ? preValue.Id : 0);
    }
Beispiel #13
0
    /// <summary>
    /// Return a value of a PreValue by value
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <param name="preValueId">id of the PreValue</param>
    /// <returns>Returns the value of the PreValue if exists, if not returns an empty string</returns>
    public static string PropertyValue(UmbracoType parameter, int preValueId)
    {
        int id = Convert.ToInt32(GetParameterValue(parameter));
        IEnumerable <PreValue> data = DataTypeValue(id);
        PreValue preValue           = data.SingleOrDefault(dt => dt.Id == preValueId);
        string   result             = (preValue != null) ? preValue.Value : string.Empty;

        return(result);
    }
        public override IDictionary <string, PreValue> ConvertEditorToDb(IDictionary <string, object> editorValue, PreValueCollection currentValue)
        {
            var val    = editorValue["items"] as JArray;
            var result = new Dictionary <string, PreValue>();

            if (val == null)
            {
                return(result);
            }

            try
            {
                var useLabel = false;
                if (editorValue.TryGetValue("useLabel", out var useLabelObj))
                {
                    useLabel           = useLabelObj is string && (string)useLabelObj == "1";
                    result["useLabel"] = new PreValue(useLabel ? "1" : "0");
                }

                // get all non-empty values
                var index = 0;
                // items get submitted in the sorted order, so just count them up
                var sortOrder = -1;
                foreach (var preValue in val.OfType <JObject>()
                         .Where(x => x["value"] != null)
                         .Select(x =>
                {
                    var idString = x["id"] == null ? "0" : x["id"].ToString();
                    int.TryParse(idString, out var id);

                    var color = x["value"].ToString();
                    if (string.IsNullOrWhiteSpace(color))
                    {
                        return(null);
                    }

                    var label = x["label"].ToString();

                    sortOrder++;

                    var value = JsonConvert.SerializeObject(new { value = color, label = label, sortOrder = sortOrder });

                    return(new PreValue(id, value, sortOrder));
                })
                         .WhereNotNull())
                {
                    result.Add(index.ToInvariantString(), preValue);
                    index++;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error <ValueListPreValueEditor>("Could not deserialize the posted value: " + val, ex);
            }

            return(result);
        }
Beispiel #15
0
        /// <summary>
        /// Updates the prevalues for the property editor
        /// </summary>
        /// <param name="prevalue">The new value</param>
        /// <param name="alias">The prevalue to update</param>
        public void UpdatePrevalueForEditor(string prevalue, string alias)
        {
            IDataTypeDefinition            datatype  = _dataTypeService.GetDataTypeDefinitionByPropertyEditorAlias(Alias).First();
            IDictionary <string, PreValue> prevalues = _dataTypeService.GetPreValuesCollectionByDataTypeId(datatype.Id).PreValuesAsDictionary;

            prevalues[alias] = new PreValue(prevalue);

            _dataTypeService.SaveDataTypeAndPreValues(datatype, prevalues);
        }
Beispiel #16
0
 private EmbeddedContentConfig GetConfig(int dataTypeId)
 {
     using (_profilingLogger.DebugDuration <EmbeddedContentValueConverter>($"GetConfig({dataTypeId})"))
     {
         PreValueCollection preValues      = _dataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeId);
         PreValue           configPreValue = preValues.PreValuesAsDictionary["embeddedContentConfig"];
         return(JsonConvert.DeserializeObject <EmbeddedContentConfig>(configPreValue.Value));
     }
 }
        public PreValue InsertPreValue(Field field, string value)
        {
            PreValue pv = new PreValue();

            pv.Field = field.Id;
            pv.Value = value;


            return(InsertPreValue(pv));
        }
Beispiel #18
0
    /// <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();
    }
        public PreValue UpdatePreValue(PreValue prevalue)
        {
            string sql = "UPDATE UFprevalues SET field = @field, value = @value, sortorder = @sortorder where id = @id;";

            sqlHelper.ExecuteNonQuery(sql,
                                      sqlHelper.CreateParameter("@field", prevalue.Field),
                                      sqlHelper.CreateParameter("@value", prevalue.Value),
                                      sqlHelper.CreateParameter("@id", prevalue.Id),
                                      sqlHelper.CreateParameter("@sortorder", prevalue.SortOrder));

            return(prevalue);
        }
        public int?GetDropDownId(string dataTypeName, string val)
        {
            var dataType = _dataTypeService.GetDataTypeDefinitionByName(dataTypeName);

            if (dataType == null)
            {
                return(null);
            }
            PreValue preValue = _dataTypeService.GetPreValuesCollectionByDataTypeId(dataType.Id).PreValuesAsArray.FirstOrDefault(d => d.Value == val);

            return(preValue != null ? preValue.Id : (int?)null);
        }
Beispiel #21
0
        /// <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;
        }
Beispiel #22
0
    /// <summary>
    /// Return the Value of a PreValue by object
    /// </summary>
    /// <param name="parameter">UmbracoType</param>
    /// <param name="value">value as a object</param>
    /// <returns>Returns the value of the Property if exists, if not returns an empty string</returns>
    public static string PropertyValue(UmbracoType parameter, object value)
    {
        string result = string.Empty;

        if (DBNull.Value != value)
        {
            int pvalue = Convert.ToInt32(value);
            int id     = Convert.ToInt32(GetParameterValue(parameter));
            IEnumerable <PreValue> data = DataTypeValue(id);
            PreValue preValue           = data.SingleOrDefault(dt => dt.Id == pvalue);
            result = (preValue != null) ? preValue.Value : string.Empty;
        }
        return(result);
    }
        public PreValue InsertPreValue(PreValue prevalue)
        {
            prevalue.Id = Guid.NewGuid();


            string sql = "INSERT INTO UFprevalues(id, field, value, sortorder) VALUES(@id, @field, @value, @sortorder);";

            sqlHelper.ExecuteNonQuery(sql,
                                      sqlHelper.CreateParameter("@id", prevalue.Id),
                                      sqlHelper.CreateParameter("@field", prevalue.Field),
                                      sqlHelper.CreateParameter("@value", prevalue.Value),
                                      sqlHelper.CreateParameter("@sortorder", prevalue.SortOrder));

            return(prevalue);
        }
Beispiel #24
0
        /// <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();
     }
 }
Beispiel #26
0
        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();
            }
        }
        public List <PreValue> GetAllPreValues(Field field)
        {
            List <PreValue> l   = new List <PreValue>();
            string          sql = "SELECT * From UFprevalues where field = @field";

            IRecordsReader rr = sqlHelper.ExecuteReader(sql,
                                                        sqlHelper.CreateParameter("@field", field.Id));

            while (rr.Read())
            {
                PreValue pv = PreValue.CreateFromDataReader(rr);
                l.Add(pv);
            }

            rr.Dispose();
            return(l);
        }
Beispiel #28
0
        /// <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);
                }
            }
        }
        public PreValue GetPreValue(Guid id)
        {
            string sql = "SELECT * From UFprevalues where id = @id";

            IRecordsReader rr = sqlHelper.ExecuteReader(sql,
                                                        sqlHelper.CreateParameter("@id", id));

            PreValue pv = new PreValue();

            if (rr.Read())
            {
                pv = PreValue.CreateFromDataReader(rr);

                return(pv);
            }
            rr.Dispose();
            return(pv);
        }
Beispiel #30
0
        /// <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);
                }
            }
        }
        public override List<PreValue> GetPreValues(Field field, Form form)
        {
            var result = new List<PreValue>();
            try
            {
                var sort = 0;
                var tr = new StreamReader(HttpContext.Current.Server.MapPath(TextFile));
                var values = tr.ReadToEnd().Split(new[] { "\r\n" }, StringSplitOptions.None);
                foreach (var value in values)
                {
                    if (string.IsNullOrEmpty(value.Trim()))
                    {
                        continue;
                    }

                    var parts = value.Split('\t');
                    if (parts.Length != 2)
                    {
                        continue;
                    }

                    var pv = new PreValue
                    {
                        Id = parts[0],
                        Value = parts[1],
                        SortOrder = sort
                    };
                    result.Add(pv);
                    sort++;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error<GetIdsAndValuesFromTextFile>(string.Format("Get Ids and values from textfile provider: {0}", ex), ex);
            }

            return result;
        }
        public override List<PreValue> GetPreValues(Field field)
        {
            List<PreValue> list = new List<PreValue>();
            string[] selectedLists = ListsToInclude.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            Api api = new Api();
            List<List> lists = api.GetLists();

            foreach (string selectedList in selectedLists)
            {
                List mailingList = lists.SingleOrDefault(l => l.ListID == selectedList);
                if (mailingList != null)
                {
                    PreValue pv = new PreValue();
                    pv.Id = mailingList.ListID;
                    pv.Value = mailingList.Name;
                    if (field != null)
                    {
                        pv.Field = field.Id;
                    }
                    list.Add(pv);
                }
            }
            return list;
        }