public void consume() { if (check()) { int i = 10; bool needToExe = false; while (i > 0) { String valueStr = null; try { RedisValue value = db.SetPop(Const.Redis_Queue_Convert); if (!value.IsNullOrEmpty) { // 如果获取到转换队列中相关的任务,那么将消息队列中的转换任务加入到执行队列中 valueStr = value.ToString(); // 目前远程任务还不支持第二代压缩算法 RemoteConvertJob job = JsonConvert.DeserializeObject <RemoteConvertJob>(valueStr); JobParams jobParams = new JobParams(); jobParams.ignoreZeroIntensity = true; jobParams.log2 = false; jobParams.threadAccelerate = true; jobParams.suffix = ""; jobParams.creator = "LIMS Admin"; jobParams.mzPrecision = job.mzPrecision; string[] items = new string[4]; ListViewItem item = new ListViewItem(items); item.SubItems[0].Text = job.sourcePath; item.SubItems[1].Text = job.type; item.SubItems[2].Text = job.getAirdAlgorithmStr(); item.SubItems[3].Text = "Waiting"; item.SubItems[4].Text = job.targetPath; JobInfo jobInfo = new JobInfo(job.sourcePath, job.targetPath, job.type, jobParams, item); if (!ConvertTaskManager.getInstance().jobTable.Contains(jobInfo.jobId)) { Program.mainForm.lvFileList.Items.Add(item); ConvertTaskManager.getInstance().pushJob(jobInfo); needToExe = true; } } } catch (Exception e) { //出现异常的情况下需要将消息会退给Redis,方便下一次重试 if (valueStr != null) { db.SetAdd(Const.Redis_Queue_Convert, valueStr); } } i--; } //如果在Redis获取到了相关的转换任务 if (needToExe) { ConvertTaskManager.getInstance().run(); } } }
private void ProproForm_Load(object sender, EventArgs e) { this.Text = SoftwareInfo.getVersion(); this.cbMzPrecision.SelectedIndex = 1; //默认选择精确到小数点后4位的精度 this.cbAlgorithm.SelectedIndex = 0; //默认选择Aird第一代压缩算法ZDPD this.cbStackLayers.SelectedIndex = 3; //默认堆叠256层 this.tbFolderPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); this.tbOperator.Text = Environment.UserName; RedisClient.getInstance(); ConvertTaskManager.getInstance().run(); }
private void refresh() { foreach (ListViewItem item in lvFileList.Items) { if (ConvertTaskManager.getInstance().jobTable[item.Text] != null) { JobInfo job = ConvertTaskManager.getInstance().jobTable[item.Text] as JobInfo; job.refreshReport = true; } } }
private void removeFile(ListViewItem fileItem) { currentFiles.Remove(fileItem.Text); if (currentFiles.Count == 0) { lblFileSelectedInfo.Text = "No file is selected"; } else { lblFileSelectedInfo.Text = currentFiles.Count + "files are selected"; } fileItem.Remove(); ConvertTaskManager.getInstance().jobTable.Remove(fileItem.Text); }
private void btnClear_Click(object sender, EventArgs e) { if (lvFileList.Items.Count != 0) { foreach (ListViewItem item in lvFileList.Items) { if (item.SubItems[3].Text.Equals("Finished")) { item.Remove(); currentFiles.Remove(item.SubItems[0].Text); ConvertTaskManager.getInstance().jobTable.Remove(item.SubItems[0].Text); } } } }
private void btnConvert_Click(object sender, EventArgs e) { if (tbFolderPath.Text == "") { MessageBox.Show("Output folder path is empty!"); return; } if (lvFileList.Items.Count == 0) { MessageBox.Show("No file is selected!"); return; } foreach (ListViewItem item in lvFileList.Items) { if (!ConvertTaskManager.getInstance().jobTable.ContainsKey(item.SubItems[0].Text)) { JobParams jobParams = new JobParams { ignoreZeroIntensity = cbIsZeroIntensityIgnore.Checked, log2 = cbLog2.Checked, threadAccelerate = cbThreadAccelerate.Checked, suffix = tbFileNameSuffix.Text, creator = tbOperator.Text, mzPrecision = Double.Parse(cbMzPrecision.Text), airdAlgorithm = cbAlgorithm.SelectedIndex + 1, // 1:ZDPD, 2:StackZDPD digit = (int)Math.Log(Int32.Parse(cbStackLayers.SelectedItem.ToString()), 2), includeCV = cbIncludingPSICV.Checked }; JobInfo jobInfo = new JobInfo(item.SubItems[0].Text, tbFolderPath.Text, item.SubItems[1].Text, jobParams, item); ConvertTaskManager.getInstance().pushJob(jobInfo); } } try { ConvertTaskManager.getInstance().run(); } catch (Exception exception) { MessageBox.Show(exception.ToString()); } }
private void printLog() { if (lvFileList.SelectedItems.Count != 0) { ListViewItem item = lvFileList.SelectedItems[lvFileList.SelectedItems.Count - 1]; string content = ""; JobInfo job = null; if (ConvertTaskManager.getInstance().jobTable[item.Text] != null) { job = ConvertTaskManager.getInstance().jobTable[item.Text] as JobInfo; for (int i = job.logs.Count - 1; i >= 0; i--) { content += job.logs[i].dateTime + " " + job.logs[i].content + "\r\n"; } string jobInfo = job.getJsonInfo(); content += jobInfo + "\r\n"; } else if (ConvertTaskManager.getInstance().errorJob[item.Text] != null) { job = ConvertTaskManager.getInstance().errorJob[item.Text] as JobInfo; for (int i = job.logs.Count - 1; i >= 0; i--) { content += job.logs[i].dateTime + " " + job.logs[i].content + "\r\n"; } string jobInfo = job.getJsonInfo(); content += jobInfo + "\r\n"; } else { content = "Not start converting!"; } tbConsole.Text = content; } else { tbConsole.Text = "select item to watch logs"; } }
private void btnClearError_Click(object sender, EventArgs e) { ConvertTaskManager.getInstance().errorJob.Clear(); }