Пример #1
0
        /// <summary>
        /// 检测图片是否存在
        /// </summary>
        /// <param name="parameter"></param>
        private void CheckPic(object sender, DoWorkEventArgs e)
        {
            try
            {
                ReadFileServerPath();

                if (FileServerPath == "")
                {
                    ShowMessage("未获取到文件服务器路径!");
                    return;
                }


                ShowMessage("开始检测人脸图片完整性!");

                int CheckPersonAll       = 0;
                int CheckPersonNotExist  = 0;
                int CheckFeatureAll      = 0;
                int CheckFeatureNotExist = 0;

                //读取人事资料
                string    sqlstr = "select photopath,personno,PersonName from control_person where status = 0 and LENGTH(photopath) > 0";
                DataTable dt     = MySqlHelper.ExecuteDataset(EnvironmentInfo.ConnectionString, sqlstr).Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string photopath  = dr["photopath"].ToString();
                    string personno   = dr["personno"].ToString();
                    string personName = dr["PersonName"].ToString();
                    CheckPersonAll++;

                    // 集中管控下发时保存的人脸路径不在head
                    if (photopath.StartsWith(@"down/pic"))
                    {
                        string temp    = photopath.Split('/')[2];
                        string dsttemp = temp.Insert(6, "/");
                        photopath = photopath.Replace(temp, dsttemp);
                    }
                    string faceFilePath = Path.Combine(FileServerPath, photopath.Replace(@"down/", ""));
                    if (!File.Exists(faceFilePath))
                    {
                        CheckPersonNotExist++;
                        LogHelper.CommLogger.Info(string.Format("人事图片检查:姓名【{1}】人事编号为【{0}】的人脸图片不存在!", personno, personName));
                        //ShowMessage(string.Format("人事图片检查:姓名【{1}】人事编号为【{0}】的人脸图片不存在!", personno, personName));
                    }
                }

                // 读取人脸特征
                string    sqlstrFeature = "select cpf.feature,cp.PersonName,cp.personno from control_person_face cpf inner join control_person cp on cpf.pguid = cp.pguid and cp.status = 0 and LENGTH(cpf.feature) > 0 and LENGTH(cp.PhotoPath)";
                DataTable dtf           = MySqlHelper.ExecuteDataset(EnvironmentInfo.ConnectionString, sqlstrFeature).Tables[0];
                foreach (DataRow dr in dtf.Rows)
                {
                    CheckFeatureAll++;
                    string photopath  = dr["feature"].ToString();
                    string personno   = dr["personno"].ToString();
                    string personName = dr["PersonName"].ToString();

                    #region 人脸特征文件夹路径日期加一个
                    //// 2.8.1E1以后的版本不用特殊处理
                    if (photopath.StartsWith(@"down/pic"))
                    {
                        string temp    = photopath.Split('/')[2];
                        string dsttemp = temp.Insert(6, "/");
                        photopath = photopath.Replace(temp, dsttemp);
                    }
                    #endregion

                    string featureFilePath = Path.Combine(FileServerPath, photopath.Replace(@"down/", ""));
                    if (!File.Exists(featureFilePath))
                    {
                        CheckFeatureNotExist++;
                        LogHelper.CommLogger.Info(string.Format("人事特征检查:姓名【{1}】人事编号为【{0}】的人脸特征不存在!", personno, personName));
                        //ShowMessage(string.Format("人事特征检查:姓名【{1}】人事编号为【{0}】的人脸特征不存在!", personno, personName));
                    }
                }
                LogHelper.CommLogger.Info(string.Format("检测人事图片共{0}个,其中图片不存在{1}个", CheckPersonAll, CheckPersonNotExist));
                LogHelper.CommLogger.Info(string.Format("检测人脸特征共{0}个,其中特征不存在{1}个", CheckFeatureAll, CheckFeatureNotExist));
                ShowMessage(string.Format("检测人事图片共{0}个,其中图片不存在{1}个,具体不存在的人事资料在日志文件中查看", CheckPersonAll, CheckPersonNotExist));
                ShowMessage(string.Format("检测人脸特征共{0}个,其中特征不存在{1}个,具体不存在的人事资料在日志文件中查看", CheckFeatureAll, CheckFeatureNotExist));
            }
            catch (Exception ex)
            {
                this.Dispatcher.Invoke(new Action(() =>
                {
                    MessageBoxHelper.MessageBoxShowWarning(ex.ToString());
                }));
            }
        }
