public MLCategoryInfo(CategoryInfo catInfo)
 {
     this.ImportCategoryInfo(catInfo);
 }
Exemple #2
0
        protected void btnSavePreview_Click(object sender, EventArgs e)
        {
            try
            {
                NewsInfo news = new NewsInfo();
                if (Request.QueryString["id"] != null)
                {
                    news.ID = Convert.ToInt32(Request.QueryString["id"]);
                }
                else if (lblNewsID.Text != "")
                {
                    news.ID = Convert.ToInt32(lblNewsID.Text);
                }
                else
                {
                    news.ID = 0;
                }
                news.CatID       = ddlCategory.SelectedValue;
                news.Content     = Server.HtmlDecode(teContent.Text);
                news.CreateID    = this.UserId;
                news.ModifyID    = this.UserId;
                news.Description = Server.HtmlDecode(txtDescription.Text);

                if (chkImageURL.Checked)
                {
                    NewsController newsCont = new NewsController();
                    DataTable      dt       = newsCont.GetFileInfo(int.Parse(ctlURL.Url.Substring(7)));
                    if (dt.Rows.Count == 1)
                    {
                        string imagePath = PortalSettings.HomeDirectory + dt.Rows[0]["Folder"].ToString() + dt.Rows[0]["FileName"].ToString();
                        news.ImageUrl = imagePath + ";" + ctlURL.Url;
                        Resize(imagePath, 600);
                    }
                }
                else
                {
                    news.ImageUrl = "";
                }

                news.Headline     = txtHeadline.Text;
                news.AllowComment = chkAllowComment.Checked;
                news.Published    = chkPublished.Checked;
                news.KeyWords     = txtKeyWords.Text.Trim();
                news.ModifyDate   = Convert.ToDateTime(txtModifyDate.Text);
                news.StartDate    = txtStartDate.Text == "" ? (DateTime?)null : Convert.ToDateTime(txtStartDate.Text);
                news.EndDate      = txtEndDate.Text == "" ? (DateTime?)null : Convert.ToDateTime(txtEndDate.Text);
                if (chkNew.Checked)
                {
                    news.Feature += 1;
                }
                if (chkHot.Checked)
                {
                    news.Feature += 2;
                }
                news.Writer = txtWriter.Text;
                if (txtDonVi.Text == "")
                {
                    news.DonVi = PortalSettings.PortalName;
                }
                else
                {
                    news.DonVi = txtDonVi.Text;
                }
                news.FromOuter = chkFromOuter.Checked;

                NewsController db = new NewsController();
                if (news.ID != 0)
                {
                    db.Update(news);
                }
                else
                {
                    db.Insert(news);
                }

                string NewsGroupString = "";
                foreach (ListItem item in lstChkNewsGroup.Items)
                {
                    if (item.Selected == true)
                    {
                        NewsGroupString += "@" + item.Value + "@";
                        if (item.Value == "__Shared__" && hdShared.Value == "0")
                        {
                            SendMailToSuperUser(new string[] { "*****@*****.**" }, news.Headline);
                            hdShared.Value = "1";
                        }
                    }
                }
                db.UpdateNewsGroupNews(news.ID, NewsGroupString);

                btnDelete.Visible = true;
                btnDelete.Attributes["onclick"] = "if(!confirm('" + Localization.GetString("lblConfirmDelete", Localization.GetResourceFile(this, "news_edit.ascx")) + "')) {return false;};";
                lblNewsID.Text = news.ID.ToString();

                //Resize image
                string          pattern = "(?<=<img[^<]+?src=\")[^\"]+";
                MatchCollection mc      = Regex.Matches(news.Content, pattern, RegexOptions.Multiline);
                foreach (Match m in mc)
                {
                    Resize(m.Value, 600);
                }
                //Resize image

                CategoryController catCont    = new CategoryController();
                CategoryInfo       catInfo    = catCont.Load(news.CatID);
                string             previewUrl = DotNetNuke.Common.Globals.NavigateURL(catInfo.DesktopViewID, "", "id/" + news.ID.ToString());
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "preview", "window.open('" + previewUrl + "','','width=800,height=600,scrollbars=1')", true);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }