コード例 #1
0
ファイル: action.aspx.cs プロジェクト: uNormatov/FreboCms
        protected override bool Insert()
        {
            ContentTypeInfo info = new ContentTypeInfo();
            info.Name = txtName.Text;
            info.TableName = txtTableName.Text;
            info.Description = txtDescription.Text;
            if (flpScreenshot.HasFile)
            {
                string guid = Guid.NewGuid().ToString();
                string fileName = guid + "_" + flpScreenshot.FileName;
                flpScreenshot.SaveAs(Server.MapPath("~/userfiles/") + fileName);
                info.Image = fileName;
            }
            else
                info.Image = "";

            _contentTypeProvider.Create(info, ErrorList);
            return CheckErrors();
        }
コード例 #2
0
ファイル: ContentType.cs プロジェクト: solarga/Asset
        public ContentTypeInfo GetModel(Guid id)
        {
            ContentTypeInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 AppCode,UserId,DepmtId,Id,ParentId,Coded,Named,Step,FlagName,Sort,Remark,RecordDate,LastUpdatedDate 
			            from ContentType
						where Id = @Id "                        );
            SqlParameter[] parms =
            {
                new SqlParameter("@Id", SqlDbType.UniqueIdentifier)
            };
            parms[0].Value = id;

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AssetDbConnString, CommandType.Text, sb.ToString(), parms))
            {
                if (reader != null)
                {
                    if (reader.Read())
                    {
                        model                 = new ContentTypeInfo();
                        model.AppCode         = reader.IsDBNull(0) ? string.Empty : reader.GetString(0);
                        model.UserId          = reader.IsDBNull(1) ? Guid.Empty : reader.GetGuid(1);
                        model.DepmtId         = reader.IsDBNull(2) ? Guid.Empty : reader.GetGuid(2);
                        model.Id              = reader.IsDBNull(3) ? Guid.Empty : reader.GetGuid(3);
                        model.ParentId        = reader.IsDBNull(4) ? Guid.Empty : reader.GetGuid(4);
                        model.Coded           = reader.IsDBNull(5) ? string.Empty : reader.GetString(5);
                        model.Named           = reader.IsDBNull(6) ? string.Empty : reader.GetString(6);
                        model.Step            = reader.IsDBNull(7) ? string.Empty : reader.GetString(7);
                        model.FlagName        = reader.IsDBNull(8) ? string.Empty : reader.GetString(8);
                        model.Sort            = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        model.Remark          = reader.IsDBNull(10) ? string.Empty : reader.GetString(10);
                        model.RecordDate      = reader.IsDBNull(11) ? DateTime.Parse("1754-01-01") : reader.GetDateTime(11);
                        model.LastUpdatedDate = reader.IsDBNull(12) ? DateTime.Parse("1754-01-01") : reader.GetDateTime(12);
                    }
                }
            }

            return(model);
        }
コード例 #3
0
ファイル: ContentType.cs プロジェクト: solarga/Asset
        public int InsertByOutput(ContentTypeInfo model)
        {
            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"insert into ContentType (Id,AppCode,UserId,DepmtId,ParentId,Coded,Named,Step,FlagName,Sort,Remark,RecordDate,LastUpdatedDate)
			            values
						(@Id,@AppCode,@UserId,@DepmtId,@ParentId,@Coded,@Named,@Step,@FlagName,@Sort,@Remark,@RecordDate,@LastUpdatedDate)
			            "            );

            SqlParameter[] parms =
            {
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@AppCode",         SqlDbType.Char,                10),
                new SqlParameter("@UserId",          SqlDbType.UniqueIdentifier),
                new SqlParameter("@DepmtId",         SqlDbType.UniqueIdentifier),
                new SqlParameter("@ParentId",        SqlDbType.UniqueIdentifier),
                new SqlParameter("@Coded",           SqlDbType.VarChar,             36),
                new SqlParameter("@Named",           SqlDbType.NVarChar,           256),
                new SqlParameter("@Step",            SqlDbType.VarChar,           1000),
                new SqlParameter("@FlagName",        SqlDbType.VarChar,             20),
                new SqlParameter("@Sort",            SqlDbType.Int),
                new SqlParameter("@Remark",          SqlDbType.NVarChar,           100),
                new SqlParameter("@RecordDate",      SqlDbType.DateTime),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value  = model.Id;
            parms[1].Value  = model.AppCode;
            parms[2].Value  = model.UserId;
            parms[3].Value  = model.DepmtId;
            parms[4].Value  = model.ParentId;
            parms[5].Value  = model.Coded;
            parms[6].Value  = model.Named;
            parms[7].Value  = model.Step;
            parms[8].Value  = model.FlagName;
            parms[9].Value  = model.Sort;
            parms[10].Value = model.Remark;
            parms[11].Value = model.RecordDate;
            parms[12].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.AssetDbConnString, CommandType.Text, sb.ToString(), parms));
        }
