Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ConfigFileHelper cfg = new ConfigFileHelper(configFileLocation.Text)
            {
                IncludePatterns = IncludePatterns,
                BlockSizeKB     = (uint)numBlockSizeKB.Value,
                Nohidden        = advSettingsList[3].CheckState,
                AutoSaveGB      = (uint)numAutoSaveGB.Value
            };

            foreach (DataGridViewRow row in exludedFilesView.Rows)
            {
                string value = string.Format("{0}", row.Cells[0].Value);
                if (!string.IsNullOrWhiteSpace(value))
                {
                    cfg.ExcludePatterns.Add(value);
                }
            }
            foreach (string text in snapShotSourcesTreeView.Nodes.Cast <TreeNode>().Select(node => node.Text).Where(text => !string.IsNullOrWhiteSpace(text)))
            {
                cfg.SnapShotSources.Add(text);
                cfg.ContentFiles.Add(text);
            }
            string trim5 = raid5Location.Text.Trim();

            if (!string.IsNullOrEmpty(trim5))
            {
                cfg.ParityFile = trim5;
                FileInfo fi = new FileInfo(trim5);
                cfg.ContentFiles.Add(fi.DirectoryName);
                string trim6 = raid6Location.Text.Trim();
                if (!string.IsNullOrEmpty(trim6))
                {
                    cfg.QParityFile = trim6;
                    fi = new FileInfo(trim6);
                    cfg.ContentFiles.Add(fi.DirectoryName);
                }
            }
            string writeResult;

            if (!string.IsNullOrEmpty(writeResult = cfg.Write()))
            {
                MessageBoxExt.Show(this, writeResult, "Config Write Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Properties.Settings.Default.ConfigFileIsValid    = ValidateData();
                Properties.Settings.Default.SnapRAIDFileLocation = snapRAIDFileLocation.Text;
                Properties.Settings.Default.ConfigFileLocation   = configFileLocation.Text;
                Properties.Settings.Default.UseVerboseMode       = advSettingsList[1].CheckState;
                Properties.Settings.Default.UseGUIMode           = advSettingsList[2].CheckState;
                Properties.Settings.Default.FindByNameInSync     = advSettingsList[3].CheckState;
                // http://elucidate.codeplex.com/workitem/10114
                Properties.Settings.Default.HiddenFilesExcluded = advSettingsList[4].CheckState;
                Properties.Settings.Default.RunWithoutCapture   = advSettingsList[0].CheckState;

                Properties.Settings.Default.Save();
                UnsavedChangesMade = false;
            }
        }
Esempio n. 2
0
        private void ElucidateForm_Shown(object sender, EventArgs e)
        {
            string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
            if (args.Contains(@"-H") ||
                args.Contains(@"--help")
                )
            {
                commonTab.PerformArgs(args);
                commonTab.SetCommonButtonsEnabledState(false); // Prevent button pushing !
            }
            else
            {
                LoadConfigFile();

                // display any warnings from the config validation
                if (srConfig.HasWarnings)
                {
                    MessageBoxExt.Show(
                        this,
                        $"There are warnings for the configuration file:{Environment.NewLine} - {string.Join(" - ", srConfig.ConfigWarnings)}",
                        "Configuration File Warnings",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);
                }
                else
                {
                    commonTab.PerformArgs(args);
                }
            }
        }
Esempio n. 3
0
 private void ExecuteDistributionLogCommand(string posNo)
 {
     if (string.IsNullOrEmpty(posNo))
     {
         MessageBoxExt.Show("提示", "获取POS编号失败!", MessageImageType.Info);
         return;
     }
     LocalUIManager.DistributionLog(posNo);
 }
Esempio n. 4
0
        /// <summary>
        /// 启动浏览器
        /// </summary>
        /// <param name="url">显示URL</param>
        internal static void OpenBrowser(string url)
        {
            UIManager.OpenDefaultBrower(url);
            var result = MessageBoxExt.ShowPay();

            if (result.HasValue && result.Value)
            {
                Messenger.Default.Send(true, "CloseProductBuy");
            }
        }