Пример #2
0
        /// <summary>
        /// 读取文件服务器中文件存储路径到FileServerPath
        /// </summary>
        private void ReadFileServerPath()
        {
            try
            {
                #region 根据门禁服务进程或者中心进程获取文件服务器路径

                string configpath = string.Empty;
                //System.Windows.Forms.FolderBrowserDialog fileDialog = new System.Windows.Forms.FolderBrowserDialog();
                var process = Process.GetProcessesByName("SmartBoxDoor.Infrastructures.Server.DoorServer").FirstOrDefault();
                //var process = Process.GetProcessesByName("encsvc").FirstOrDefault();
                var processcenter = Process.GetProcessesByName("SmartCenter.Host").FirstOrDefault();
                //var processcenter = Process.GetProcessesByName("devenv").FirstOrDefault();

                if (process != null)
                {
                    var existpath = Path.Combine(new FileInfo(process.MainModule.FileName).Directory.FullName, @"SmartFile\down\Config\AppSettings.config");
                    existpath = existpath.Replace("SmartBoxDoor\\", "");
                    if (File.Exists(existpath))
                    {
                        configpath = existpath;
                    }
                    else
                    {
                        ShowMessage(existpath + "不存在");
                    }
                }
                else
                {
                    ShowMessage("未发现运行门禁服务");
                }
                if (processcenter != null)
                {
                    var existpath = Path.Combine(new FileInfo(processcenter.MainModule.FileName).Directory.FullName, @"SmartFile\down\Config\AppSettings.config");
                    existpath = existpath.Replace("SmartCenter\\", "");
                    if (File.Exists(existpath))
                    {
                        configpath = existpath;
                    }
                    else
                    {
                        ShowMessage(existpath + "不存在");
                    }
                }
                else
                {
                    ShowMessage("未发现运行中心服务");
                }

                #endregion

                #region 根据文件服务器config读取文件存储路径:不要写死,万一配置文件增加结点,则取不到配置
                if (!string.IsNullOrEmpty(configpath))
                {
                    FileStream fs = new FileStream(configpath, FileMode.Open, FileAccess.Read);

                    StreamReader sr = new StreamReader(fs, Encoding.Default);
                    while (!sr.EndOfStream)
                    {
                        string tmp = sr.ReadLine();
                        if (tmp.Contains("DownFilePath"))
                        {
                            List <string> lst = tmp.Split('=').ToList();
                            FileServerPath = lst[2].Replace(@"/>", "");
                            FileServerPath = FileServerPath.Trim();
                            break;
                        }
                    }
                    sr.Close();
                    sr.Dispose();
                    fs.Close();
                    fs.Dispose();

                    FileServerPath = FileServerPath.Replace("\\\\", "\\").Replace("\"", "");//TrimStart("\"".ToCharArray()).TrimEnd("\"".ToCharArray());
                }
                #endregion


                #region 如果输入的源文件目录有效,采用输入目录

                this.Dispatcher.Invoke(new Action(() =>
                {
                    //输入的源文件目录为空或者不存在,使用获取到的文件服务器目录
                    if (string.IsNullOrEmpty(SrcFilePath) || !Directory.Exists(SrcFilePath))
                    {
                        if (!string.IsNullOrEmpty(FileServerPath))
                        {
                            SrcFilePath = FileServerPath;
                            ShowMessage("使用获取到的文件服务器路径:" + FileServerPath);
                        }
                        else
                        {
                            ShowMessage("无法获取到文件服务器路径,请手动输入源文件路径。例如D:\\FileSavePath");
                        }
                    }
                    else
                    {
                        FileServerPath = SrcFilePath;
                        ShowMessage("使用输入的源文件路径:" + FileServerPath);
                    }
                }));

                #endregion
            }
            catch (Exception ex)
            {
                this.Dispatcher.Invoke(new Action(() =>
                {
                    MessageBoxHelper.MessageBoxShowWarning(ex.ToString());
                }));
            }
        }
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            await this.window.RunAsyncOperation(async() =>
            {
                if (this.LowestRoleAllowedComboBox.SelectedIndex < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("A permission level must be selected");
                    return;
                }

                int cooldown = 0;
                if (!string.IsNullOrEmpty(this.CooldownTextBox.Text))
                {
                    if (!int.TryParse(this.CooldownTextBox.Text, out cooldown) || cooldown < 0)
                    {
                        await MessageBoxHelper.ShowMessageDialog("Cooldown must be 0 or greater");
                        return;
                    }
                }

                if (string.IsNullOrEmpty(this.ChatCommandTextBox.Text))
                {
                    await MessageBoxHelper.ShowMessageDialog("Commands is missing");
                    return;
                }

                if (!CommandBase.IsValidCommandString(this.ChatCommandTextBox.Text))
                {
                    await MessageBoxHelper.ShowMessageDialog("Triggers contain an invalid character");
                    return;
                }

                IEnumerable <string> commandStrings = new List <string>(this.ChatCommandTextBox.Text.Replace("!", "").Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries));
                if (commandStrings.Count() == 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("At least 1 chat trigger must be specified");
                    return;
                }

                if (commandStrings.GroupBy(c => c).Where(g => g.Count() > 1).Count() > 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("Each chat trigger must be unique");
                    return;
                }

                foreach (PermissionsCommandBase command in ChannelSession.AllEnabledChatCommands)
                {
                    if (command.IsEnabled && this.GetExistingCommand() != command)
                    {
                        if (commandStrings.Any(c => command.Commands.Contains(c, StringComparer.InvariantCultureIgnoreCase)))
                        {
                            await MessageBoxHelper.ShowMessageDialog("There already exists an enabled, chat command that uses one of the command strings you have specified");
                            return;
                        }
                    }
                }

                ActionBase action = this.actionControl.GetAction();
                if (action == null)
                {
                    if (this.actionControl is ChatActionControl)
                    {
                        await MessageBoxHelper.ShowMessageDialog("The chat message must not be empty");
                    }
                    else if (this.actionControl is SoundActionControl)
                    {
                        await MessageBoxHelper.ShowMessageDialog("The sound file path must not be empty");
                    }
                    return;
                }

                RequirementViewModel requirement = new RequirementViewModel(EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.LowestRoleAllowedComboBox.SelectedItem), cooldown: cooldown);

                ChatCommand newCommand = new ChatCommand(commandStrings.First(), commandStrings, requirement);
                newCommand.IsBasic     = true;
                newCommand.Actions.Add(action);

                if (this.autoAddToChatCommands)
                {
                    if (this.command != null)
                    {
                        ChannelSession.Settings.ChatCommands.Remove(this.command);
                    }
                    ChannelSession.Settings.ChatCommands.Add(newCommand);
                }

                this.CommandSavedSuccessfully(newCommand);

                await ChannelSession.SaveSettings();

                this.window.Close();
            });
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtEmployeeCode.Text))
            {
                Ultils.SetColorErrorTextControl(txtEmployeeCode, "Vui lòng nhập vào Code của nhân viên");
            }
            else if (string.IsNullOrEmpty(txtEmployeeName.Text))
            {
                Ultils.SetColorErrorTextControl(txtEmployeeName, "Vui lòng nhập vào tên người yêu cầu!");
            }
            else if (string.IsNullOrEmpty(gridLookUpEditDepartment.Text))
            {
                Ultils.GridLookUpEditControlNotNull(gridLookUpEditDepartment, "một Bộ phận");
            }

            else
            {
                var issue = new Issue()
                {
                    IssueID   = lblReceiptID.Text,
                    IssueDate = DateTime.Now,
                    Total     = Convert.ToInt32(_total),
                    //Price = Convert.ToInt32(_price),
                    Active          = true,
                    CreatedBy       = Program.CurrentUser.Username,
                    EmployeeCode    = txtEmployeeCode.Text,
                    EmployeeRequest = txtEmployeeName.Text,
                    DepartmentID    = gridLookUpEditDepartment.EditValue.ToString()
                };

                try
                {
                    _issueService.Add(issue);
                    _logService.InsertLog(Program.CurrentUser.Username, "Xuất kho", this.Text);
                    foreach (Cart cart in _order.Carts)
                    {
                        InsertIssueDetails(lblReceiptID.Text, cart.ProductId, cart.Quantity, cart.Price, cart.Total, gridLookUpEditDepartment.EditValue.ToString());
                        _inventoryService.InsertOrUpdateIssue(cart.ProductId, cart.Quantity, lblReceiptID.Text);
                    }
                    if (_order.Carts.Count > 0)
                    {
                        _order.Carts.Clear();
                    }

                    MessageBoxHelper.ShowMessageBoxInfo("Nhập hàng thành công!");
                    gridControlStockImport.DataSource = null;
                    ResetProductControls();
                    EnabledButtonSaveAndPrint(false);
                    // Tạo tiếp ID
                    lblReceiptID.Text = _issueService.NextId();
                }
                catch (SqlException ex)
                {
                    MessageBoxHelper.ShowMessageBoxError(ex.Message);
                }
                catch (Exception ex)
                {
                    MessageBoxHelper.ShowMessageBoxError(ex.Message);
                }
            }
        }