コード例 #4
0
ファイル: ContentType.cs プロジェクト: 2644783865/Wuye
        public IList <ContentTypeInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms)
        {
            int startIndex = (pageIndex - 1) * pageSize + 1;
            int endIndex   = pageIndex * pageSize;

            string cmdText = @"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber,
			                 Id,TypeName,TypeCode,TypeValue,ParentId,Sort,IsSys,LastUpdatedDate
							 from ContentType"                            ;

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += " where 1=1 " + sqlWhere;
            }
            cmdText += ")as objTable where RowNumber between " + startIndex + " and " + endIndex + " ";

            IList <ContentTypeInfo> list = new List <ContentTypeInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentTypeInfo model = new ContentTypeInfo();
                        model.Id              = reader.GetGuid(1);
                        model.TypeName        = reader.GetString(2);
                        model.TypeCode        = reader.GetString(3);
                        model.TypeValue       = reader.GetString(4);
                        model.ParentId        = reader.GetGuid(5);
                        model.Sort            = reader.GetInt32(6);
                        model.IsSys           = reader.GetBoolean(7);
                        model.LastUpdatedDate = reader.GetDateTime(8);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
コード例 #5
0
        public List <ContentTypeInfo> GetListByJoin()
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select ct.Id,ct.TypeName,ct.TypeCode,ct.TypeValue,ct.ParentId,ct.Sort,ct.PictureId,ct.IsSys,ct.LastUpdatedDate,
                        cp.OriginalPicture,cp.BPicture,cp.MPicture,cp.SPicture
			            from ContentType ct
                        left join ContentPicture cp on cp.Id = ct.PictureId
					    order by ct.LastUpdatedDate desc,ct.Sort desc "                    );

            List <ContentTypeInfo> list = new List <ContentTypeInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentTypeInfo model = new ContentTypeInfo();
                        model.Id              = reader.GetGuid(0);
                        model.TypeName        = reader.GetString(1);
                        model.TypeCode        = reader.GetString(2);
                        model.TypeValue       = reader.GetString(3);
                        model.ParentId        = reader.GetGuid(4);
                        model.Sort            = reader.GetInt32(5);
                        model.PictureId       = reader.IsDBNull(6) ? Guid.Empty : reader.GetGuid(6);
                        model.IsSys           = reader.GetBoolean(7);
                        model.LastUpdatedDate = reader.GetDateTime(8);
                        model.OriginalPicture = reader.IsDBNull(9) ? "" : reader.GetString(9);
                        model.BPicture        = reader.IsDBNull(10) ? "" : reader.GetString(10);
                        model.MPicture        = reader.IsDBNull(11) ? "" : reader.GetString(11);
                        model.SPicture        = reader.IsDBNull(12) ? "" : reader.GetString(12);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