Esempio n. 5
0
        //private void tabControl_Selected(object sender, TabControlEventArgs e)
        //{

        //    else if (e.TabPage == tabCoveragePage)
        //    {
        //        if (!Properties.Settings.Default.ConfigFileIsValid) return;
        //        try
        //        {
        //            ConfigFileHelper cfg = new ConfigFileHelper(Properties.Settings.Default.ConfigFileLocation);
        //            cfg.Read();
        //            List<string> displayLines = cfg.SnapShotSources;
        //            // Add the Parity lines to show the amount of drive space currently occupied by SnapRaid
        //            displayLines.Add(new FileInfo(cfg.ParityFile1).DirectoryName);
        //            if (!string.IsNullOrEmpty(cfg.ParityFile2))
        //            {
        //                displayLines.Add(new FileInfo(cfg.ParityFile2).DirectoryName);
        //            }
        //            driveSpace.StartProcessing(displayLines);
        //        }
        //        catch
        //        {
        //            // ignored
        //        }
        //    }
        //}

        //private void tabControl_Deselected(object sender, TabControlEventArgs e)
        //{
        //    if (e.TabPage != RecoveryOperations) return;
        //    if (WindowState == FormWindowState.Maximized)
        //    {
        //        WindowState = FormWindowState.Normal;
        //    }
        //}

        private void btnRemoveOutput_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes != MessageBoxExt.Show(this, @"Are you sure you want to perform this task ?",
                                                       "Remove SnapRAID Output files.", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                return;
            }

            try
            {
                ConfigFileHelper cfg = new ConfigFileHelper(Properties.Settings.Default.ConfigFileLocation);
                if (!cfg.Read())
                {
                    MessageBoxExt.Show(this, "Failed to read the config file.", "Config Read Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                FileInfo fi;
                if (!string.IsNullOrEmpty(cfg.ParityFile1))
                {
                    fi = new FileInfo(cfg.ParityFile1);
                    if (fi.Exists)
                    {
                        fi.Delete();
                    }
                }
                if (!string.IsNullOrEmpty(cfg.ParityFile2))
                {
                    fi = new FileInfo(cfg.ParityFile2);
                    if (fi.Exists)
                    {
                        fi.Delete();
                    }
                }

                if (cfg.ContentFiles == null)
                {
                    return;
                }

                foreach (string contentFile in cfg.ContentFiles.Where(contentFile => !string.IsNullOrEmpty(contentFile)))
                {
                    fi = new FileInfo(contentFile);
                    if (fi.Exists)
                    {
                        fi.Delete();
                    }
                }
            }
            catch (Exception ex)
            {
                //ExceptionHandler.ReportException(ex, "btnRemoveOutput_Click has thrown: ");
                KryptonMessageBox.Show(this, ex.Message, @"Remove SnapRAID Output files.");
            }
        }
Esempio n. 6
0
 private void btnRemoveOutput_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes == MessageBoxExt.Show(this, "Are you sure you want to perform this task ?",
                                                "Remove SnapRAID Output files.", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
     {
         try
         {
             ConfigFileHelper cfg = new ConfigFileHelper(Properties.Settings.Default.ConfigFileLocation);
             string           readResult;
             if (!string.IsNullOrEmpty(readResult = cfg.Read()))
             {
                 MessageBoxExt.Show(this, readResult, "Config Read Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 FileInfo fi;
                 if (!string.IsNullOrEmpty(cfg.ParityFile))
                 {
                     fi = new FileInfo(cfg.ParityFile);
                     if (fi.Exists)
                     {
                         fi.Delete();
                     }
                 }
                 if (!string.IsNullOrEmpty(cfg.QParityFile))
                 {
                     fi = new FileInfo(cfg.QParityFile);
                     if (fi.Exists)
                     {
                         fi.Delete();
                     }
                 }
                 if (cfg.ContentFiles != null)
                 {
                     foreach (string contentFile in cfg.ContentFiles.Where(contentFile => !string.IsNullOrEmpty(contentFile)))
                     {
                         fi = new FileInfo(contentFile);
                         if (fi.Exists)
                         {
                             fi.Delete();
                         }
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Log.Error(ex, "btnRemoveOutput_Click has thrown: ");
             MessageBox.Show(this, ex.Message, "Remove SnapRAID Output files.");
         }
     }
 }
Esempio n. 7
0
        private void ExecuteRecoveryCommand(PosInfoDataObject posInfo)
        {
            bool?isRecovery = MessageBoxExt.Show("提示", "待该POS机从商户处完成收回才可以\r\n进行回收,是否确认并回收?", MessageImageType.Info, MessageBoxButtonType.OKCancel);

            if (isRecovery.HasValue && isRecovery.Value)
            {
                CommunicateManager.Invoke <ITPosService>(service =>
                {
                    service.RetrievePos(posInfo.CompanyID, posInfo.PosNo);
                    this.Initialize();
                }, UIManager.ShowErr);
            }
        }
Esempio n. 8
0
 private void Settings_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (UnsavedChangesMade &&
         (e.CloseReason == CloseReason.UserClosing)
         )
     {
         if (DialogResult.No == MessageBoxExt.Show(this, "You have made changes that have not been saved.\n\nDo you wish to discard and exit?",
                                                   "Settings have changed..", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
         {
             e.Cancel = true;
         }
     }
 }
Esempio n. 9
0
        /// <summary>
        /// 启动浏览器
        /// </summary>
        /// <param name="url">显示URL</param>
        internal static void OpenBrowser(string url)
        {
            var proc = new System.Diagnostics.Process {
                StartInfo = { FileName = url }
            };

            proc.Start();
            var result = MessageBoxExt.ShowPay();

            if (result.HasValue && result.Value)
            {
                Messenger.Default.Send(true, "CloseSMSPay");
            }
        }
Esempio n. 10
0
        private void ReadConfigDetails()
        {
            exludedFilesView.Rows.Clear();
            snapShotSourcesTreeView.Nodes.Clear();

            if (!File.Exists(configFileLocation.Text))
            {
                if (Properties.Settings.Default.UseWindowsSettings)
                {
                    exludedFilesView.Rows.Add(@"\$RECYCLE.BIN\");
                    exludedFilesView.Rows.Add(@"\System Volume Information\");
                    exludedFilesView.Rows.Add(@"*.bak");
                    exludedFilesView.Rows.Add(@"Thumbs.db");
                }
                else
                {
                    exludedFilesView.Rows.Add(@"*.bak");
                    exludedFilesView.Rows.Add(@"/lost+found/");
                    exludedFilesView.Rows.Add(@"/tmp/");
                }
            }
            else
            {
                ConfigFileHelper cfg = new ConfigFileHelper(configFileLocation.Text);
                string           readResult;
                if (!string.IsNullOrEmpty(readResult = cfg.Read()))
                {
                    MessageBoxExt.Show(this, readResult, "Config Read Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                IncludePatterns               = cfg.IncludePatterns;
                numBlockSizeKB.Value          = cfg.BlockSizeKB;
                advSettingsList[3].CheckState = cfg.Nohidden;
                numAutoSaveGB.Value           = cfg.AutoSaveGB;
                foreach (string excludePattern in cfg.ExcludePatterns.Where(excludePattern => !string.IsNullOrWhiteSpace(excludePattern)))
                {
                    exludedFilesView.Rows.Add(excludePattern);
                }
                foreach (string source in cfg.SnapShotSources.Where(source => !string.IsNullOrWhiteSpace(source)))
                {
                    snapShotSourcesTreeView.Nodes.Add(new TreeNode(source, 7, 7));
                }
                raid5Location.Text = cfg.ParityFile;
                raid6Location.Text = cfg.QParityFile;
            }
            UnsavedChangesMade = false;
            driveSpace.StartProcessing((from TreeNode node in snapShotSourcesTreeView.Nodes select node.Text).ToList());
        }
Esempio n. 11
0
        private void ElucidateForm_Shown(object sender, EventArgs e)
        {
            LoadConfigFile();

            // display any warnings from the config validation
            if (srConfig.HasWarnings)
            {
                MessageBoxExt.Show(
                    this,
                    $"There are warnings for the configuration file:{Environment.NewLine} - {string.Join(" - ", srConfig.ConfigWarnings)}",
                    "Configuration File Warnings",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }
            else
            {
                string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
                if (args.Any())
                {
                    // https://github.com/commandlineparser/commandline
                    ParserResult <AllOptions> optsResult = Parser.Default.ParseArguments <AllOptions>(args);
                    optsResult.WithParsed <AllOptions>(DisplayStdOptions);
                    optsResult.WithNotParsed(DisplayErrors);
                    ParserResult <object> parserResult = Parser.Default.ParseArguments <SyncVerb, DiffVerb, CheckVerb, FixVerb, ScrubVerb, DupVerb, StatusVerb>(args);
                    parserResult.WithNotParsed(DisplayErrors);
                    // Order is important as commands "Can" be chained"
                    // See http://www.snapraid.it/manual scrubbing for an indication of order
                    parserResult.WithParsed <DiffVerb>(verb => DisplayAndCall(verb, Diff_Click));
                    parserResult.WithParsed <CheckVerb>(verb => DisplayAndCall(verb, Check_Click));
                    parserResult.WithParsed <SyncVerb>(verb => DisplayAndCall(verb, Sync_Click));
                    parserResult.WithParsed <ScrubVerb>(verb => DisplayAndCall(verb, Scrub_Click));
                    parserResult.WithParsed <DupVerb>(verb => DisplayAndCall(verb, DupFinder_Click));
                    parserResult.WithParsed <StatusVerb>(verb => DisplayAndCall(verb, btnStatus_Click));
                    parserResult.WithParsed <FixVerb>(verb => DisplayAndCall(verb, Fix_Click));
                    // Verbs not done as they do not have buttons yet
                    // list
                    // smart
                    // up
                    // down
                    // pool
                    // devices
                    // touch
                    // rehash
                }
            }
        }
Esempio n. 12
0
        private void ElucidateForm_Shown(object sender, EventArgs e)
        {
            LoadConfigFile();

            // display any warnings from the config validation
            if (srConfig.HasWarnings)
            {
                MessageBoxExt.Show(
                    this,
                    $"There are warnings for the configuration file:{Environment.NewLine} - {string.Join(" - ", srConfig.ConfigWarnings)}",
                    "Configuration File Warnings",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }
            else
            {
                commonTab.PerformArgs(Environment.GetCommandLineArgs().Skip(1).ToArray());
            }
        }
Esempio n. 13
0
        private void ElucidateForm_Shown(object sender, EventArgs e)
        {
            ConfigFileHelper cfg = new ConfigFileHelper(Properties.Settings.Default.ConfigFileLocation);

            if (!cfg.Read())
            {
                MessageBoxExt.Show(this, "Failed to read the config file.", "Config Read Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Properties.Settings.Default.ConfigFileIsValid = cfg.ConfigFileExists;

            EnableIfValid(Properties.Settings.Default.ConfigFileIsValid);

            if (!Properties.Settings.Default.ConfigFileIsValid)
            {
                // open the settings form since the config is not valid
                settingsToolStripMenuItem_Click(sender, e);
            }
        }
Esempio n. 14
0
        private void deleteAllSnapRAIDRaidFilesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <string> parityFiles = new List <string>();

            List <string> contentFiles = new List <string>();

            if (!string.IsNullOrWhiteSpace(srConfig.ParityFile1))
            {
                parityFiles.Add(srConfig.ParityFile1);
            }

            if (!string.IsNullOrWhiteSpace(srConfig.ParityFile2))
            {
                parityFiles.Add(srConfig.ParityFile2);
            }

            if (!string.IsNullOrWhiteSpace(srConfig.ZParityFile))
            {
                parityFiles.Add(srConfig.ZParityFile);
            }

            if (!string.IsNullOrWhiteSpace(srConfig.ParityFile3))
            {
                parityFiles.Add(srConfig.ParityFile3);
            }

            if (!string.IsNullOrWhiteSpace(srConfig.ParityFile4))
            {
                parityFiles.Add(srConfig.ParityFile4);
            }

            if (!string.IsNullOrWhiteSpace(srConfig.ParityFile5))
            {
                parityFiles.Add(srConfig.ParityFile5);
            }

            if (!string.IsNullOrWhiteSpace(srConfig.ParityFile6))
            {
                parityFiles.Add(srConfig.ParityFile6);
            }

            foreach (string file in srConfig.ContentFiles)
            {
                contentFiles.Add(file);
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(@"Are you sure you want to remove the files below?");

            sb.AppendLine(@"This action cannot be undone.");

            sb.AppendLine();

            foreach (string file in parityFiles)
            {
                sb.AppendLine($@"Parity File: {file}");
            }

            foreach (string file in contentFiles)
            {
                sb.AppendLine($@"Content File: {file}");
            }

            DialogResult result = KryptonMessageBox.Show(
                this,
                sb.ToString(),
                @"Delete All SnapRAID Files",
                MessageBoxButtons.YesNoCancel,
                MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                try
                {
                    foreach (string file in parityFiles)
                    {
                        File.Delete(file);
                    }

                    foreach (string file in contentFiles)
                    {
                        File.Delete(file);
                    }

                    MessageBoxExt.Show(this, @"The SnapRAID files have been removed", @"Files Removed");
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }
            }
        }
Esempio n. 15
0
        private async Task <bool> TrySendMessage(string messageText, long userId)
        {
            while (true)
            {
                try
                {
                    VkApp.Api.Messages.Send(new VkNet.Model.RequestParams.MessagesSendParams
                    {
                        Message     = messageText,
                        UserId      = userId,
                        Attachments = Attachments,
                        RandomId    = VkApp.GetRandomId(),
                        CaptchaKey  = AnticaptchaWorker.LastCaptcha,
                        CaptchaSid  = AnticaptchaWorker.LastCaptchaSid,
                    });

                    return(true);
                }
                catch (CaptchaNeededException captcha)
                {
                    AnticaptchaWorker.LastCaptchaSid = captcha.Sid;
                    AnticaptchaWorker.LastCaptchaUri = captcha.Img.AbsoluteUri;

                    var anticaptchaBalance = AnticaptchaWorker.Api.GetBalance();                     // TODO: NullReferenceException.

                    if (AnticaptchaWorker.Api != null)
                    {
                        this.Text = $"Главная | Баланс: {anticaptchaBalance} | Решается капча";
                    }
                    else
                    {
                        this.Text = $"Главная | Баланс: --- | Решается капча";
                    }

                    using (var captchaForm = new CaptchaForm(captcha.Img.AbsoluteUri))
                    {
                        if (AnticaptchaWorker.Api == null && (true || anticaptchaBalance < 0.005))                         // TODO: чего нахуй
                        {
                            captchaForm.ShowDialog();
                        }

                        // Wait
                        while (AnticaptchaWorker.LastCaptcha == null)
                        {
                            continue;
                        }
                    }

                    if (AnticaptchaWorker.Api != null)
                    {
                        this.Text = $"Главная | Баланс: {AnticaptchaWorker.Api.GetBalance()} | {AnticaptchaWorker.LastCaptcha}";
                    }
                }
                catch (TooManyRequestsException)
                {
                    this.Text = $"Главная | Баланс: {AnticaptchaWorker.Api.GetBalance()} | Слишком много запросов в секунду.";
                    await Task.Delay(1000);
                }
                catch (TooMuchSentMessagesException ex)
                {
                    string errormessage = $"Лимит на рассылку исчерпан. Рассылка будет остановлена. \n\n" +
                                          $"  Код ошибки: {ex.ErrorCode}\n{ex.Message}";
                    MessageBoxExt.ShowInNewThread(errormessage);
                    return(false);
                }
                catch (AccessDeniedException ex)
                {
                    string errormessage = $"Отказано в доступе. \nПользователь ID: {userId}\n\n" +
                                          $"  Код ошибки: {ex.ErrorCode}\n{ex.Message}";

                    MessageBoxExt.ShowInNewThread(errormessage);
                    return(false);
                }
                catch (UnknownException ex)
                {
                    string errormessage = $"Неизвестная ошибка на стороне VK. \nПользователь ID: {userId}\n\n" +
                                          $"  Код ошибки: {ex.ErrorCode}\n{ex.Message}";

                    MessageBoxExt.ShowInNewThread(errormessage);
                    return(false);
                }
                catch (Exception ex)
                {
                    string errormessage = $"Неизвестная общая ошибка. \nПользователь ID: {userId}\n\n" +
                                          $"  {ex.Message}";

                    MessageBoxExt.ShowInNewThread(errormessage);
                    return(false);
                }
            }
        }