Exemple #1
0
        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
            #region Request
            m_Serviced = DataProcessingProvider.GetProcessedInt(Request.QueryString["ServiceId"]);
            m_preTabId = DataProcessingProvider.GetProcessedInt(Request.QueryString["PreTabId"]);
            if (m_Serviced == -1)
            {
                m_strCategories = DataProcessingProvider.GetProcessedString(Request.QueryString["Categories"]);
                if (m_strCategories == "")
                {
                    m_strCategories = ",-1,";
                }
                else
                {
                    m_strCategories = DataProcessingProvider.GetProcessedBatchString(m_strCategories);
                }
            }
            else
            {
                m_strCategories = CategoryProvider.GetItemCategoryString(m_Serviced, ServiceProvider.TypeId);
            }

            #endregion

            #region Settings
            //Load Folder
            m_strFolderName = CategoryProvider.GetDefaultFolderPath(m_strCategories, this.PortalId);
            if (m_strFolderName == "")
            {
                m_strFolderName = (string)Settings[ServiceInsertSettings.FOLDER_IMAGE_KEY];
                if (m_strFolderName == null || m_strFolderName.Length == 0)
                {
                    m_strFolderName = ServiceInsertSettings.FOLDER_IMAGE_DEFAULT;
                }
            }
            string strFolderPath = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, m_strFolderName);
            if (!System.IO.Directory.Exists(strFolderPath))
            {
                m_strFolderName = ServiceInsertSettings.FOLDER_IMAGE_DEFAULT;
            }

            m_strExtension = LoadStringSetting(ServiceInsertSettings.EXTENSTION_KEY, ServiceInsertSettings.EXTENSTION_VALUE_DEFAULT);
            m_linkUpload   = LoadStringSetting(ServiceInsertSettings.LINKUPLOAD_KEY, ServiceInsertSettings.LINKUPLOAD_VALUE_DEFAULT);
            #endregion

            #region Datetime

            lnkExpiredDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtExpiredDate).Replace("M/d/yyyy", "MM/dd/yyyy").Replace("d/MM/yyyy", "dd/MM/yyyy").Replace("MM/dd/yyyy", "dd/MM/yyyy");
            //Điền dữ liệu vào các control
            imgExpiredDate.ImageUrl = string.Format("{0}/images/calendar.png", this.ModulePath);

            lnkDisplayDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtDisplayDate).Replace("M/d/yyyy", "MM/dd/yyyy").Replace("d/MM/yyyy", "dd/MM/yyyy").Replace("MM/dd/yyyy", "dd/MM/yyyy");
            //Điền dữ liệu vào các control
            imgDisplayDate.ImageUrl = string.Format("{0}/images/calendar.png", this.ModulePath);
            #endregion

            #region Register

            DotNetNuke.UI.Skins.Skin objParentSkin = DotNetNuke.UI.Skins.Skin.GetParentSkin(this);
            if (objParentSkin != null)
            {
                objParentSkin.RegisterModuleActionEvent(this.ModuleId, new ActionEventHandler(ModuleAction_Click));
            }
            if (m_Serviced == -1)
            {
                m_objRole = new Role(this.UserId, GetSuperMode(), this.PortalId, ServiceProvider.TypeId);
            }
            else
            {
                m_objRole = new Role(this.UserId, m_Serviced, GetSuperMode(), this.PortalId, ServiceProvider.TypeId);
            }
            #endregion
        }
