public static PageSetting GetArticleSetting(Maticsoft.Model.CMS.Content contModel, string pageName = "CMS", ApplicationKeyType applicationType = 4) { if (contModel == null) { contModel = new Maticsoft.Model.CMS.Content(); } PageSetting setting = new PageSetting(pageName, applicationType, "Base"); if (!string.IsNullOrWhiteSpace(contModel.Meta_Title)) { setting._title = contModel.Meta_Title; } else { setting._title = ConfigSystem.GetValueByCache(setting.KeyTitle, setting._applicationType); if (string.IsNullOrWhiteSpace(setting._title)) { setting._title = ConfigSystem.GetValueByCache("Title", ApplicationKeyType.System); } } if (!string.IsNullOrWhiteSpace(contModel.Meta_Keywords)) { setting._keywords = contModel.Meta_Keywords; } else { setting._keywords = ConfigSystem.GetValueByCache(setting.KeyKeywords, setting._applicationType); if (string.IsNullOrWhiteSpace(setting._keywords)) { setting._keywords = ConfigSystem.GetValueByCache("Keywords", ApplicationKeyType.System); } } if (!string.IsNullOrWhiteSpace(contModel.Meta_Description)) { setting._description = contModel.Meta_Description; } else { setting._description = ConfigSystem.GetValueByCache(setting.KeyDescription, setting._applicationType); if (string.IsNullOrWhiteSpace(setting._description)) { setting._description = ConfigSystem.GetValueByCache("Description", ApplicationKeyType.System); } } if (setting._title.IndexOf("{hostname}", StringComparison.Ordinal) > -1) { setting._title = ReplaceHostName(setting._title); } if (setting._keywords.IndexOf("{hostname}", StringComparison.Ordinal) > -1) { setting._keywords = ReplaceHostName(setting._keywords); } if (setting._description.IndexOf("{hostname}", StringComparison.Ordinal) > -1) { setting._description = ReplaceHostName(setting._description); } setting.Replace(new string[][] { new string[] { "{cname}", contModel.Title }, new string[] { "{cid}", contModel.ContentID.ToString() }, new string[] { "{ctname}", contModel.ClassName }, new string[] { "{cateid}", contModel.ClassID.ToString() } }); return setting; }
public List<Maticsoft.Model.CMS.Content> ContentToList(DataTable dt) { List<Maticsoft.Model.CMS.Content> list = new List<Maticsoft.Model.CMS.Content>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { DataRow row = dt.Rows[i]; if (row != null) { Maticsoft.Model.CMS.Content item = new Maticsoft.Model.CMS.Content(); if ((row["ContentID"] != null) && (row["ContentID"].ToString() != "")) { item.ContentID = int.Parse(row["ContentID"].ToString()); } if (row["Title"] != null) { item.Title = row["Title"].ToString(); } if (row["SubTitle"] != null) { item.SubTitle = row["SubTitle"].ToString(); } if (row["Summary"] != null) { item.Summary = row["Summary"].ToString(); } if (row["Description"] != null) { item.Description = row["Description"].ToString(); } if (row["ImageUrl"] != null) { item.ImageUrl = row["ImageUrl"].ToString(); } if (row["ThumbImageUrl"] != null) { item.ThumbImageUrl = row["ThumbImageUrl"].ToString(); } if (row["NormalImageUrl"] != null) { item.NormalImageUrl = row["NormalImageUrl"].ToString(); } if ((row["CreatedDate"] != null) && (row["CreatedDate"].ToString() != "")) { item.CreatedDate = DateTime.Parse(row["CreatedDate"].ToString()); } if ((row["CreatedUserID"] != null) && (row["CreatedUserID"].ToString() != "")) { item.CreatedUserID = int.Parse(row["CreatedUserID"].ToString()); } if ((row["LastEditUserID"] != null) && (row["LastEditUserID"].ToString() != "")) { item.LastEditUserID = new int?(int.Parse(row["LastEditUserID"].ToString())); } if ((row["LastEditDate"] != null) && (row["LastEditDate"].ToString() != "")) { item.LastEditDate = new DateTime?(DateTime.Parse(row["LastEditDate"].ToString())); } if (row["LinkUrl"] != null) { item.LinkUrl = row["LinkUrl"].ToString(); } if ((row["PvCount"] != null) && (row["PvCount"].ToString() != "")) { item.PvCount = int.Parse(row["PvCount"].ToString()); } if ((row["State"] != null) && (row["State"].ToString() != "")) { item.State = int.Parse(row["State"].ToString()); } if ((row["ClassID"] != null) && (row["ClassID"].ToString() != "")) { item.ClassID = int.Parse(row["ClassID"].ToString()); } if (row["Keywords"] != null) { item.Keywords = row["Keywords"].ToString(); } if ((row["Sequence"] != null) && (row["Sequence"].ToString() != "")) { item.Sequence = int.Parse(row["Sequence"].ToString()); } if ((row["IsRecomend"] != null) && (row["IsRecomend"].ToString() != "")) { if ((row["IsRecomend"].ToString() == "1") || (row["IsRecomend"].ToString().ToLower() == "true")) { item.IsRecomend = true; } else { item.IsRecomend = false; } } if ((row["IsHot"] != null) && (row["IsHot"].ToString() != "")) { if ((row["IsHot"].ToString() == "1") || (row["IsHot"].ToString().ToLower() == "true")) { item.IsHot = true; } else { item.IsHot = false; } } if ((row["IsColor"] != null) && (row["IsColor"].ToString() != "")) { if ((row["IsColor"].ToString() == "1") || (row["IsColor"].ToString().ToLower() == "true")) { item.IsColor = true; } else { item.IsColor = false; } } if ((row["IsTop"] != null) && (row["IsTop"].ToString() != "")) { if ((row["IsTop"].ToString() == "1") || (row["IsTop"].ToString().ToLower() == "true")) { item.IsTop = true; } else { item.IsTop = false; } } if (row["Attachment"] != null) { item.Attachment = row["Attachment"].ToString(); } if (row["Remary"] != null) { item.Remary = row["Remary"].ToString(); } if ((row["TotalComment"] != null) && (row["TotalComment"].ToString() != "")) { item.TotalComment = int.Parse(row["TotalComment"].ToString()); } if ((row["TotalSupport"] != null) && (row["TotalSupport"].ToString() != "")) { item.TotalSupport = int.Parse(row["TotalSupport"].ToString()); } if ((row["TotalFav"] != null) && (row["TotalFav"].ToString() != "")) { item.TotalFav = int.Parse(row["TotalFav"].ToString()); } if ((row["TotalShare"] != null) && (row["TotalShare"].ToString() != "")) { item.TotalShare = int.Parse(row["TotalShare"].ToString()); } if (row["BeFrom"] != null) { item.BeFrom = row["BeFrom"].ToString(); } if (row["FileName"] != null) { item.FileName = row["FileName"].ToString(); } if (row["Meta_Title"] != null) { item.Meta_Title = row["Meta_Title"].ToString(); } if (row["Meta_Description"] != null) { item.Meta_Description = row["Meta_Description"].ToString(); } if (row["Meta_Keywords"] != null) { item.Meta_Keywords = row["Meta_Keywords"].ToString(); } if (row["SeoUrl"] != null) { item.SeoUrl = row["SeoUrl"].ToString(); } if (row["SeoImageAlt"] != null) { item.SeoImageAlt = row["SeoImageAlt"].ToString(); } if (row["SeoImageTitle"] != null) { item.SeoImageTitle = row["SeoImageTitle"].ToString(); } if (row["StaticUrl"] != null) { item.StaticUrl = row["StaticUrl"].ToString(); } if (row["ComCount"] != null) { item.ComCount = Globals.SafeInt(row["ComCount"].ToString(), 0); } list.Add(item); } } } return list; }
protected void btnSave_Click(object sender, EventArgs e) { int classID = Globals.SafeInt(this.ddlType.SelectedValue, 0); if (classID <= 0) { MessageBox.ShowFailTip(this, CMS.ContentErrorAddClass); } else { Maticsoft.Model.CMS.ContentClass model = this.bllContentClass.GetModel(classID); if (model != null) { if (!model.AllowAddContent) { MessageBox.ShowFailTip(this, CMS.ContentErrorAddContent); return; } if ((2 == model.ClassModel) && this.bll.ExistsByClassID(classID)) { MessageBox.ShowFailTip(this, CMS.ContentErrorAddMoreContent); return; } } if (string.IsNullOrWhiteSpace(this.txtTitle.Text.Trim())) { MessageBox.ShowFailTip(this, CMS.TitleErrorAddContent); } else if (this.bll.ExistTitle(this.txtTitle.Text.Trim())) { MessageBox.ShowFailTip(this, CMS.ContentTooltipTitleExist); } else { Maticsoft.Model.CMS.Content content; content = new Maticsoft.Model.CMS.Content { Title = Globals.HtmlEncode(this.txtTitle.Text), SubTitle = Globals.HtmlEncode(this.txtTitle.Text), Summary = Globals.HtmlEncode(this.txtSummary.Text), CreatedUserID = base.CurrentUser.UserID, LastEditDate = new DateTime?(content.CreatedDate = DateTime.Now), LastEditUserID = new int?(base.CurrentUser.UserID), PvCount = 0, State = Globals.SafeInt(this.radlState.SelectedValue, 0), ClassID = classID, Description = this.txtContent.Text }; string oldValue = string.Format("/Upload/Temp/{0}/", DateTime.Now.ToString("yyyyMMdd")); string newValue = string.Format("/Upload/CMS/Article/{0}/", DateTime.Now.ToString("yyyyMM")); string.Format("/Upload/CMS/Files/{0}/", DateTime.Now.ToString("yyyyMM")); ArrayList fileNameList = new ArrayList(); if (!string.IsNullOrWhiteSpace(this.HiddenField_ICOPath.Value)) { string str3 = string.Format(this.HiddenField_ICOPath.Value, ""); fileNameList.Add(str3.Replace(oldValue, "")); content.ImageUrl = str3.Replace(oldValue, newValue); } content.TotalComment = 0; content.TotalSupport = 0; content.TotalFav = 0; content.TotalShare = 0; int num2 = this.bll.Add(content); if (0 < num2) { if (!string.IsNullOrWhiteSpace(this.HiddenField_ICOPath.Value)) { FileManage.MoveFile(base.Server.MapPath(oldValue), base.Server.MapPath(newValue), fileNameList); } string str4 = ""; str4 = this.chkSina.Checked ? "3" : ""; if (this.chkQQ.Checked) { str4 = str4 + (string.IsNullOrWhiteSpace(str4) ? "13" : ",13"); } UserBind bind = new UserBind(); string valueByCache = ConfigSystem.GetValueByCache("WeiBo_CMS_Url"); string url = "http://" + Globals.DomainFullName + string.Format(valueByCache, num2); bind.SendWeiBo(-1, str4, content.Title, url, content.ImageUrl); if (!string.IsNullOrWhiteSpace(this.ddlType.SelectedValue)) { MessageBox.ShowSuccessTip(this, Site.TooltipSaveOK, "ListSimple.aspx?classid=" + this.ddlType.SelectedValue); } else { MessageBox.ShowSuccessTip(this, Site.TooltipSaveOK, "ListSimple.aspx?type=0"); } } } } }
public Maticsoft.Model.CMS.Content DataRowToModel(DataRow row) { Maticsoft.Model.CMS.Content content = new Maticsoft.Model.CMS.Content(); if (row != null) { if ((row["ContentID"] != null) && (row["ContentID"].ToString() != "")) { content.ContentID = int.Parse(row["ContentID"].ToString()); } if (row["Title"] != null) { content.Title = row["Title"].ToString(); } if (row["SubTitle"] != null) { content.SubTitle = row["SubTitle"].ToString(); } if (row["Summary"] != null) { content.Summary = row["Summary"].ToString(); } if (row["Description"] != null) { content.Description = row["Description"].ToString(); } if (row["ImageUrl"] != null) { content.ImageUrl = row["ImageUrl"].ToString(); } if (row["ThumbImageUrl"] != null) { content.ThumbImageUrl = row["ThumbImageUrl"].ToString(); } if (row["NormalImageUrl"] != null) { content.NormalImageUrl = row["NormalImageUrl"].ToString(); } if ((row["CreatedDate"] != null) && (row["CreatedDate"].ToString() != "")) { content.CreatedDate = DateTime.Parse(row["CreatedDate"].ToString()); } if ((row["CreatedUserID"] != null) && (row["CreatedUserID"].ToString() != "")) { content.CreatedUserID = int.Parse(row["CreatedUserID"].ToString()); } if ((row["LastEditUserID"] != null) && (row["LastEditUserID"].ToString() != "")) { content.LastEditUserID = new int?(int.Parse(row["LastEditUserID"].ToString())); } if ((row["LastEditDate"] != null) && (row["LastEditDate"].ToString() != "")) { content.LastEditDate = new DateTime?(DateTime.Parse(row["LastEditDate"].ToString())); } if (row["LinkUrl"] != null) { content.LinkUrl = row["LinkUrl"].ToString(); } if ((row["PvCount"] != null) && (row["PvCount"].ToString() != "")) { content.PvCount = int.Parse(row["PvCount"].ToString()); } if ((row["State"] != null) && (row["State"].ToString() != "")) { content.State = int.Parse(row["State"].ToString()); } if ((row["ClassID"] != null) && (row["ClassID"].ToString() != "")) { content.ClassID = int.Parse(row["ClassID"].ToString()); } if (row["Keywords"] != null) { content.Keywords = row["Keywords"].ToString(); } if ((row["Sequence"] != null) && (row["Sequence"].ToString() != "")) { content.Sequence = int.Parse(row["Sequence"].ToString()); } if ((row["IsRecomend"] != null) && (row["IsRecomend"].ToString() != "")) { if ((row["IsRecomend"].ToString() == "1") || (row["IsRecomend"].ToString().ToLower() == "true")) { content.IsRecomend = true; } else { content.IsRecomend = false; } } if ((row["IsHot"] != null) && (row["IsHot"].ToString() != "")) { if ((row["IsHot"].ToString() == "1") || (row["IsHot"].ToString().ToLower() == "true")) { content.IsHot = true; } else { content.IsHot = false; } } if ((row["IsColor"] != null) && (row["IsColor"].ToString() != "")) { if ((row["IsColor"].ToString() == "1") || (row["IsColor"].ToString().ToLower() == "true")) { content.IsColor = true; } else { content.IsColor = false; } } if ((row["IsTop"] != null) && (row["IsTop"].ToString() != "")) { if ((row["IsTop"].ToString() == "1") || (row["IsTop"].ToString().ToLower() == "true")) { content.IsTop = true; } else { content.IsTop = false; } } if (row["Attachment"] != null) { content.Attachment = row["Attachment"].ToString(); } if (row["Remary"] != null) { content.Remary = row["Remary"].ToString(); } if ((row["TotalComment"] != null) && (row["TotalComment"].ToString() != "")) { content.TotalComment = int.Parse(row["TotalComment"].ToString()); } if ((row["TotalSupport"] != null) && (row["TotalSupport"].ToString() != "")) { content.TotalSupport = int.Parse(row["TotalSupport"].ToString()); } if ((row["TotalFav"] != null) && (row["TotalFav"].ToString() != "")) { content.TotalFav = int.Parse(row["TotalFav"].ToString()); } if ((row["TotalShare"] != null) && (row["TotalShare"].ToString() != "")) { content.TotalShare = int.Parse(row["TotalShare"].ToString()); } if (row["BeFrom"] != null) { content.BeFrom = row["BeFrom"].ToString(); } if (row["FileName"] != null) { content.FileName = row["FileName"].ToString(); } if (row["Meta_Title"] != null) { content.Meta_Title = row["Meta_Title"].ToString(); } if (row["Meta_Description"] != null) { content.Meta_Description = row["Meta_Description"].ToString(); } if (row["Meta_Keywords"] != null) { content.Meta_Keywords = row["Meta_Keywords"].ToString(); } if (row["SeoUrl"] != null) { content.SeoUrl = row["SeoUrl"].ToString(); } if (row["SeoImageAlt"] != null) { content.SeoImageAlt = row["SeoImageAlt"].ToString(); } if (row["SeoImageTitle"] != null) { content.SeoImageTitle = row["SeoImageTitle"].ToString(); } if (row["StaticUrl"] != null) { content.StaticUrl = row["StaticUrl"].ToString(); } } return content; }
public Maticsoft.Model.CMS.Content GetModelEx(int ContentID) { StringBuilder builder = new StringBuilder(); builder.Append("select top 1 CMSS.*,UserName as CreatedUserName from CMS_Content CMSS LEFT JOIN Accounts_Users AS AU ON AU.UserID = CMSS.CreatedUserID "); builder.Append(" where State=0 AND ContentID=@ContentID"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@ContentID", SqlDbType.Int, 4) }; cmdParms[0].Value = ContentID; Maticsoft.Model.CMS.Content content = new Maticsoft.Model.CMS.Content(); DataSet ds = DbHelperSQL.Query(builder.ToString(), cmdParms); if (DataSetTools.DataSetIsNull(ds)) { return null; } if (ds.Tables[0].Rows.Count <= 0) { return null; } if ((ds.Tables[0].Rows[0]["ContentID"] != null) && (ds.Tables[0].Rows[0]["ContentID"].ToString() != "")) { content.ContentID = int.Parse(ds.Tables[0].Rows[0]["ContentID"].ToString()); } if ((ds.Tables[0].Rows[0]["Title"] != null) && (ds.Tables[0].Rows[0]["Title"].ToString() != "")) { content.Title = ds.Tables[0].Rows[0]["Title"].ToString(); } if ((ds.Tables[0].Rows[0]["SubTitle"] != null) && (ds.Tables[0].Rows[0]["SubTitle"].ToString() != "")) { content.SubTitle = ds.Tables[0].Rows[0]["SubTitle"].ToString(); } if ((ds.Tables[0].Rows[0]["Summary"] != null) && (ds.Tables[0].Rows[0]["Summary"].ToString() != "")) { content.Summary = ds.Tables[0].Rows[0]["Summary"].ToString(); } if ((ds.Tables[0].Rows[0]["Description"] != null) && (ds.Tables[0].Rows[0]["Description"].ToString() != "")) { content.Description = ds.Tables[0].Rows[0]["Description"].ToString(); } if ((ds.Tables[0].Rows[0]["ImageUrl"] != null) && (ds.Tables[0].Rows[0]["ImageUrl"].ToString() != "")) { content.ImageUrl = ds.Tables[0].Rows[0]["ImageUrl"].ToString(); } if ((ds.Tables[0].Rows[0]["ThumbImageUrl"] != null) && (ds.Tables[0].Rows[0]["ThumbImageUrl"].ToString() != "")) { content.ThumbImageUrl = ds.Tables[0].Rows[0]["ThumbImageUrl"].ToString(); } if ((ds.Tables[0].Rows[0]["NormalImageUrl"] != null) && (ds.Tables[0].Rows[0]["NormalImageUrl"].ToString() != "")) { content.NormalImageUrl = ds.Tables[0].Rows[0]["NormalImageUrl"].ToString(); } if ((ds.Tables[0].Rows[0]["CreatedDate"] != null) && (ds.Tables[0].Rows[0]["CreatedDate"].ToString() != "")) { content.CreatedDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreatedDate"].ToString()); } if ((ds.Tables[0].Rows[0]["CreatedUserName"] != null) && (ds.Tables[0].Rows[0]["CreatedUserName"].ToString() != "")) { content.CreatedUserName = ds.Tables[0].Rows[0]["CreatedUserName"].ToString(); } if ((ds.Tables[0].Rows[0]["CreatedUserID"] != null) && (ds.Tables[0].Rows[0]["CreatedUserID"].ToString() != "")) { content.CreatedUserID = int.Parse(ds.Tables[0].Rows[0]["CreatedUserID"].ToString()); } if ((ds.Tables[0].Rows[0]["LastEditUserID"] != null) && (ds.Tables[0].Rows[0]["LastEditUserID"].ToString() != "")) { content.LastEditUserID = new int?(int.Parse(ds.Tables[0].Rows[0]["LastEditUserID"].ToString())); } if ((ds.Tables[0].Rows[0]["LastEditDate"] != null) && (ds.Tables[0].Rows[0]["LastEditDate"].ToString() != "")) { content.LastEditDate = new DateTime?(DateTime.Parse(ds.Tables[0].Rows[0]["LastEditDate"].ToString())); } if ((ds.Tables[0].Rows[0]["LinkUrl"] != null) && (ds.Tables[0].Rows[0]["LinkUrl"].ToString() != "")) { content.LinkUrl = ds.Tables[0].Rows[0]["LinkUrl"].ToString(); } if ((ds.Tables[0].Rows[0]["PvCount"] != null) && (ds.Tables[0].Rows[0]["PvCount"].ToString() != "")) { content.PvCount = int.Parse(ds.Tables[0].Rows[0]["PvCount"].ToString()); } if ((ds.Tables[0].Rows[0]["State"] != null) && (ds.Tables[0].Rows[0]["State"].ToString() != "")) { content.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString()); } if ((ds.Tables[0].Rows[0]["ClassID"] != null) && (ds.Tables[0].Rows[0]["ClassID"].ToString() != "")) { content.ClassID = int.Parse(ds.Tables[0].Rows[0]["ClassID"].ToString()); } if ((ds.Tables[0].Rows[0]["Keywords"] != null) && (ds.Tables[0].Rows[0]["Keywords"].ToString() != "")) { content.Keywords = ds.Tables[0].Rows[0]["Keywords"].ToString(); } if ((ds.Tables[0].Rows[0]["Sequence"] != null) && (ds.Tables[0].Rows[0]["Sequence"].ToString() != "")) { content.Sequence = int.Parse(ds.Tables[0].Rows[0]["Sequence"].ToString()); } if ((ds.Tables[0].Rows[0]["IsRecomend"] != null) && (ds.Tables[0].Rows[0]["IsRecomend"].ToString() != "")) { if ((ds.Tables[0].Rows[0]["IsRecomend"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsRecomend"].ToString().ToLower() == "true")) { content.IsRecomend = true; } else { content.IsRecomend = false; } } if ((ds.Tables[0].Rows[0]["IsHot"] != null) && (ds.Tables[0].Rows[0]["IsHot"].ToString() != "")) { if ((ds.Tables[0].Rows[0]["IsHot"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsHot"].ToString().ToLower() == "true")) { content.IsHot = true; } else { content.IsHot = false; } } if ((ds.Tables[0].Rows[0]["IsColor"] != null) && (ds.Tables[0].Rows[0]["IsColor"].ToString() != "")) { if ((ds.Tables[0].Rows[0]["IsColor"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsColor"].ToString().ToLower() == "true")) { content.IsColor = true; } else { content.IsColor = false; } } if ((ds.Tables[0].Rows[0]["IsTop"] != null) && (ds.Tables[0].Rows[0]["IsTop"].ToString() != "")) { if ((ds.Tables[0].Rows[0]["IsTop"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsTop"].ToString().ToLower() == "true")) { content.IsTop = true; } else { content.IsTop = false; } } if ((ds.Tables[0].Rows[0]["Attachment"] != null) && (ds.Tables[0].Rows[0]["Attachment"].ToString() != "")) { content.Attachment = ds.Tables[0].Rows[0]["Attachment"].ToString(); } if ((ds.Tables[0].Rows[0]["Remary"] != null) && (ds.Tables[0].Rows[0]["Remary"].ToString() != "")) { content.Remary = ds.Tables[0].Rows[0]["Remary"].ToString(); } if ((ds.Tables[0].Rows[0]["TotalComment"] != null) && (ds.Tables[0].Rows[0]["TotalComment"].ToString() != "")) { content.TotalComment = int.Parse(ds.Tables[0].Rows[0]["TotalComment"].ToString()); } if ((ds.Tables[0].Rows[0]["TotalSupport"] != null) && (ds.Tables[0].Rows[0]["TotalSupport"].ToString() != "")) { content.TotalSupport = int.Parse(ds.Tables[0].Rows[0]["TotalSupport"].ToString()); } if ((ds.Tables[0].Rows[0]["TotalFav"] != null) && (ds.Tables[0].Rows[0]["TotalFav"].ToString() != "")) { content.TotalFav = int.Parse(ds.Tables[0].Rows[0]["TotalFav"].ToString()); } if ((ds.Tables[0].Rows[0]["TotalShare"] != null) && (ds.Tables[0].Rows[0]["TotalShare"].ToString() != "")) { content.TotalShare = int.Parse(ds.Tables[0].Rows[0]["TotalShare"].ToString()); } if (ds.Tables[0].Rows[0]["BeFrom"] != null) { content.BeFrom = ds.Tables[0].Rows[0]["BeFrom"].ToString(); } return content; }
public List<Maticsoft.Model.CMS.Content> DataTableToListEx(DataTable dt) { List<Maticsoft.Model.CMS.Content> list = new List<Maticsoft.Model.CMS.Content>(); if (DataTableTools.DataTableIsNull(dt)) { return null; } int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Maticsoft.Model.CMS.Content item = new Maticsoft.Model.CMS.Content(); if ((dt.Rows[i]["ContentID"] != null) && (dt.Rows[i]["ContentID"].ToString() != "")) { item.ContentID = int.Parse(dt.Rows[i]["ContentID"].ToString()); } if ((dt.Rows[i]["Title"] != null) && (dt.Rows[i]["Title"].ToString() != "")) { item.Title = dt.Rows[i]["Title"].ToString(); } if ((dt.Rows[i]["SubTitle"] != null) && (dt.Rows[i]["SubTitle"].ToString() != "")) { item.SubTitle = dt.Rows[i]["SubTitle"].ToString(); } if ((dt.Rows[i]["Summary"] != null) && (dt.Rows[i]["Summary"].ToString() != "")) { item.Summary = dt.Rows[i]["Summary"].ToString(); } if ((dt.Rows[i]["Description"] != null) && (dt.Rows[i]["Description"].ToString() != "")) { item.Description = dt.Rows[i]["Description"].ToString(); } if ((dt.Rows[i]["ImageUrl"] != null) && (dt.Rows[i]["ImageUrl"].ToString() != "")) { item.ImageUrl = dt.Rows[i]["ImageUrl"].ToString(); } if ((dt.Rows[i]["ThumbImageUrl"] != null) && (dt.Rows[i]["ThumbImageUrl"].ToString() != "")) { item.ThumbImageUrl = dt.Rows[i]["ThumbImageUrl"].ToString(); } if ((dt.Rows[i]["NormalImageUrl"] != null) && (dt.Rows[i]["NormalImageUrl"].ToString() != "")) { item.NormalImageUrl = dt.Rows[i]["NormalImageUrl"].ToString(); } if ((dt.Rows[i]["CreatedDate"] != null) && (dt.Rows[i]["CreatedDate"].ToString() != "")) { item.CreatedDate = DateTime.Parse(dt.Rows[i]["CreatedDate"].ToString()); } if ((dt.Rows[i]["CreatedUserID"] != null) && (dt.Rows[i]["CreatedUserID"].ToString() != "")) { item.CreatedUserID = int.Parse(dt.Rows[i]["CreatedUserID"].ToString()); } if ((dt.Rows[i]["CreatedUserName"] != null) && (dt.Rows[i]["CreatedUserName"].ToString() != "")) { item.CreatedUserName = dt.Rows[i]["CreatedUserName"].ToString(); } if ((dt.Rows[i]["LastEditUserID"] != null) && (dt.Rows[i]["LastEditUserID"].ToString() != "")) { item.LastEditUserID = new int?(int.Parse(dt.Rows[i]["LastEditUserID"].ToString())); } if ((dt.Rows[i]["LastEditDate"] != null) && (dt.Rows[i]["LastEditDate"].ToString() != "")) { item.LastEditDate = new DateTime?(DateTime.Parse(dt.Rows[i]["LastEditDate"].ToString())); } if ((dt.Rows[i]["LinkUrl"] != null) && (dt.Rows[i]["LinkUrl"].ToString() != "")) { item.LinkUrl = dt.Rows[i]["LinkUrl"].ToString(); } if ((dt.Rows[i]["PvCount"] != null) && (dt.Rows[i]["PvCount"].ToString() != "")) { item.PvCount = int.Parse(dt.Rows[i]["PvCount"].ToString()); } if ((dt.Rows[i]["State"] != null) && (dt.Rows[i]["State"].ToString() != "")) { item.State = int.Parse(dt.Rows[i]["State"].ToString()); } if ((dt.Rows[i]["ClassID"] != null) && (dt.Rows[i]["ClassID"].ToString() != "")) { item.ClassID = int.Parse(dt.Rows[i]["ClassID"].ToString()); } if ((dt.Rows[i]["ClassName"] != null) && (dt.Rows[i]["ClassName"].ToString() != "")) { item.ClassName = dt.Rows[i]["ClassName"].ToString(); } if ((dt.Rows[i]["Keywords"] != null) && (dt.Rows[i]["Keywords"].ToString() != "")) { item.Keywords = dt.Rows[i]["Keywords"].ToString(); } if ((dt.Rows[i]["Sequence"] != null) && (dt.Rows[i]["Sequence"].ToString() != "")) { item.Sequence = int.Parse(dt.Rows[i]["Sequence"].ToString()); } if ((dt.Rows[i]["IsRecomend"] != null) && (dt.Rows[i]["IsRecomend"].ToString() != "")) { if ((dt.Rows[i]["IsRecomend"].ToString() == "1") || (dt.Rows[i]["IsRecomend"].ToString().ToLower() == "true")) { item.IsRecomend = true; } else { item.IsRecomend = false; } } if ((dt.Rows[i]["IsHot"] != null) && (dt.Rows[i]["IsHot"].ToString() != "")) { if ((dt.Rows[i]["IsHot"].ToString() == "1") || (dt.Rows[i]["IsHot"].ToString().ToLower() == "true")) { item.IsHot = true; } else { item.IsHot = false; } } if ((dt.Rows[i]["IsColor"] != null) && (dt.Rows[i]["IsColor"].ToString() != "")) { if ((dt.Rows[i]["IsColor"].ToString() == "1") || (dt.Rows[i]["IsColor"].ToString().ToLower() == "true")) { item.IsColor = true; } else { item.IsColor = false; } } if ((dt.Rows[i]["IsTop"] != null) && (dt.Rows[i]["IsTop"].ToString() != "")) { if ((dt.Rows[i]["IsTop"].ToString() == "1") || (dt.Rows[i]["IsTop"].ToString().ToLower() == "true")) { item.IsTop = true; } else { item.IsTop = false; } } if ((dt.Rows[i]["Attachment"] != null) && (dt.Rows[i]["Attachment"].ToString() != "")) { item.Attachment = dt.Rows[i]["Attachment"].ToString(); } if ((dt.Rows[i]["Remary"] != null) && (dt.Rows[i]["Remary"].ToString() != "")) { item.Remary = dt.Rows[i]["Remary"].ToString(); } if ((dt.Rows[i]["TotalComment"] != null) && (dt.Rows[i]["TotalComment"].ToString() != "")) { item.TotalComment = int.Parse(dt.Rows[i]["TotalComment"].ToString()); } if ((dt.Rows[i]["TotalSupport"] != null) && (dt.Rows[i]["TotalSupport"].ToString() != "")) { item.TotalSupport = int.Parse(dt.Rows[i]["TotalSupport"].ToString()); } if ((dt.Rows[i]["TotalFav"] != null) && (dt.Rows[i]["TotalFav"].ToString() != "")) { item.TotalFav = int.Parse(dt.Rows[i]["TotalFav"].ToString()); } if ((dt.Rows[i]["TotalShare"] != null) && (dt.Rows[i]["TotalShare"].ToString() != "")) { item.TotalShare = int.Parse(dt.Rows[i]["TotalShare"].ToString()); } if (dt.Rows[i]["BeFrom"] != null) { item.BeFrom = dt.Rows[i]["BeFrom"].ToString(); } list.Add(item); } } return list; }