Esempio n. 1
0
        private void cboDefaultGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            ArrayList arrayList = new ArrayList();

            if (cboDefaultGroup.Text != "")
            {
                int iD = ComicGroup.GetID(cboDefaultGroup.Text);
                arrayList.Add("group_id=" + iD);
            }
            if (cboDefaultPublisher.Text != "")
            {
                int iD2 = ComicPublisher.GetID(cboDefaultPublisher.Text);
                arrayList.Add("pub_id=" + iD2);
            }
            cboDefaultSeries.Items.Clear();
            cboDefaultSeries.Items.Add("");
            string str = "";

            if (arrayList.Count > 0)
            {
                str = "WHERE " + string.Join(" AND ", CC.StringList(arrayList));
            }
            Query query = CC.SQL.ExecQuery("SELECT name FROM series " + str);

            while (query.NextResult())
            {
                cboDefaultSeries.Items.Add(query.hash["name"]);
            }
        }
Esempio n. 2
0
        //Determine what the filepath of the issue should be
		public string GenerateFilename()
		{
			string libraryDir = Settings.Default.LibraryDir;
			string text = null;
			Query query = null;
			string str = CC.URLize(SeriesName);
			string text2 = CC.URLize(Name);
			string text3 = null;
			int num = 0;
			libraryDir += "\\";
			libraryDir = libraryDir + PublisherName + "\\";
			libraryDir = libraryDir + GroupName + "\\";
			libraryDir = libraryDir + str + "\\";
			libraryDir += str;
			if (SeriesType != 2)
			{
				query = CC.SQL.ExecQuery("SELECT DISTINCT series_vol FROM issues WHERE series_id=" + SeriesID);
				query.NextResult();
				if (query.NextResult())
				{
					libraryDir = libraryDir + " v" + SeriesVolume;
				}
				query.Close();
				switch (Type)
				{
				case 0:
					libraryDir = libraryDir + " #" + Number.ToString("000");
					break;
				case 1:
					libraryDir = libraryDir + " Annual " + Number;
					break;
				case 2:
					if (text2 != "")
					{
						libraryDir = libraryDir + " " + text2;
					}
					break;
				}
				if ((text2 != "") & (Type != 2))
				{
					libraryDir = libraryDir + " (" + text2 + ")";
				}
			}
			text3 = CC.GetArchiveType(FileName);
			text = libraryDir;
			if (FileName != libraryDir + text3)
			{
				while (File.Exists(text + text3))
				{
					num++;
					text = libraryDir + " " + num;
				}
				return text + text3;
			}
			return FileName;
		}