コード例 #6
0
ファイル: ScannerController.cs プロジェクト: Qdabra/QFS
        private static void GetContentTypes(SiteInfo info, ClientContext clientContext, SP.Web web)
        {
            try
            {
                clientContext.Load(web.AvailableContentTypes,
                                   acts => acts.Where(act => act.Group == "Microsoft InfoPath" && act.Hidden == false)
                                   .Include(
                                       act => act.Description,
                                       act => act.DisplayFormTemplateName,
                                       act => act.DisplayFormUrl,
                                       act => act.DocumentTemplate,
                                       act => act.DocumentTemplateUrl,
                                       act => act.EditFormTemplateName,
                                       act => act.EditFormUrl,
                                       act => act.Group,
                                       act => act.Hidden,
                                       act => act.Id,
                                       act => act.Name,
                                       act => act.NewFormTemplateName,
                                       act => act.NewFormUrl,
                                       act => act.ReadOnly,
                                       act => act.SchemaXml,
                                       act => act.Scope,
                                       act => act.Sealed,
                                       act => act.StringId
                                       ));
                clientContext.ExecuteQuery();

                foreach (Microsoft.SharePoint.Client.ContentType ct in web.AvailableContentTypes)
                {
                    ContentTypeInfo cti = new ContentTypeInfo(ct);

                    info.ContentTypes.Add(cti);
                }
            }
            catch (Exception ex)
            {
                info.Messages.Add("Error collecting available content types");
            }
        }
コード例 #7
0
        public int Update(ContentTypeInfo model)
        {
            StringBuilder sb = new StringBuilder(500);

            sb.Append(@"update ContentType set UserId = @UserId,Coded = @Coded,Named = @Named,ParentId = @ParentId,Step = @Step,FlagName = @FlagName,Openness = @Openness,Sort = @Sort,Remark = @Remark,RecordDate = @RecordDate,LastUpdatedDate = @LastUpdatedDate 
			            where AppCode = @AppCode and Id = @Id
					    "                    );

            SqlParameter[] parms =
            {
                new SqlParameter("@AppCode",         SqlDbType.Char,                10),
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@UserId",          SqlDbType.UniqueIdentifier),
                new SqlParameter("@Coded",           SqlDbType.VarChar,             36),
                new SqlParameter("@Named",           SqlDbType.NVarChar,           256),
                new SqlParameter("@ParentId",        SqlDbType.UniqueIdentifier),
                new SqlParameter("@Step",            SqlDbType.VarChar,           1000),
                new SqlParameter("@FlagName",        SqlDbType.VarChar,             20),
                new SqlParameter("@Openness",        SqlDbType.TinyInt),
                new SqlParameter("@Sort",            SqlDbType.Int),
                new SqlParameter("@Remark",          SqlDbType.NVarChar,           100),
                new SqlParameter("@RecordDate",      SqlDbType.DateTime),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value  = model.AppCode;
            parms[1].Value  = model.Id;
            parms[2].Value  = model.UserId;
            parms[3].Value  = model.Coded;
            parms[4].Value  = model.Named;
            parms[5].Value  = model.ParentId;
            parms[6].Value  = model.Step;
            parms[7].Value  = model.FlagName;
            parms[8].Value  = model.Openness;
            parms[9].Value  = model.Sort;
            parms[10].Value = model.Remark;
            parms[11].Value = model.RecordDate;
            parms[12].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.TygaSoftDbConnString, CommandType.Text, sb.ToString(), parms));
        }
コード例 #8
0
        public IList <ContentTypeInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,TypeName,TypeCode,TypeValue,ParentId,Sort,PictureId,HasChild,IsSys,LastUpdatedDate
                        from ContentType ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.Append("order by Sort,LastUpdatedDate desc");

            IList <ContentTypeInfo> list = new List <ContentTypeInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentTypeInfo model = new ContentTypeInfo();
                        model.Id              = reader.GetGuid(0);
                        model.TypeName        = reader.GetString(1);
                        model.TypeCode        = reader.GetString(2);
                        model.TypeValue       = reader.GetString(3);
                        model.ParentId        = reader.GetGuid(4);
                        model.Sort            = reader.GetInt32(5);
                        model.PictureId       = reader.GetGuid(6);
                        model.HasChild        = reader.GetBoolean(7);
                        model.IsSys           = reader.GetBoolean(8);
                        model.LastUpdatedDate = reader.GetDateTime(9);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
