Example #1
0
 /// <summary>
 /// Create one column site of Taxonomy
 /// </summary>
 /// <param name="args"></param>
 private static bool CreateColumnSiteTaxonomy(ParamsCreateSite args,  SPFieldType type)
 {
     var result = false;
     var columnSite =
         new SiteColumn(new ParamsSiteColumnDefaultValue
         {
             Web = args.Web,
             Name = args.Name,
             FieldType = type,
             Requiered = args.Requiered,
             Group = args.Group,
             AddPrefix = args.AddPrefix,
             DefaultValue = args.DefaultValue
         });
     if (!columnSite.Exist())
     {
         result = columnSite.CreateTaxonomy(args.GroupTerm, args.Term, args.MultiValue, args.Requiered);
     }
     args.Name = (args.AddPrefix) ? string.Concat(Constants.Prefix, args.Name) : args.Name;
     columnSite.RenameField(args.Name,
         string.IsNullOrEmpty(args.DisplayName) 
         ? args.Name 
         : args.DisplayName);
     if (args.Hidden)
     {
         columnSite.Hidden();
     }
     return result;
 }
Example #2
0
        private static void CreateColumnInList(ParamsColumnSite args)
        {
            var type = GetFieldType(args.FieldType);

            if (args.FieldType.Equals("Taxonomy"))
            {
                var columnSite = new SiteColumn
                                     (new ParamsSiteColumnDefaultValue
                {
                    Name         = args.Name,
                    FieldType    = type,
                    Requiered    = args.Requiered,
                    Group        = args.Group,
                    DefaultValue = args.DefaultValue,
                    AddPrefix    = args.AddPrefix
                });
                args.List.AddField(columnSite);
            }
            else
            {
                SiteColumn columnSite;
                switch (type)
                {
                case SPFieldType.MultiChoice:
                case SPFieldType.Choice:
                    columnSite = new SiteColumn(new ParamsSiteColumnChoices
                    {
                        Web       = args.List.Web,
                        Name      = args.Name,
                        FieldType = type,
                        Choices   = args.Choice,
                        Group     = args.Group,
                        AddPrefix = args.AddPrefix
                    },
                                                args.DefaultValue, args.Requiered);
                    break;

                default:
                    columnSite = new SiteColumn(new ParamsSiteColumnDefaultValue
                    {
                        Web          = args.List.Web,
                        Name         = args.Name,
                        FieldType    = type,
                        Requiered    = args.Requiered,
                        Group        = args.Group,
                        DefaultValue = args.DefaultValue,
                        MultiValue   = args.MultiValue,
                        AddPrefix    = args.AddPrefix
                    });
                    break;
                }

                if (!args.List.ExistField(columnSite))
                {
                    args.List.AddField(columnSite);
                }
            }
        }
Example #3
0
 private static bool CreateColumnSetParameters(ParamsCreateSite args, SiteColumn columnSite)
 {
     var result = false;
     if (!columnSite.Exist())
     {
         result = columnSite.Create();               
         if (args.Hidden) columnSite.Hidden();
     }
     return result;
 }
Example #4
0
        /// <summary>
        /// Create one column site
        /// </summary>
        /// <param name="args"></param>
        private static void CreateColumnSite(ParamsCreateSite args)
        {
            try
            {                
                var type = GetFieldType(args.FieldType);
                if (args.FieldType.Equals("Taxonomy"))
                {
                    CreateColumnSiteTaxonomy(args, type);
                }
                else
                {
                    SiteColumn columnSite;
                    switch (type)
                    {
                        case SPFieldType.MultiChoice:
                        case SPFieldType.Choice:
                            columnSite = new SiteColumn(
                                new ParamsSiteColumnChoices
                                {
                                    Web = args.Web,
                                    Name = args.Name,
                                    FieldType = type,
                                    Choices = args.Choice,
                                    Group = args.Group,
                                    AddPrefix = args.AddPrefix,
                                    DisplayName = args.DisplayName
                                }, args.DefaultValue, args.Requiered);
                            break;
                        case SPFieldType.Calculated:
                            columnSite = new SiteColumn(
                                new ParamsSiteColumnBaseExtended
                                {
                                    Web = args.Web,
                                    Name = args.Name,
                                    FieldType = type,
                                    Requiered = args.Requiered,
                                    Group = args.Group,
                                    AddPrefix = args.AddPrefix,
                                    DisplayName = args.DisplayName
                                }, args.Formula);
                            break;
                        case SPFieldType.Currency:
                            columnSite = new SiteColumn(
                                new ParamsSiteColumnBaseExtended
                            {
                                Web = args.Web,
                                Name = args.Name,
                                FieldType = type,
                                Requiered = args.Requiered,
                                Group = args.Group,
                                AddPrefix = args.AddPrefix,
                                DisplayName = args.DisplayName
                            }, args.FormatCurrency);
                            break;
                        case SPFieldType.DateTime:
                            columnSite = new SiteColumn(
                                new ParamsSiteColumnBaseExtended
                            {
                                Web = args.Web,
                                Name = args.Name,
                                FieldType = type,
                                Requiered = args.Requiered,
                                Group = args.Group,
                                AddPrefix = args.AddPrefix,
                                DisplayName = args.DisplayName
                            }, args.Date);
                            break;
                        default:
                            columnSite = new SiteColumn(
                                new ParamsSiteColumnDefaultValue
                                {
                                Web = args.Web,
                                Name = args.Name,
                                FieldType = type,
                                Requiered = args.Requiered,
                                Group = args.Group,
                                AddPrefix = args.AddPrefix,
                                DefaultValue = args.DefaultValue,
                                MultiValue = args.MultiValue,
                                DisplayName = args.DisplayName
                            });

                            break;
                    }
                    CreateColumnSetParameters(args, columnSite);
                }
                args.Web.Update();                
            }
            catch (Exception exception)
            {
                Logger.Error(string.Concat("Error CreateColumnSite", exception.Message));                
            }
        }
Example #5
0
 private static void CreateSiteColumn(SiteColumn column)
 {
 }