Example #1
0
        public static void SaveKeywords(params string[] keywordsInput)
        {
            string piracy;
            string keywords         = piracy = string.Empty;
            string keywordsToUse    = keywordsInput[0];
            string ignorables       = keywordsInput[1];
            string piracyKeywords   = keywordsInput[2];
            string piracyIgnorables = keywordsInput[3];

            if (!keywordsToUse.Trim().IsEmpty())
            {
                keywords = keywordsToUse.RemoveTrailingNewLine().Replace("\n", ", ");
            }

            if (!ignorables.Trim().IsEmpty())
            {
                keywords += ignorables.RemoveTrailingNewLine().Replace("\n", ", -").StartWith(", -");
            }

            if (!piracyKeywords.Trim().IsEmpty())
            {
                piracy = piracyKeywords.RemoveTrailingNewLine().Replace("\n", ", ");
            }

            if (!piracyIgnorables.Trim().IsEmpty())
            {
                piracy += piracyIgnorables.RemoveTrailingNewLine().Replace("\n", ", -").StartWith(", -");
            }

            Keyword.GetInstance().SaveKeywords(keywords, piracy);
        }
Example #2
0
        public static void Search(object sender, DoWorkEventArgs e)
        {
            worker = sender as BackgroundWorker;

            try
            {
                /**
                 * Preparations before searching
                 */

                List <string> foundIds      = new List <string>();
                int           eventCounter  = 0; // Counter for total found events
                int           actionCounter = 0; // how many actions have been reported
                SetupTable();
                _keywords = Keyword.GetInstance();
                _event    = Event.GetInstance();
                _event.MapEvents();
                _keywords.Map();

                if (_event.NoEvents())
                {
                    return;
                }

                /**
                 * We're good to search
                 */
                Stopwatch watch = Stopwatch.StartNew();

                Report(0, Arr.ToString(_keywords.Items, ", "), ref actionCounter);
                Report(1, _event.Events.Count, ref actionCounter);

                PerformSearch(ref eventCounter, ref actionCounter, foundIds);

                Report(2, eventCounter, ref actionCounter);
                Report(3, eventCounter, ref actionCounter);

                if (eventCounter == 0)
                {
                    Messages.NoEventLogHasKeyword();
                }

                watch.Stop();
                double elapsedTime = watch.Elapsed.TotalSeconds;

                Report(4, elapsedTime, ref actionCounter);

                e.Result = foundIds;
            }
            catch (Exception error)
            {
                worker.ReportProgress(0, "Log: Error: " + error.Message);
                Messages.ProblemOccured("searching events for keywords");
            }
        }
Example #3
0
        /// <summary>
        /// Create bug report
        /// </summary>
        /// <param name="bugreport" />
        private static void CreateBugReport(string bugreport)
        {
            try
            {
                ClearDebugFolder();

                int createdFiles = 0;

                if (Event.GetInstance().Events is List <string> && Event.GetInstance().Events.Count > 0)
                {
                    List <string> log = new List <string>();

                    for (int i = 0; i < Event.GetInstance().Events.Count; i++)
                    {
                        log.Add(i + " " + Event.GetInstance().Events[i].Replace("\n", "\r\n") + "\r\n");
                    }

                    File.WriteAllText(GetPath + "eventlog-debug.txt", Arr.ToString(log));
                    File.WriteAllText(GetPath + "eventlog.txt", Arr.ToString(Event.GetInstance().Events));
                    createdFiles++;
                }

                string bugReport = bugreport.Replace("\n", "\r\n");

                File.WriteAllText(GetPath + "problemReport.txt", bugReport);
                createdFiles++;

                if (!Keyword.GetInstance().GetAllKeywords().IsEmpty())
                {
                    File.WriteAllText(GetPath + @"Keywords.txt", Keyword.GetInstance().GetAllKeywords());
                    createdFiles++;
                }

                if (createdFiles == 0)
                {
                    Messages.ErrorLogCollection();
                }
            }
            catch (Exception e)
            {
                Exception = e.Message;
            }
        }
Example #4
0
        public static void CreateReport(string bugText)
        {
            if (Event.GetInstance().FileLocation.Exists&& Keyword.GetInstance().GetAllKeywords().IsEmpty())
            {
                Messages.NoLogSaved();

                return;
            }

            CreateBugReport(bugText);

            if (Exception != null)
            {
                Messages.ErrorLogCollection();
                return;
            }

            Messages.LogSaved();
        }
Example #5
0
        public Form1()
        {
            InitializeComponent();

            try
            {
                EventSearchEvent += Search;
                saveKeywords     += Helper.SaveKeywords;

                Helper.Form = this;
                dataGridView1.BackgroundColor   = BackColor;
                dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.Disable;

                // Instantiating
                Bootstrap.Boot();

                SetBackgroundWorkerProperties();

                Keywords = Keyword.GetInstance();
                Events   = Event.GetInstance();

                rtbKeywordsToUse.Text   = Keywords.Items.ToString("\n");
                rtbIgnorables.Text      = Keywords.Ignorable.ToString("\n");
                rtbPiracyKeywords.Text  = Keywords.Piracy.ToString("\n");
                rtbPiracyIgnorable.Text = Keywords.IgnorablePiracy.ToString("\n");

                currentCheckListState = 1;
            }
            catch (Exception error)
            {
                Helper.Report("ERROR LOADING FILES: " + error.Message + error.StackTrace);
            }

            UpdateButtonStyles();

            // Enables key events
            KeyPreview = true;
            AllowDrop  = true;

            openFileDialog1.InitialDirectory = Bootstrap.CurrentLocation;

            Helper.Report("Initialization completed!");
        }
 private static void InitProps()
 {
     Events   = Event.GetInstance();
     Keywords = Keyword.GetInstance();
 }