Пример #5
0
        private async Task ShowUserDialog(UserViewModel user)
        {
            if (user != null && !user.IsAnonymous)
            {
                UserDialogResult result = await MessageBoxHelper.ShowUserDialog(user);

                switch (result)
                {
                case UserDialogResult.Purge:
                    await ChannelSession.Chat.PurgeUser(user.UserName);

                    break;

                case UserDialogResult.Timeout1:
                    await ChannelSession.Chat.TimeoutUser(user.UserName, 60);

                    break;

                case UserDialogResult.Timeout5:
                    await ChannelSession.Chat.TimeoutUser(user.UserName, 300);

                    break;

                case UserDialogResult.Ban:
                    if (await MessageBoxHelper.ShowConfirmationDialog(string.Format("This will ban the user {0} from this channel. Are you sure?", user.UserName)))
                    {
                        await ChannelSession.Chat.BanUser(user);
                    }
                    break;

                case UserDialogResult.Unban:
                    await ChannelSession.Chat.UnBanUser(user);

                    break;

                case UserDialogResult.Follow:
                    ExpandedChannelModel channelToFollow = await ChannelSession.Connection.GetChannel(user.UserName);

                    await ChannelSession.Connection.Follow(channelToFollow, ChannelSession.User);

                    break;

                case UserDialogResult.Unfollow:
                    ExpandedChannelModel channelToUnfollow = await ChannelSession.Connection.GetChannel(user.UserName);

                    await ChannelSession.Connection.Unfollow(channelToUnfollow, ChannelSession.User);

                    break;

                case UserDialogResult.PromoteToMod:
                    if (await MessageBoxHelper.ShowConfirmationDialog(string.Format("This will promote the user {0} to a moderator of this channel. Are you sure?", user.UserName)))
                    {
                        await ChannelSession.Chat.ModUser(user);
                    }
                    break;

                case UserDialogResult.DemoteFromMod:
                    if (await MessageBoxHelper.ShowConfirmationDialog(string.Format("This will demote the user {0} from a moderator of this channel. Are you sure?", user.UserName)))
                    {
                        await ChannelSession.Chat.UnModUser(user);
                    }
                    break;

                case UserDialogResult.MixerPage:
                    Process.Start($"https://mixer.com/{user.UserName}");
                    break;

                case UserDialogResult.EditUser:
                    UserDataEditorWindow window = new UserDataEditorWindow(ChannelSession.Settings.UserData[user.ID]);
                    await Task.Delay(100);

                    window.Show();
                    await Task.Delay(100);

                    window.Focus();
                    break;

                case UserDialogResult.Close:
                default:
                    // Just close
                    break;
                }
            }
        }
        public override async Task <bool> Validate()
        {
            if (string.IsNullOrEmpty(this.NameTextBox.Text))
            {
                await MessageBoxHelper.ShowMessageDialog("Name is missing");

                return(false);
            }

            if (this.LowestRoleAllowedComboBox.SelectedIndex < 0)
            {
                await MessageBoxHelper.ShowMessageDialog("A permission level must be selected");

                return(false);
            }

            if (!await this.CurrencySelector.Validate())
            {
                return(false);
            }

            if (string.IsNullOrEmpty(this.ChatCommandTextBox.Text))
            {
                await MessageBoxHelper.ShowMessageDialog("Commands is missing");

                return(false);
            }

            if (this.ChatCommandTextBox.Text.Any(c => !Char.IsLetterOrDigit(c) && !Char.IsWhiteSpace(c) && c != '!'))
            {
                await MessageBoxHelper.ShowMessageDialog("Commands can only contain letters and numbers");

                return(false);
            }

            if (!string.IsNullOrEmpty(this.CooldownTextBox.Text))
            {
                int cooldown = 0;
                if (!int.TryParse(this.CooldownTextBox.Text, out cooldown) || cooldown < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("Cooldown must be 0 or greater");

                    return(false);
                }
            }

            foreach (PermissionsCommandBase command in ChannelSession.AllChatCommands)
            {
                if (this.GetExistingCommand() != command && this.NameTextBox.Text.Equals(command.Name))
                {
                    await MessageBoxHelper.ShowMessageDialog("There already exists a command with the same name");

                    return(false);
                }
            }

            IEnumerable <string> commandStrings = this.GetCommandStrings();

            if (commandStrings.GroupBy(c => c).Where(g => g.Count() > 1).Count() > 0)
            {
                await MessageBoxHelper.ShowMessageDialog("Each command string must be unique");

                return(false);
            }

            foreach (PermissionsCommandBase command in ChannelSession.AllChatCommands)
            {
                if (command.IsEnabled && this.GetExistingCommand() != command)
                {
                    if (commandStrings.Any(c => command.Commands.Contains(c)))
                    {
                        await MessageBoxHelper.ShowMessageDialog("There already exists an enabled, chat command that uses one of the command strings you have specified");

                        return(false);
                    }
                }
            }

            return(true);
        }
Пример #7
0
 public static DialogResult smethod_1()
 {
     return(MessageBoxHelper.Show("获取和更新企业配置信息失败!", "企业配置信息验证", MessageBoxButtons.OK, MessageBoxIcon.Hand));
 }
Пример #8
0
        private async Task ReadMagEncodeData()
        {
            MessageDialog insertCardDialog = null;

            viewModel.Track1Data = "";
            viewModel.Track2Data = "";
            viewModel.Track3Data = "";
            JobStatusControl.ClearLog();

            Console.SetOut(new TextBoxTextWriter(JobStatusControl.JobStatusLog));

            await printerManager.PerformAction("Reading mag encode data...", (zebraCardPrinter, connection) => {
                if (printerManager.IsPrinterReady(zebraCardPrinter, JobStatusControl))
                {
                    Console.WriteLine(); // Start logging on new line after printer ready check

                    CardSource cardSource = (CardSource)Enum.Parse(typeof(CardSource), viewModel.SelectedSource);

                    Dictionary <string, string> jobSettings = new Dictionary <string, string> {
                        { ZebraCardJobSettingNames.CARD_SOURCE, cardSource.ToString() },
                        { ZebraCardJobSettingNames.CARD_DESTINATION, viewModel.SelectedDestination.ToString() }
                    };

                    zebraCardPrinter.SetJobSettings(jobSettings);

                    if (cardSource == CardSource.ATM)
                    {
                        insertCardDialog = DialogHelper.ShowInsertCardDialog();
                    }

                    MagTrackData magTrackData = zebraCardPrinter.ReadMagData(DataSource.Track1 | DataSource.Track2 | DataSource.Track3, true);

                    if (string.IsNullOrEmpty(magTrackData.Track1) && string.IsNullOrEmpty(magTrackData.Track2) && string.IsNullOrEmpty(magTrackData.Track3))
                    {
                        Console.WriteLine("No data read from card.");
                    }

                    Application.Current.Dispatcher.Invoke(() => {
                        viewModel.Track1Data = magTrackData.Track1;
                        viewModel.Track2Data = magTrackData.Track2;
                        viewModel.Track3Data = magTrackData.Track3;
                    });
                }
            }, (exception) => {
                string errorMessage = $"Error reading mag encode data: {exception.Message}";
                MessageBoxHelper.ShowError(errorMessage);
                Console.WriteLine(errorMessage);
            });

            if (insertCardDialog != null)
            {
                insertCardDialog.Close();
            }

            StreamWriter streamWriter = new StreamWriter(Console.OpenStandardOutput())
            {
                AutoFlush = true
            };

            Console.SetOut(streamWriter);
        }
        public override async Task <CommandBase> GetNewCommand()
        {
            if (await this.Validate())
            {
                if (this.command == null)
                {
                    if (this.OtherEventTypeTextBox.Visibility == Visibility.Visible)
                    {
                        this.command = new EventCommand(EnumHelper.GetEnumValueFromString <OtherEventTypeEnum>(this.OtherEventTypeTextBox.Text), ChannelSession.Channel.id.ToString());
                    }
                    else if (this.EventTypeComboBox.Visibility == Visibility.Visible)
                    {
                        ConstellationEventTypeEnum eventType = EnumHelper.GetEnumValueFromString <ConstellationEventTypeEnum>((string)this.EventTypeComboBox.SelectedItem);

                        ChannelAdvancedModel channel = null;
                        UserModel            user    = null;

                        if (eventType.ToString().Contains("channel") || eventType.ToString().Contains("progression"))
                        {
                            channel = await ChannelSession.Connection.GetChannel(uint.Parse(this.EventIDTextBox.Text));

                            if (channel == null)
                            {
                                await MessageBoxHelper.ShowMessageDialog("Unable to find the channel for the specified username");

                                return(null);
                            }
                        }
                        else if (eventType.ToString().Contains("user"))
                        {
                            user = await ChannelSession.Connection.GetUser(uint.Parse(this.EventIDTextBox.Text));

                            if (user == null)
                            {
                                await MessageBoxHelper.ShowMessageDialog("Unable to find a user for the specified username");

                                return(null);
                            }
                        }

                        if (channel != null)
                        {
                            this.command = new EventCommand(eventType, channel);
                        }
                        else if (user != null)
                        {
                            this.command = new EventCommand(eventType, user);
                        }
                        else
                        {
                            this.command = new EventCommand(eventType);
                        }
                    }

                    if (ChannelSession.Settings.EventCommands.Any(se => se.UniqueEventID.Equals(this.command.UniqueEventID)))
                    {
                        await MessageBoxHelper.ShowMessageDialog("This event already exists");

                        return(null);
                    }

                    ChannelSession.Settings.EventCommands.Add(this.command);
                }
                this.command.Unlocked = this.UnlockedControl.Unlocked;
                return(this.command);
            }
            return(null);
        }
Пример #10
0
 public static void smethod_0(object object_0, object object_1)
 {
     MessageBoxHelper.Show("发票(发票代码:" + object_0 + "   发票号码:" + object_1 + ")验签失败,请手工作废该发票!", "发票验签失败", MessageBoxButtons.OK, MessageBoxIcon.Hand);
 }
