protected void Page_Load(object sender, EventArgs e) { var id = Request.QueryString["id"]; if (!IsPostBack) { var ctx = new DataContext(); var dt = ctx.ExecuteDataTable("Select * from Content Where State<>255 And ID=" + id); if (dt != null && dt.Rows.Count > 0) { Content = dt.ToList <Model.Content>()[0]; } img_1.ImgUrls = Content.ImageUrls; //加载栏目 var bllChannels = new BLL.Channel(); var channels = bllChannels.GetChannels(ctx); ddlChannel.Items.Add(new ListItem("==请选择==", "0")); foreach (var channel in channels) { var item = new ListItem(channel.Name, channel.ID.ToString()); item.Attributes.Add("contentType", channel.ContentType.ToString()); item.Attributes.Add("class", "channel"); item.Attributes.Add("type", channel.Type.ToString()); if (Content.ChannelID == channel.ID) { item.Attributes.Add("Selected", "Selected"); } ddlChannel.Items.Add(item); } } }
public OwcContent(Model.Content content) { this.Type = content.Type; this.Url = content.Url; this.Text = content.Value; this.Any = content.Extension == null ? null : content.Extension.GetObject <XmlElement>(); }
protected void btnSubmit_Click(object sender, EventArgs e) { string CreateBy = string.Empty; if (Utils.GetCookie(PTSKeys.ADMIN_NAME, PTSKeys.CDL_CMS_KEY) != null) { CreateBy = Utils.GetCookie(PTSKeys.ADMIN_NAME, PTSKeys.CDL_CMS_KEY); } int _ErrCode = 0; int _RowEffects = 0; Model.Content model = new Model.Content(); if (id > 0) { model = bll.GetModel(id, -1, -1, -1, 1, 1); } model.Title = txtTitle.Text.Trim(); model.TitleUrl = Utils.GenURL(txtTitle.Text.Trim()); model.Image = txtImage.Value; model.ContentTypeID = Convert.ToInt32(ddlContentType.SelectedValue); model.Intro = txtIntro.Value; model.FullContent = txtContent.Value; model.Status = Convert.ToInt32(rdStatus.SelectedValue); model.CreateBy = CreateBy; bll.Update(model, ref _ErrCode, ref _RowEffects); if (_RowEffects > 0) { JscriptMsg(_ErrCode.ToString(), "List.aspx", "Success"); } else { JscriptMsg(_ErrCode.ToString(), "", "Error"); } }
private AjaxResult Edit() { var title = Request.Form["title"]; var channel = Request.Form["channel"]; var content = Request.Form["content"]; var recommend = Request.Form["recommend"]; var image = Request.Form["image"]; var remark = Request.Form["remark"]; var id = Request.Form["id"]; AjaxResult re = new AjaxResult(); if (string.IsNullOrEmpty(title)) { re.Success = 0; re.Message = "标题不能为空"; return(re); } if (string.IsNullOrEmpty(channel)) { re.Success = 0; re.Message = "栏目不能为空"; return(re); } if (string.IsNullOrEmpty(content)) { re.Success = 0; re.Message = "内容不能为空"; return(re); } BLL.BLLBase bll = new BLLBase(); ctx.BeginTransaction(); try { var tb = ctx.ExecuteDataTable("Select * from Channel Where ID=" + channel); if (tb == null && tb.Rows.Count < 1) { throw new Exception("获取频道信息出错"); } var channelObj = tb.ToList <Model.Channel>()[0]; var contentObj = new Model.Content() { ID = Convert.ToInt16(id), Attributes = recommend, ChannelCode = channelObj.Code, ChannelName = channelObj.Name, ChannelID = channelObj.ID, ContentText = content, ImageUrls = common.Common.UploadImagePath + image.Replace("common.Common.UploadImagePath", ""), ModifiedBy = PubFunc.GetAdminID(), ModifyDate = DateTime.Now, Remark = remark, Type = channelObj.ContentType, State = 0, Title = title }; bll.Update(ctx, contentObj); ctx.CommitTransaction(); re.Success = 1; re.Message = "添加成功"; } catch (Exception exception) { ctx.RollBackTransaction(); re.Success = 0; re.Message = exception.Message; throw; } finally { ctx.CloseConnection(); } return(re); }
private void ShowInfo(int _id) { Model.Content model = new Model.Content(); model = bll.GetModel(id, -1, -1, -1, 1, 1); if (null != model && model.ContentID > 0) { txtTitle.Text = model.Title; ddlContentType.SelectedValue = model.ContentTypeID.ToString(); txtImage.Value = model.Image; txtIntro.Value = model.Intro; txtContent.Value = model.FullContent; rdStatus.SelectedValue = model.Status.ToString(); } }
public List<Model.Content> GetList(Int64 _ContentID, Int64 _ContentTypeID, int _Status, int _Lang, int _Start, int _Limit) { List<Model.Content> lModel = new List<Model.Content>(); try { SqlParameter[] p = { new SqlParameter("@ContentID", SqlDbType.Int, 4), new SqlParameter("@ContentTypeID", SqlDbType.Int, 4), new SqlParameter("@ContentStatus", SqlDbType.Int, 4), new SqlParameter("@Lang", SqlDbType.Int, 4), new SqlParameter("@Start", SqlDbType.Int, 4), new SqlParameter("@Limit", SqlDbType.Int, 4), }; p[0].Value = _ContentID; p[1].Value = _ContentTypeID; p[2].Value = _Status; p[3].Value = _Lang; p[4].Value = _Start; p[5].Value = _Limit; DataTable dt = db.ExcuteSelectReturnDataTable("Content_Select", CommandType.StoredProcedure, p); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { Model.Content model = new Model.Content(); model.Ind = Convert.ToInt32(dr["Ind"]); model.ContentID = Convert.ToInt32(dr["ContentID"]); model.ContentTypeID = Convert.ToInt32(dr["ContentTypeID"]); model.ContentID = Convert.ToInt32(dr["ContentID"]); model.ContentTypeName = dr["ContentTypeName"].ToString(); model.ContentTypeUrl = dr["ContentTypeUrl"].ToString(); model.Title = dr["Title"].ToString(); model.TitleUrl = dr["TitleUrl"].ToString(); model.Image = dr["Image"].ToString(); model.Intro = dr["Intro"].ToString(); model.FullContent = dr["Content"].ToString(); model.Status = Convert.ToInt32(dr["Status"]); model.StatusText = dr["StatusText"].ToString(); model.Lang = Convert.ToInt32(dr["Lang"]); model.CreateBy = dr["CreateBy"].ToString(); model.CreateTime = dr["CreateTime"].ToString(); model.UpdateBy = dr["UpdateBy"].ToString(); model.UpdateTime = dr["UpdateTime"].ToString(); model.TotalRow = Convert.ToInt32(dr["TotalRow"]); lModel.Add(model); } } } catch (Exception ex) { PTSLog.Error(ex.Message); } return lModel; }
private void btnSubmit_Click(object sender, EventArgs e) { try { Model.Content oContent = new Model.Content(); if (!CheckSubmit()) { return; } oContent.Folder = cboLibrary.SelectedItem as Model.Folder; //--------------------------------------------------------- //oContent.Name = txtContent.Text; oContent.Tags = new List <string>(); oContent.Name = cboBrank.Text + cboWorkflow.Text + DateTime.Now.ToString("yyMMddHHmmssff"); oContent.Tags.Add(oContent.Name.Replace(" ", "_")); //----------------------------------------------------------- //Update Field Library oContent.LibraryFieldValues = new Dictionary <string, object>(); var library = oUCMSApiClient.Folder.GetLibrary(oContent.Folder.Id); foreach (var item in library.Fields) { oContent.LibraryFieldValues.Add(item.Id, item.DefaultValue); } if (library.ContentTypes.Count > 0) { var contentType = oUCMSApiClient.ContentType.GetById(library.ContentTypes[0].Id); oContent.ContentType = new Model.ContentType() { Id = contentType.Id }; oContent.Values = new Dictionary <string, object>(); foreach (var item in contentType.Fields) //Chon gia tri cho contentType { oContent.Values.Add(item.Name, item.DefaultValue); } } oContent.Values.Add("BranchId", cboBrank.Text); var oContentMd = oUCMSApiClient.Content.Create(oContent); //oUCMSApiClient.Content.SetPrivateData(oContentMd.Id, new Model.ContentPrivateData() { }); // ---------Attachment----------------------------------------------------------------- oUCMSApiClient.Content.Checkout(oContentMd.Id);//Checkout content foreach (String item in tempNameFolders.Split(';')) { if (item.Trim().Length > 0) { var attachment = new Model.Attachment(); attachment.Name = Path.GetFileName(item.Trim()); attachment.ContentId = oContentMd.Id; attachment.MIME = Path.GetExtension(item.Trim()).Replace(".", "image/"); attachment.Data = File.ReadAllBytes(item.Trim()); attachment.Type = Model.Enum.AttachmentType.Public; attachment.Path = item.Trim(); oUCMSApiClient.Attachment.Upload(attachment); } } oUCMSApiClient.Content.Checkin(oContentMd.Id); // Checkint content //----------------------------------------------------------------------------------------- //---Insert content in workflow------------------------------------------------------------ Model.WorkflowItem oWorkflowItem = new Model.WorkflowItem(); oWorkflowItem.Content = oContentMd; oWorkflowItem.WorkflowStep = new Model.WorkflowStep() { Id = (cboWorkflowStep.SelectedItem as Model.WorkflowStep).Id }; oWorkflowItem.Workflow = new Model.Workflow() { Id = (cboWorkflow.SelectedItem as Model.Workflow).Id }; oWorkflowItem.State = Model.Enum.WorkflowItemState.Ready; oWorkflowItem.Priority = Model.Enum.WorkflowItemPriority.Normal; oUCMSApiClient.WorkflowItem.Insert(oWorkflowItem, true); //----------------------------------------------------------------------------------------- MessageBox.Show("Cập nhật thành công"); txtContent.Text = ""; txtFolders.Text = ""; } catch (Exception ex) { } }