Exemple #2
0
        protected void UpdateData()
        {
            try
            {
                //Detect Empty Text
                if (this.txtTitle.Text == "")
                {
                    this.lblError.Text    = Localization.GetString("errEmptyName.Text", this.LocalResourceFile);
                    this.lblError.Visible = true;
                    return;
                }

                //string strSummary = txtSummary.Text;


                string strSummary      = DataProcessingProvider.RemoveTags(this.txtSummary.Text);
                string strContent      = DataProcessingProvider.RemoveTags(this.htmlContent.Text);
                string strAddRichInfo1 = DataProcessingProvider.RemoveTags(this.txtAddRichInfo1.Text);
                string strAddRichInfo2 = DataProcessingProvider.RemoveTags(this.txtAddRichInfo2.Text);
                string strAddRichInfo3 = DataProcessingProvider.RemoveTags(this.txtAddRichInfo3.Text);
                bool   blIsOpenNewTab  = chIsUrlWeb.Checked;
                //Detect Role

                if (!((m_objRole.HasRole((int)Connection.UtilsProvider.CoreRole.Create) && m_Serviced == -1) || ((m_objRole.HasRole((int)Connection.UtilsProvider.CoreRole.EditAfter) || m_objRole.HasRole((int)Connection.UtilsProvider.CoreRole.EditAll)) && m_Serviced != -1)))
                {
                    this.lblError.Text = Localization.GetString("errNoRole.Text", this.LocalResourceFile);
                    //this.lblError.Text = m_objRole.HasRole((int)THCore.CoreRole.Create).ToString();
                    this.lblError.Visible = true;
                    return;
                }

                string strImageFile = "";
                string strAvatar    = "";

                string strFolderName = m_strCategories;
                strFolderName = CategoryProvider.GetDefaultFolderPath(UIProvider.GetListBoxSelectedItems(",", chkCategoryList), this.PortalId);
                if (strFolderName == "" || strFolderName == null || strFolderName.Length == 0)
                {
                    strFolderName = "Folder";
                }
                string strFolderPath = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, strFolderName);
                if (!System.IO.Directory.Exists(strFolderPath))
                {
                    strFolderName = m_strFolderName;
                }

                /*
                 * if (txtImageFile.PostedFile.FileName.Length != 0) //&& chkUseImage.Checked
                 * {
                 *  string strFileName = txtImageFile.PostedFile.FileName.Substring(txtImageFile.PostedFile.FileName.LastIndexOf(@"\") + 1);
                 *  strImageFile = string.Format("{0}{1}", strFolderName, strFileName);
                 *  string strParentFolder = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, strFolderName);
                 *  FileProvider.Upload(this.PortalId, strFolderName, strFileName,
                 *      txtImageFile.PostedFile.InputStream);
                 *  //FileSystemUtils.UploadFile(strParentFolder.Replace("/", @"\"), txtImageFile.PostedFile, false);
                 * }*/
                strImageFile = DNNRelatedProvider.GetFilePath(urlImageFile.Url, this.PortalId);
                if (strImageFile == "")
                {
                    strImageFile = txtImageFileOld.Text;
                }

                /*
                 * if (txtAvatar.PostedFile.FileName.Length != 0) //&& chkUseImage.Checked
                 * {
                 *  string strFileName = txtAvatar.PostedFile.FileName.Substring(txtAvatar.PostedFile.FileName.LastIndexOf(@"\") + 1);
                 *  strAvatar = string.Format("{0}{1}", strFolderName, strFileName);
                 *  string strParentFolder = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, strFolderName);
                 *  FileProvider.Upload(this.PortalId, strFolderName, strFileName,
                 *      txtAvatar.PostedFile.InputStream);
                 * // FileSystemUtils.UploadFile(strParentFolder.Replace("/", @"\"), txtAvatar.PostedFile, false);
                 * }*/
                strAvatar = DNNRelatedProvider.GetFilePath(urlAvatar.Url, this.PortalId);
                if (strAvatar == "")
                {
                    strAvatar = txtAvatarOld.Text;
                }

                int    iOrder   = -1;
                string strOrder = txtOrder.Text;
                if (!int.TryParse(strOrder, out iOrder))
                {
                    this.lblError.Text    = Localization.GetString("errFormatOrder.Text", this.LocalResourceFile);
                    this.lblError.Visible = true;
                    return;
                }

                DateTime ExpiredDate;
                ExpiredDate = DateTime.ParseExact(txtExpiredDate.Text, "dd/MM/yyyy", null);


                DateTime DisplayDate;
                if (txtDisplayDate.Text == "")
                {
                    DisplayDate = DateTime.Today;
                }
                else
                {
                    DisplayDate = DateTime.ParseExact(txtDisplayDate.Text, "dd/MM/yyyy", null);
                }


                DisplayDate.AddHours(DateTime.Now.Hour);
                DisplayDate.AddMinutes(DateTime.Now.Minute);
                DisplayDate.AddSeconds(DateTime.Now.Second);



                // Get Hot Period
                int intPeriod;
                if (!int.TryParse(this.txtHotPeriod.Text, out intPeriod))
                {
                    intPeriod = 0;
                }

                m_strCategories = UIProvider.GetListBoxSelectedItems(",", chkCategoryList);
                if (m_strCategories.Equals(""))
                {
                    this.lblError.Text    = "Chưa chọn chuyên mục";
                    this.lblError.Visible = true;
                    return;
                }

                string strAddInfo1 = txtAddInfo1.Text;
                string strAddInfo2 = txtAddInfo2.Text;
                string strAddInfo3 = txtAddInfo3.Text;
                string strAddInfo4 = txtAddInfo4.Text;
                string strAddInfo5 = txtAddInfo5.Text;
                //Going into action.
                int result = 1;

                if (m_Serviced == -1)
                {
                    string realTitle = "";
                    realTitle = DataProcessingProvider.RemoveTags(this.txtTitle.Text);
                    result    = ServiceProvider.InsertImage(realTitle, strSummary, strImageFile, strAvatar, blIsOpenNewTab, strContent, DateTime.Now, ExpiredDate, DisplayDate, DateTime.Now, this.UserId, chkIsHot.Checked, intPeriod, this.PortalId, false, iOrder, m_strCategories, strAddInfo1, strAddInfo2, strAddInfo3, strAddInfo4, strAddInfo5, strAddRichInfo1, strAddRichInfo2, strAddRichInfo3);
                    if (result > 0)
                    {
                        LogProvider.InsertLogAction(result, ServiceProvider.TypeId, "", this.PortalId, (int)Connection.UtilsProvider.LogAction.Create, this.UserInfo.Username, this.UserId, realTitle, true, m_strCategories);
                    }
                }
                else
                {
                    string realTitle = "";
                    realTitle = DataProcessingProvider.RemoveTags(this.txtTitle.Text);
                    DateTime CreateDate = DateTime.Parse(txtCreatedDateOld.Text);
                    //ServiceProvider.UpdateImage(m_Serviced, txtTitleOld.Text, strSummary, strImageFile, strAvatar, blIsOpenNewTab, strContent, CreateDate, ExpiredDate, DisplayDate, DateTime.Now, this.UserId, chkIsHot.Checked, intPeriod, this.PortalId, false, iOrder, TH.Utils.UIProvider.GetListBoxSelectedItems(",", chkCategoryList));
                    ServiceProvider.UpdateImage(m_Serviced, realTitle, strSummary, strImageFile, strAvatar, blIsOpenNewTab, strContent, CreateDate, ExpiredDate, DisplayDate, DateTime.Now, this.UserId, chkIsHot.Checked, intPeriod, this.PortalId, false, iOrder, m_strCategories, strAddInfo1, strAddInfo2, strAddInfo3, strAddInfo4, strAddInfo5, strAddRichInfo1, strAddRichInfo2, strAddRichInfo3);
                    result = m_Serviced;
                    if (result > 0)
                    {
                        LogProvider.InsertLogAction(result, ServiceProvider.TypeId, "", this.PortalId, (int)Connection.UtilsProvider.LogAction.Update, this.UserInfo.Username, this.UserId, this.txtTitleOld.Text, true, m_strCategories);
                    }
                }


                if (result == -2)
                {
                    this.lblError.Text    = Localization.GetString("errSameName.Text", this.LocalResourceFile);
                    this.lblError.Visible = true;
                }
                else if (result <= 0)
                {
                    this.lblError.Text    = Localization.GetString("errSomeError.Text", this.LocalResourceFile);
                    this.lblError.Visible = true;
                }
                else
                {
                    JumpBack(false, result);
                }
            }
            catch (Exception ex)
            {
                this.lblError.Text    = ex.GetType().ToString();
                this.lblError.Visible = true;
            }
        }
