public static CRecords get_LastDataRecords(String sCategory, int iNumberOfRecord) { CRecords myRecs = new CRecords(); CRecords retRecs = new CRecords(); String dataFileName = System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesPhysicalPath"].ToString() + "File/Data/" + System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName + "\\" + sCategory + ".xml"; if (File.Exists(dataFileName)) { myRecs.load_File(dataFileName); } else { myRecs.Save(dataFileName); } if (myRecs.Count <= iNumberOfRecord) { for (int i = myRecs.Count - 1; i >= 0; i--) { retRecs.Add(myRecs.Record(i)); } } else { for (int j = myRecs.Count - 1; j >= myRecs.Count - iNumberOfRecord; j--) { retRecs.Add(myRecs.Record(j)); } } return(retRecs); }
public static DataTable get_DataTableRecords(String sCategory) { DataTable Data = new DataTable(); Data.TableName = "CONTENT"; Data.Columns.Add(new DataColumn("ID", typeof(int))); Data.Columns.Add(new DataColumn("TITLE", typeof(string))); Data.Columns.Add(new DataColumn("CATEGORY", typeof(string))); CRecords myRecs = new CRecords(); String dataFileName = System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesPhysicalPath"].ToString() + "File/Data/" + System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName + "\\" + sCategory + ".xml"; if (File.Exists(dataFileName)) { myRecs.load_File(dataFileName); if (myRecs.Count > 0) { for (int i = myRecs.Count - 1; i >= 0; i--) { DataRow row = Data.NewRow(); row["ID"] = myRecs.Record(i).Controlfields.Controlfield("001").Value; row["TITLE"] = myRecs.Record(i).Datafields.Datafield("245").Subfields.Subfield("a").Value; row["CATEGORY"] = myRecs.Record(i).Controlfields.Controlfield("003").Value; Data.Rows.Add(row); } } } return(Data); }
public static CRecord get_DataRecord(String sCategory, string sID) { CRecords myRecs = new CRecords(); String dataFileName = System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesPhysicalPath"].ToString() + "File/Data/" + System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName + "\\" + sCategory + ".xml"; if (File.Exists(dataFileName)) { myRecs.load_File(dataFileName); } else { myRecs.Save(dataFileName); } if (myRecs.Count > 0) { switch (sID.ToLower()) { case "first": return(myRecs.Record(0)); break; case "last": return(myRecs.Record(myRecs.Count - 1)); break; default: int iID = int.Parse("0" + sID); myRecs.Filter("001", sID, true); if (myRecs.Count > 0) { return(myRecs.Record(0)); } else { CRecord myRec = new CRecord(); myRec.load_File(FileTemplateDataProvider.get_WorkformTemplateFile(sCategory)); return(myRec); } break; } } else { CRecord myRec1 = new CRecord(); myRec1.load_File(FileTemplateDataProvider.get_WorkformTemplateFile(sCategory)); return(myRec1); } }
public static CRecords get_DataRecords(String sCategory) { CRecords myRecs = new CRecords(); String dataFileName = System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesPhysicalPath"].ToString() + "File/Data/" + System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName + "\\" + sCategory + ".xml"; if (File.Exists(dataFileName)) { myRecs.load_File(dataFileName); } else { myRecs.Save(dataFileName); } return(myRecs); }
public static void save_DataRecord(String sCategory, CRecord saveRecord) { saveRecord.Controlfields.Controlfield("005").Value = DateTime.Now.ToLongDateString(); CRecords myRecs = new CRecords(); String dataFileName = System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesPhysicalPath"].ToString() + "File/Data/" + System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName + "\\" + sCategory + ".xml"; if (File.Exists(dataFileName)) { myRecs.load_File(dataFileName); } else { myRecs.Save(dataFileName); } CControlfield Cf = new CControlfield(); String sID = "0"; if (saveRecord.Controlfields.get_Controlfield("001", ref Cf)) { if (Cf.Value == "") { Cf.Value = "0"; } sID = Cf.Value; } else { Cf = new CControlfield(); Cf.Tag = "001"; Cf.Value = "0"; saveRecord.Controlfields.Add(Cf); } myRecs.Filter("001", sID, true); if (myRecs.Count > 0) { CRecord ptOldRec = myRecs.Record(0); myRecs.Replace(ref ptOldRec, ref saveRecord); } else { myRecs.Add(saveRecord); } myRecs.Save(dataFileName); }
public static int add_DataRecord(String sCategory, CRecord addRecord) { addRecord.Controlfields.Controlfield("005").Value = DateTime.Now.ToLongDateString(); CRecords myRecs = new CRecords(); String dataFileName = System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesPhysicalPath"].ToString() + "File/Data/" + System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName + "\\" + sCategory + ".xml"; if (File.Exists(dataFileName)) { myRecs.load_File(dataFileName); } else { myRecs.Save(dataFileName); } int iID = 0; myRecs.Filter("001", iID.ToString(), true); while (myRecs.Count > 0) { iID++; myRecs.Refresh(); myRecs.Filter("001", iID.ToString(), true); } CControlfield Cf = new CControlfield(); if (addRecord.Controlfields.get_Controlfield("001", ref Cf)) { Cf.Value = iID.ToString(); } else { Cf = new CControlfield(); Cf.Tag = "001"; Cf.Value = iID.ToString(); addRecord.Controlfields.Add(Cf); } myRecs.Add(addRecord); myRecs.Save(dataFileName); myRecs.Refresh(); return(iID); }
public static CRecords get_DataRecords(String sCategory, String sSubCategory) { CRecords myRecs = new CRecords(); CRecords retRecs = new CRecords(); String dataFileName = System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesPhysicalPath"].ToString() + "File/Data/" + System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName + "\\" + sCategory + ".xml"; if (File.Exists(dataFileName)) { myRecs.load_File(dataFileName); myRecs.Filter("003", sCategory + "." + sSubCategory, true); for (int i = myRecs.Count; i < myRecs.Count; i++) { retRecs.Add(myRecs.Record(i)); } } else { myRecs.Save(dataFileName); } return(retRecs); }
public static void increase_DownloadCount(String sCategory, int iIndex) { CRecords myRecs = new CRecords(); String dataFileName = System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesPhysicalPath"].ToString() + "File/Data/" + System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName + "\\" + sCategory + ".xml"; if (File.Exists(dataFileName)) { myRecs.load_File(dataFileName); } else { myRecs.Save(dataFileName); } if (iIndex < myRecs.Count) { CRecord myRec = myRecs.Record(iIndex); myRec.Datafields.Datafield("245").Subfields.Subfield("n").Value = (int.Parse("0" + myRec.Datafields.Datafield("245").Subfields.Subfield("n").Value) + 1).ToString(); } myRecs.Save(dataFileName); }
public static void delete_DataRecord(String sCategory, string sID) { CRecords myRecs = new CRecords(); String dataFileName = System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesPhysicalPath"].ToString() + "File/Data/" + System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName + "\\" + sCategory + ".xml"; if (File.Exists(dataFileName)) { myRecs.load_File(dataFileName); } else { myRecs.Save(dataFileName); } myRecs.Filter("001", sID, true); if (myRecs.Count > 0) { myRecs.Remove(0); } myRecs.Save(dataFileName); }
protected void linkImportContentButton_Click(object sender, EventArgs e) { litErrorSpaceHolder.Text = ""; //try //{ divDefaultCategory.Visible = false; DataTable contentTable = create_ContentTable(); if (String.IsNullOrEmpty(txtFileName.Text)) { throw new Exception("You must select a source file!"); } //chuyển đổi địa chỉ URL sang Physycal string sFileURL = txtFileName.Text; string sFileName = sFileURL.Replace(System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesVirtuaPath"], System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesPhysicalPath"]); sFileName = sFileName.Replace("/", "\\"); if (!System.IO.File.Exists(sFileName)) { throw new Exception("Source file does not exists!"); } else { divDefaultCategory.Visible = true; } CRecords myRecs = new CRecords(); myRecs.load_File(sFileName); int iSkipCount = 0; for (int i = 0; i < myRecs.Count; i++) { CRecord myRec = new CRecord(); myRec.load_Xml(myRecs.Record(i).OuterXml); if (myRec.get_LeaderValueByPos(6, 6) == "s")//system tables data { import_SystemTableData(myRec); } else { Int32 iID = String.IsNullOrEmpty(myRecs.Record(i).Controlfields.Controlfield("001").Value) ? 0 : Int32.Parse(myRecs.Record(i).Controlfields.Controlfield("001").Value); Int32 iCatID = String.IsNullOrEmpty(myRecs.Record(i).Controlfields.Controlfield("002").Value) ? 0 : Int32.Parse(myRecs.Record(i).Controlfields.Controlfield("002").Value); switch (radioImportTypes.SelectedValue) { case "0": //append myRec.Controlfields.Controlfield("001").Value = "0"; switch (radioForceToDefaultCategory.SelectedValue) { case "0": //auto detech category id if (!LegoWebAdmin.BusLogic.Categories.is_CATEGORY_ID_EXIST(iCatID)) { myRec.Controlfields.Controlfield("002").Value = dropCategories.SelectedValue; } break; case "1": //force to default category myRec.Controlfields.Controlfield("002").Value = dropCategories.SelectedValue; break; } LegoWebAdmin.BusLogic.MetaContents.save_META_CONTENTS_XML(myRec.OuterXml, this.Page.User.Identity.Name); break; case "1": //skip if ID exsist if (!LegoWebAdmin.BusLogic.MetaContents.is_META_CONTENTS_EXIST(iID)) { switch (radioForceToDefaultCategory.SelectedValue) { case "0": //auto detech category id if (!LegoWebAdmin.BusLogic.Categories.is_CATEGORY_ID_EXIST(iCatID)) { myRec.Controlfields.Controlfield("002").Value = dropCategories.SelectedValue; } break; case "1": //force to default category myRec.Controlfields.Controlfield("002").Value = dropCategories.SelectedValue; break; } LegoWebAdmin.BusLogic.MetaContents.save_META_CONTENTS_XML(myRec.OuterXml, this.Page.User.Identity.Name); } else { iSkipCount++; } break; case "2": switch (radioForceToDefaultCategory.SelectedValue) { case "0": //auto detech category id if (!LegoWebAdmin.BusLogic.Categories.is_CATEGORY_ID_EXIST(iCatID)) { myRec.Controlfields.Controlfield("002").Value = dropCategories.SelectedValue; } break; case "1": //force to default category myRec.Controlfields.Controlfield("002").Value = dropCategories.SelectedValue; break; } LegoWebAdmin.BusLogic.MetaContents.save_META_CONTENTS_XML(myRec.OuterXml, this.Page.User.Identity.Name); break; } } } litErrorSpaceHolder.Text = String.Format("Imports successfully {0} records, skips {1}!.", myRecs.Count.ToString(), iSkipCount.ToString()); // } // 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 btnAnalyse_Click(object sender, EventArgs e) { litErrorSpaceHolder.Text = ""; try { divDefaultCategory.Visible = false; DataTable contentTable = create_ContentTable(); if (String.IsNullOrEmpty(txtFileName.Text)) { throw new Exception("You must select a source file!"); } //chuyển đổi địa chỉ URL sang Physycal string sFileURL = txtFileName.Text; string sFileName = sFileURL.Replace(System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesVirtuaPath"], System.Configuration.ConfigurationManager.AppSettings["LegoWebFilesPhysicalPath"]); sFileName = sFileName.Replace("/", "\\"); if (!System.IO.File.Exists(sFileName)) { throw new Exception("File doest not exists!"); } else { divDefaultCategory.Visible = true; } CRecords myRecs = new CRecords(); myRecs.load_File(sFileName); for (int i = 0; i < myRecs.Count; i++) { DataRow row = contentTable.NewRow(); if (myRecs.Record(i).get_LeaderValueByPos(6, 6) == "s")//system tables data { row["META_CONTENT_ID"] = 0; row["META_CONTENT_TITLE"] = myRecs.Record(i).Datafields.Datafield("245").Subfields.Subfield("a").Value; row["LANG_CODE"] = ""; row["CATEGORY_ID"] = 0; } else { row["META_CONTENT_ID"] = String.IsNullOrEmpty(myRecs.Record(i).Controlfields.Controlfield("001").Value) ? 0 : Int32.Parse(myRecs.Record(i).Controlfields.Controlfield("001").Value); row["META_CONTENT_TITLE"] = myRecs.Record(i).Datafields.Datafield("245").Subfields.Subfield("a").Value; row["LANG_CODE"] = myRecs.Record(i).Controlfields.Controlfield("008").get_ValueByPos(35, 36); row["CATEGORY_ID"] = String.IsNullOrEmpty(myRecs.Record(i).Controlfields.Controlfield("002").Value) ? 0 : Int32.Parse(myRecs.Record(i).Controlfields.Controlfield("002").Value); } contentTable.Rows.Add(row); } metaContentRepeater.DataSource = contentTable; metaContentRepeater.DataBind(); } 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); } }