IssueGeneralWarning() публичный Метод

public IssueGeneralWarning ( string message, string submessage, string file ) : void
message string
submessage string
file string
Результат void
Пример #1
0
        public static void SendAllTorrents()
        {
            try
            {
                ErrorWindow ew = new ErrorWindow();

                if (!DirectoryHandler.GetFileExists(SettingsHandler.GetTorrentClientFolder() + "\\uTorrent.exe"))
                {
                    ew.IssueGeneralWarning("Be sure uTorrent folder is correct", "uTorrent.exe does not exist", null);
                }
                else
                {
                    table.Columns["Handled"].ReadOnly = false;
                    table.Columns["Error"].ReadOnly = false;

                    foreach (DataRow row in dataset.Tables[0].Rows)
                    {
                        try
                        {
                            if (!(bool)row["Error"] && !(bool)row["Handled"] && !row["File Path"].Equals(DBNull.Value))
                            {
                                if (DirectoryHandler.GetFileExists((string)row["File Path"]))
                                {
                                    try
                                    {
                                        Process sendTorrentProcess = new Process();
                                        //torrentClient.exe /directory "C:\Save Path" "D:\Some folder\your.torrent"

                                        string fullArgument = "/directory " + "\"" + row["Save Structure"] + "\" "
                                            + "\"" + row["File Path"] + "\"";
                                        sendTorrentProcess.StartInfo.WorkingDirectory = SettingsHandler.GetTorrentClientFolder();
                                        sendTorrentProcess.StartInfo.Arguments = fullArgument;
                                        sendTorrentProcess.StartInfo.FileName = SettingsHandler.GetTorrentClient();

                                        sendTorrentProcess.Start();

                                        Thread.Sleep(100);
                                        sendTorrentProcess.Dispose();
                                        sendTorrentProcess.Close();

                                        row.BeginEdit();
                                        row["Handled"] = true;
                                        row.EndEdit();

                                    }
                                    catch (Exception e)
                                    {
                                        Debug.Print(e.ToString());
                                    }
                                }
                                else
                                {
                                    row.BeginEdit();
                                    row["Error"] = true;
                                    row["Birth"] = "File does not exist";
                                    row.EndEdit();
                                }
                            }
                            else if (row["File Path"].Equals(DBNull.Value))
                            {
                                row.BeginEdit();
                                row["Error"] = true;
                                row["Site Origin"] = "No file path";
                                row.EndEdit();
                            }
                        }
                        catch (Exception e)
                        {
                            row.BeginEdit();
                            row["Error"] = true;
                            row["Birth"] = e.Message;
                            row.EndEdit();
                        }
                    }
                    TorrentXMLHandler.table.Columns["Handled"].ReadOnly = true;
                    TorrentXMLHandler.table.Columns["Error"].ReadOnly = true;
                    TorrentXMLHandler.table.AcceptChanges();
                }
            }
            catch (Exception e)
            {
                ErrorWindow ew = new ErrorWindow();
                ew.IssueGeneralWarning("Fatal Error", "Please report", e.Message + "\n" + e.StackTrace);
            }
        }
