Ejemplo n.º 1
0
        /// <summary>
        /// Writes out the registration information
        /// </summary>
        public static bool Register(string key)
        {
            lock (LockKey)
            {
                string rawKey = key;

                _regType  = RegTypes.Free;
                _unlocked = false;

                if (rawKey != ProKey)
                {
                    return(false);
                }

                _unlocked = true;
                key       = EncodeKey(key);

                try
                {
                    // this can fail due to permissions in the install folder
                    File.WriteAllText(RegisterFileInstall, key);
                }
                catch
                {
                    // write in the common folder
                    LanguageUtils.IgnoreErrors(() => File.WriteAllText(RegisterFile, key));
                }

                _regType = RegTypes.Professional;
            }
            return(true);
        }
Ejemplo n.º 2
0
        private void createOutputFile()
        {
            if (File.Exists(OutputPath))
            {
                LanguageUtils.IgnoreErrors(() => File.Delete(OutputPath));
            }
            else if (!Directory.Exists(OutDir))
            {
                Directory.CreateDirectory(OutDir);
            }
            object misValue = System.Reflection.Missing.Value;

            if (oXL == null)
            {
                MessageBox.Show("Excel is not installed!!");
                return;
            }

            oWB                = oXL.Workbooks.Add(misValue);
            oSheet             = (Excel.Worksheet)oWB.Worksheets.get_Item(1);
            oSheet.Cells[1, 1] = "SYMBOL";
            oSheet.Cells[1, 2] = "DATE";
            oSheet.Cells[1, 3] = "TIME";
            oSheet.Cells[1, 4] = "AVERAGE IV";

            LanguageUtils.IgnoreErrors(() => oWB.SaveAs(OutputPath));

            oXL.Quit();
        }