コード例 #9
0
        public int Update(ContentTypeInfo model)
        {
            if (IsExist(model.TypeCode, model.ParentId, model.Id))
            {
                return(110);
            }

            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"update ContentType set TypeName = @TypeName,TypeCode = @TypeCode,TypeValue = @TypeValue,ParentId = @ParentId,Sort = @Sort,PictureId = @PictureId,HasChild = @HasChild,IsSys = @IsSys,LastUpdatedDate = @LastUpdatedDate 
			            where Id = @Id
					    "                    );

            SqlParameter[] parms =
            {
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@TypeName",        SqlDbType.NVarChar,           50),
                new SqlParameter("@TypeCode",        SqlDbType.VarChar,            50),
                new SqlParameter("@TypeValue",       SqlDbType.NVarChar,          256),
                new SqlParameter("@ParentId",        SqlDbType.UniqueIdentifier),
                new SqlParameter("@Sort",            SqlDbType.Int),
                new SqlParameter("@PictureId",       SqlDbType.UniqueIdentifier),
                new SqlParameter("@HasChild",        SqlDbType.Bit),
                new SqlParameter("@IsSys",           SqlDbType.Bit),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.TypeName;
            parms[2].Value = model.TypeCode;
            parms[3].Value = model.TypeValue;
            parms[4].Value = model.ParentId;
            parms[5].Value = model.Sort;
            parms[6].Value = model.PictureId;
            parms[7].Value = model.HasChild;
            parms[8].Value = model.IsSys;
            parms[9].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString(), parms));
        }
コード例 #10
0
        public List <ContentTypeInfo> GetListByJoin()
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select ct.Id,ct.TypeName,ct.TypeCode,ct.TypeValue,ct.ParentId,ct.Sort,ct.PictureId,ct.IsSys,ct.LastUpdatedDate,
                        pc.FileExtension,pc.FileDirectory,pc.RandomFolder
			            from ContentType ct
                        left join Picture_Content pc on pc.Id = ct.PictureId
					    order by ct.Sort, ct.LastUpdatedDate desc "                    );

            List <ContentTypeInfo> list = new List <ContentTypeInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentTypeInfo model = new ContentTypeInfo();
                        model.Id              = reader.GetGuid(0);
                        model.TypeName        = reader.GetString(1);
                        model.TypeCode        = reader.GetString(2);
                        model.TypeValue       = reader.GetString(3);
                        model.ParentId        = reader.GetGuid(4);
                        model.Sort            = reader.GetInt32(5);
                        model.PictureId       = reader.IsDBNull(6) ? Guid.Empty : reader.GetGuid(6);
                        model.IsSys           = reader.GetBoolean(7);
                        model.LastUpdatedDate = reader.GetDateTime(8);
                        model.FileExtension   = reader.IsDBNull(9) ? "" : reader.GetString(9);
                        model.FileDirectory   = reader.IsDBNull(10) ? "" : reader.GetString(10);
                        model.RandomFolder    = reader.IsDBNull(11) ? "" : reader.GetString(11);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
