public void save_MetaContentRecord() { save_MetaContentData(); _MetaContent = new ContentEditorDataHelper(); _MetaContent.load_Xml(Session["METADATA"].ToString()); if (!is_UserCanUpdateContent(_MetaContent.CategoryID)) { throw new Exception("You are not authozied to update this category meta contents!"); } int retID = LegoWebAdmin.BusLogic.MetaContents.save_META_CONTENTS_XML(_MetaContent.OuterXml, this.Page.User.Identity.Name); if (retID > 0 && _MetaContent.AccessLevel >= 2) { //save access roles string sAccessRoles = null; for (int i = 0; i < cblRoles.Items.Count; i++) { if (cblRoles.Items[i].Selected) { sAccessRoles += ((sAccessRoles != null?",":"") + cblRoles.Items[i].Value); } } LegoWebAdmin.BusLogic.MetaContents.set_ACCESS_ROLES(retID, sAccessRoles); } Session["METADATA"] = null; Response.Redirect("MetaContentManager.aspx?section_id=" + dropSections.SelectedValue.ToString() + "&category_id=" + dropCategories.SelectedValue.ToString()); }
protected void update_MetaContent() { _MetaContent = new ContentEditorDataHelper(); _MetaContent.load_Xml(Session["METADATA"].ToString()); this.txtMetaContentID.Text = _MetaContent.MetaContentID.ToString(); this.txtMetaContentAlias.Text = _MetaContent.Alias; if (_MetaContent.MetaContentID > 0) { int iCategoryId = _MetaContent.CategoryID; int iSectionId = (int)LegoWebAdmin.BusLogic.Categories.get_CATEGORY_BY_ID(iCategoryId).Tables[0].Rows[0]["SECTION_ID"]; load_Sections(iSectionId); load_Categories(iSectionId); dropCategories.SelectedValue = iCategoryId.ToString(); } DataTable marcTable = _MetaContent.get_MarcDatafieldTable(); CRecord labelRec = new CRecord(); labelRec.load_File(FileTemplateDataProvider.get_LabelTemplateFile(LegoWebAdmin.BusLogic.Categories.get_CATEGORY_TEMPLATE_NAME(int.Parse(dropCategories.SelectedValue.ToString())))); _MetaContent.set_DataTableLabel(ref marcTable, labelRec); repeater_DataBind(marcTable); this.radioRecordStatus.SelectedValue = _MetaContent.RecordStatus.ToString(); this.txtLocalCode.Text = _MetaContent.LocalCode; this.labelEntryDate.Text = _MetaContent.EntryDate; this.labelCreator.Text = _MetaContent.Creator; this.labelModifyDate.Text = _MetaContent.ModifyDate; this.labelModifier.Text = _MetaContent.Modifier; this.dropLanguages.SelectedValue = _MetaContent.LangCode; this.dropAccessLevels.SelectedValue = _MetaContent.AccessLevel.ToString(); this.dropImportantLevels.SelectedValue = _MetaContent.ImportantLevel.ToString(); if (_MetaContent.AccessLevel >= 2)//special permission { cblRoles.Visible = true; //get roles in formation string[] accessRoles = LegoWebAdmin.BusLogic.MetaContents.get_ACCESS_ROLES(_MetaContent.MetaContentID); if (accessRoles != null && accessRoles.Length > 0) { for (int i = 0; i < accessRoles.Length; i++) { for (int j = 0; j < cblRoles.Items.Count; j++) { if (cblRoles.Items[j].Value == accessRoles[i]) { cblRoles.Items[j].Selected = true; } } } } } else { cblRoles.Visible = false; } load_listAddTag(); this.txtAddValue.Attributes.Add("onClick", "changeInputID('" + this.txtAddValue.ClientID.ToString() + "'); return false;"); Session["METADATA"] = _MetaContent.OuterXml; }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { load_TemplateNames(); if (CommonUtility.GetInitialValue("meta_content_id", null) != null) { int iMetaContentId = Int32.Parse(CommonUtility.GetInitialValue("meta_content_id", null).ToString()); _MetaContentObject = new ContentEditorDataHelper(); string sXmlData = LegoWebAdmin.BusLogic.MetaContents.get_META_CONTENT_MARCXML(iMetaContentId, 1); _MetaContentObject.load_Xml(sXmlData); dpTemplateNames.SelectedValue = LegoWebAdmin.BusLogic.Categories.get_CATEGORY_TEMPLATE_NAME(_MetaContentObject.CategoryID); Session["METADATA"] = _MetaContentObject.OuterXml; preview_MetaContent(); } else if (Session["METADATA"] != null) { _MetaContentObject = new ContentEditorDataHelper(); _MetaContentObject.load_Xml(Session["METADATA"].ToString()); dpTemplateNames.SelectedValue = LegoWebAdmin.BusLogic.Categories.get_CATEGORY_TEMPLATE_NAME(_MetaContentObject.CategoryID); preview_MetaContent(); } } } catch (Exception ex) { throw ex; } }
public void Take_LinkRelatedContents() { try { if (Session["METADATA"] == null) { Response.Redirect("MetaContentEditor.aspx"); } LegoWebAdmin.DataProvider.ContentEditorDataHelper _MetaContentObject = new ContentEditorDataHelper(); _MetaContentObject.load_Xml(Session["METADATA"].ToString()); DataTable marcTable = _MetaContentObject.get_MarcDatafieldTable(); CDatafield Df = new CDatafield(); for (int i = 0; i < this.metaContentManagerRepeater.Items.Count; i++) { CheckBox cbRow = ((CheckBox)metaContentManagerRepeater.Items[i].FindControl("chkSelect")); if (cbRow.Checked == true) { TextBox txtMetaContentId = (TextBox)metaContentManagerRepeater.Items[i].FindControl("txtMetaContentId"); if (txtMetaContentId != null) { int iTagIndex = marcTable.Rows.Count; Int32 iMetaContentId = Int32.Parse(txtMetaContentId.Text); Label labelMetaContentTitle = (Label)metaContentManagerRepeater.Items[i].FindControl("labelMetaContentTitle"); if (labelMetaContentTitle != null) { DataRow addRow = marcTable.NewRow(); addRow["TAG"] = 780; addRow["TAG_INDEX"] = iTagIndex; addRow["SUBFIELD_CODE"] = "t"; addRow["SUBFIELD_LABEL"] = " "; addRow["SUBFIELD_TYPE"] = "TEXT"; addRow["SUBFIELD_VALUE"] = labelMetaContentTitle.Text; marcTable.Rows.Add(addRow); addRow = marcTable.NewRow(); addRow["TAG"] = 780; addRow["TAG_INDEX"] = iTagIndex; addRow["SUBFIELD_CODE"] = "w"; addRow["SUBFIELD_LABEL"] = " "; addRow["SUBFIELD_TYPE"] = "NUMBER"; addRow["SUBFIELD_VALUE"] = iMetaContentId; marcTable.Rows.Add(addRow); } } } } _MetaContentObject.bind_TableDataToMarc(ref marcTable); Session["METADATA"] = _MetaContentObject.OuterXml; Response.Redirect("MetaContentEditor.aspx"); } catch (Exception ex) { throw ex; } }
public void preview_MetaContent() { if (Session["METADATA"] == null) { throw new Exception("Session['METADATA']==null in preview_MetaContent()"); } _MetaContentObject = new ContentEditorDataHelper(); _MetaContentObject.load_Xml(Session["METADATA"].ToString()); string sTemplateName = LegoWebAdmin.DataProvider.FileTemplateDataProvider.get_XsltTemplateFile(dpTemplateNames.SelectedValue); this.litContentViewer.Text = _MetaContentObject.XsltFile_Transform(sTemplateName); }
public void Delete_PreviewRecord() { if (Session["METADATA"] == null) { throw new Exception("Session['METADATA']==null in preview_MetaContent()"); } _MetaContentObject = new ContentEditorDataHelper(); _MetaContentObject.load_Xml(Session["METADATA"].ToString()); if (_MetaContentObject.MetaContentID > 0) { LegoWebAdmin.BusLogic.MetaContents.movetrash_META_CONTENTS(_MetaContentObject.MetaContentID); } Session["METADATA"] = null; Response.Redirect("MetaContentManager.aspx"); }
protected void cmdAddTagOrSubfield_Click(object sender, EventArgs e) { save_MetaContentData();//save data first _MetaContent = new ContentEditorDataHelper(); _MetaContent.load_Xml(Session["METADATA"].ToString()); CRecord labelRec = new CRecord(); labelRec.load_File(FileTemplateDataProvider.get_LabelTemplateFile(LegoWebAdmin.BusLogic.Categories.get_CATEGORY_TEMPLATE_NAME(int.Parse(dropCategories.SelectedValue.ToString())))); CDatafield Df = labelRec.Datafields.Datafield(listAddTag.SelectedValue.ToString()); DataTable marcTable = _MetaContent.get_MarcDatafieldTable(); int iTagIndex = 0; if (marcTable.Rows.Count > 0) { DataRow[] maxRows = marcTable.Select("TAG_INDEX=Max(TAG_INDEX)"); iTagIndex = int.Parse("0" + maxRows[0]["TAG_INDEX"].ToString()); } if (listAddSubfieldCode.SelectedValue == "")//add new tag { for (int i = 0; i < Df.Subfields.Count; i++) { DataRow nRow = marcTable.NewRow(); nRow["TAG"] = Df.Tag; nRow["TAG_INDEX"] = iTagIndex + 1; nRow["SUBFIELD_CODE"] = Df.Subfields.Subfield(i).Code; nRow["SUBFIELD_TYPE"] = Df.Subfields.Subfield(i).Type; nRow["SUBFIELD_LABEL"] = Df.Subfields.Subfield(i).Value; nRow["SUBFIELD_VALUE"] = txtAddValue.Text; marcTable.Rows.Add(nRow); } marcTable.DefaultView.Sort = "TAG, TAG_INDEX ASC"; _MetaContent.set_DataTableLabel(ref marcTable, labelRec); repeater_DataBind(marcTable); _MetaContent.bind_TableDataToMarc(ref marcTable); Session["METADATA"] = _MetaContent.OuterXml; return; } else//add subfield to existing tag or new tag only one subfield { CSubfield Sf = Df.Subfields.Subfield(listAddSubfieldCode.SelectedValue.ToString()); #region add to subfield to selected tag if have one for (int i = 0; i < this.marcTextRepeater.Items.Count; i++) { CheckBox cb = ((CheckBox)marcTextRepeater.Items[i].FindControl("RowLevelCheckBox")); if (cb.Checked) { Label labelTag = (Label)marcTextRepeater.Items[i].FindControl("labelTag"); if (labelTag.Text == listAddTag.SelectedValue.ToString()) { DataRow nRow = marcTable.NewRow(); nRow["TAG"] = labelTag.Text; Label labelTagIndex = (Label)marcTextRepeater.Items[i].FindControl("labelTagIndex"); nRow["TAG_INDEX"] = int.Parse(labelTagIndex.Text); nRow["SUBFIELD_CODE"] = Sf.Code; nRow["SUBFIELD_TYPE"] = Sf.Type; nRow["SUBFIELD_LABEL"] = Sf.Value; nRow["SUBFIELD_VALUE"] = txtAddValue.Text; marcTable.Rows.Add(nRow); //sort go here marcTable.DefaultView.Sort = "TAG, TAG_INDEX ASC"; _MetaContent.set_DataTableLabel(ref marcTable, labelRec); repeater_DataBind(marcTable); _MetaContent.bind_TableDataToMarc(ref marcTable); Session["METADATA"] = _MetaContent.OuterXml; return; } } } #endregion //if don't have match selected tag find existing tag for (int i = 0; i < marcTable.Rows.Count; i++) { if (marcTable.Rows[i]["TAG"].ToString() == listAddTag.SelectedValue.ToString()) { DataRow nRow = marcTable.NewRow(); nRow["TAG"] = marcTable.Rows[i]["TAG"]; nRow["TAG_INDEX"] = marcTable.Rows[i]["TAG_INDEX"]; nRow["SUBFIELD_CODE"] = Sf.Code; nRow["SUBFIELD_TYPE"] = Sf.Type; nRow["SUBFIELD_LABEL"] = Sf.Value; nRow["SUBFIELD_VALUE"] = txtAddValue.Text; marcTable.Rows.Add(nRow); //sort go here marcTable.DefaultView.Sort = "TAG, TAG_INDEX ASC"; _MetaContent.set_DataTableLabel(ref marcTable, labelRec); repeater_DataBind(marcTable); _MetaContent.bind_TableDataToMarc(ref marcTable); Session["METADATA"] = _MetaContent.OuterXml; return; } } //don't have existing match tag create new tag with one subfield DataRow addRow = marcTable.NewRow(); addRow["TAG"] = Df.Tag; addRow["TAG_INDEX"] = iTagIndex + 1; addRow["SUBFIELD_CODE"] = Sf.Code; addRow["SUBFIELD_TYPE"] = Sf.Type; addRow["SUBFIELD_LABEL"] = Sf.Value; addRow["SUBFIELD_VALUE"] = txtAddValue.Text; marcTable.Rows.Add(addRow); //sort go here marcTable.DefaultView.Sort = "TAG, TAG_INDEX ASC"; _MetaContent.set_DataTableLabel(ref marcTable, labelRec); repeater_DataBind(marcTable); _MetaContent.bind_TableDataToMarc(ref marcTable); Session["METADATA"] = _MetaContent.OuterXml; return; } }
protected void cmdRemoveSelectedRow_Click(object sender, EventArgs e) { save_MetaContentData(); _MetaContent = new ContentEditorDataHelper(); _MetaContent.load_Xml(Session["METADATA"].ToString()); DataTable marcTable = _MetaContent.get_MarcDatafieldTable(); for (int i = 0; i < this.marcTextRepeater.Items.Count; i++) { CheckBox cb = ((CheckBox)marcTextRepeater.Items[i].FindControl("RowLevelCheckBox")); if (cb != null && cb.Checked) { //remove by TAG_INDEX and SUBFIELD_CODE Label labelSubfieldID = ((Label)marcTextRepeater.Items[i].FindControl("labelSubfieldID")); if (labelSubfieldID != null && !String.IsNullOrEmpty(labelSubfieldID.Text) && labelSubfieldID.Text != "0") { LegoWebAdmin.BusLogic.MetaContents.remove_META_CONTENT_SUBFIELD(int.Parse(labelSubfieldID.Text)); DataRow[] remRows = marcTable.Select(" SUBFIELD_ID=" + labelSubfieldID.Text); if (remRows != null) { marcTable.Rows.Remove(remRows[0]); } } else { Label labelTagIndex = ((Label)marcTextRepeater.Items[i].FindControl("labelTagIndex")); Label labelSubfieldCode = ((Label)marcTextRepeater.Items[i].FindControl("labelSubfieldCode")); if (labelTagIndex != null && labelSubfieldCode != null) { DataRow[] remRows = marcTable.Select("TAG_INDEX=" + labelTagIndex.Text + " AND SUBFIELD_CODE='" + labelSubfieldCode.Text + "'"); if (remRows != null) { marcTable.Rows.Remove(remRows[0]); } } } } } for (int i = 0; i < this.marcNTextRepeater.Items.Count; i++) { CheckBox cb = ((CheckBox)marcNTextRepeater.Items[i].FindControl("RowLevelCheckBox")); if (cb != null && cb.Checked) { //remove by TAG_INDEX and SUBFIELD_CODE Label labelSubfieldID = ((Label)marcNTextRepeater.Items[i].FindControl("labelSubfieldID")); if (labelSubfieldID != null && !String.IsNullOrEmpty(labelSubfieldID.Text)) { LegoWebAdmin.BusLogic.MetaContents.remove_META_CONTENT_SUBFIELD(int.Parse(labelSubfieldID.Text)); DataRow[] remRows = marcTable.Select(" SUBFIELD_ID=" + labelSubfieldID.Text); if (remRows != null) { marcTable.Rows.Remove(remRows[0]); } } else { Label labelTagIndex = ((Label)marcNTextRepeater.Items[i].FindControl("labelTagIndex")); Label labelSubfieldCode = ((Label)marcNTextRepeater.Items[i].FindControl("labelSubfieldCode")); if (labelTagIndex != null && labelSubfieldCode != null) { DataRow[] remRows = marcTable.Select("TAG_INDEX=" + labelTagIndex.Text + " AND SUBFIELD_CODE='" + labelSubfieldCode.Text + "'"); if (remRows != null) { marcTable.Rows.Remove(remRows[0]); } } } } } CRecord labelRec = new CRecord(); labelRec.load_File(FileTemplateDataProvider.get_LabelTemplateFile(LegoWebAdmin.BusLogic.Categories.get_CATEGORY_TEMPLATE_NAME(int.Parse(dropCategories.SelectedValue.ToString())))); _MetaContent.set_DataTableLabel(ref marcTable, labelRec); repeater_DataBind(marcTable); _MetaContent.bind_TableDataToMarc(ref marcTable); Session["METADATA"] = _MetaContent.OuterXml; }
protected void save_MetaContentData() { try { _MetaContent = new ContentEditorDataHelper(); _MetaContent.load_Xml(Session["METADATA"].ToString()); _MetaContent.Alias = txtMetaContentAlias.Text; if (!String.IsNullOrEmpty(this.dropCategories.SelectedValue)) { _MetaContent.CategoryID = Convert.ToInt16(this.dropCategories.SelectedValue.ToString()); } _MetaContent.LocalCode = txtLocalCode.Text; //check duplicate in local code go here if (!String.IsNullOrEmpty(txtLocalCode.Text)) { if (LegoWebAdmin.BusLogic.MetaContents.is_LocalCode_Exist(txtLocalCode.Text, _MetaContent.CategoryID, _MetaContent.MetaContentID)) { throw new Exception("Local Code is already existed!"); } } _MetaContent.RecordStatus = int.Parse(this.radioRecordStatus.SelectedValue); _MetaContent.LangCode = this.dropLanguages.SelectedValue.ToString(); _MetaContent.AccessLevel = int.Parse(this.dropAccessLevels.SelectedValue); _MetaContent.ImportantLevel = int.Parse(this.dropImportantLevels.SelectedValue); DataTable marcTable = _MetaContent.create_MarcDataTable(); for (int i = 0; i < marcTextRepeater.Items.Count; i++) { DataRow nRow = marcTable.NewRow(); Label labelTag = (Label)marcTextRepeater.Items[i].FindControl("labelTag"); if (labelTag != null) { nRow["TAG"] = labelTag.Text; } else { throw new Exception("Error: save_MetaContentData labelTag==null"); } Label labelTagIndex = (Label)marcTextRepeater.Items[i].FindControl("labelTagIndex"); if (labelTagIndex != null) { nRow["TAG_INDEX"] = int.Parse(labelTagIndex.Text); } else { throw new Exception("Error: save_MetaContentData labelTagIndex==null"); } Label labelSubfieldID = (Label)marcTextRepeater.Items[i].FindControl("labelSubfieldID"); if (labelSubfieldID != null && !String.IsNullOrEmpty(labelSubfieldID.Text)) { nRow["SUBFIELD_ID"] = Int32.Parse(labelSubfieldID.Text); } Label labelSubfieldCode = (Label)marcTextRepeater.Items[i].FindControl("labelSubfieldCode"); if (labelSubfieldCode != null) { nRow["SUBFIELD_CODE"] = labelSubfieldCode.Text; } else { throw new Exception("Error: save_MetaContentData labelSubfieldCode==null"); } Label labelSubfieldLabel = (Label)marcTextRepeater.Items[i].FindControl("labelSubfieldLabel"); if (labelSubfieldLabel != null) { nRow["SUBFIELD_LABEL"] = labelSubfieldLabel.Text; } else { throw new Exception("Error: save_MetaContentData labelSubfieldLabel==null"); } Label labelSubfieldType = (Label)marcTextRepeater.Items[i].FindControl("labelSubfieldType"); if (labelSubfieldType != null) { nRow["SUBFIELD_TYPE"] = labelSubfieldType.Text; TextBox Subfield_Value = (TextBox)marcTextRepeater.Items[i].FindControl("Subfield_Value"); if (Subfield_Value != null) { nRow["SUBFIELD_VALUE"] = Subfield_Value.Text; } } else { throw new Exception("Error: save_MetaContentData labelSubfieldType==null"); } marcTable.Rows.Add(nRow); } /*marcNTextRepeater*/ #region marcNTextRepeater for (int i = 0; i < marcNTextRepeater.Items.Count; i++) { DataRow nRow = marcTable.NewRow(); Label labelTag = (Label)marcNTextRepeater.Items[i].FindControl("labelTag"); if (labelTag != null) { nRow["TAG"] = labelTag.Text; } else { throw new Exception("Error: save_MetaContentData labelTag==null"); } Label labelTagIndex = (Label)marcNTextRepeater.Items[i].FindControl("labelTagIndex"); if (labelTagIndex != null) { nRow["TAG_INDEX"] = int.Parse(labelTagIndex.Text); } else { throw new Exception("Error: save_MetaContentData labelTagIndex==null"); } Label labelSubfieldID = (Label)marcNTextRepeater.Items[i].FindControl("labelSubfieldID"); if (labelSubfieldID != null && !String.IsNullOrEmpty(labelSubfieldID.Text)) { nRow["SUBFIELD_ID"] = labelSubfieldID.Text; } Label labelSubfieldCode = (Label)marcNTextRepeater.Items[i].FindControl("labelSubfieldCode"); if (labelSubfieldCode != null) { nRow["SUBFIELD_CODE"] = labelSubfieldCode.Text; } else { throw new Exception("Error: save_MetaContentData labelSubfieldCode==null"); } Label labelSubfieldLabel = (Label)marcNTextRepeater.Items[i].FindControl("labelSubfieldLabel"); if (labelSubfieldLabel != null) { nRow["SUBFIELD_LABEL"] = labelSubfieldLabel.Text; } else { throw new Exception("Error: save_MetaContentData labelSubfieldLabel==null"); } Label labelSubfieldType = (Label)marcNTextRepeater.Items[i].FindControl("labelSubfieldType"); if (labelSubfieldType != null) { nRow["SUBFIELD_TYPE"] = labelSubfieldType.Text; FCKeditor fckValue = (FCKeditor)marcNTextRepeater.Items[i].FindControl("NTEXT_Value"); if (fckValue != null) { nRow["SUBFIELD_VALUE"] = HttpUtility.HtmlDecode(fckValue.Value); } } else { throw new Exception("Error: save_MetaContentData labelSubfieldType==null"); } marcTable.Rows.Add(nRow); } #endregion marcNTextRepeater _MetaContent.bind_TableDataToMarc(ref marcTable); Session["METADATA"] = _MetaContent.OuterXml; } catch (Exception ex) { throw new Exception("Data error:" + ex.Message + "\n" + ex.InnerException); } }