public void bind_TableDataToMarc(ref DataTable marcDataTable) { if (marcDataTable.Rows.Count == 0) { return; } //remove all old datafields while (this.Datafields.Count > 0) { this.Datafields.Remove(0); this.Datafields.Refresh(); } for (int i = 0; i < marcDataTable.Rows.Count; i++) { CDatafield Df = new CDatafield(); int tagIndex = int.Parse(marcDataTable.Rows[i]["TAG_INDEX"].ToString()); Df.Tag = marcDataTable.Rows[i]["TAG"].ToString(); while ((i < marcDataTable.Rows.Count) && (tagIndex == int.Parse(marcDataTable.Rows[i]["TAG_INDEX"].ToString()))) { CSubfield Sf = new CSubfield(); Sf.ID = marcDataTable.Rows[i]["SUBFIELD_ID"].ToString(); Sf.Code = marcDataTable.Rows[i]["SUBFIELD_CODE"].ToString(); Sf.Type = marcDataTable.Rows[i]["SUBFIELD_TYPE"].ToString(); Sf.Value = marcDataTable.Rows[i]["SUBFIELD_VALUE"].ToString(); Df.Subfields.Add(Sf); i++; } i--;//back to for step this.Datafields.Add(Df); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!String.IsNullOrEmpty(_box_css_name)) { if (_box_css_name.IndexOf("-title-") > 0) { string sBoxTop = String.Format("<div id=\"{0}\"><div class=\"t\"><div class=\"t\"><div class=\"t\"></div></div></div><div class=\"title\">{1}</div><div class=\"m\"><div class=\"clearfix\">", _box_css_name, LegoWebSite.Buslgic.CommonParameters.asign_COMMON_PARAMETER(this.Title)); string sBoxBottom = "</div><div class=\"clr\"></div></div><div class=\"b\"><div class=\"b\"><div class=\"b\"></div></div></div></div>"; this.litBoxTop.Text = sBoxTop; this.litBoxBottom.Text = sBoxBottom; } else { string sBoxTop = String.Format("<div id=\"{0}\"><div class=\"t\"><div class=\"t\"><div class=\"t\"></div></div></div><div class=\"m\"><div class=\"clearfix\">", _box_css_name); string sBoxBottom = "</div><div class=\"clr\"></div></div><div class=\"b\"><div class=\"b\"><div class=\"b\"></div></div></div></div>"; this.litBoxTop.Text = sBoxTop; this.litBoxBottom.Text = sBoxBottom; } } DataTable cntData = LegoWebSite.Buslgic.MetaContents.get_MOST_READ_CONTENTS(_category_id, _number_of_record, System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.ToLower()); if (cntData.Rows.Count > 0) { CRecord myRec = new CRecord(); CSubfield Sf = new CSubfield(); string sTemplateFileName = LegoWebSite.DataProvider.FileTemplateDataProvider.get_XsltTemplateFile(_template_name); UrlQuery myPost = new UrlQuery(); if (!String.IsNullOrEmpty(_default_post_page)) { myPost = new UrlQuery(_default_post_page); } CRecords outRecs = new CRecords(); for (int i = 0; i < cntData.Rows.Count; i++) { int meta_content_id = (int)cntData.Rows[i]["META_CONTENT_ID"]; myRec.load_Xml(LegoWebSite.Buslgic.MetaContents.get_META_CONTENT_MARCXML(meta_content_id, 0)); if (myRec.Datafields.Datafield("245").Subfields.get_Subfield("n", ref Sf)) { Sf.Value = cntData.Rows[i]["READ_COUNT"].ToString(); } else { Sf.ReConstruct(); Sf.Code = "n"; Sf.Value = cntData.Rows[i]["READ_COUNT"].ToString(); myRec.Datafields.Datafield("245").Subfields.Add(Sf); } myPost.Set("contentid", cntData.Rows[i]["META_CONTENT_ID"].ToString()); myRec.Controlfields.Controlfield("001").Value = myPost.AbsoluteUri; outRecs.Add(myRec); } this.litContent.Text = outRecs.XsltFile_Transform(sTemplateFileName); } } }
protected void linkExportButton_Click(object sender, EventArgs e) { CRecords exRecs = new CRecords(); CRecord myRec = new CRecord(); CControlfield Cf = new CControlfield(); CDatafield Df = new CDatafield(); CSubfield Sf = new CSubfield(); DataTable tbData = new DataTable(); try { switch (radioFilterType.SelectedValue) { case "0": int iSectionID = 0; int iCategoryID = 0; if (dropSections.SelectedValue != null) { iSectionID = int.Parse(dropSections.SelectedValue.ToString()); } if (dropCategories.SelectedValue != null) { iCategoryID = int.Parse(dropCategories.SelectedValue.ToString()); } tbData = LegoWebAdmin.BusLogic.MetaContents.get_META_CONTENT_BY_CATEGORY_ID(iCategoryID, iSectionID).Tables[0]; for (int i = 0; i < tbData.Rows.Count; i++) { string sXmlContent = LegoWebAdmin.BusLogic.MetaContents.get_META_CONTENT_MARCXML(Int16.Parse(tbData.Rows[i]["META_CONTENT_ID"].ToString()), 1); myRec.load_Xml(sXmlContent); exRecs.Add(myRec); } break; case "1": int iFromID = String.IsNullOrEmpty(txtFromId.Text) ? 0 : int.Parse(txtFromId.Text); int iToID = String.IsNullOrEmpty(txtToId.Text) ? 0 : int.Parse(txtToId.Text); tbData = LegoWebAdmin.BusLogic.MetaContents.get_META_CONTENT_BY_ID(iFromID, iToID).Tables[0]; for (int i = 0; i < tbData.Rows.Count; i++) { string sXmlContent = LegoWebAdmin.BusLogic.MetaContents.get_META_CONTENT_MARCXML(Int16.Parse(tbData.Rows[i]["META_CONTENT_ID"].ToString()), 1); myRec.load_Xml(sXmlContent); exRecs.Add(myRec); } break; case "2": //create each system table one MarcRecord //leader 06 = s mean system table data record //001 value is TABLE NAME //LEGOWEB_COMMON_PARAMETERS myRec = new CRecord(); myRec.set_LeaderValueByPos("s", 6, 6); Cf = new CControlfield(); Cf.Tag = "001"; Cf.Value = "LEGOWEB_COMMON_PARAMETERS"; myRec.Controlfields.Add(Cf); Df = new CDatafield(); Df.Tag = "245"; Df.SubfieldsText = "$aLEGOWEB_COMMON_PARAMETERS TABLE DATA"; myRec.Datafields.Add(Df); tbData = LegoWebAdmin.BusLogic.CommonParameters.get_LEGOWEB_COMMON_PARAMETERS().Tables[0]; foreach (DataRow row in tbData.Rows) { //a PARAMETER_NAME nvarchar(50) Unchecked //b PARAMETER_TYPE smallint Checked //c PARAMETER_VI_VALUE nvarchar(255) Checked //d PARAMETER_EN_VALUE nvarchar(255) Checked //e PARAMETER_DESCRIPTION nvarchar(255) Checked Df = new CDatafield(); Df.Tag = "650"; Df.SubfieldsText = String.Format("$a{0}$b{1}$c{2}$d{3}$e{4}", row["PARAMETER_NAME"].ToString(), row["PARAMETER_TYPE"].ToString(), row["PARAMETER_VI_VALUE"].ToString(), row["PARAMETER_EN_VALUE"].ToString(), row["PARAMETER_DESCRIPTION"].ToString()); myRec.Datafields.Add(Df); } exRecs.Add(myRec); //LEGOWEB_SECTIONS myRec = new CRecord(); myRec.set_LeaderValueByPos("s", 6, 6); Cf = new CControlfield(); Cf.Tag = "001"; Cf.Value = "LEGOWEB_SECTIONS"; myRec.Controlfields.Add(Cf); Df = new CDatafield(); Df.Tag = "245"; Df.SubfieldsText = "$aLEGOWEB_SECTIONS TABLE DATA"; myRec.Datafields.Add(Df); tbData = LegoWebAdmin.BusLogic.Sections.get_LEGOWEB_SECTIONS().Tables[0]; foreach (DataRow row in tbData.Rows) { //a SECTION_ID int Unchecked //b SECTION_VI_TITLE nvarchar(250) Unchecked //c SECTION_EN_TITLE nvarchar(250) Checked Df = new CDatafield(); Df.Tag = "650"; Df.SubfieldsText = String.Format("$a{0}$b{1}$c{2}", row["SECTION_ID"].ToString(), row["SECTION_VI_TITLE"].ToString(), row["SECTION_EN_TITLE"].ToString()); myRec.Datafields.Add(Df); } exRecs.Add(myRec); //LEGOWEB_CATEGORIES myRec = new CRecord(); myRec.set_LeaderValueByPos("s", 6, 6); Cf = new CControlfield(); Cf.Tag = "001"; Cf.Value = "LEGOWEB_CATEGORIES"; myRec.Controlfields.Add(Cf); Df = new CDatafield(); Df.Tag = "245"; Df.SubfieldsText = "$aLEGOWEB_CATEGORIES TABLE DATA"; myRec.Datafields.Add(Df); tbData = LegoWebAdmin.BusLogic.Categories.get_LEGOWEB_CATEGORIES().Tables[0]; foreach (DataRow row in tbData.Rows) { //a CATEGORY_ID int Unchecked //b PARENT_CATEGORY_ID int Checked //c SECTION_ID int Unchecked //d CATEGORY_VI_TITLE nvarchar(250) Unchecked //e CATEGORY_EN_TITLE nvarchar(250) Checked //f CATEGORY_ALIAS nvarchar(250) Checked //g CATEGORY_TEMPLATE_NAME nvarchar(50) Checked //h CATEGORY_IMAGE_URL nvarchar(250) Checked //i MENU_ID int Unchecked //j IS_PUBLIC bit Checked //k ADMIN_LEVEL smallint Checked //l ADMIN_ROLES nvarchar(250) Checked //m SEO_TITLE nvarchar(100) Checked //n SEO_DESCRIPTION nvarchar(255) Checked //o SEO_KEYWORDS nvarchar(255) Checked //p ORDER_NUMBER smallint //q SORT_CONTENT_BY smallint -- since 10-03-2012 Df = new CDatafield(); Df.Tag = "650"; Df.SubfieldsText = String.Format("$a{0}$b{1}$c{2}$d{3}$e{4}$f{5}$g{6}$h{7}$i{8}$j{9}$k{10}$l{11}$m{12}$n{13}$o{14}$p{15}$q{16}", row["CATEGORY_ID"].ToString(), row["PARENT_CATEGORY_ID"].ToString(), row["SECTION_ID"].ToString(), row["CATEGORY_VI_TITLE"].ToString(), row["CATEGORY_EN_TITLE"].ToString(), row["CATEGORY_ALIAS"].ToString(), row["CATEGORY_TEMPLATE_NAME"].ToString(), row["CATEGORY_IMAGE_URL"].ToString(), row["MENU_ID"].ToString(), row["IS_PUBLIC"].ToString(), row["ADMIN_LEVEL"].ToString(), row["ADMIN_ROLES"].ToString(), row["SEO_TITLE"].ToString(), row["SEO_DESCRIPTION"].ToString(), row["SEO_KEYWORDS"].ToString(), row["ORDER_NUMBER"].ToString(), row["SORT_CONTENT_BY"].ToString()); myRec.Datafields.Add(Df); } exRecs.Add(myRec); //LEGOWEB_MENU_TYPES myRec = new CRecord(); myRec.set_LeaderValueByPos("s", 6, 6); Cf = new CControlfield(); Cf.Tag = "001"; Cf.Value = "LEGOWEB_MENU_TYPES"; myRec.Controlfields.Add(Cf); Df = new CDatafield(); Df.Tag = "245"; Df.SubfieldsText = "$aLEGOWEB_MENU_TYPES TABLE DATA"; myRec.Datafields.Add(Df); tbData = LegoWebAdmin.BusLogic.MenuTypes.get_LEGOWEB_MENU_TYPES().Tables[0]; foreach (DataRow row in tbData.Rows) { //a MENU_TYPE_ID smallint Unchecked //b MENU_TYPE_VI_TITLE nvarchar(50) Unchecked //c MENU_TYPE_EN_TITLE nvarchar(50) Unchecked //d MENU_TYPE_DESCRIPTION nvarchar(250) Checked Df = new CDatafield(); Df.Tag = "650"; Df.SubfieldsText = String.Format("$a{0}$b{1}$c{2}$d{3}", row["MENU_TYPE_ID"].ToString(), row["MENU_TYPE_VI_TITLE"].ToString(), row["MENU_TYPE_EN_TITLE"].ToString(), row["MENU_TYPE_DESCRIPTION"].ToString()); myRec.Datafields.Add(Df); } exRecs.Add(myRec); //LEGOWEB_MENUS myRec = new CRecord(); myRec.set_LeaderValueByPos("s", 6, 6); Cf = new CControlfield(); Cf.Tag = "001"; Cf.Value = "LEGOWEB_MENUS"; myRec.Controlfields.Add(Cf); Df = new CDatafield(); Df.Tag = "245"; Df.SubfieldsText = "$aLEGOWEB_MENUS TABLE DATA"; myRec.Datafields.Add(Df); tbData = LegoWebAdmin.BusLogic.Menus.get_LEGOWEB_MENUS().Tables[0]; foreach (DataRow row in tbData.Rows) { //a MENU_ID int Unchecked //b PARENT_MENU_ID int Unchecked //c MENU_TYPE_ID int Unchecked //d MENU_VI_TITLE nvarchar(50) Checked //e MENU_EN_TITLE nvarchar(50) Checked //f MENU_IMAGE_URL nvarchar(250) Checked //g MENU_LINK_URL nvarchar(50) Checked //h BROWSER_NAVIGATE tinyint Unchecked //i IS_PUBLIC bit Unchecked //j ORDER_NUMBER smallint Df = new CDatafield(); Df.Tag = "650"; Df.SubfieldsText = String.Format("$a{0}$b{1}$c{2}$d{3}$e{4}$f{5}$g{6}$h{7}$i{8}$j{9}", row["MENU_ID"].ToString(), row["PARENT_MENU_ID"].ToString(), row["MENU_TYPE_ID"].ToString(), row["MENU_VI_TITLE"].ToString(), row["MENU_EN_TITLE"].ToString(), row["MENU_IMAGE_URL"].ToString(), row["MENU_LINK_URL"].ToString(), row["BROWSER_NAVIGATE"].ToString(), row["IS_PUBLIC"].ToString(), row["ORDER_NUMBER"].ToString()); myRec.Datafields.Add(Df); } exRecs.Add(myRec); //#region KIPOS TABLES //myRec = new CRecord(); //myRec.set_LeaderValueByPos("s", 6, 6); //Cf = new CControlfield(); //Cf.Tag = "001"; //Cf.Value = "CAT_DMD_CATEGORY"; //myRec.Controlfields.Add(Cf); //Df = new CDatafield(); //Df.Tag = "245"; //Df.SubfieldsText = "$aCAT_DMD_CATEGORY"; //myRec.Datafields.Add(Df); //tbData = LegoWebAdmin.BusLogic.Menus.get_LEGOWEB_MENUS().Tables[0]; //foreach (DataRow row in tbData.Rows) //{ // //a MENU_ID int Unchecked // //b PARENT_MENU_ID int Unchecked // //c MENU_TYPE_ID int Unchecked // //d MENU_VI_TITLE nvarchar(50) Checked // //e MENU_EN_TITLE nvarchar(50) Checked // //f MENU_IMAGE_URL nvarchar(250) Checked // //g MENU_LINK_URL nvarchar(50) Checked // //h BROWSER_NAVIGATE tinyint Unchecked // //i IS_PUBLIC bit Unchecked // //j ORDER_NUMBER smallint // Df = new CDatafield(); // Df.Tag = "650"; // Df.SubfieldsText = String.Format("$a{0}$b{1}$c{2}$d{3}$e{4}$f{5}$g{6}$h{7}$i{8}$j{9}", row["MENU_ID"].ToString(), row["PARENT_MENU_ID"].ToString(), row["MENU_TYPE_ID"].ToString(), row["MENU_VI_TITLE"].ToString(), row["MENU_EN_TITLE"].ToString(), row["MENU_IMAGE_URL"].ToString(), row["MENU_LINK_URL"].ToString(), row["BROWSER_NAVIGATE"].ToString(), row["IS_PUBLIC"].ToString(), row["ORDER_NUMBER"].ToString()); // myRec.Datafields.Add(Df); //} //exRecs.Add(myRec); //#endregion KIPOS TABLES break; } if (exRecs.Count <= 0) { throw new Exception("No data to export!"); } Response.ContentType = "APPLICATION/OCTET-STREAM"; //set the filename Response.AddHeader("Content-Disposition", "attachment;filename=\"legowebdata.xml\""); String outStream = exRecs.OuterXml; Response.Write(outStream); Response.End(); } catch (Exception ex) { String errorFomat = @"<dl id='system-message'> <dd class='error message fade'> <ul> <li>{0}</li> </ul> </dd> </dl>"; litErrorSpaceHolder.Text = String.Format(errorFomat, ex.Message); } }
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; } }
public static DataTable get_PollData(int iPollContentId, out string sQuestion, out int iTotalVoteCount) { iTotalVoteCount = 0; sQuestion = null; DataTable pollData = new DataTable(); DataColumn IDcol = new DataColumn("ID"); IDcol.DataType = System.Type.GetType("System.Int32"); pollData.Columns.Add(IDcol); DataColumn voteCountCol = new DataColumn("VoteCount"); voteCountCol.DataType = System.Type.GetType("System.Int32"); pollData.Columns.Add(voteCountCol); DataColumn ChoiceCol = new DataColumn("Choice"); ChoiceCol.DataType = System.Type.GetType("System.String"); pollData.Columns.Add(ChoiceCol); DataColumn orderCol = new DataColumn("OrderNumber"); orderCol.DataType = System.Type.GetType("System.Int32"); pollData.Columns.Add(orderCol); CRecord pollRecord = new CRecord(); CDatafield Df = new CDatafield(); CSubfield Sf = new CSubfield(); pollRecord.load_Xml(LegoWebSite.Buslgic.MetaContents.get_META_CONTENT_MARCXML(iPollContentId, 0)); pollRecord.Sort(); //get Question First sQuestion = pollRecord.Datafields.Datafield("245").Subfields.Subfield("a").Value; CDatafields ChoiceDfs = pollRecord.Datafields; ChoiceDfs.Filter("650"); for (int i = 0; i < ChoiceDfs.Count; i++) { string sChoice = ""; int iID = 0; int iVoteCount = 0; int iOrderNumber = 0; Df = ChoiceDfs.Datafield(i); if (Df.Subfields.get_Subfield("0", ref Sf)) { iOrderNumber = String.IsNullOrEmpty(Sf.Value)?0:int.Parse(Sf.Value); } if (Df.Subfields.get_Subfield("a", ref Sf)) { sChoice = Sf.Value; iID = int.Parse(Sf.ID); } else { sChoice = "No choice info"; } if (Df.Subfields.get_Subfield("n", ref Sf)) { iTotalVoteCount += int.Parse(Sf.Value); iVoteCount = int.Parse(Sf.Value); } DataRow row = pollData.NewRow(); row["ID"] = iID; row["Choice"] = sChoice; row["VoteCount"] = iVoteCount; row["OrderNumber"] = iOrderNumber; pollData.Rows.Add(row); } pollData.DefaultView.Sort = " OrderNumber ASC"; return(pollData); }