Esempio n. 3
0
        public bool SaveChanges()
        {
            ArrayList arrayList = new ArrayList();

            //SQL sQL = new SQL();
            if (Changes.Count > 0)
            {
                if (Changes.Contains("Name"))
                {
                    arrayList.Add("name='" + SQL.Prepare(iName) + "'");
                }
                if (Changes.Contains("PublisherID"))
                {
                    arrayList.Add("pub_id='" + iPublisherID + "'");
                    CC.SQL.ExecQuery("UPDATE series SET pub_id=" + iPublisherID + " WHERE group_id=" + ID);
                }
                CC.SQL.ExecQuery("UPDATE groups SET " + string.Join(",", CC.StringList(arrayList)) + " WHERE id=" + ID);
                if (Settings.Default.OrganizeMethod != 0)
                {
                    Query query = CC.SQL.ExecQuery("SELECT name FROM publishers WHERE id=" + PublisherID);
                    query.NextResult();

                    string name = (string)query.hash[0];
                    query.Close();

                    if (Changes.Contains("Name"))
                    {
                        string text  = Settings.Default.LibraryDir + "\\" + CC.URLize(name) + "\\" + CC.URLize(OldName) + "\\";
                        string text2 = Settings.Default.LibraryDir + "\\" + CC.URLize(name) + "\\" + CC.URLize(Name) + "\\";
                        CC.SQL.ExecQuery("UPDATE issues SET filename=" + CC.SQLReplaceLeft("filename", text, text2));
                        CC.Rename(text, text2);
                    }
                    if (Changes.Contains("PublisherID"))
                    {
                        query = CC.SQL.ExecQuery("SELECT name FROM publishers WHERE id=" + OldPublisherID);
                        query.NextResult();

                        string name2 = (string)query.hash[0];
                        query.Close();
                        string text  = Settings.Default.LibraryDir + "\\" + CC.URLize(name2) + "\\" + CC.URLize(Name) + "\\";
                        string text2 = Settings.Default.LibraryDir + "\\" + CC.URLize(name) + "\\" + CC.URLize(Name) + "\\";
                        CC.SQL.ExecQuery("UPDATE issues SET filename=" + CC.SQLReplaceLeft("filename", text, text2));
                        CC.Rename(text, text2);
                    }
                }
                Changes.Remove("Name");
                Changes.Remove("PublisherID");
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        //Clicking on the cover gives the option to select a new cover
        private void CoverPreview_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            MainForm       mainForm       = new MainForm();
            ComicIssue     comicIssue     = (ComicIssue)CC.Issues[CurrentIssue];

            openFileDialog.Filter = "JPEG Files|*.jpg;*.jpeg|GIF Files|*.gif|PNG Files|*.png|Bitmap Files|*.bmp";
            openFileDialog.ShowDialog();
            if (openFileDialog.FileName != "")
            {
                CC.CreateThumbnail(openFileDialog.FileName, Settings.Default.CoverDir + "\\" + comicIssue.ID + ".jpg");
                mainForm.IssueCovers.Images.RemoveByKey(Convert.ToString(comicIssue.ID));
                CoverPreview.Image = CC.GetIssueCover(comicIssue.ID);
            }
        }
Esempio n. 5
0
 //Unimplemented Smart Readlist feature
 public string SmartSQL()
 {
     if (Smart)
     {
         ArrayList arrayList = new ArrayList();
         SQL       sQL       = new SQL();
         Query     query     = sQL.ExecQuery("SELECT * FROM readlist_smart WHERE list_id=" + ID);
         while (query.NextResult())
         {
             arrayList.Add((string)query.hash["prop"] + " " + (string)query.hash["op"] + " " + (string)query.hash["val"]);
         }
         return(string.Join(" AND ", CC.StringList(arrayList)));
     }
     return("");
 }
Esempio n. 6
0
        public bool SaveChanges()
        {
            ArrayList arrayList = new ArrayList();

            if (Changes.Count > 0)
            {
                if (Changes.Contains("Name"))
                {
                    arrayList.Add("name='" + SQL.Prepare(iName) + "'");
                    Changes.Remove("Name");
                }
                CC.SQL.ExecQuery("UPDATE publishers SET " + string.Join(",", CC.StringList(arrayList)) + " WHERE id=" + ID);
                return(true);
            }
            return(false);
        }
Esempio n. 7
0
 public new bool SaveChanges()
 {
     base.SaveChanges();
     if (Changes.Count > 0)
     {
         ArrayList arrayList = new ArrayList();
         if (Changes.Contains("Position"))
         {
             arrayList.Add("pos='" + iPosition + "'");
             Changes.Remove("Position");
         }
         CC.SQL.ExecQuery("UPDATE readlist_issues SET " + string.Join(",", CC.StringList(arrayList)) + " WHERE id=" + RowID);
         return(true);
     }
     return(false);
 }
Esempio n. 8
0
        //Handle the assignment of groups to publisher, including moving directories
        public void AdoptGroups(ArrayList Groups)
        {
            SQL    sQL   = new SQL();
            string text  = Settings.Default.LibraryDir + "\\" + Name + "\\";
            string text2 = "";

            if (Settings.Default.OrganizeMethod != 0)
            {
                foreach (ComicSeries Group in Groups)
                {
                    text2 = Settings.Default.LibraryDir + "\\" + Group.PublisherName + "\\";
                    sQL.ExecQuery("UPDATE issues SET filename=" + CC.SQLReplaceLeft("filename", text2, text) + " WHERE series_id=" + Group.ID);
                    Directory.Move(text2 + Group.Name + "\\", text + Group.Name + "\\");
                }
            }
            sQL.ExecQuery("UPDATE series SET group_id=" + ID + " WHERE series_id IN (" + string.Join(",", CC.StringList(Groups)) + ")");
        }
Esempio n. 9
0
        //Delete a series and its issues
        public void Delete(bool Files)
        {
            SQL   sQL   = new SQL();
            Query query = sQL.ExecQuery("SELECT id FROM issues WHERE series_id=" + ID);

            while (query.NextResult())
            {
                ComicIssue comicIssue = new ComicIssue((int)query.hash["id"]);
                comicIssue.Delete(Files);
            }
            sQL.ExecQuery("DELETE FROM series WHERE id=" + ID);
            if (Settings.Default.OrganizeMethod != 0)
            {
                try
                {
                    //Delete folder for series if file org is turned on
                    Directory.Delete(Settings.Default.LibraryDir + "\\" + CC.URLize(PublisherName) + "\\" + CC.URLize(GroupName) + "\\" + CC.URLize(Name));
                }
                catch
                {
                }
            }
        }
Esempio n. 10
0
        private void LoadIssue(int ItemIndex)
        {
            chkPublished.Checked = false;
            CurrentIssue         = ItemIndex;
            ComicIssue comicIssue = (ComicIssue)CC.Issues[ItemIndex];

            cmdNext.Enabled       = ((CurrentIssue != CC.Issues.Count - 1) ? true : false);
            cmdPrev.Enabled       = ((CurrentIssue != 0) ? true : false);
            txtPlot.Text          = comicIssue.Name;
            cboSeries.Text        = comicIssue.SeriesName;
            udNumber.Value        = comicIssue.Number;
            udVol.Value           = comicIssue.SeriesVolume;
            cboType.SelectedIndex = comicIssue.Type;
            txtComments.Text      = comicIssue.Comments;
            try
            {
                datePublished.Value = comicIssue.Published;
            }
            catch
            {
            }
            lblPlot.Text   = comicIssue.Name;
            lblSeries.Text = comicIssue.SeriesName;

            if (comicIssue.SeriesType != 2)
            {
                switch (comicIssue.Type)
                {
                case 0:
                    lblNumber.Text = "Issue #" + comicIssue.Number;
                    break;

                case 1:
                    lblNumber.Text = "Annual " + comicIssue.Number;
                    break;

                case 2:
                    lblNumber.Text = "Special";
                    break;
                }
            }
            else
            {
                lblNumber.Text = "One-shot";
            }
            lblNumber.Text = lblNumber.Text + " (" + comicIssue.Pages + " Pages)";
            switch (Path.GetExtension(comicIssue.FileName))
            {
            case ".cbr":
                lblKind.Text = "Comic Book RAR File";
                break;

            case ".cbz":
                lblKind.Text = "Comic Book Zip File";
                break;

            case ".pdf":
                lblKind.Text = "Comic Book PDF File";
                break;
            }
            lblSize.Text = CC.ByteToString((double)comicIssue.FileSize);
            if (comicIssue.Published.Year != 1)
            {
                lblPublished.Text = comicIssue.Published.ToString("MM yyyy");
            }
            else
            {
                lblPublished.Text = "Unknown";
            }
            lblAdded.Text      = comicIssue.DateAdded.ToString("M/d/yyyy h:mm tt");
            CoverPreview.Image = CC.GetIssueCover(comicIssue.ID);
            lblFileName.Text   = comicIssue.FileName;

            //If file organization is turned on and the issue is missing, disable everything.
            if (Settings.Default.OrganizeMethod != 0)
            {
                foreach (Control control in tabInfo.TabPages[1].Controls)
                {
                    control.Enabled = !comicIssue.Missing;
                }
                OK_Button.Enabled = !comicIssue.Missing;
            }
        }
Esempio n. 11
0
		public Exception Process()
		{
			FileStream fileStream = new FileStream(FileName, FileMode.Open);
			FileSize = (int)fileStream.Length;
			MD5 = CC.md5file(fileStream);
			fileStream.Close();
			int num = -1;
			if (Settings.Default.FindDuplicates)
			{
				num = FindDuplicate();
			}
			if (num == -1)
			{
				string archiveType;
				try
				{
					archiveType = CC.GetArchiveType(FileName);
				}
				catch (Exception result)
				{
					return result;
				}
				string text = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), "CarbonImport");
				if (!Directory.Exists(text))
				{
					Directory.CreateDirectory(text);
				}
				SaveChanges();
				ArrayList arrayList = new ArrayList();
				try
				{
					if (archiveType == ".cbr")
					{
						Unrar unrar = new Unrar();
						unrar.ArchivePathName = FileName;
						unrar.Open(Unrar.OpenMode.List);
						while (unrar.ReadHeader())
						{
							if (!unrar.CurrentFile.IsDirectory & CC.IsImageExt(unrar.CurrentFile.FileName))
							{
								arrayList.Add(unrar.CurrentFile.FileName);
							}
							unrar.Skip();
						}
						unrar.Close();
						arrayList.Sort();
						unrar.Open(Unrar.OpenMode.Extract);
						while (unrar.ReadHeader())
						{
							if (unrar.CurrentFile.FileName == (string)arrayList[0])
							{
								if (Settings.Default.ThumbGen)
								{
									text = Path.Combine(text, ID + Path.GetExtension(unrar.CurrentFile.FileName));
									unrar.Extract(text);
								}
								break;
							}
							unrar.Skip();
						}
						unrar.Close();
					}
					else if (archiveType == ".cbz")
					{
						ZipFile zipFile = new ZipFile(FileName);
						foreach (ZipEntry item in zipFile)
						{
							if (item.IsFile & CC.IsImageExt(item.Name) && item.Name.Substring(0, 1) != "." && !item.Name.Contains("/") && !item.Name.Contains("/."))
							{
								arrayList.Add(item.Name);
							}
						}
						zipFile.Close();
						arrayList.Sort();
						if (Settings.Default.ThumbGen)
						{
							text = Path.Combine(text, ID + Path.GetExtension((string)arrayList[0]));
							CC.unzip(FileName, (string)arrayList[0], text);
						}
					}
					if ((Path.GetExtension(text).ToLower() == ".png") | (Path.GetExtension(text).ToLower() == ".gif"))
					{
						text = CC.ConvertJPG(text);
					}
					Pages = arrayList.Count;
					SaveChanges();
				}
				catch (Exception result2)
				{
					return result2;
				}
				if (Settings.Default.OrganizeMethod != 0)
				{
					OrganizeFile();
				}
				if ((archiveType != ".pdf") & Settings.Default.ThumbGen)
				{
					try
					{
                        String dst = Path.Combine(Application.StartupPath, Settings.Default.CoverDir) + "\\" + ID + ".jpg";
						CC.CreateThumbnail(text, dst);
						File.Delete(text);
					}
					catch (Exception result3)
					{
						return result3;
					}
				}
			}
			return null;
		}