Ejemplo n.º 3
0
        internal static void UnRegister()
        {
            _unlocked = false;
            _regType  = RegTypes.Free;

            LanguageUtils.IgnoreErrors(() => File.Delete(RegisterFile));
            LanguageUtils.IgnoreErrors(() => File.Delete(RegisterFileInstall));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds a new word to add-on the dictionary for a given locale
 /// </summary>
 /// <param name="word"></param>
 /// <param name="lang"></param>
 public static bool AddWordToDictionary(string word, string lang = "en-US")
 {
     return(LanguageUtils.IgnoreErrors(() =>
     {
         var dictPath = Path.Combine(ExternalDictionaryFolder, lang + "_custom.txt");
         File.AppendAllText(dictPath, word + "\r\n");
         _spellChecker.Add(word);
     }));
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Handles files that were dropped on the tree view
        /// </summary>
        /// <param name="files">array of files</param>
        void HandleDroppedFiles(string[] files)
        {
            if (files == null)
            {
                return;
            }

            Window.ShowStatusProgress("Copying files and folders...");
            WindowUtilities.DoEvents();

            string errors = "";

            Task.Run(() =>
            {
                foreach (var file in files)
                {
                    var isFile = File.Exists(file);
                    var isDir  = Directory.Exists(file);
                    if (!isDir && !isFile)
                    {
                        continue;
                    }

                    string nPath;
                    if (isFile)
                    {
                        nPath = Path.Combine(ActivePathItem.FullPath, Path.GetFileName(file));
                        if (!LanguageUtils.IgnoreErrors(() => File.Copy(file, nPath, overwrite: true)))
                        {
                            errors += $"{nPath},";
                        }
                    }
                    else
                    {
                        nPath = Path.Combine(ActivePathItem.FullPath, Path.GetFileName(file));
                        if (!LanguageUtils.IgnoreErrors(() => FileUtils.CopyDirectory(file, nPath)))
                        {
                            errors += $"{nPath},";
                        }
                    }
                }
                Dispatcher.InvokeAsync(() =>
                {
                    if (string.IsNullOrEmpty(errors))
                    {
                        Window.ShowStatusSuccess($"Files and Folders copied.");
                    }
                    else
                    {
                        Window.ShowStatusError($"There were errors copying files and folders.");
                    }
                });
            });
        }
Ejemplo n.º 6
0
        public void RemoveUrls()
        {
            OutputTextBox.AppendText("Unblocking ad servers...");

            var newFile = File.ReadAllLines(_hostsPath)
                          .Where(line => !AdServerUrls().Any(s => string.Equals(line, $"{Mapping} {s}", StringComparison.OrdinalIgnoreCase)))
                          .ToList();

            LanguageUtils.IgnoreErrors <ArgumentOutOfRangeException>(() => newFile.RemoveAt(newFile.IndexOf(Header)));

            File.WriteAllLines(_hostsPath, newFile);

            OutputTextBox.AppendText(SpareForm.TaskFinishedString, Color.Green);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Call this method to shut down the VBCSCompiler if our
        /// application started it.
        /// </summary>
        public static void ShutdownRoslyn()
        {
            var processes = Process.GetProcessesByName("VBCSCompiler");

            if (processes != null)
            {
                foreach (var process in processes)
                {
                    // only shut down 'our' VBCSCompiler
                    var fn = GetMainModuleFileName(process);
                    if (fn.Contains(App.InitialStartDirectory, StringComparison.InvariantCultureIgnoreCase))
                    {
                        LanguageUtils.IgnoreErrors(() => process.Kill());
                    }
                }
            }
        }
Ejemplo n.º 8
0
 public void FillCache()
 {
     LanguageUtils.IgnoreErrors(() => _userLogic.GetAllUsersAsync());
     LanguageUtils.IgnoreErrors(() => _userRolesLogic.GetUserRolesAsync());
 }
Ejemplo n.º 9
0
 public void ClreaAllCache()
 {
     LanguageUtils.IgnoreErrors(() => _userLogic.ClearUsersCache());
     LanguageUtils.IgnoreErrors(() => _userRolesLogic.ClearUserRolesCache());
 }
Ejemplo n.º 10
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (halt)
            {
                return;
            }

            else
            {
                if (startBtn.Text == "View Output")
                {
                    Process.Start(SelectedFolder + "/Output");
                    return;
                }


                startBtn.Enabled = false;
                label2.Visible   = true;

                // CREATE OUTPUT FILE///////////////////////////////////////////////////////
                if (File.Exists(OutputPath))
                {
                    LanguageUtils.IgnoreErrors(() => File.Delete(OutputPath));
                }
                else if (!Directory.Exists(OutDir))
                {
                    Directory.CreateDirectory(OutDir);
                }

                // CHECK IF EXCEL IS INSTALLED/////////////////////////////////////////////////
                if (oXL == null)
                {
                    MessageBox.Show("Excel is not installed!!");
                    return;
                }
                // INSERT HEADER ROW///////////////////////////////////////////////////
                object misValue = System.Reflection.Missing.Value;
                oWB                = oXL.Workbooks.Add(misValue);
                oSheet             = (Excel.Worksheet)oWB.Worksheets.get_Item(1);
                oSheet.Cells[1, 1] = "SYMBOL";
                oSheet.Cells[1, 2] = "DATE";
                oSheet.Cells[1, 3] = "TIME";
                oSheet.Cells[1, 4] = "AVERAGE IV";


                // CALCULATE AVERAGE FROM FILES AND PUSH RESULTS TO OUTPUT FILE//////////////

                foreach (string excelFile in Folder)
                {
                    double avg = calculateAVG(getMIDIV(excelFile));
                    fsymbol = SplitFilename(excelFile, 1);
                    fdate   = SplitFilename(excelFile, 2);
                    ftime   = SplitFilename(excelFile, 3);

                    xlRange = oSheet.UsedRange;
                    int rowCount = xlRange.Rows.Count;

                    oSheet.Cells[rowCount + 1, 1] = fsymbol;
                    oSheet.Cells[rowCount + 1, 2] = fdate;
                    oSheet.Cells[rowCount + 1, 3] = ftime;
                    oSheet.Cells[rowCount + 1, 4] = avg;
                }
                LanguageUtils.IgnoreErrors(() => oWB.SaveAs(OutputPath));

                oXL.Quit();

                label3.Visible   = true;
                startBtn.Enabled = true;
                startBtn.Text    = "View Output";
            }
        }