Пример #11
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            IntegralCriterionMethods method = IntegralCriterionMethods.AdditiveCriterion;

            if (this.rbnAdditiveCriterion.Checked)
            {
                if (this.chbUtilityFunction.Checked)
                {
                    method = IntegralCriterionMethods.AdditiveCriterionWithUtilityFunction;
                }
                else
                {
                    method = IntegralCriterionMethods.AdditiveCriterion;
                }
            }
            if (this.rbnMultiplicativeCriterion.Checked)
            {
                if (this.chbUtilityFunction.Checked)
                {
                    //method = IntegralCriterionMethods.MultiplicativeCriterionWithUtilityFunction;
                    throw new NotImplementedException();
                }
                else
                {
                    // Проверим, все ли критерии имеют одинаковый тип
                    if (MultiplicativeCriterionSolver.CriteriaHaveSimilarType(this._model))
                    {
                        method = IntegralCriterionMethods.MultiplicativeCriterion;
                    }
                    else
                    {
                        // Критерии имеют разный тип. Скажем пользователю,
                        // что нельзя ПОКА ЧТО использовать этот метод для
                        // поиска окончательного решения
                        MessageBoxHelper.ShowStop("Критерии в модели имеют разный тип: некоторые максимизируются, а некоторые минимизируются\nК сожалению, выбранный метод поиска окончательного решения работает только для моделей,\nв которых все критерии имеют одинаковый тип");
                        return;
                    }
                }
            }
            if (this.rbnMiniMax.Checked)
            {
                method = IntegralCriterionMethods.MinimaxMethod;
            }

            if (this.rbnGeneticAlgorithm.Checked)
            {
                this._nextForm = new AdditiveGaParamsForm(this, this._model);
            }
            else
            {
                if (this.chbUtilityFunction.Checked)
                {
                    this._nextForm = new UtilityFunctionForm(this, this._model, method);
                }
                else if (!this.chbUtilityFunction.Checked)
                {
                    this._nextForm = new IntegralResultsForm(this, this._model, null, method);
                }
            }


            this._nextForm.Show();
            this.Hide();
        }