Esempio n. 12
0
		public bool SaveChanges()
		{
			SQL sQL = new SQL();
			if (ID != -1)
			{
				if (Changes.Count > 0)
				{
					ArrayList arrayList = new ArrayList();
					if (Changes.Contains("FileSize"))
					{
						arrayList.Add("filesize=" + iFileSize);
						Changes.Remove("FileSize");
					}
					if (Changes.Contains("FileName"))
					{
						arrayList.Add("filename='" + SQL.Prepare(iFileName) + "', undo_filename='" + SQL.Prepare(UndoFilename) + "'");
						Changes.Remove("FileName");
					}
					if (Changes.Contains("Number"))
					{
						arrayList.Add("issue_no=" + iNumber);
						Changes.Remove("Number");
					}
					if (Changes.Contains("Type"))
					{
						arrayList.Add("type=" + iType);
						Changes.Remove("Type");
					}
					if (Changes.Contains("Name"))
					{
						arrayList.Add("name='" + SQL.Prepare(iName) + "'");
						Changes.Remove("Name");
					}
					if (Changes.Contains("Published"))
					{
						arrayList.Add("published='" + iPublished.ToString() + "'");
						Changes.Remove("Published");
					}
					if (Changes.Contains("SeriesVolume"))
					{
						arrayList.Add("series_vol=" + iSeriesVolume);
						Changes.Remove("Published");
					}
					if (Changes.Contains("Missing"))
					{
						arrayList.Add("missing=" + iMissing.ToString());
						Changes.Remove("Missing");
					}
					if (Changes.Contains("Comments"))
					{
						arrayList.Add("comments='" + SQL.Prepare(iComments) + "'");
						Changes.Remove("Comments");
					}
					if (Changes.Contains("Marked"))
					{
						arrayList.Add("marked=" + iMarked.ToString());
						Changes.Remove("Marked");
						Status = ((!iMissing) ? (iMarked ? 1 : (-1)) : 0);
					}
					if (Changes.Contains("Pages"))
					{
						arrayList.Add("pages=" + iPages);
						Changes.Remove("Pages");
					}
					if (Changes.Contains("SeriesID"))
					{
						arrayList.Add("series_id=" + iSeriesID);
						Changes.Remove("SeriesID");
					}
					if (Changes.Contains("MD5"))
					{
						arrayList.Add("MD5='" + iMD5 + "'");
						Changes.Remove("MD5");
					}
					if (arrayList.Count > 0)
					{
						CC.SQL.ExecQuery("UPDATE issues SET " + string.Join(",", CC.StringList(arrayList)) + " WHERE id=" + Convert.ToString(ID));
					}
					GetStatus();
					return true;
				}
				return false;
			}
			string query = "INSERT INTO issues (issue_no, name, series_id, series_vol, filesize, filename, undo_filename, pages, type, date_added, MD5, comments) VALUES (" + Number + ", '" + SQL.Prepare(Name) + "', " + SeriesID + ", " + SeriesVolume + ", " + FileSize + ", '" + SQL.Prepare(FileName) + "', '', " + Pages + ", " + Type + ", NOW(), '" + MD5 + "', '" + SQL.Prepare(Comments) + "')";
			sQL.ExecQuery(query);
			Query query2 = sQL.ExecQuery("SELECT id FROM issues WHERE filename='" + SQL.Prepare(FileName) + "'");
			query2.NextResult();
			ID = (int)query2.hash["id"];
			query2.Close();
			GetInfo();
			return true;
		}