コード例 #11
0
ファイル: ContentType.cs プロジェクト: solarga/Asset
        public IList <ContentTypeInfo> GetList()
        {
            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select AppCode,UserId,DepmtId,Id,ParentId,Coded,Named,Step,FlagName,Sort,Remark,RecordDate,LastUpdatedDate 
			            from ContentType
					    order by Sort "                    );

            IList <ContentTypeInfo> list = new List <ContentTypeInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AssetDbConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentTypeInfo model = new ContentTypeInfo();
                        model.AppCode         = reader.IsDBNull(0) ? string.Empty : reader.GetString(0);
                        model.UserId          = reader.IsDBNull(1) ? Guid.Empty : reader.GetGuid(1);
                        model.DepmtId         = reader.IsDBNull(2) ? Guid.Empty : reader.GetGuid(2);
                        model.Id              = reader.IsDBNull(3) ? Guid.Empty : reader.GetGuid(3);
                        model.ParentId        = reader.IsDBNull(4) ? Guid.Empty : reader.GetGuid(4);
                        model.Coded           = reader.IsDBNull(5) ? string.Empty : reader.GetString(5);
                        model.Named           = reader.IsDBNull(6) ? string.Empty : reader.GetString(6);
                        model.Step            = reader.IsDBNull(7) ? string.Empty : reader.GetString(7);
                        model.FlagName        = reader.IsDBNull(8) ? string.Empty : reader.GetString(8);
                        model.Sort            = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        model.Remark          = reader.IsDBNull(10) ? string.Empty : reader.GetString(10);
                        model.RecordDate      = reader.IsDBNull(11) ? DateTime.Parse("1754-01-01") : reader.GetDateTime(11);
                        model.LastUpdatedDate = reader.IsDBNull(12) ? DateTime.Parse("1754-01-01") : reader.GetDateTime(12);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
コード例 #12
0
        public int Insert(ContentTypeInfo model)
        {
            if (IsExist(model.TypeCode, model.ParentId, null))
            {
                return(110);
            }

            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"insert into ContentType (TypeName,TypeCode,TypeValue,ParentId,Sort,PictureId,HasChild,IsSys,LastUpdatedDate)
			            values
						(@TypeName,@TypeCode,@TypeValue,@ParentId,@Sort,@PictureId,@HasChild,@IsSys,@LastUpdatedDate)
			            "            );

            SqlParameter[] parms =
            {
                new SqlParameter("@TypeName",        SqlDbType.NVarChar,           50),
                new SqlParameter("@TypeCode",        SqlDbType.VarChar,            50),
                new SqlParameter("@TypeValue",       SqlDbType.NVarChar,          256),
                new SqlParameter("@ParentId",        SqlDbType.UniqueIdentifier),
                new SqlParameter("@Sort",            SqlDbType.Int),
                new SqlParameter("@PictureId",       SqlDbType.UniqueIdentifier),
                new SqlParameter("@HasChild",        SqlDbType.Bit),
                new SqlParameter("@IsSys",           SqlDbType.Bit),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value = model.TypeName;
            parms[1].Value = model.TypeCode;
            parms[2].Value = model.TypeValue;
            parms[3].Value = model.ParentId;
            parms[4].Value = model.Sort;
            parms[5].Value = model.PictureId;
            parms[6].Value = model.HasChild;
            parms[7].Value = model.IsSys;
            parms[8].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString(), parms));
        }
コード例 #13
0
        /// <summary>
        /// 获取公告类别json格式字符串
        /// </summary>
        /// <returns></returns>
        public string GetTreeJsonForContentTypeByTypeCode(string typeCode)
        {
            ContentTypeInfo model = GetModelByTypeCode(typeCode);

            if (model == null)
            {
                return("[]");
            }
            SqlParameter parm = new SqlParameter("@ParentId", SqlDbType.UniqueIdentifier);

            parm.Value = model.Id;
            List <ContentTypeInfo> list       = GetList("and ParentId = @ParentId", parm).ToList <ContentTypeInfo>();
            StringBuilder          jsonAppend = new StringBuilder();

            if (list == null || list.Count == 0)
            {
                return("[]");
            }

            CreateTreeJson(list, model.Id, ref jsonAppend);

            return(jsonAppend.ToString());
        }