Пример #12
0
        /// <summary>
        /// event is fired when the 'ProcedureButton' is clicked.
        /// </summary>
        private void ProcedureButton_Click(object sender, System.EventArgs e)
        {
            // locals
            string procedureText = "";
            string ifExistsText  = "";
            string temp          = "";

            try
            {
                // Call Save
                OnSave();

                // if Install Procedure is Install and the Open Project exists
                if ((InstallProcedureMethod == InstallProcedureMethodEnum.Install) && (this.HasOpenProject))
                {
                    // create the SqlConnection
                    System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection();

                    // set the index
                    int index = this.ProcedureTextBox.Text.ToLower().IndexOf("-- check if the procedure already exists");

                    // if index
                    if (index > 0)
                    {
                        // set the temp
                        temp = this.ProcedureTextBox.Text.Substring(index).Trim();

                        // set the index2
                        int index2 = temp.ToLower().IndexOf("go" + Environment.NewLine);

                        // if the index2 was set
                        if (index2 > 0)
                        {
                            // set the ifExistsText
                            ifExistsText = temp.Substring(0, index2).Trim();
                        }
                    }

                    // Get the text
                    temp = this.ProcedureTextBox.Text.Replace("GO", "").Replace("Go", "");

                    // If the temp string exists
                    if (TextHelper.Exists(temp))
                    {
                        // Get the index
                        index = temp.ToLower().IndexOf("create procedure");

                        // if the index was found
                        if (index >= 0)
                        {
                            // get the procedureText
                            procedureText = temp.Substring(index);
                        }

                        // if the Databases collection exists and there is exactly 1 database
                        if ((this.OpenProject.HasDatabases) && (this.OpenProject.Databases.Count == 1))
                        {
                            // set the ConnectionString
                            connection.ConnectionString = this.OpenProject.Databases[0].ConnectionString;

                            // open
                            connection.Open();

                            // Excecute the procedureText
                            SqlHelper.ExecuteNonQuery(connection, System.Data.CommandType.Text, ifExistsText);

                            // Excecute the procedureText
                            SqlHelper.ExecuteNonQuery(connection, System.Data.CommandType.Text, procedureText);

                            // close
                            connection.Close();

                            // Show the message
                            MessageBoxHelper.ShowMessage("The stored procedure has been installed to your SQL Server.", "Procedure Installed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else if (installProcedureMethod == InstallProcedureMethodEnum.Manually)
                {
                    // Set the text
                    Clipboard.SetText(ProcedureTextBox.Text);

                    // Show the message
                    MessageBoxHelper.ShowMessage("The stored procedure text has been copied to the clipboard.", "Procedure Copied");
                }
            }
            catch (Exception error)
            {
                // for debugging only
                DebugHelper.WriteDebugError("ProcedureButton_Click", "NewStoredProcedureEditor", error);

                // Show a message
                MessageBoxHelper.ShowMessage("An error occurred installing your stored procedure", "Install Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #13
0
        public void OkDialog(bool forceOverwrite = false)
        {
            var helper = new MessageBoxHelper(this);

            var driftTable = new MeasuredDriftTimeTable(gridMeasuredDriftTimes);

            var table = new ChargeRegressionTable(gridRegression);

            string name;

            if (!helper.ValidateNameTextBox(textName, out name))
            {
                return;
            }

            if (_existing.Contains(r => !Equals(_predictor, r) && Equals(name, r.Name)) && !forceOverwrite)
            {
                if (MessageBox.Show(this,
                                    TextUtil.LineSeparate(string.Format(Resources.EditDriftTimePredictorDlg_OkDialog_An_ion_mobility_predictor_with_the_name__0__already_exists_, name),
                                                          Resources.EditDriftTimePredictorDlg_OkDialog_Do_you_want_to_change_it_),
                                    Program.Name, MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }
            }
            if (driftTable.GetTableMeasuredIonMobility(cbOffsetHighEnergySpectra.Checked, Units) == null) // Some error detected in the measured drift times table
            {
                return;
            }
            if (table.GetTableChargeRegressionLines() == null) // Some error detected in the charged regression lines table
            {
                return;
            }
            double resolvingPower = 0;
            double widthAtDt0     = 0;
            double widthAtDtMax   = 0;

            IonMobilityWindowWidthCalculator.IonMobilityPeakWidthType peakWidthType;
            if (cbLinear.Checked)
            {
                if (!helper.ValidateDecimalTextBox(textWidthAtDt0, out widthAtDt0))
                {
                    return;
                }
                if (!helper.ValidateDecimalTextBox(textWidthAtDtMax, out widthAtDtMax))
                {
                    return;
                }
                var errmsg = ValidateWidth(widthAtDt0);
                if (errmsg != null)
                {
                    helper.ShowTextBoxError(textWidthAtDt0, errmsg);
                    return;
                }
                errmsg = ValidateWidth(widthAtDtMax);
                if (errmsg != null)
                {
                    helper.ShowTextBoxError(textWidthAtDtMax, errmsg);
                    return;
                }
                peakWidthType = IonMobilityWindowWidthCalculator.IonMobilityPeakWidthType.linear_range;
            }
            else
            {
                if (!helper.ValidateDecimalTextBox(textResolvingPower, out resolvingPower))
                {
                    return;
                }

                var errmsg = ValidateResolvingPower(resolvingPower);
                if (errmsg != null)
                {
                    helper.ShowTextBoxError(textResolvingPower, errmsg);
                    return;
                }
                peakWidthType = IonMobilityWindowWidthCalculator.IonMobilityPeakWidthType.resolving_power;
            }

            if ((comboLibrary.SelectedIndex > 0) && (comboLibrary.SelectedItem.ToString().Length == 0))
            {
                MessageBox.Show(this, Resources.EditDriftTimePredictorDlg_OkDialog_Drift_time_prediction_requires_an_ion_mobility_library_,
                                Program.Name);
                comboLibrary.Focus();
                return;
            }
            var ionMobilityLibrary = _driverIonMobilityLibraryListComboDriver.SelectedItem;

            IonMobilityPredictor predictor =
                new IonMobilityPredictor(name, driftTable.GetTableMeasuredIonMobility(cbOffsetHighEnergySpectra.Checked, Units),
                                         ionMobilityLibrary, table.GetTableChargeRegressionLines(), peakWidthType, resolvingPower, widthAtDt0, widthAtDtMax);

            _predictor = predictor;

            DialogResult = DialogResult.OK;
        }
        private void RepairDoor(object sender, DoWorkEventArgs e)
        {
            if (IsRunning)
            {
                return;
            }
            else
            {
                IsRunning = true;
            }
            if (_doorServerInfoList.Count == 0)
            {
                ShowMessage("未能找到任何门禁服务");
                return;
            }

            ///检测总项目
            int CountAll = 0;
            ///通过总项目
            int CountCorrect = 0;

            ShowMessage("=====================");
            #region 检测卡不能自动下载问题
            CountAll++;
            ShowMessageDelay("开始检查sync_doornum......");
            if (CheckSyncDoorNum())
            {
                ShowMessage("检测到sync_doornum数值错误,会导致卡数据无法自动下载!已自动修复!");
            }
            else
            {
                CountCorrect++;
                ShowMessage("sync_doornum无异常 √");
            }
            #endregion

            #region 检测门禁服务配置文件中MAC地址
            CountAll++;
            ShowMessageDelay("开始检查门禁服务配置.......");
            if (CheckDoorServerMac())
            {
                string str = string.Empty;
                if (IsConfigMac == "true")
                {
                    str = string.Format("检测到门禁服务配置MAC地址错误,CONFIG文件中MAC地址配置为{0},数据库中门禁服务MAC地址为{1},是否自动修复?", ConfigMAC, sqlMac);
                }
                else
                {
                    str = string.Format("检测到门禁服务配置文件未启用MAC地址配置,可自动配置MAC地址为{0},是否自动配置?", sqlMac);
                }

                Dispatcher.Invoke(new Action(() =>
                {
                    if (MessageBoxHelper.MessageBoxShowQuestion(str) == MessageBoxResult.Yes)
                    {
                        if (FixDoorServerMac())
                        {
                            MessageBoxHelper.MessageBoxShowSuccess("配置门禁服务MAC地址完成!已结束门禁进程等待进程自动重启!");
                        }
                        else
                        {
                            MessageBoxHelper.MessageBoxShowError("配置门禁服务MAC地址失败!");
                        }
                    }
                }));
            }
            else
            {
                CountCorrect++;
                ShowMessage("门禁服务无异常 √");
            }
            #endregion

            #region 检测下载HTTP保存参数
            CountAll++;
            ShowMessageDelay("开始检查HTTP保存参数......");
            switch (CheckHttpConfig())
            {
            case enumHTTPConfig.ALLRIGHT: ShowMessage("HTTP保存参数无异常 √"); CountCorrect++; break;

            case enumHTTPConfig.ERROR: ShowMessage("检查过程中报错,请联系研发"); break;

            case enumHTTPConfig.RepairAndRestart:
                ShowMessage("HTTP保存参数不一致,已修改为" + AfterRepair_ServerURL + " " + AfterRepair_DownloadServerUrl);
                ShowMessage("请确认是否正确");
                ShowMessage("正在重启门禁服务");
                break;

            case enumHTTPConfig.RepairButNoRestart:
                ShowMessage("HTTP保存参数不一致,已修改为" + AfterRepair_ServerURL + " " + AfterRepair_DownloadServerUrl);
                ShowMessage("请确认是否正确");
                ShowMessage("未发现门禁服务");
                break;
            }
            #endregion

            #region 检测未知设备问题
            CountAll++;
            ShowMessageDelay("开始检查未知设备问题......");
            switch (CheckUnkownDevice())
            {
            case enumHTTPConfig.ALLRIGHT: ShowMessage("没有发现未知设备 √"); CountCorrect++; break;

            case enumHTTPConfig.ERROR: ShowMessage("检查过程中报错,请联系研发"); break;

            case enumHTTPConfig.RepairAndRestart:
            case enumHTTPConfig.RepairButNoRestart:
                ShowMessage("检查到未知设备问题,共" + FindSqlError + "个");
                ShowMessage("该问题需要手动重启IIS服务中的SmartWeb等,请手动重启后再次搜索设备!");
                break;
            }
            #endregion

            #region 检测操作失败,请重试问题
            CountAll++;
            ShowMessageDelay("开始检查完全下载操作失败,请重试问题......");
            switch (CheckFailProblem())
            {
            case enumHTTPConfig.ALLRIGHT: ShowMessage("没有发现操作失败情况 √"); CountCorrect++; break;

            case enumHTTPConfig.ERROR: ShowMessage("检查过程中报错,请联系研发"); break;

            case enumHTTPConfig.RepairButNoRestart:
                ShowMessage("已修复完全下载操作失败,请重试问题,请重新完全下载!");
                break;
            }
            #endregion
            ShowMessageDelay("检查结束,检查项:" + CountAll + "个,通过项:" + CountCorrect + "个");
            ShowMessage("=====================");
            IsRunning = false;
        }
Пример #15
0
 public static DialogResult smethod_3()
 {
     return(MessageBoxHelper.Show("获取和更新企业配置信息成功!", "企业配置信息验证", MessageBoxButtons.OK, MessageBoxIcon.Asterisk));
 }
Пример #16
0
 private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     MessageBoxHelper.Show(AppResources.Strings["ErrorCommon"]);
 }
Пример #17
0
 public static void smethod_4(object object_0, object object_1)
 {
     MessageBoxHelper.Show("电子发票(发票代码:" + object_0 + "   发票号码:" + object_1 + ")验签失败,系统已作废该发票,稍后系统会重新上传该张发票!", "电子发票作废", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
 }
Пример #18
0
        private async void RetrieveSettingsRanges()
        {
            viewModel.Sources.Clear();
            viewModel.Destinations.Clear();
            viewModel.CoercivityTypes.Clear();

            await printerManager.PerformAction("Retrieving settings ranges...", (zebraCardPrinter, connection) => {
                bool hasMagEncoder = zebraCardPrinter.HasMagneticEncoder();
                bool hasLaminator  = zebraCardPrinter.HasLaminator();

                if (hasMagEncoder)
                {
                    string cardSourceRange = zebraCardPrinter.GetJobSettingRange(ZebraCardJobSettingNames.CARD_SOURCE);
                    if (cardSourceRange != null)
                    {
                        foreach (CardSource source in Enum.GetValues(typeof(CardSource)))
                        {
                            if (cardSourceRange.Contains(source.ToString()))
                            {
                                Application.Current.Dispatcher.Invoke(() => {
                                    viewModel.Sources.Add(source.ToString());
                                });
                            }
                        }
                    }

                    string cardDestinationRange = zebraCardPrinter.GetJobSettingRange(ZebraCardJobSettingNames.CARD_DESTINATION);
                    if (cardDestinationRange != null)
                    {
                        foreach (CardDestination destination in Enum.GetValues(typeof(CardDestination)))
                        {
                            if (cardDestinationRange.Contains(destination.ToString()))
                            {
                                if (!destination.ToString().Contains("Laminator") || hasLaminator)
                                {
                                    Application.Current.Dispatcher.Invoke(() => {
                                        viewModel.Destinations.Add(destination.ToString());
                                    });
                                }
                            }
                        }
                    }

                    string coercivityTypeRange = zebraCardPrinter.GetJobSettingRange(ZebraCardJobSettingNames.MAG_COERCIVITY);
                    if (coercivityTypeRange != null)
                    {
                        foreach (CoercivityType coercivityType in Enum.GetValues(typeof(CoercivityType)))
                        {
                            if (coercivityTypeRange.Contains(coercivityType.ToString()))
                            {
                                Application.Current.Dispatcher.Invoke(() => {
                                    viewModel.CoercivityTypes.Add(coercivityType.ToString());
                                });
                            }
                        }
                    }
                }
                else
                {
                    MessageBoxHelper.ShowError("Unable to proceed with demo because no magnetic encoder was found.");
                }
            }, (exception) => {
                string errorMessage = $"Error retrieving settings ranges: {exception.Message}";
                MessageBoxHelper.ShowError(errorMessage);
                JobStatusControl.UpdateLog(errorMessage);

                Application.Current.Dispatcher.Invoke(() => {
                    viewModel.Sources.Clear();
                    viewModel.Destinations.Clear();
                    viewModel.CoercivityTypes.Clear();
                });
            }, null);
        }
Пример #19
0
 public static void smethod_5(object object_0, object object_1)
 {
     MessageBoxHelper.Show("电子发票(发票代码:" + object_0 + "   发票号码:" + object_1 + ")验签失败,该发票已跨月或者已抄税,系统无法作废该发票,请开红票冲销该张发票!", "电子发票验签失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
 }
Пример #20
0
        protected override object[] doService(object[] param)
        {
            if (param.Length < 8)
            {
                throw new ArgumentException("参数错误,至少有8个参数");
            }
            string oldSZ = param[0] as string;
            string oldBM = param[1] as string;
            string str3  = (param[2] as string).Trim();
            string str4  = (param[3] as string).Trim();
            string str5  = (param[4] as string).Trim();
            string s     = (param[5] as string).Trim();
            string str7  = (param[6] as string).Trim();
            string str8  = (param[7] as string).Trim();
            string str9  = "";
            string str10 = "";
            string str11 = "";
            string str12 = "";

            if (param.Length > 8)
            {
                str9 = (param[8] as string).Trim();
            }
            if (param.Length > 9)
            {
                str10 = (param[9] as string).Trim();
            }
            if (param.Length > 10)
            {
                str11 = (param[10] as string).Trim();
            }
            if (param.Length > 11)
            {
                str12 = (param[11] as string).Trim();
            }
            if (str3.Length == 0)
            {
                MessageBoxHelper.Show("请输入税种名称", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(new object[] { "Cancel" });
            }
            if (str4.Length == 0)
            {
                MessageBoxHelper.Show("请输入商品税目编码", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(new object[] { "Cancel" });
            }
            if (str5.Length == 0)
            {
                MessageBoxHelper.Show("请输入商品税目名称", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(new object[] { "Cancel" });
            }
            if (s.Length == 0)
            {
                MessageBoxHelper.Show("请输入商品税目税率", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(new object[] { "Cancel" });
            }
            BMSPSMModel spsmEntity = new BMSPSMModel {
                SZ    = str3,
                MC    = str5,
                BM    = str4,
                SLV   = double.Parse(s),
                ZSL   = double.Parse(str7),
                SLJS  = byte.Parse(str8),
                JSDW  = str9,
                SE    = double.Parse(str10),
                MDXS  = double.Parse(str11),
                FHDBZ = bool.Parse(str12)
            };
            string str13 = this.spsmManager.ModifyGoodsTax(spsmEntity, oldSZ, oldBM);

            if (str13 == "0")
            {
                str13 = "OK";
                return(new object[] { str13 });
            }
            this.log.Info("新增商品税目失败:" + str13);
            return(new object[] { "Error:", str13 });
        }
Пример #21
0
 public static void smethod_6(string string_0)
 {
     MessageBoxHelper.Show(string_0, "异常票", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
 }
Пример #22
0
        static App()
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

            #region [ #BUG-001 ]

            // The type initializer for 'LayerCake.Generator.App' threw an exception.
            // The calling thread must be STA, because many UI components require this.

            // When using VS, sometimes (after full recompilation) the process is run twice, breakpoints seem to be KO and the TaskManager shows only 1 process.
            // There is a ghost process that fails with PreferenceManager.IsFirstRun (returns True instead of False)...

            // VS issue?

            //if (PreferenceManager.IsFirstRun)
            //{
            //	System.Windows.MessageBox.Show(string.Format(
            //	   "The App is starting -> {0} and exit (PreferenceManager.IsFirstRun = {1})",
            //	   System.Diagnostics.Process.GetCurrentProcess().Id,
            //	   PreferenceManager.IsFirstRun),
            //	   "");
            //}

            //System.Windows.MessageBox.Show(string.Format(
            //	"The App is starting -> {0} (PreferenceManager.IsFirstRun = {1})",
            //	System.Diagnostics.Process.GetCurrentProcess().Id,
            //	PreferenceManager.IsFirstRun),
            //	"");

            #endregion

            if (PreferenceManager.IsFirstRun)
            {
                Window window = new WelcomeWindow();

                window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                window.ShowDialog();
            }

            if (!App.SelectConfigFile())
            {
                Environment.Exit(-1);
            }

            if (App.IsWrongConfigFile)
            {
                MessageBoxResult result = MessageBoxHelper.Show(
                    "Wrong file!\r\n\r\nIt seems that you haven't read the documentation of the product.\r\nDo you want to report to the documentation?",
                    "Wrong file!",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Stop);

                if (result == MessageBoxResult.Yes)
                {
                    System.Diagnostics.Process.Start("http://www.layercake-generator.net/Documentation/Index.html");
                }

                Environment.Exit(-3);
            }
        }
Пример #23
0
 public static void smethod_7(string string_0)
 {
     MessageBoxHelper.Show(string_0, "异常", MessageBoxButtons.OK, MessageBoxIcon.Hand);
 }
Пример #24
0
        public override void Initialize()
        {
            this.OnInitializing = true;

            bool isInitialized = false;

            try
            {
                isInitialized = _processor.Initialize(App.ConfigFilePath);

                if (isInitialized)
                {
                    PreferenceManager.ExecutionCount++;
                    PreferenceManager.LastExecutionTime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    PreferenceManager.LastConfigFilePath = App.ConfigFilePath;

                    IList <CheckedListItem <TableInfo> > tables = new List <CheckedListItem <TableInfo> >();

                    _processor.TableNames.ForEach(tableName =>
                    {
                        tables.Add(new CheckedListItem <TableInfo>(new TableInfo(tableName), isChecked: true));
                    });

                    this.Tables = tables;

                    foreach (var table in this.Tables)                     // register PropertyChanged events
                    {
                        table.PropertyChanged += this.OnTableIsCheckedPropertyChanged;
                    }

                    this.HasExcludedTables = !_processor.ExcludedTableNames.IsNullOrEmpty();
                }
            }
            catch (TypeInitializationException)
            {
                #region [ #BUG-001 ]

                // The type initializer for 'LayerCake.Generator.App' threw an exception.
                // The calling thread must be STA, because many UI components require this.

                // 1. To reproduce this bug, go to App.xaml.cs / App() and look for #BUG-001 keyword
                // 2. Uncomment the following line

                //MessageBoxHelper.Show(x.ToString(), "TypeInitializationException", MessageBoxButton.OK, MessageBoxImage.Error);

                #endregion
            }
            catch (Exception x)
            {
                MessageBoxHelper.Show(
                    x.GetFullMessage(false, "\r\n\r\n"),
                    "Processor Initialization Error!",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
            finally
            {
                this.OnInitializing = false;

                if (!isInitialized)
                {
                    this.CanAcceptUserInteraction = false;                     // locks IHM (Quit button is available)
                }
            }
        }
Пример #25
0
 public static void smethod_8(string string_0)
 {
     MessageBoxHelper.Show(string_0, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
 }
Пример #26
0
        /// <summary>
        /// 根据路径备份
        /// </summary>
        /// <param name="parameter"></param>
        public void FacePicBackUp(object sender, DoWorkEventArgs e)
        {
            try
            {
                ReadFileServerPath();


                this.Dispatcher.Invoke(new Action(() =>
                {
                    if (FileServerPath == "")
                    {
                        MessageBoxHelper.MessageBoxShowWarning("未获取到文件服务器路径!");
                        return;
                    }
                    if (FilePath == "")
                    {
                        MessageBoxHelper.MessageBoxShowWarning("请选择有效的备份路径!");
                        return;
                    }
                }));


                #region 初始化变量
                CountPersonAll        = 0;
                CountPersonNotExists  = 0;
                CountPersonSuccess    = 0;
                CountPersonFail       = 0;
                CountFeatureAll       = 0;
                CountFeatureNotExists = 0;
                CountFeatureSuccess   = 0;
                CountFeatureFail      = 0;
                #endregion

                //读取人事资料
                string sqlstr = "select photopath,personno,PersonName from control_person where status = 0 and LENGTH(photopath) > 0";
                //MySqlDataReader reader
                DataTable dt = MySqlHelper.ExecuteDataset(EnvironmentInfo.ConnectionString, sqlstr).Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    CountPersonAll++;
                    string photopath = dr["photopath"].ToString();

                    // 集中管控下发时保存的人脸路径不在head
                    if (photopath.StartsWith(@"down/pic"))
                    {
                        string temp    = photopath.Split('/')[2];
                        string dsttemp = temp.Insert(6, "/");
                        photopath = photopath.Replace(temp, dsttemp);
                    }

                    CopyPersonFile(photopath, dr, true);
                }

                //读取人脸特征
                string    sqlstrFeature = "select cpf.feature,cp.PersonName,cp.personno from control_person_face cpf inner join control_person cp on cpf.pguid = cp.pguid and LENGTH(cpf.feature) > 0 ";
                DataTable dtfeature     = MySqlHelper.ExecuteDataset(EnvironmentInfo.ConnectionString, sqlstrFeature).Tables[0];
                foreach (DataRow dr in dtfeature.Rows)
                {
                    CountFeatureAll++;
                    string photopath = dr["feature"].ToString();

                    // 集中管控下发时保存的人脸路径不在head
                    if (photopath.StartsWith(@"down/pic"))
                    {
                        string temp    = photopath.Split('/')[2];
                        string dsttemp = temp.Insert(6, "/");
                        photopath = photopath.Replace(temp, dsttemp);
                    }
                    CopyPersonFile(photopath, dr, false);
                }

                ShowMessage(string.Format("获取到的文件服务器路径为:{0}", FileServerPath));
                ShowMessage(string.Format("备份人事图片共{0}个,其中成功{1}个,人事图片不存在{2}个,失败{3}个", CountPersonAll, CountPersonSuccess, CountPersonNotExists, CountPersonFail));
                ShowMessage(string.Format("备份人脸特征共{0}个,其中成功{1}个,特征图片不存在{2}个,失败{3}个", CountFeatureAll, CountFeatureSuccess, CountFeatureNotExists, CountFeatureFail));
            }
            catch (Exception ex)
            {
                MessageBoxHelper.MessageBoxShowWarning(ex.ToString());
            }
        }
        private bool BuildPeptideSearchLibrary(CancelEventArgs e)
        {
            // Nothing to build, if now search files were specified
            if (!SearchFilenames.Any())
            {
                var libraries = DocumentContainer.Document.Settings.PeptideSettings.Libraries;
                if (!libraries.HasLibraries)
                {
                    return(false);
                }
                var libSpec = libraries.LibrarySpecs.FirstOrDefault(s => s.IsDocumentLibrary);
                return(libSpec != null && LoadPeptideSearchLibrary(libSpec));
            }

            double           cutOffScore;
            MessageBoxHelper helper = new MessageBoxHelper(WizardForm);

            if (!helper.ValidateDecimalTextBox(textCutoff, 0, 1.0, out cutOffScore))
            {
                e.Cancel = true;
                return(false);
            }
            ImportPeptideSearch.CutoffScore = cutOffScore;

            BiblioSpecLiteBuilder builder;

            try
            {
                builder = ImportPeptideSearch.GetLibBuilder(DocumentContainer.Document, DocumentContainer.DocumentFilePath, cbIncludeAmbiguousMatches.Checked);
                builder.PreferEmbeddedSpectra = PreferEmbeddedSpectra;
            }
            catch (FileEx.DeleteException de)
            {
                MessageDlg.ShowException(this, de);
                return(false);
            }

            bool retry = false;

            do
            {
                using (var longWaitDlg = new LongWaitDlg
                {
                    Text = Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Building_Peptide_Search_Library,
                    Message = Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Building_document_library_for_peptide_search_,
                })
                {
                    // Disable the wizard, because the LongWaitDlg does not
                    try
                    {
                        ImportPeptideSearch.ClosePeptideSearchLibraryStreams(DocumentContainer.Document);
                        var status = longWaitDlg.PerformWork(WizardForm, 800,
                                                             monitor => LibraryManager.BuildLibraryBackground(DocumentContainer, builder, monitor, new LibraryManager.BuildState(null, null)));
                        if (status.IsError)
                        {
                            // E.g. could not find external raw data for MaxQuant msms.txt; ask user if they want to retry with "prefer embedded spectra" option
                            if (BiblioSpecLiteBuilder.IsLibraryMissingExternalSpectraError(status.ErrorException))
                            {
                                var response = ShowLibraryMissingExternalSpectraError(WizardForm, status.ErrorException);
                                if (response == UpdateProgressResponse.cancel)
                                {
                                    return(false);
                                }
                                else if (response == UpdateProgressResponse.normal)
                                {
                                    builder.PreferEmbeddedSpectra = true;
                                }

                                retry = true;
                            }
                            else
                            {
                                MessageDlg.ShowException(WizardForm, status.ErrorException);
                                return(false);
                            }
                        }
                    }
                    catch (Exception x)
                    {
                        MessageDlg.ShowWithException(WizardForm, TextUtil.LineSeparate(string.Format(Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Failed_to_build_the_library__0__,
                                                                                                     Path.GetFileName(BiblioSpecLiteSpec.GetLibraryFileName(DocumentContainer.DocumentFilePath))), x.Message), x);
                        return(false);
                    }
                }
            } while (retry);

            var docLibSpec = builder.LibrarySpec.ChangeDocumentLibrary(true);

            Settings.Default.SpectralLibraryList.Insert(0, docLibSpec);

            // Go ahead and load the library - we'll need it for
            // the modifications and chromatograms page.
            if (!LoadPeptideSearchLibrary(docLibSpec))
            {
                return(false);
            }

            var selectedIrtStandard = comboStandards.SelectedItem as IrtStandard;
            var addedIrts           = false;

            if (selectedIrtStandard != null && selectedIrtStandard != IrtStandard.EMPTY)
            {
                addedIrts = AddIrtLibraryTable(docLibSpec.FilePath, selectedIrtStandard);
            }

            var docNew = ImportPeptideSearch.AddDocumentSpectralLibrary(DocumentContainer.Document, docLibSpec);

            if (docNew == null)
            {
                return(false);
            }

            if (addedIrts)
            {
                docNew = ImportPeptideSearch.AddRetentionTimePredictor(docNew, docLibSpec);
            }

            DocumentContainer.ModifyDocumentNoUndo(doc => docNew);

            if (!string.IsNullOrEmpty(builder.AmbiguousMatchesMessage))
            {
                MessageDlg.Show(WizardForm, builder.AmbiguousMatchesMessage);
            }
            return(true);
        }
Пример #28
0
        /// <summary>
        /// 复制文件到备份路径
        /// </summary>
        /// <param name="sourcePath">数据库中的文件路径</param>
        public void CopyPersonFile(string sourcePath, DataRow dr, bool IsPerson)
        {
            try
            {
                string personno   = dr["personno"].ToString();
                string personName = dr["PersonName"].ToString();

                sourcePath = sourcePath.Replace("/", "\\");
                //完整目标文件夹路径
                //string FactSavePath = Path.GetDirectoryName(FilePath + "\\FileSavePath" + sourcePath.Replace("down", ""));
                string FactSavePath = Path.GetDirectoryName(BackUpPath + "\\FileSavePath" + sourcePath.Replace("down", ""));
                //完整源文件路径
                string FaceSourcePath = sourcePath.Replace("down", FileServerPath);
                //完整目标文件路径
                //string FaceDestPath = FilePath + "\\FileSavePath" + sourcePath.Replace("down", "");
                string FaceDestPath = BackUpPath + "\\FileSavePath" + sourcePath.Replace("down", "");
                //如果指定的目标文件夹路径不存在,则创建该存储路径
                if (!Directory.Exists(FactSavePath))
                {
                    //创建
                    Directory.CreateDirectory(FactSavePath);
                }

                #region 保存文件
                if (!File.Exists(FaceSourcePath))
                {
                    if (IsPerson)
                    {
                        CountPersonNotExists++;
                        ShowMessage(string.Format("警告:姓名【{1}】人事编号为【{0}】的图片不存在!", personno, personName));
                    }
                    else
                    {
                        CountFeatureNotExists++;
                        ShowMessage(string.Format("警告:姓名【{1}】人事编号为【{0}】的特征文件不存在!", personno, personName));
                    }
                    return;
                }

                // 复制成功不打印,否则打印太多会滚动覆盖
                if (File.Exists(FaceDestPath))
                {
                    if (IsPerson)
                    {
                        CountPersonSuccess++;
                        //ShowMessage(string.Format("备份姓名【{1}】人事编号为【{0}】的图片时,目标文件已存在", personno, personName));
                    }
                    else
                    {
                        CountFeatureSuccess++;
                        //ShowMessage(string.Format("备份姓名【{1}】人事编号为【{0}】的特征文件时,目标文件已存在", personno, personName));
                    }
                }
                else
                {
                    File.Copy(FaceSourcePath, FaceDestPath, false);
                    if (IsPerson)
                    {
                        CountPersonSuccess++;
                        //ShowMessage(string.Format("备份姓名【{1}】人事编号为【{0}】的图片成功", personno, personName));
                    }
                    else
                    {
                        CountFeatureSuccess++;
                        //ShowMessage(string.Format("备份姓名【{1}】人事编号为【{0}】的特征文件成功", personno, personName));
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                //如果一个文件无法正常备份那么所有的都会无法正常备份,只弹窗提示一次报错
                if (CountFeatureFail == 0 && CountPersonFail == 0)
                {
                    MessageBoxHelper.MessageBoxShowWarning(ex.ToString());
                }

                if (IsPerson)
                {
                    CountPersonFail++;
                }
                else
                {
                    CountFeatureFail++;
                }
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            if (mls_address.Text.IsNullOrEmpty() || mls_port.Text.IsNullOrEmpty() || txtInitName.Text.IsNullOrEmpty() || txtAccesskey.Text.IsNullOrEmpty() || groupNameBox.Text.IsNullOrEmpty())
            {
                MessageBoxHelper.ShowBoxExclamation("请输入完整正确的上线信息,否则可能造成上线失败!");
                return;
            }

            if (groupNameBox.Text == "全部")
            {
                MessageBoxHelper.ShowBoxExclamation("分组名不能'全部'!");
                return;
            }

            logList.Items.Clear();

            logList.Items.Add("配置信息初始化..");

            var autoRun    = false;
            var svcInstall = false;

            if (installMode.SelectedIndex == 1)
            {
                autoRun = true;
            }
            else if (installMode.SelectedIndex == 2)
            {
                svcInstall = true;
            }

            var options = new ServiceOptions()
            {
                Id                 = Guid.NewGuid().ToString(),
                Host               = mls_address.Text,
                Port               = int.Parse(mls_port.Text),
                Remark             = txtInitName.Text,
                AccessKey          = int.Parse(txtAccesskey.Text),
                IsHide             = ishide.Checked,
                IsAutoRun          = autoRun,
                IsMutex            = mutex.Checked,
                InstallService     = svcInstall,
                ServiceName        = "SiMayService",
                ServiceDisplayName = "SiMay远程被控服务",
                SessionMode        = sessionModeList.SelectedIndex,
                GroupName          = groupNameBox.Text
            };
            string name = "SiMayService.exe";

            string datfileName = Path.Combine(Environment.CurrentDirectory, "dat", name);

            logList.Items.Add("准备将配置信息写入文件中");

            if (!File.Exists(datfileName))
            {
                logList.Items.Add("配置文件不存在.");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter   = "可执行文件|*.exe";
            dlg.Title    = "生成";
            dlg.FileName = "SiMayService";
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                logList.Items.Add("配置信息写入被终止了!");
                return;
            }
            if (dlg.FileName != "")
            {
                logList.Items.Add("配置信息写入中...");
                var  optionsBytes = PacketSerializeHelper.SerializePacket(options);
                bool err          = this.WirteOptions(optionsBytes, datfileName, dlg.FileName);

                if (err != true)
                {
                    logList.Items.Add("配置信息写入失败,请检查配置文件是否被占用!");
                    return;
                }

                logList.Items.Add("配置信息写入成功!");
            }
            else
            {
                logList.Items.Add("配置信息写入被终止了!");
                return;
            }
            MessageBoxHelper.ShowBoxExclamation("服务端文件已生成到位置:" + dlg.FileName);

            this.Close();
        }
Пример #30
0
 public void OkDialog()
 {
     MessageBoxHelper helper = new MessageBoxHelper(this);
     string name;
     if (!helper.ValidateNameTextBox(tbxName, out name))
     {
         return;
     }
     if (name != _originalGroupComparisonDef.Name &&
         _existingGroupComparisons.Any(comparison => comparison.Name == name))
     {
         helper.ShowTextBoxError(tbxName, GroupComparisonStrings.EditGroupComparisonDlg_btnOK_Click_There_is_already_a_group_comparison_named__0__, name);
         return;
     }
     double confidenceLevel;
     if (!helper.ValidateDecimalTextBox(tbxConfidenceLevel, 0, 100, out confidenceLevel))
     {
         return;
     }
     DialogResult = DialogResult.OK;
 }
Пример #31
0
        private void SearchPCB(string productionId)
        {
            splashScreenManager2.ShowWaitForm();
            if (string.IsNullOrEmpty(productionId))
            {
                splashScreenManager2.CloseWaitForm();
                Ultils.TextControlNotNull(txtSearchPCB, "Nhập vào từ khóa cần tìm!");
                txtSearchPCB.SelectAll();
            }
            else
            {
                if (comboBoxEditSearchByKey.EditValue.Equals("Production ID"))
                {
                    var logs = _murataService.GetProducts_Murata_by_ID(productionId);
                    var list = new List <Murata>();
                    if (logs != null)
                    {
                        list.Add(logs);
                        gridControlData.DataSource = list;
                        btnDelete.Enabled          = true;
                        splashScreenManager2.CloseWaitForm();
                    }
                    else
                    {
                        splashScreenManager2.CloseWaitForm();
                        MessageBoxHelper.ShowMessageBoxWaring($"No results width ID:[{productionId}]");
                        txtSearchPCB.SelectAll();
                        txtSearchPCB.Focus();
                    }
                }
                else if (comboBoxEditSearchByKey.EditValue.Equals("Box ID"))
                {
                    string strLength = txtSearchPCB.Text;
                    if (strLength.Length >= 3)
                    {
                        if (strLength.Substring(0, 3).ToUpper() != "F00")
                        {
                            splashScreenManager2.CloseWaitForm();
                            Ultils.EditTextErrorMessage(txtSearchPCB, "BOX ID phải bắt đầu bằng F00");
                            txtSearchPCB.SelectAll();
                        }
                        else
                        {
                            var logs = _murataService.GetProducts_Murata_by_BoxId(productionId).ToList();

                            if (logs.Any())
                            {
                                gridControlData.DataSource = logs;
                                btnDelete.Enabled          = true;
                                splashScreenManager2.CloseWaitForm();
                            }
                            else
                            {
                                splashScreenManager2.CloseWaitForm();
                                MessageBoxHelper.ShowMessageBoxWaring($"Không tìm thấy PCB nào trong Box [{productionId}]");
                                txtSearchPCB.SelectAll();
                                txtSearchPCB.Focus();
                            }
                        }
                    }
                }
            }
        }