Esempio n. 13
0
        public bool SaveChanges()
        {
            ArrayList arrayList = new ArrayList();

            if (Changes.Count > 0)
            {
                if (Changes.Contains("Name"))
                {
                    arrayList.Add("name='" + SQL.Prepare(iName) + "'");
                }
                if (Changes.Contains("Type"))
                {
                    arrayList.Add("type=" + iType);
                    Changes.Remove("Type");
                }
                CC.SQL.ExecQuery("UPDATE series SET " + string.Join(",", CC.StringList(arrayList)) + " WHERE id=" + ID);
                if (Settings.Default.OrganizeMethod != 0)
                {
                    if (Changes.Contains("Name"))
                    {
                        //Rename folders
                        string text  = Settings.Default.LibraryDir + "\\" + CC.URLize(PublisherName) + "\\" + CC.URLize(GroupName) + "\\" + CC.URLize(OldName) + "\\";
                        string text2 = Settings.Default.LibraryDir + "\\" + CC.URLize(PublisherName) + "\\" + CC.URLize(GroupName) + "\\" + CC.URLize(Name) + "\\";
                        CC.SQL.ExecQuery("UPDATE issues SET filename=" + CC.SQLReplaceLeft("filename", text, text2));
                        CC.Rename(text, text2);
                    }
                    Changes.Remove("Name");
                }
                return(true);
            }
            return(false);
        }