コード例 #14
0
        private void Init(DataRow row)
        {
            if (_contentTypeInfo == null)
            {
                if (_contentTypeProvider == null)
                    _contentTypeProvider = new ContentTypeProvider();
                if (_generalConnection == null)
                    _generalConnection = new GeneralConnection();
            }

            if (_contentTypeInfo == null)
                _contentTypeInfo = _contentTypeProvider.Select(_contentTypeId, ErrorInfoList);

            _dataSet = FormHelper.GetDataSet(_contentTypeInfo.XmlSchema);
            _dataTable = _dataSet.Tables[0];
            _dataRow = _dataTable.NewRow();
            _dataTable.Rows.Add(_dataRow);
            Name = _contentTypeInfo.Name;
            TableName = _contentTypeInfo.TableName;

            FillColumns();
            if (IsEdit)
            {
                if (ContentId != 0)
                {
                    var parameters = new object[1, 3];
                    parameters[0, 0] = "@Id";
                    parameters[0, 1] = _contentId;
                    DataTable dt = _generalConnection.ExecuteDataTableQuery(TableName + ".select", parameters,
                                                                            ErrorInfoList);
                    if (dt != null && dt.Rows.Count > 0)
                        FillDefaultRowValues(dt.Rows[0]);
                }
                else
                {
                    FillDefaultRowValues(row);
                }
            }
            IsPublished = ValidationHelper.GetBoolean(GetValue("IsPublished"), false);
        }
コード例 #15
0
 /// <summary>
 /// Event Receiver Info (Content Type)
 /// </summary>
 /// <param name="contentType">The content type</param>
 /// <param name="type">The event receiver type</param>
 /// <param name="syncType">The synchronization type</param>
 public EventReceiverInfo(ContentTypeInfo contentType, SPEventReceiverType type, SPEventReceiverSynchronization syncType)
     : this(contentType, type, syncType, string.Empty, string.Empty)
 {
 }
コード例 #16
0
 /// <summary>
 /// Event Receiver Info (Content Type)
 /// </summary>
 /// <param name="contentType">The content type</param>
 /// <param name="type">The event receiver type</param>
 public EventReceiverInfo(ContentTypeInfo contentType, SPEventReceiverType type)
     : this(contentType, type, SPEventReceiverSynchronization.Default)
 {
 }
