void SaveHtml()
        {
            bool recordsaved = false;

            try
            {
                DataSourceMaster.UpdateParameters["Description"].DefaultValue = HtmlEditor1.Html;
                DataSourceMaster.UpdateParameters["PageID"].DefaultValue      = ASPxComboBox1.Value.ToString();
                DataSourceMaster.Update();
                recordsaved = true;
            }
            catch (Exception e)
            {
                // throw;
                recordsaved          = false;
                divMessage.Visible   = true;
                divMessage.InnerHtml = "ERROR: " + Environment.NewLine + e.Message;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "toastMsg", "$(\"#pageToastMsg\").modal('show');", true);
            }
            finally
            {
                if (recordsaved)
                {
                    /*
                     * if (recordsaved)
                     * {
                     *
                     * string contentType = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ContentTypeASPxComboBox.Text.ToString());
                     * string category = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(CategoryComboBox.Value.ToString());
                     * string subCategory = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(SubCategoryComboBox.Value.ToString());
                     * string title = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(TitleTextBox.Value.ToString());
                     *
                     * if (!string.IsNullOrEmpty(contentType)
                     *  && !string.IsNullOrEmpty(category)
                     *  && !string.IsNullOrEmpty(subCategory)
                     *  && !string.IsNullOrEmpty(title)
                     *  )
                     * {
                     *
                     *  string imgDir = Server.MapPath("~/Content/Img/" + contentType + "/" + category + "/" + subCategory + "/" + title);
                     *  string fileDir = Server.MapPath("~/Content/Files/" + contentType + "/" + category + "/" + subCategory + "/" + title);
                     *
                     *  if (!Directory.Exists(imgDir)) { _ = Directory.CreateDirectory(imgDir); }
                     *  if (!Directory.Exists(fileDir)) { _ = Directory.CreateDirectory(fileDir); }
                     *
                     * }
                     *
                     * }
                     */
                }
            }
        }
예제 #2
0
        void SaveHtml()
        {
            bool recordsaved = false;

            try
            {
                DataSourceMaster.UpdateParameters["ContentTypeID"].DefaultValue = ContentTypeASPxComboBox.Value.ToString();
                DataSourceMaster.UpdateParameters["PageStatusID"].DefaultValue  = PageStatusComboBox.Value.ToString();
                DataSourceMaster.UpdateParameters["Category"].DefaultValue      = CategoryComboBox.Value.ToString();
                DataSourceMaster.UpdateParameters["SubCategory"].DefaultValue   = SubCategoryComboBox.Value.ToString();
                DataSourceMaster.UpdateParameters["Title"].DefaultValue         = TitleTextBox.Value.ToString();
                DataSourceMaster.UpdateParameters["MetaKeywords"].DefaultValue  = MetaKeywordsTokenBox.Value.ToString();
                DataSourceMaster.UpdateParameters["Description"].DefaultValue   = DescriptionMemo.Value.ToString();
                DataSourceMaster.UpdateParameters["PageType"].DefaultValue      = ContentTypeASPxComboBox.Text;
                DataSourceMaster.UpdateParameters["Body"].DefaultValue          = HtmlEditor1.Html;
                DataSourceMaster.UpdateParameters["Notes"].DefaultValue         = NotesMemo.Value.ToString();
                DataSourceMaster.UpdateParameters["PageID"].DefaultValue        = ASPxComboBoxSearch.Value.ToString();
                DataSourceMaster.Update();
                recordsaved = true;
            }
            catch (Exception e)
            {
                // throw;
                recordsaved          = false;
                divMessage.Visible   = true;
                divMessage.InnerHtml = "ERROR: " + Environment.NewLine + e.Message;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "toastMsg", "$(\"#pageToastMsg\").modal('show');", true);
            }
            finally
            {
                if (recordsaved)
                {
                    string contentType = (ContentTypeASPxComboBox.Text.ToString().ToLower());
                    string category    = (CategoryComboBox.Value.ToString());
                    string subCategory = (SubCategoryComboBox.Value.ToString());
                    string title       = (TitleTextBox.Value.ToString());

                    if (!string.IsNullOrEmpty(contentType) &&
                        !string.IsNullOrEmpty(category) &&
                        !string.IsNullOrEmpty(subCategory) &&
                        !string.IsNullOrEmpty(title)
                        )
                    {
                        string imgDir  = Server.MapPath("~/Content/Img/" + contentType + "/" + category + "/" + subCategory + "/" + title);
                        string fileDir = Server.MapPath("~/Content/Files/" + contentType + "/" + category + "/" + subCategory + "/" + title);

                        if (!Directory.Exists(imgDir))
                        {
                            _ = Directory.CreateDirectory(imgDir);
                        }
                        if (!Directory.Exists(fileDir))
                        {
                            _ = Directory.CreateDirectory(fileDir);
                        }
                    }
                }

                divMessage.Visible   = true;
                divMessage.InnerHtml = "Página Guardada.";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "toastMsg", "$(\"#pageToastMsg\").modal('show');", true);
            }
        }