private void ExportPoetToTextFile(GanjoorPoet poet, string targetFolder, DbBrowser dbBrowser) { if (!Directory.Exists(targetFolder)) { Directory.CreateDirectory(targetFolder); } StringBuilder sb = new StringBuilder(); if (Settings.Default.ExportPoetName) { string poetNameSeparator = Settings.Default.ExportPoetSep; if (!string.IsNullOrEmpty(poetNameSeparator)) { sb.AppendLine(poetNameSeparator); } sb.AppendLine(poet._Name); if (!string.IsNullOrEmpty(poetNameSeparator)) { sb.AppendLine(poetNameSeparator); } } GanjoorCat poetCat = dbBrowser.GetCategory(poet._CatID); DRY_ExportCat(dbBrowser, poetCat, sb); List <int> lstSubCategories = dbBrowser.GetAllSubCats(poetCat._ID); foreach (int catId in lstSubCategories) { DRY_ExportCat(dbBrowser, dbBrowser.GetCategory(catId), sb); } File.WriteAllText(Path.Combine(targetFolder, GPersianTextSync.Farglisize(poet._Name) + ".txt"), sb.ToString()); }
private GDBInfo ExtracInfoFromGDBFileAndAddToGrid(string FileName, string ext, int FileSize) { GDBInfo gdb = null; DbBrowser gdbBrowser = new DbBrowser(FileName); if (gdbBrowser.Poets.Count != 1) { MessageBox.Show("این ابزار در حال حاضر تنها مجموعههای حاوی یک شاعر را پشتیبانی میکند."); } else { GanjoorPoet poet = gdbBrowser.Poets[0]; gdb = new GDBInfo(); gdb.CatName = poet._Name; gdb.PoetID = poet._ID; int minCatID, minPoemID; gdbBrowser.GetMinIDs(poet._ID, out minCatID, out minPoemID); gdb.CatID = minCatID; gdb.FileExt = ext; gdb.FileSizeInByte = FileSize; gdb.LowestPoemID = minPoemID; gdb.PubDate = DateTime.Now; } gdbBrowser.CloseDb(); return(gdb); }
private void FillTree(int PoetID) { DbBrowser db = _RefDb == null ? new DbBrowser() : _RefDb; treeCats.Nodes.Clear(); if (PoetID == 0) { treeCats.Nodes.Add("همه").Tag = 0; foreach (GanjoorPoet poet in db.Poets) { TreeNode newPoet = treeCats.Nodes.Add(poet._Name); newPoet.Tag = poet._CatID; AddSubCats(db, newPoet, poet._CatID); } } else { GanjoorPoet poet = db.GetPoet(PoetID); TreeNode newPoet = treeCats.Nodes.Add(poet._Name); newPoet.Tag = poet._CatID; AddSubCats(db, newPoet, poet._CatID); } if (_RefDb == null) { db.CloseDb(); } }
/// <summary> /// دو نمونه از کلاس را مقایسه کرده نتیجه را باز می گرداند. /// </summary> /// <returns>true if equal</returns> public override bool Equals(object obj) { if (obj is GanjoorPoet) { GanjoorPoet otherPoet = obj as GanjoorPoet; return (this._ID == otherPoet._ID && this._Name == otherPoet._Name); } return(false); }
private void mnuExport_Click(object sender, EventArgs e) { using (TextExporter eDlg = new TextExporter()) { if (eDlg.ShowDialog(this) == DialogResult.OK) { using (FolderBrowserDialog dlg = new FolderBrowserDialog()) { dlg.Description = "مسیر خروجیها را انتخاب کنید"; dlg.ShowNewFolderButton = true; if (dlg.ShowDialog(this) == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this.Enabled = false; Application.DoEvents(); string targetFolder = dlg.SelectedPath; DbBrowser dbBrowser = new DbBrowser(); for (int i = 0; i < dbBrowser.Poets.Count; i++) { GanjoorPoet poet = dbBrowser.Poets[i]; switch (Settings.Default.ExportLevel) { case "Poet": ExportPoetToTextFile(poet, targetFolder, dbBrowser); break; case "Cat": ExportCatToTextFile(i, dbBrowser.GetCategory(poet._CatID), targetFolder, dbBrowser); break; default: ExportCatToTextFile(i, dbBrowser.GetCategory(poet._CatID), targetFolder, dbBrowser, true); break; } } dbBrowser.CloseDb(); Cursor.Current = Cursors.Default; this.Enabled = true; MessageBox.Show("خروجی تولید شد.", "اعلان", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign); } } } } }