コード例 #17
0
        /// <summary>
        /// Builds the entire element.
        /// </summary>
        /// <param name="contentTypeInfo">The content type info.</param>
        /// <returns>The XElement representing the content type.</returns>
        static XElement BuildContentTypeElement(ContentTypeInfo contentTypeInfo)
        {
            XNamespace sharePointNamespace = XNamespace.Get("http://schemas.microsoft.com/sharepoint/");

            XElement contentType = new XElement("ContentType");

            if (!String.IsNullOrEmpty(contentTypeInfo.Id))
            {
                XAttribute id = new XAttribute("ID", contentTypeInfo.Id);
                contentType.Add(id);
            }

            if (!String.IsNullOrEmpty(contentTypeInfo.Name))
            {
                XAttribute name = new XAttribute("Name", contentTypeInfo.Name);
                contentType.Add(name);
            }

            if (!String.IsNullOrEmpty(contentTypeInfo.Description))
            {
                XAttribute description = new XAttribute("Description", contentTypeInfo.Description);
                contentType.Add(description);
            }

            if (!String.IsNullOrEmpty(contentTypeInfo.Group))
            {
                XAttribute group = new XAttribute("Group", contentTypeInfo.Group);
                contentType.Add(group);
            }

            if (contentTypeInfo.Inherits != null)
            {
                XAttribute inherits = new XAttribute("Inherits", contentTypeInfo.Inherits);
                contentType.Add(inherits);
            }

            if (contentTypeInfo.Hidden != null)
            {
                XAttribute hidden = new XAttribute("Hidden", contentTypeInfo.Hidden);
                contentType.Add(hidden);
            }

            if (contentTypeInfo.ReadOnly != null)
            {
                XAttribute readOnly = new XAttribute("ReadOnly", contentTypeInfo.ReadOnly);
                contentType.Add(readOnly);
            }

            if (contentTypeInfo.Sealed != null)
            {
                XAttribute sealedValue = new XAttribute("Sealed", contentTypeInfo.Sealed);
                contentType.Add(sealedValue);
            }

            //Add the field refs
            if (contentTypeInfo.FieldRefs != null && contentTypeInfo.FieldRefs.Length > 0)
            {
                XElement fieldRefs = new XElement("FieldRefs");

                foreach (var item in contentTypeInfo.FieldRefs)
                {
                    fieldRefs.Add(new XElement("FieldRef",
                                               new XAttribute("ID", item.Id),
                                               new XAttribute("Name", item.Name),
                                               new XAttribute("DisplayName", item.DisplayName)));
                }

                contentType.Add(fieldRefs);
            }

            //Add the document template
            if (!String.IsNullOrEmpty(contentTypeInfo.DocumentTemplate))
            {
                contentType.Add(new XElement(sharePointNamespace + "DocumentTemplate", new XAttribute("TargetName", contentTypeInfo.DocumentTemplate)));
            }

            if (contentTypeInfo.XmlDocuments != null && contentTypeInfo.XmlDocuments.Length > 0)
            {
                XElement xmlDocuments = new XElement(sharePointNamespace + "XmlDocuments");

                foreach (string xmlDocument in contentTypeInfo.XmlDocuments)
                {
                    XElement   xDocument = XElement.Parse(xmlDocument);
                    string     ns        = "http://schemas.microsoft.com/sharepoint/v3/contenttype/forms";
                    XAttribute xmlns     = xDocument.Attribute("xmlns");
                    if (xmlns != null)
                    {
                        ns = xmlns.Value;
                    }

                    xmlDocuments.Add(new XElement(sharePointNamespace + "XmlDocument",
                                                  new XAttribute("NamespaceURI", ns),
                                                  xDocument));
                }

                contentType.Add(xmlDocuments);
            }

            return(contentType);
        }
コード例 #18
0
        private static ContentTypeInfo GetContentTypeImportProperties(ISharePointCommandContext context,
                                                                      string contentTypeName)
        {
            SPContentType contentType = context.Web.AvailableContentTypes[contentTypeName];

            if (contentType == null)
            {
                context.Logger.WriteLine(String.Format(Resources.ContentTypeSharePointCommands_GetContentTypePropertiesException, contentTypeName), LogCategory.Error);
                return(null);
            }

            ContentTypeInfo info = new ContentTypeInfo();

            if (contentType != null)
            {
                info.Id          = contentType.Id.ToString();
                info.Name        = contentType.Name;
                info.Description = contentType.Description;
                info.Group       = contentType.Group;
                info.Sealed      = contentType.Sealed;
                info.Hidden      = contentType.Hidden;
                info.ReadOnly    = contentType.ReadOnly;

                SPContentType parentContentType = contentType.Parent;

                List <ContentTypeInfo.FieldRef> fields = new List <ContentTypeInfo.FieldRef>();
                foreach (SPField field in contentType.Fields)
                {
                    // check if the field is in the parent content type, skip it...
                    if (parentContentType.Fields.ContainsField(field.StaticName))
                    {
                        continue;
                    }

                    ContentTypeInfo.FieldRef fieldRef = new ContentTypeInfo.FieldRef();
                    fieldRef.Id          = field.Id.ToString();
                    fieldRef.Name        = field.StaticName;
                    fieldRef.DisplayName = field.Title;

                    fields.Add(fieldRef);
                }

                if (fields.Count > 0)
                {
                    info.FieldRefs = fields.ToArray();
                }

                if (!String.IsNullOrEmpty(contentType.DocumentTemplate))
                {
                    info.DocumentTemplate = contentType.DocumentTemplate;
                }

                if (contentType.XmlDocuments != null && contentType.XmlDocuments.Count > 0)
                {
                    List <string> xmlDocs = new List <string>();
                    foreach (string doc in contentType.XmlDocuments)
                    {
                        xmlDocs.Add(doc);
                    }
                    info.XmlDocuments = xmlDocs.ToArray();
                }
            }

            return(info);
        }