Exemple #3
0
        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
            #region Request
            m_ProductId = DataProcessingProvider.GetProcessedInt(Request.QueryString["ProductId"]);
            m_preTabId  = DataProcessingProvider.GetProcessedInt(Request.QueryString["PreTabId"]);
            m_strTags   = ",";
            if (m_ProductId == -1)
            {
                m_strCategories = DataProcessingProvider.GetProcessedString(Request.QueryString["Categories"]);
                if (m_strCategories == "")
                {
                    m_strCategories = ",-1,";
                }
                else
                {
                    m_strCategories = DataProcessingProvider.GetProcessedBatchString(m_strCategories);
                }
            }
            else
            {
                DataTable dtTags = DotNetNuke.Data.DataProvider.Instance().ExecuteDataSet("THCore_CM_GetItemTags", m_ProductId, ProductProvider.TypeId).Tables[0];
                if (dtTags.Rows.Count > 0)
                {
                    for (int i = 0; i < dtTags.Rows.Count; i++)
                    {
                        m_strTags = m_strTags + dtTags.Rows[i][0].ToString() + ",";
                    }
                }
                m_strCategories = CategoryProvider.GetItemCategoryString(m_ProductId, ProductProvider.TypeId);
            }
            //Dynamic Form
            string[] arrCategories = m_strCategories.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            int      iCategory     = -1;
            int.TryParse(arrCategories[0].Trim(), out iCategory);

            m_strExtension = LoadStringSetting(ProductInsertSettings.EXTENSTION_KEY, ProductInsertSettings.EXTENSTION_VALUE_DEFAULT);
            //string strExtendedSettings = CategoryProvider.GetExtendedSettings(iCategory);
            string strExtendedSettings = m_strExtension;

            dtConfig = new DataTable();
            dtConfig = XMLProvider.XmlString2DataTable(strExtendedSettings);
            try
            {
                if (dtConfig != null && dtConfig.Rows.Count > 0)
                {
                    CreateDynamicForm(dtConfig);
                }
            }
            catch (Exception ex)
            {
                lblError.Text         = ex.Message;
                this.lblError.Visible = true;
            }
            #endregion
            #region Settings
            //Load Folder
            m_strFolderName = CategoryProvider.GetDefaultFolderPath(m_strCategories, this.PortalId);
            if (m_strFolderName == "")
            {
                m_strFolderName = (string)Settings[ProductInsertSettings.FOLDER_IMAGE_KEY];
                if (m_strFolderName == null || m_strFolderName.Length == 0)
                {
                    m_strFolderName = ProductInsertSettings.FOLDER_IMAGE_DEFAULT;
                }
            }
            string strFolderPath = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, m_strFolderName);
            if (!System.IO.Directory.Exists(strFolderPath))
            {
                m_strFolderName = ProductInsertSettings.FOLDER_IMAGE_DEFAULT;
            }


            #endregion
            #region Datetime
            lnkExpiredDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtExpiredDate).Replace("M/d/yyyy", "MM/dd/yyyy").Replace("d/MM/yyyy", "dd/MM/yyyy").Replace("MM/dd/yyyy", "dd/MM/yyyy");
            //Điền dữ liệu vào các control
            imgExpiredDate.ImageUrl = string.Format("{0}/images/calendar.png", this.ModulePath);

            lnkProducedDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtProducedDate).Replace("M/d/yyyy", "MM/dd/yyyy").Replace("d/MM/yyyy", "dd/MM/yyyy").Replace("MM/dd/yyyy", "dd/MM/yyyy");
            //Điền dữ liệu vào các control
            imgProducedDate.ImageUrl = string.Format("{0}/images/calendar.png", this.ModulePath);

            lnkDisplayDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtDisplayDate).Replace("M/d/yyyy", "MM/dd/yyyy").Replace("d/MM/yyyy", "dd/MM/yyyy").Replace("MM/dd/yyyy", "dd/MM/yyyy");
            //Điền dữ liệu vào các control
            imgDisplayDate.ImageUrl = string.Format("{0}/images/calendar.png", this.ModulePath);



            #endregion
            #region Register
            DotNetNuke.UI.Skins.Skin objParentSkin = DotNetNuke.UI.Skins.Skin.GetParentSkin(this);
            if (objParentSkin != null)
            {
                objParentSkin.RegisterModuleActionEvent(this.ModuleId, new ActionEventHandler(ModuleAction_Click));
            }
            if (m_ProductId == -1)
            {
                m_objRole = new Role(this.UserId, GetSuperMode(), this.PortalId, ProductProvider.TypeId);
            }
            else
            {
                m_objRole = new Role(this.UserId, m_ProductId, GetSuperMode(), this.PortalId, ProductProvider.TypeId);
            }
            #endregion
        }