Пример #2
0
        //To be called only from DoWork
        public List<FileInfo> UnzipFiles(string[] zipFiles)
        {
            List<FileInfo> items = new List<FileInfo>();
            List<FileInfo> fileinfos = new List<FileInfo>();
            foreach (string zipfile in zipFiles)
            {
                try
                {
                    fileinfos.Add(new FileInfo(zipfile));
                }
                catch (Exception e)
                {
                    LogError(e.Message + "\n" + e.StackTrace);
                }
            }

            FastZip fz = new FastZip();
            ErrorWindow ew = new ErrorWindow();

            string[] files = null;
            string filename;
            DirectoryInfo destination;
            int total = zipFiles.Length;
            double progress = 0;
            double count = 0;
            foreach (FileInfo zipfile in fileinfos)
            {
                filename = zipfile.Name;
                filename = filename.Replace(zipfile.Extension, "");
                string dest = SettingsHandler.GetTorrentSaveFolder() + @"\[CSL]--Temp\" + filename + @"\";
                destination = new DirectoryInfo(dest);
                if (!destination.Exists)
                {
                    try
                    {
                        destination.Create();
                    }
                    catch (Exception e)
                    {
                        LogError(e.Message + "\n" + e.StackTrace);
                    }
                }

                try
                {
                    fz.ExtractZip(zipfile.FullName, destination.FullName, ".torrent");
                }
                catch (Exception) { ew.IssueGeneralWarning("No action necessary", "Warning: Could not unzip " + filename, zipfile.Name); }

                try
                {
                    files = Directory.GetFiles(destination.FullName,
                        "*.torrent", SearchOption.AllDirectories);
                }
                catch (DirectoryNotFoundException) { ew.IssueGeneralWarning("No action necessary", "Warning: " + filename + "was empty", zipfile.Name); }

                finally
                {
                    foreach (string file in files)
                    {
                        try
                        {
                            items.Add(new FileInfo(file));
                        }
                        catch (Exception e)
                        {
                            LogError(e.Message + "\n" + e.StackTrace);
                        }
                    }
                }

                progress = (++count / total) * 100;

                if (progress <= 100 && progress >= 0)
                    ReportProgress((int)progress);
            }

            return items;
        }
Пример #3
0
        public static string SendTorrent(string save, string path)
        {
            ErrorWindow ew = new ErrorWindow();

            if (!DirectoryHandler.GetFileExists(SettingsHandler.GetTorrentClientFolder() + "\\uTorrent.exe"))
            {
                ew.IssueGeneralWarning("Be sure uTorrent folder is correct", "uTorrent.exe does not exist", null);
                return "uTorrent.exe does not exist";
            }
            else
            {
                try
                {
                    Process sendTorrentProcess = new Process();
                    //torrentClient.exe /directory "C:\Save Path" "D:\Some folder\your.torrent"
                    if (DirectoryHandler.GetFileExists(path))
                    {
                        string fullArgument = "/directory " + "\"" + save + "\" "
                            + "\"" + path + "\"";
                        sendTorrentProcess.StartInfo.WorkingDirectory = SettingsHandler.GetTorrentClientFolder();
                        sendTorrentProcess.StartInfo.Arguments = fullArgument;
                        sendTorrentProcess.StartInfo.FileName = SettingsHandler.GetTorrentClient();

                        sendTorrentProcess.Start();

                        Thread.Sleep(100);
                        sendTorrentProcess.Dispose();
                        sendTorrentProcess.Close();
                    }
                    else
                    {
                        return "File does not exist";
                    }
                }
                catch (Exception e)
                {
                    if (path == null || path == "")
                    {
                        return "Empty file path";
                    }
                    else
                    {
                        return e.Message;
                    }
                }

                return "SUCCESS";
            }
        }
Пример #4
0
        public static string GetHTMLLookUp(string value)
        {
            ErrorWindow ew = new ErrorWindow();
            StreamReader sr = null;

            string[] ab = new string[2];
            string a;
            string b;
            int c = 0;
            string[] lines = null;
            string replace;

            if (value == null)
                return value;
            try
            {
                sr = new StreamReader(System.Windows.Forms.Application.StartupPath + @"\HTML-Look-Up.txt");

                while (!sr.EndOfStream)
                {
                    ab = sr.ReadLine().Split(' ');
                    a = ab[0];
                    b = ab[1];

                    if (value.Contains(a) || value.Contains(b))
                    {
                        while (value.Contains(a))
                        {
                            replace = sr.ReadLine();
                            value = value.Replace(a, replace);
                        }
                        while (value.Contains(b))
                        {
                            replace = sr.ReadLine();
                            value = value.Replace(b, replace);
                        }
                    }
                    else
                    {
                        sr.ReadLine();
                    }
                }
            }
            catch (FileNotFoundException)
            {
                ew.IssueGeneralWarning("HTML replacing will not occur", "Could not find HTML-Look-Up.txt...", null);
            }
            catch (Exception e)
            {
                ew.IssueGeneralWarning("Error..", lines[c], e.Message);
            }
            finally
            {
                if (sr != null)
                    sr.Dispose();
            }

            return value;
        }