コード例 #19
0
        public int InsertByOutput(ContentTypeInfo model)
        {
            _db.ContentTypes.Insert(model);

            return(1);
        }
コード例 #20
0
 public int InsertByOutput(ContentTypeInfo model)
 {
     return(dal.InsertByOutput(model));
 }
コード例 #21
0
ファイル: ContentType.cs プロジェクト: solarga/Asset
        private void CreateTreeJson(IEnumerable <ContentTypeInfo> q, object parentId, ContentTypeInfo rootNode, ref StringBuilder jsonAppend)
        {
            jsonAppend.Append("[");
            var qChild = q.Where(x => x.ParentId.Equals(parentId));

            if (qChild != null && qChild.Count() > 0)
            {
                int index = 0;
                foreach (var model in qChild)
                {
                    var state = (model.Id == rootNode.Id) ? "open" : "closed";
                    var sText = model.ParentId.Equals(Guid.Empty) ? model.Named : string.Format("{0}({1})", model.Coded, model.Named);
                    jsonAppend.AppendFormat(@"{{""id"":""{0}"",""text"":""{1}"",""state"":""{2}"",""attributes"":{3}", model.Id, sText, state, JsonConvert.SerializeObject(model));
                    if (q.Any(r => r.ParentId.Equals(model.Id)))
                    {
                        jsonAppend.Append(",\"children\":");
                        CreateTreeJson(q, model.Id, rootNode, ref jsonAppend);
                    }
                    jsonAppend.Append("}");
                    if (index < qChild.Count() - 1)
                    {
                        jsonAppend.Append(",");
                    }
                    index++;
                }
            }
            jsonAppend.Append("]");
        }
コード例 #22
0
        public int Update(ContentTypeInfo model)
        {
            _db.ContentTypes.Update(model);

            return(1);
        }
コード例 #23
0
 public int Update(ContentTypeInfo model)
 {
     return(dal.Update(model));
 }
コード例 #24
0
        public string SaveContentType(ContentTypeInfo model)
        {
            string errorMsg = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(model.TypeName))
                {
                    return(MC.Submit_Params_InvalidError);
                }
                if (string.IsNullOrWhiteSpace(model.TypeCode))
                {
                    return(MC.Submit_Params_InvalidError);
                }
                if (string.IsNullOrWhiteSpace(model.TypeValue))
                {
                    return(MC.Submit_Params_InvalidError);
                }

                Guid gId = Guid.Empty;
                Guid.TryParse(model.Id.ToString(), out gId);
                model.Id = gId;

                Guid parentId = Guid.Empty;
                Guid.TryParse(model.ParentId.ToString(), out parentId);
                model.ParentId        = parentId;
                model.LastUpdatedDate = DateTime.Now;

                ContentType bll    = new ContentType();
                int         effect = -1;

                using (TransactionScope scope = new TransactionScope())
                {
                    if (!gId.Equals(Guid.Empty))
                    {
                        effect = bll.Update(model);
                    }
                    else
                    {
                        model.HasChild = false;
                        effect         = bll.Insert(model);
                    }

                    bll.UpdateHasChild(gId);
                    bll.UpdateHasChild(parentId);

                    scope.Complete();
                }

                if (effect == 110)
                {
                    return(MC.Submit_Exist);
                }
                if (effect > 0)
                {
                    return("1");
                }
                else
                {
                    return(MC.Submit_Error);
                }
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }

            return(MC.GetString(MC.Submit_Ex_Error, errorMsg));
        }