private string GetRoleString() { string strResult; m_isManage = false; if (m_objTable.Rows.Count == 0) { strResult = ""; } else { int i; strResult = ","; int roleId; for (i = 0; i < m_objTable.Rows.Count; i++) { roleId = DataProcessingProvider.GetProcessedInt(m_objTable.Rows[i][0].ToString()); if (roleId != -1) { if (StrManageRoles.Contains(roleId.ToString())) { m_isManage = true; } strResult = strResult + m_objTable.Rows[i][0].ToString() + ","; } } if (strResult == ",") { strResult = ""; } } return(strResult); }
protected void JumpBack(bool isStay, int Serviced) { string strCategoryUrl = "-1"; string[] strCategoriesUrl = DataProcessingProvider.GetProcessedString(Request.QueryString["Categories"]).Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (strCategoriesUrl != null && strCategoriesUrl.Length > 0) { strCategoryUrl = strCategoriesUrl[0]; } else { strCategoriesUrl = m_strCategories.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); strCategoryUrl = strCategoriesUrl[0]; } if (strCategoryUrl.Equals("-1")) { Response.Redirect(Globals.NavigateURL(m_preTabId)); } else { if (!Globals.NavigateURL(m_preTabId).Contains("?")) { Response.Redirect(Globals.NavigateURL(m_preTabId) + "?CategoryId=" + strCategoryUrl); } else { Response.Redirect(Globals.NavigateURL(m_preTabId) + "&&CategoryId=" + strCategoryUrl); } } }
protected void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (!this.Page.IsPostBack) { cboType.Items.Clear(); cboType.DataSource = UtilityProvider.GetCoreType(); cboType.DataTextField = "TypeName"; cboType.DataValueField = "TypeId"; cboRecycleBin.Items.Clear(); cboRecycleBin.DataSource = DataProcessingProvider.ProcessDataTable(UtilityProvider.GetTabs(this.PortalId, -1), 1, 2); cboRecycleBin.DataTextField = "TabName"; cboRecycleBin.DataValueField = "TabId"; cboRelated.Items.Clear(); cboRelated.DataSource = DataProcessingProvider.ProcessDataTable(UtilityProvider.GetTabs(this.PortalId, -1), 1, 2); cboRelated.DataTextField = "TabName"; cboRelated.DataValueField = "TabId"; cboTypeGroup.Items.Clear(); cboTypeGroup.DataSource = DataProcessingProvider.ProcessDataTable(UtilityProvider.GetTabs(this.PortalId, -1), 1, 2); cboTypeGroup.DataTextField = "TabName"; cboTypeGroup.DataValueField = "TabId"; DataBind(); ListItem li = new ListItem(); li.Text = "All"; li.Value = "-1"; cboType.Items.Insert(0, li); cboType.SelectedValue = m_typeId.ToString(); cboRecycleBin.SelectedValue = m_recyleBinLink.ToString(); cboRelated.SelectedValue = m_relatedLink.ToString(); cboTypeGroup.SelectedValue = m_tagGroupLink.ToString(); txtTypeInclude.Text = m_typeInclude; txtTypeReturn.Text = m_typeReturn; #region Load Show Choice & Alt Text //Load show choice this.chkDip1.Checked = m_isShowDip1; this.chkDip2.Checked = m_isShowDip1; this.chkDip3.Checked = m_isShowDip1; this.chkDip4.Checked = m_isShowDip1; this.chkDip5.Checked = m_isShowDip1; //Load alt text this.txtDip1.Text = m_altSourceDip1; this.txtDip2.Text = m_altSourceDip2; this.txtDip3.Text = m_altSourceDip3; this.txtDip4.Text = m_altSourceDip4; this.txtDip5.Text = m_altSourceDip5; #endregion } }
/// <summary> /// Áp dụng cho trường hợp thêm action cho nhiều item, có biết category của item. /// </summary> /// <param name="strItems">Chuỗi batchstring chứa id của các item</param> /// <param name="typeId">Loại của item</param> /// <param name="portalId">Mã Id của Portal</param> /// <param name="actionId">Loại hành động</param> /// <param name="actionOwner">Người thực hiện hành động</param> /// <param name="actionOwnerId">Mã người thực hiện hành động</param> /// <param name="actionValue">Giá trị của hành động</param> /// <param name="isChangeName">Hành động có thay đổi tên không</param> /// <param name="strCategories">Chuỗi batchstring chứa id của các category.</param> public static void InsertManyLogAction(string strItems, int typeId, int portalId, int actionId, string actionOwner, int actionOwnerId, string actionValue, bool isChangeName, string strCategories) { string[] items = DataProcessingProvider.GetBatchStringItems(strItems, ","); int itemId; foreach (string item in items) { itemId = int.Parse(item); LogProvider.InsertLogAction(itemId, typeId, "", portalId, actionId, actionOwner, actionOwnerId, actionValue, false, strCategories); } }
/// <summary> /// Thêm một item vào nhiều tag của một tag group cùng lúc và đảm bảo rằng những tag này là những tag duy nhất mà item có trong tag group. /// Kết quả của hàm này là đối với tag group được chỉ định, item chỉ có các tag vừa được thêm mà không có các tag khác. /// </summary> /// <param name="itemId">Mã của item.</param> /// <param name="strTags">Chuỗi batchstring chứa id của các tag đích.</param> /// <param name="typeId">Loại của item và Tag.</param> /// <param name="tagGroupId">Mã của nhóm từ khóa chứa strTag.</param> public static void AttachItemToManyTags(int itemId, string strTags, int typeId, int tagGroupId) { if (strTags != "" && strTags != ",") { string[] strSplitTags = DataProcessingProvider.GetBatchStringItems(strTags, ","); int i; strTags = ","; for (i = 0; i < strSplitTags.Length; i++) { strTags = strTags + strSplitTags[i].Trim() + ","; } TM_InsertBatchTagItem(itemId, strTags, typeId, tagGroupId); } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { if (m_isPassOnce) { return; } aLinkUpload.HRef = m_linkUpload; //Set DisplayDate to Today, Set ExpiredDate to ten years after. this.txtDisplayDate.Text = DateTime.Now.ToString("dd/MM/yyyy"); this.txtExpiredDate.Text = DateTime.Now.AddYears(10).ToString("dd/MM/yyyy"); //Load Categories //if (m_Serviced == -1) //{ this.chkCategoryList.DataSource = DataProcessingProvider.ProcessDataTable(CategoryProvider.GetExcludedCategories(this.PortalId, -1, ServiceProvider.TypeId), 1, 2); this.chkCategoryList.DataTextField = "Name"; this.chkCategoryList.DataValueField = "CategoryId"; this.chkCategoryList.DataBind(); UIProvider.BindListBox(chkCategoryList, m_strCategories); //} //else //{ // TH.Core.Providers.Utilities.UIProvider.PopulateCategories(this.chkCategoryList, m_strCategories, ServiceProvider.TypeId, this.UserId, GetSuperMode(), true, m_Serviced); //} //Bind Data if (m_Serviced != -1) { ImageBinding(); } m_isPassOnce = true; } } catch (Exception ex) { lblError.Text = ex.Message; this.lblError.Visible = true; } }
protected void BindCboExcludedCategories(int TypeId) { try { this.cbCategories.Items.Clear(); this.cbCategories.DataSource = DataProcessingProvider.ProcessDataTable(CategoryProvider.GetExcludedCategories(this.PortalId, m_intCategoryId, TypeId), 1, 2); this.cbCategories.DataValueField = "CategoryId"; this.cbCategories.DataTextField = "Name"; this.cbCategories.DataBind(); this.cbCategories.Items.Insert(0, Localization.GetString("mssNoParent.Text", this.LocalResourceFile)); this.cbCategories.Items[0].Value = "-1"; } catch (Exception ex) { lblError.Text = ex.Message; this.lblError.Visible = true; } }
public static int TL_GetCounter(int itemId, int typeId) { SqlConnection objConnection = new SqlConnection(Connection.UtilsProvider.ObjUtils.StrConnection); try { int result; result = DataProcessingProvider.GetProcessedInt(SqlHelper.ExecuteScalar(objConnection, Connection.UtilsProvider.ObjUtils.GetStoreName_THCore("TL", "GetCounter"), itemId, typeId).ToString(), 0); return(result); } finally { if (null != objConnection) { objConnection.Close(); } } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); m_intCategoryId = DataProcessingProvider.GetProcessedInt(Request.QueryString["CategoryId"]); int i; if (Settings[MgmtCategoryListSettings.TYPE_ID_KEY] == null || !int.TryParse(Settings[MgmtCategoryListSettings.TYPE_ID_KEY].ToString(), out i)) { m_typeId = MgmtCategoryListSettings.TYPE_ID; } else { m_typeId = int.Parse(Settings[MgmtCategoryListSettings.TYPE_ID_KEY].ToString()); } if (Request.QueryString["Type"] != null) { try { m_typeId = int.Parse(Request.QueryString["Type"]); } catch { } } if (m_typeId == -1) { m_IsAllType = true; } else { m_IsAllType = false; } if (Settings[MgmtCategoryListSettings.TYPE_INCLUDE_KEY] == null) { m_typeInclude = MgmtCategoryListSettings.TYPE_INCLUDE; } else { m_typeInclude = Settings[MgmtCategoryListSettings.TYPE_INCLUDE_KEY].ToString(); } if (Settings[MgmtCategoryListSettings.TYPE_RETURN_KEY] == null) { m_typeReturn = MgmtCategoryListSettings.TYPE_RETURN; } else { m_typeReturn = Settings[MgmtCategoryListSettings.TYPE_RETURN_KEY].ToString(); } ////Load Show Choices //m_isShowDip1 = LoadBaseTrueSetting(UserMgmtCategorySettings.IS_SHOW_DIP1); //m_isShowDip2 = LoadBaseTrueSetting(UserMgmtCategorySettings.IS_SHOW_DIP2); //m_isShowDip3 = LoadBaseTrueSetting(UserMgmtCategorySettings.IS_SHOW_DIP3); //m_isShowDip4 = LoadBaseTrueSetting(UserMgmtCategorySettings.IS_SHOW_DIP4); //m_isShowDip5 = LoadBaseTrueSetting(UserMgmtCategorySettings.IS_SHOW_DIP5); ////Load Alt Text //m_altSourceDip1 = LoadStringSetting(UserMgmtCategorySettings.ALT_SOURCE_DIP1, UserMgmtCategorySettings.ALT_SOURCE_DIP1); //m_altSourceDip2 = LoadStringSetting(UserMgmtCategorySettings.ALT_SOURCE_DIP2, UserMgmtCategorySettings.ALT_SOURCE_DIP2); //m_altSourceDip3 = LoadStringSetting(UserMgmtCategorySettings.ALT_SOURCE_DIP3, UserMgmtCategorySettings.ALT_SOURCE_DIP3); //m_altSourceDip4 = LoadStringSetting(UserMgmtCategorySettings.ALT_SOURCE_DIP4, UserMgmtCategorySettings.ALT_SOURCE_DIP4); //m_altSourceDip5 = LoadStringSetting(UserMgmtCategorySettings.ALT_SOURCE_DIP5, UserMgmtCategorySettings.ALT_SOURCE_DIP5); /* * if (!m_isShowDip1) { lblDip1.Visible = false; chbDip1.Visible = false; } * if (!m_isShowDip2) { lblDip2.Visible = false; chbDip2.Visible = false; } * if (!m_isShowDip3) { lblDip3.Visible = false; chbDip3.Visible = false; } * if (!m_isShowDip4) { lblDip4.Visible = false; chbDip4.Visible = false; } * if (!m_isShowDip5) { lblDip5.Visible = false; chbDip5.Visible = false; } */ DotNetNuke.UI.Skins.Skin objParentSkin = DotNetNuke.UI.Skins.Skin.GetParentSkin(this); if (objParentSkin != null) { objParentSkin.RegisterModuleActionEvent(this.ModuleId, new ActionEventHandler(ModuleAction_Click)); } }
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; } }
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 }
protected string GetValueDynamic(string FolderName) { if (dtConfig != null && dtConfig.Rows.Count > 0) { string strData = "<DS>"; for (int i = 0; i < dtConfig.Rows.Count; i++) { string strName = dtConfig.Rows[i]["Name"].ToString(); string strTitle = dtConfig.Rows[i]["Title"].ToString(); string strType = dtConfig.Rows[i]["Type"].ToString().ToUpper(); string strWidth = dtConfig.Rows[i]["Width"].ToString(); switch (strType) { case "STRING": try { TextBox sobjTxtTg = new TextBox(); sobjTxtTg = (TextBox)this.FindControl(strName); strData += "<DT>"; strData += string.Format("<Name>{0}</Name>", strName); strData += string.Format("<Type>{0}</Type>", "STRING"); strData += string.Format("<Value><![CDATA[{0}]]></Value>", sobjTxtTg.Text); strData += "</DT>"; } catch (Exception ex) { this.lblError.Text = ex.GetType().ToString(); this.lblError.Visible = true; } break; case "RICHTEXT": try { DotNetNuke.UI.WebControls.DNNRichTextEditControl rtobjTxtTg = new DotNetNuke.UI.WebControls.DNNRichTextEditControl(); rtobjTxtTg = (DotNetNuke.UI.WebControls.DNNRichTextEditControl) this.FindControl(strName); strData += "<DT>"; strData += string.Format("<Name>{0}</Name>", strName); strData += string.Format("<Type>{0}</Type>", "RICHTEXT"); strData += string.Format("<Value><![CDATA[{0}]]></Value>", DataProcessingProvider.RemoveTags(rtobjTxtTg.Value.ToString())); strData += "</DT>"; } catch (Exception ex) { this.lblError.Text = ex.GetType().ToString(); this.lblError.Visible = true; } break; case "IMAGE": try { HtmlInputFile iobjTxtFile = new HtmlInputFile(); iobjTxtFile = (HtmlInputFile)this.FindControl(strName); string strImmageUrl = ""; if (iobjTxtFile.PostedFile.FileName.Length != 0) { string strFileName = iobjTxtFile.PostedFile.FileName.Substring(iobjTxtFile.PostedFile.FileName.LastIndexOf(@"\") + 1); strImmageUrl = string.Format("{0}{1}", FolderName, strFileName); string strParentFolder = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, FolderName); FileProvider.Upload(this.PortalId, FolderName, strFileName, iobjTxtFile.PostedFile.InputStream); // FileSystemUtils.UploadFile(strParentFolder.Replace("/", @"\"), iobjTxtFile.PostedFile, false); } if (strImmageUrl == "") { TextBox iobjTxtTg = new TextBox(); iobjTxtTg = (TextBox)this.FindControl(strName + "_HIDE"); strImmageUrl = iobjTxtTg.Text; } strData += "<DT>"; strData += string.Format("<Name>{0}</Name>", strName); strData += string.Format("<Type>{0}</Type>", "IMAGE"); strData += string.Format("<Value><![CDATA[{0}]]></Value>", strImmageUrl); strData += "</DT>"; } catch (Exception ex) { this.lblError.Text = ex.GetType().ToString(); this.lblError.Visible = true; } break; default: break; } } strData += "</DS>"; return(strData); } else { return(""); } }
protected void UpdateData() { try { //Detect Empty Text if (this.txtProductName.Text == "") { this.lblError.Text = Localization.GetString("errEmptyName.Text", this.LocalResourceFile); this.lblError.Visible = true; return; } string strLead = txtLead.Text; string strCode = txtCode.Text; string strSummary = txtSummary.Text; string straddRichInfo1 = txtaddRichInfo1.Text; string straddRichInfo2 = txtaddRichInfo2.Text; string straddRichInfo3 = txtaddRichInfo3.Text; string strWeight = txtWeight.Text; double fWeight = -1; if (!double.TryParse(strWeight, out fWeight)) { this.lblError.Text = Localization.GetString("errFormatWeight.Text", this.LocalResourceFile); this.lblError.Visible = true; return; } int iPrice = -1; string strPrice = txtPrice.Text; if (!int.TryParse(strPrice, out iPrice)) { this.lblError.Text = Localization.GetString("errFormatPrice.Text", this.LocalResourceFile); this.lblError.Visible = true; return; } int iPriceOld = -1; string strPriceOld = txtPriceOld.Text; if (!int.TryParse(strPriceOld, out iPriceOld)) { this.lblError.Text = Localization.GetString("errFormatPriceOld.Text", this.LocalResourceFile); this.lblError.Visible = true; return; } 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; } string strStatusProduct = txtStatusProduct.Text; string straddInfo1 = txtaddInfo1.Text; string straddInfo2 = txtaddInfo2.Text; string straddInfo3 = txtaddInfo3.Text; string straddInfo4 = txtaddInfo4.Text; string straddInfo5 = txtaddInfo5.Text; string straddInfo6 = txtaddInfo6.Text; //Detect Role if (!((m_objRole.HasRole((int)Connection.UtilsProvider.CoreRole.Create) && m_ProductId == -1) || ((m_objRole.HasRole((int)Connection.UtilsProvider.CoreRole.EditAfter) || m_objRole.HasRole((int)Connection.UtilsProvider.CoreRole.EditAll)) && m_ProductId != -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 strSmallimage = ""; string strLargeimage = ""; string strImageAdd1 = ""; string strImageAdd2 = ""; string strImageAdd3 = ""; string strFolderName = m_strCategories; strSmallimage = DNNRelatedProvider.GetFilePath(urlSmallImage.Url, this.PortalId); strLargeimage = DNNRelatedProvider.GetFilePath(urlLargeImage.Url, this.PortalId); strImageAdd1 = DNNRelatedProvider.GetFilePath(urlSmallImageImgAdd1.Url, this.PortalId); strImageAdd2 = DNNRelatedProvider.GetFilePath(urlSmallImageImgAdd2.Url, this.PortalId); strImageAdd3 = DNNRelatedProvider.GetFilePath(urlSmallImageImgAdd3.Url, this.PortalId); /* * strFolderName = CategoryProvider.GetDefaultFolderPath(TH.Utils.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; #region * if (txtSmallimage.PostedFile.FileName.Length != 0) //&& chkUseImage.Checked * { * string strFileName = txtSmallimage.PostedFile.FileName.Substring(txtSmallimage.PostedFile.FileName.LastIndexOf(@"\") + 1); * strSmallimage = string.Format("{0}{1}", strFolderName, strFileName); * string strParentFolder = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, strFolderName); * FileSystemUtils.UploadFile(strParentFolder.Replace("/", @"\"), txtSmallimage.PostedFile, false); * * } * if (strSmallimage == "") * strSmallimage = txtSmallimageOld.Text; #endregion #region * if (txtLargeimage.PostedFile.FileName.Length != 0) //&& chkUseImage.Checked * { * string strFileName = txtLargeimage.PostedFile.FileName.Substring(txtLargeimage.PostedFile.FileName.LastIndexOf(@"\") + 1); * strLargeimage = string.Format("{0}{1}", strFolderName, strFileName); * string strParentFolder = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, strFolderName); * FileSystemUtils.UploadFile(strParentFolder.Replace("/", @"\"), txtLargeimage.PostedFile, false); * } * * if (strLargeimage == "") * strLargeimage = txtLargeimageOld.Text; #endregion #region imageAdd1 * * if (txtAddImage1.PostedFile.FileName.Length != 0) //&& chkUseImage.Checked * { * string strFileName = txtAddImage1.PostedFile.FileName.Substring(txtAddImage1.PostedFile.FileName.LastIndexOf(@"\") + 1); * strImageAdd1 = string.Format("{0}{1}", strFolderName, strFileName); * string strParentFolder = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, strFolderName); * FileSystemUtils.UploadFile(strParentFolder.Replace("/", @"\"), txtAddImage1.PostedFile, false); * } * * if (strImageAdd1 == "") * strImageAdd1 = txtImageAdd1Old.Text; #endregion #region imageAdd2 * * if (txtAddImage2.PostedFile.FileName.Length != 0) //&& chkUseImage.Checked * { * string strFileName = txtAddImage2.PostedFile.FileName.Substring(txtAddImage2.PostedFile.FileName.LastIndexOf(@"\") + 1); * strImageAdd2 = string.Format("{0}{1}", strFolderName, strFileName); * string strParentFolder = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, strFolderName); * FileSystemUtils.UploadFile(strParentFolder.Replace("/", @"\"), txtAddImage2.PostedFile, false); * } * * if (strImageAdd2 == "") * strImageAdd2 = txtImageAdd2Old.Text; #endregion #region imageAdd3 * * if (txtAddImage3.PostedFile.FileName.Length != 0) //&& chkUseImage.Checked * { * string strFileName = txtAddImage3.PostedFile.FileName.Substring(txtAddImage3.PostedFile.FileName.LastIndexOf(@"\") + 1); * strImageAdd3 = string.Format("{0}{1}", strFolderName, strFileName); * string strParentFolder = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, strFolderName); * FileSystemUtils.UploadFile(strParentFolder.Replace("/", @"\"), txtAddImage3.PostedFile, false); * } * * if (strImageAdd3 == "") * strImageAdd3 = txtImageAdd3Old.Text; #endregion */ DateTime ProducedDate; ProducedDate = DateTime.ParseExact(txtProducedDate.Text, "dd/MM/yyyy", null); 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; } // DyncmicForm string strExtendedSettings = GetValueDynamic(strFolderName); m_strCategories = UIProvider.GetListBoxSelectedItems(",", chkCategoryList); m_strTags = UIProvider.GetListBoxSelectedItems(",", chkTags); if (m_strCategories.Equals("")) { this.lblError.Text = "Chưa chọn chuyên mục"; this.lblError.Visible = true; return; } //Going into action. int result = 1; if (m_ProductId == -1) { string realProductName = ""; realProductName = DataProcessingProvider.RemoveTags(this.txtProductName.Text); result = ProductProvider.InsertProduct(realProductName, strLead, DataProcessingProvider.RemoveTags(strSummary), strSmallimage, strLargeimage, fWeight, DateTime.Now, ExpiredDate, DateTime.Now, ProducedDate, true, false, chkIsHot.Checked, intPeriod, this.UserId, this.PortalId, false, iPrice, iPriceOld, strStatusProduct, strExtendedSettings, iOrder, m_strCategories, strCode, strImageAdd1, strImageAdd2, strImageAdd3, DisplayDate, straddInfo1, straddInfo2, straddInfo3, straddInfo4, straddInfo5, straddInfo6, DataProcessingProvider.RemoveTags(straddRichInfo1), DataProcessingProvider.RemoveTags(straddRichInfo2), DataProcessingProvider.RemoveTags(straddRichInfo3), m_strTags, 1); if (result > 0) { #region danh dau them moi try { File.WriteAllText(Server.MapPath("/DesktopModules/TH.NUCE.Utils/Configuration/ResetCache.txt"), "1"); File.WriteAllText(Server.MapPath("/DesktopModules/TH.NUCE.Utils/Configuration/ResetCache_" + this.PortalId + ".txt"), "1"); } catch (Exception ex) { } #endregion LogProvider.InsertLogAction(result, ProductProvider.TypeId, "", this.PortalId, (int)Connection.UtilsProvider.LogAction.Create, this.UserInfo.Username, this.UserId, this.txtProductName.Text, true, m_strCategories); } } else { DateTime CreateDate = DateTime.Parse(txtCreatedDateOld.Text); string realTitle = ""; realTitle = DataProcessingProvider.RemoveTags(this.txtProductName.Text); ProductProvider.UpdateProduct(m_ProductId, realTitle, strLead, DataProcessingProvider.RemoveTags(strSummary), strSmallimage, strLargeimage, fWeight, CreateDate, ExpiredDate, DateTime.Now, ProducedDate, true, false, chkIsHot.Checked, intPeriod, this.UserId, this.PortalId, false, iPrice, iPriceOld, strStatusProduct, iOrder, strExtendedSettings, m_strCategories, strCode, strImageAdd1, strImageAdd2, strImageAdd3, DisplayDate, straddInfo1, straddInfo2, straddInfo3, straddInfo4, straddInfo5, straddInfo6, DataProcessingProvider.RemoveTags(straddRichInfo1), DataProcessingProvider.RemoveTags(straddRichInfo2), DataProcessingProvider.RemoveTags(straddRichInfo3), m_strTags, 1); result = m_ProductId; if (result > 0) { #region danh dau them moi try { File.WriteAllText(Server.MapPath("/DesktopModules/TH.NUCE.Utils/Configuration/ResetCache.txt"), "1"); File.WriteAllText(Server.MapPath("/DesktopModules/TH.NUCE.Utils/Configuration/ResetCache_" + this.PortalId + ".txt"), "1"); } catch (Exception ex) { } #endregion LogProvider.InsertLogAction(result, ProductProvider.TypeId, "", this.PortalId, (int)Connection.UtilsProvider.LogAction.Update, this.UserInfo.Username, this.UserId, this.txtProductName.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.Text = ex.ToString(); this.lblError.Visible = true; } }
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 }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { if (m_isPassOnce) { return; } //Set DisplayDate to Today, Set ExpiredDate to ten years after. this.txtDisplayDate.Text = DateTime.Now.ToString("dd/MM/yyyy"); this.txtExpiredDate.Text = DateTime.Now.AddYears(10).ToString("dd/MM/yyyy"); this.txtProducedDate.Text = DateTime.Now.AddYears(10).ToString("dd/MM/yyyy"); txtWeight.Text = "0"; txtPrice.Text = "0"; txtPriceOld.Text = "0"; txtOrder.Text = "100"; //Load Categories //if (m_ProductId == -1) //{ this.chkCategoryList.DataSource = DataProcessingProvider.ProcessDataTable(CategoryProvider.GetExcludedCategories(this.PortalId, -1, ProductProvider.TypeId), 1, 2); this.chkCategoryList.DataTextField = "Name"; this.chkCategoryList.DataValueField = "CategoryId"; this.chkCategoryList.DataBind(); UIProvider.BindListBox(chkCategoryList, m_strCategories); //Tag this.chkTags.DataSource = DotNetNuke.Data.DataProvider.Instance().ExecuteDataSet("THCore_CM_GetTags", this.PortalId, 3).Tables[0]; this.chkTags.DataTextField = "Name"; this.chkTags.DataValueField = "TagID"; this.chkTags.DataBind(); UIProvider.BindListBox(chkTags, m_strTags); //} //else //{ // TH.Core.Providers.Utilities.UIProvider.PopulateCategories(this.chkCategoryList, m_strCategories, ProductProvider.TypeId, this.UserId, GetSuperMode(), true, m_ProductId); //} //Bind Data if (m_ProductId != -1) { ProductBinding(); } m_isPassOnce = true; } } catch (Exception ex) { lblError.Text = ex.Message; this.lblError.Visible = true; } }