コード例 #1
0
ファイル: Hometask6_2.cs プロジェクト: VynarN/Workshop
        static void Hometask6_2()
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            var appSettings = ConfigurationManager.GetSection("Hometask6/ExcelFileComparator") as NameValueCollection;

            if (appSettings != null)
            {
                var file             = appSettings.Get("File");
                var fileToSaveResult = appSettings.Get("Result");
                var ui              = appSettings.Get("UI");
                var userInterface   = GetUserInteface(ui, fileToSaveResult);
                var listsComparator = new ExcelListsComparator(file, ('A', 'B'), userInterface);
                listsComparator.Compare();
            }
            else
            {
                Logger.Log(new SettingsPropertyNotFoundException());
            }

            watch.Stop();
            var elapsedSeconds = (watch.ElapsedMilliseconds / 1000.0);

            Console.WriteLine("Execution time: " + elapsedSeconds);
            DelayAndClear();
        }
コード例 #2
0
ファイル: OneDriveTask.cs プロジェクト: VynarN/Workshop
        static void OneDriveTask()
        {
            var appSettings = ConfigurationManager.GetSection("Hometask6/OneDriveHomework") as NameValueCollection;

            if (appSettings != null)
            {
                var notParsedLink    = appSettings.Get("downloadLink");
                var fileName         = appSettings.Get("fileName");
                var fileToSaveResult = appSettings.Get("result");
                var directory        = appSettings.Get("directory");
                var ui      = appSettings.Get("UI");
                var browser = appSettings.Get("browser");

                var userInterface = GetUserInteface(ui, fileToSaveResult);

                // Link specified in app.config cannot contain a symbol '&' so it is replaced by '???'
                // thus it need to be parsed to use it in the program.
                var parsedLink = OneDriveTaskAuxiliary.ParseLink(notParsedLink);

                // Open the browser to download the referenced file.
                var proc = Process.Start(browser, parsedLink);

                // Make sure the download is complete.
                proc.EnableRaisingEvents = true;
                proc.Exited += new EventHandler((sender, args) =>
                {
                    // This should be done to distinguish copies of the file which may differ
                    // by their names i. e. filename(_number_)
                    var downloadedFile = OneDriveTaskAuxiliary.GetLatestDownloadedFile(fileName, directory);

                    var listsComparator = new ExcelListsComparator(downloadedFile, ('A', 'B'), userInterface);

                    listsComparator.Compare();
                });

                // Wait here until all the operations are completed.
                while (!proc.HasExited)
                {
                }

                DelayAndClear();
            }
            else
            {
                Logger.Log(new SettingsPropertyNotFoundException());
            }
        }