Esempio n. 14
0
        public void AdoptSeries(ArrayList Series)
        {
            SQL       sQL       = new SQL();
            string    text      = Settings.Default.LibraryDir + "\\" + CC.URLize(PublisherName) + "\\" + CC.URLize(Name);
            string    text2     = "";
            ArrayList arrayList = new ArrayList();

            foreach (ComicSeries item in Series)
            {
                if (Settings.Default.OrganizeMethod != 0)
                {
                    text2 = Settings.Default.LibraryDir + "\\" + CC.URLize(item.PublisherName) + "\\" + CC.URLize(item.GroupName);
                    sQL.ExecQuery("UPDATE issues SET filename=" + CC.SQLReplaceLeft("filename", text2, text) + " WHERE series_id=" + item.ID);
                    try
                    {
                        Directory.Move(text2 + "\\" + CC.URLize(item.Name), text + "\\" + CC.URLize(item.Name));
                    }
                    catch
                    {
                    }
                }
                arrayList.Add(Convert.ToString(item.ID));
                item.GroupID   = ID;
                item.GroupName = Name;
            }
            sQL.ExecQuery("UPDATE series SET group_id=" + ID + ", pub_id=" + PublisherID + " WHERE id IN (" + string.Join(",", CC.StringList(arrayList)) + ")");
        }