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.txtTitle.Text == "") { this.lblError.Text = Localization.GetString("errEmptyName.Text", this.LocalResourceFile); this.lblError.Visible = true; return; } string strSummary = txtSummary.Text; string strContent = DataProcessingProvider.RemoveTags(this.htmlContent.Text); string strVideoLength = txtLengthVideo.Text; bool blIsOpenNewTab = chIsUrlWeb.Checked; //Detect Role if (!((m_objRole.HasRole((int)Connection.UtilsProvider.CoreRole.Create) && m_VideoId == -1) || ((m_objRole.HasRole((int)Connection.UtilsProvider.CoreRole.EditAfter) || m_objRole.HasRole((int)Connection.UtilsProvider.CoreRole.EditAll)) && m_VideoId != -1))) { this.lblError.Text = Localization.GetString("errNoRole.Text", this.LocalResourceFile); //this.lblError.Text = m_objRole.HasRole((int)Connection.UtilsProvider.CoreRole.Create).ToString(); this.lblError.Visible = true; return; } string strVideoFile = ""; 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 (txtVideoFile.PostedFile.FileName.Length != 0) //&& chkUseImage.Checked { string strFileName = txtVideoFile.PostedFile.FileName.Substring(txtVideoFile.PostedFile.FileName.LastIndexOf(@"\") + 1); strVideoFile = string.Format("{0}{1}", strFolderName, strFileName); string strParentFolder = string.Format("{0}{1}", PortalSettings.HomeDirectoryMapPath, strFolderName); FileProvider.Upload(this.PortalId, strFolderName, strFileName, txtVideoFile.PostedFile.InputStream); // string strReturnUploadFile=FileSystemUtils.UploadFile(strParentFolder.Replace("/", @"\"), txtVideoFile.PostedFile, false); } if (strVideoFile == "") { strVideoFile = txtVideoFileOld.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); * //FileSystemUtils.UploadFile(strParentFolder.Replace("/", @"\"), txtAvatar.PostedFile, false); * FileProvider.Upload(this.PortalId, strFolderName, strFileName, * txtAvatar.PostedFile.InputStream); * } * * if (strAvatar == "") * strAvatar = txtAvatarOld.Text;*/ 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); string strAddInfo1 = txtAddInfo1.Text; string strAddInfo2 = txtAddInfo2.Text; string strAddInfo3 = txtAddInfo3.Text; string strAddInfo4 = txtAddInfo4.Text; string strAddInfo5 = txtAddInfo5.Text; // 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; } //Going into action. int result = 1; if (m_VideoId == -1) { string realTitle = ""; realTitle = DataProcessingProvider.RemoveTags(this.txtTitle.Text); result = VideoProvider.InsertVideo(realTitle, strSummary, strVideoFile, strAvatar, blIsOpenNewTab, strVideoLength, strContent, DateTime.Now, ExpiredDate, DisplayDate, DateTime.Now, this.UserId, chkIsHot.Checked, intPeriod, this.PortalId, false, iOrder, m_strCategories, strAddInfo1, strAddInfo2, strAddInfo3, strAddInfo4, strAddInfo5); if (result > 0) { LogProvider.InsertLogAction(result, VideoProvider.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); //VideoProvider.UpdateVideo(m_VideoId, txtTitleOld.Text, strSummary, strVideoFile, strAvatar, blIsOpenNewTab, strVideoLength, strContent, CreateDate, ExpiredDate, DisplayDate, DateTime.Now, this.UserId, chkIsHot.Checked, intPeriod, this.PortalId, false, iOrder, TH.Utils.UIProvider.GetListBoxSelectedItems(",", chkCategoryList)); VideoProvider.UpdateVideo(m_VideoId, realTitle, strSummary, strVideoFile, strAvatar, blIsOpenNewTab, strVideoLength, strContent, CreateDate, ExpiredDate, DisplayDate, DateTime.Now, this.UserId, chkIsHot.Checked, intPeriod, this.PortalId, false, iOrder, m_strCategories, strAddInfo1, strAddInfo2, strAddInfo3, strAddInfo4, strAddInfo5); result = m_VideoId; if (result > 0) { LogProvider.InsertLogAction(result, VideoProvider.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; } }