private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == dataGridView1.Columns["deleteColumn"].Index) { VisaTask vt = dataGridView1.Rows[e.RowIndex].DataBoundItem as VisaTask; Logger.Warning("Удаляю задание " + vt.GetInfo()); _engine.DeleteTask(vt); dataGridView1.Rows.RemoveAt(e.RowIndex); DeleteTask(vt); SendMessage(vt, Actions.Delete); } if (e.ColumnIndex == dataGridView1.Columns["duplColumn"].Index) { var currItem = (VisaTask)dataGridView1.CurrentRow.DataBoundItem; using (DuplForm form = new DuplForm()) { form.FillCombo(Const.GetListFromDict(Const.SettingsCities)); if (form.ShowDialog(this) == DialogResult.OK) { VisaTask vt = currItem.Clone(); vt.City = form.GetSelectedCity(); vt.CityCode = Const.CityCodeByCity(vt.City); _visaTasks.Add(vt); VisaTask.Save(_visaTasks, VisaEntityType.New); _engine.RefreshViewTabs(); SendMessage(vt, Actions.Create); } } } }
private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == dataGridView2.Columns["deleteColumn2"].Index) { VisaTask vt = dataGridView2.Rows[e.RowIndex].DataBoundItem as VisaTask; Logger.Warning("Удаляю завершенное/удаленное задание " + vt.GetInfo()); dataGridView2.Rows.RemoveAt(e.RowIndex); VisaTask.Save(_completedVisaTasks, VisaEntityType.Completed); vt.Save(); SendMessage(vt, Actions.Remove); } else if (e.ColumnIndex == dataGridView2.Columns["restoreColumn"].Index) { VisaTask vt = dataGridView2.Rows[e.RowIndex].DataBoundItem as VisaTask; Logger.Warning("Восстанавливаю завершенное/удаленное задание " + vt.GetInfo()); dataGridView2.Rows.RemoveAt(e.RowIndex); VisaTask.Save(_completedVisaTasks, VisaEntityType.Completed); _visaTasks.Add(vt); VisaTask.Save(_visaTasks, VisaEntityType.New); _engine.RefreshViewTabs(); SendMessage(vt, Actions.Restore); } }
private void DeleteTask(VisaTask vt) { _visaTasks.Remove(vt); VisaTask.Save(_visaTasks, VisaEntityType.New); _completedVisaTasks.Add(vt); VisaTask.Save(_completedVisaTasks, VisaEntityType.Completed); }
private void SendMessage(VisaTask task, Actions action) { if (action == Actions.Create || action == Actions.Restore) { if (!CheckOnProcessExists(task.City)) { string newDir = Path.Combine(AssemblyDirectory, task.City); if (!Directory.Exists(newDir)) { Directory.CreateDirectory(newDir); Directory.CreateDirectory(Path.Combine(newDir, COMM)); } startProcess(task.City, newDir, new BindingList <VisaTask>() { task }); } } Message mess = new Message() { Action = action, Task = task }; Message.Serialize(mess, FilePath(task.City, task.Receipt.Replace("/", "_"))); }
public VisaTask Clone() { VisaTask vt = new VisaTask(); vt.ArrivalDt = ArrivalDt; vt.Category = Category; vt.CategoryCode = CategoryCode; vt.City = City; vt.CityCode = CityCode; vt.CountAdult = CountAdult; vt.CountChild = CountChild; vt.Dob = Dob; vt.Email = Email; vt.LastName = LastName; vt.Name = Name; vt.Nationality = Nationality; vt.PassportEndDate = PassportEndDate; vt.Password = Password; vt.Priority = Priority; vt.Purpose = Purpose; vt.PurposeCode = PurposeCode; vt.Receipt = Receipt; vt.RedLine = RedLine; vt.GreenLine = GreenLine; vt.RegistrationInfo = RegistrationInfo; vt.Status = Status; vt.StatusCode = StatusCode; return(vt); }
void Value_TaskEvent(VisaTask task) { if (ETaskEvent != null) { ETaskEvent(task); } }
public void DeleteTask(VisaTask visaTask) { if (_cityTasks.ContainsKey(visaTask.CityV)) { VisaTab visaTab = _cityTasks[visaTask.CityV]; visaTab.CheckOnDeleteTask(visaTask); } }
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.CurrentCell == null) { return; } if (e.ColumnIndex == dataGridView1.Columns["City"].Index) { var currItem = (VisaTask)dataGridView1.CurrentRow.DataBoundItem; var prevItem = currItem.Clone(); prevItem.City = _cityBefore.Substring(_cityBefore.IndexOf(")") + 1); SendMessage(prevItem, Actions.Delete); currItem.CityCode = Const.CityCodeByCity(dataGridView1.CurrentCell.Value.ToString()); SendMessage(currItem, Actions.Create); Logger.Info(string.Format("Город изменен с {0} на {1}", _cityBefore, currItem.City)); TabPage tp1 = null; TabPage tp2 = null; foreach (TabPage tab in tabControl1.TabPages) { string tabtextClear = tab.Text; if (tab.Text.IndexOf("~") != -1) { tabtextClear = tab.Text.Remove(tab.Text.IndexOf("~")); } if (_cityBefore.Equals(tabtextClear)) { tp1 = tab; } else if (currItem.CityV.Equals(tabtextClear)) { tp2 = tab; } } if (tp1 != null) { tabControl1.TabPages.Remove(tp1); _engine.DeleteCityKey(_cityBefore); } if (tp2 != null) { tabControl1.TabPages.Remove(tp2); _engine.DeleteCityKey(currItem.CityV); } _cityBefore = string.Empty; _engine.RefreshViewTabs(); VisaTask.Save(_visaTasks, VisaEntityType.New); } else if (e.ColumnIndex == dataGridView1.Columns["priorityComboBoxColumn"].Index) { VisaTask.Save(_visaTasks, VisaEntityType.New); } }
private void txtEmail_Validated(object sender, EventArgs e) { if (!VisaTask.IsValidEmailAddress(txtEmail.Text)) { emailErrorProvider.SetError(txtEmail, "Не правильный email"); } else { emailErrorProvider.SetError(txtEmail, string.Empty); } }
private void txtPass_Validated(object sender, EventArgs e) { if (!VisaTask.IsValidPassword(txtPass.Text)) { PasserrorProvider.SetError(txtPass, "Пароль должен содержать не менее 8 символов"); } else { PasserrorProvider.SetError(txtPass, string.Empty); } }
private void btnaddTask_Click(object sender, EventArgs e) { txtEmail.Focus(); txtPass.Focus(); txtEmail.Focus(); if (!VisaTask.IsValidEmailAddress(txtEmail.Text)) { return; } if (!VisaTask.IsValidPassword(txtPass.Text)) { return; } VisaTask task = new VisaTask() { ArrivalDt = dtArrivalDate.Text, Receipt = txtBillNum.Text, Category = cbxCategory.SelectedItem.ToString(), CategoryCode = Const.CategoryCodeByCat(cbxCategory.SelectedItem.ToString()), City = cbxCity.SelectedItem.ToString(), CityCode = Const.CityCodeByCity(cbxCity.SelectedItem.ToString()), CountAdult = (int)numCountA.Value, CountChild = (int)numCountC.Value, Dob = dtDob.Text, Email = txtEmail.Text, LastName = txtLastName.Text, Name = txtName.Text, Nationality = cbxNation.SelectedItem.ToString(), PassportEndDate = dtEndPass.Text, Password = txtPass.Text, Purpose = cbxPurpose.SelectedItem.ToString(), PurposeCode = Const.PurposeCodeByPurpose(cbxPurpose.SelectedItem.ToString()), Status = cbxStatus.SelectedItem.ToString(), StatusCode = Const.StatusCodeByStatus(cbxStatus.SelectedItem.ToString()), RedLine = dtRedLine.Text, GreenLine = dtGreenLine.Text, Priority = cbxPriority.SelectedIndex }; Logger.Info("Задание добавленно " + task.GetInfo()); _visaTasks.Add(task); VisaTask.Save(_visaTasks, VisaEntityType.New); dataGridView1.Refresh(); SendMessage(task, Actions.Create); _engine.RefreshViewTabs(); txtPass.Text = txtName.Text = txtBillNum.Text = txtEmail.Text = txtLastName.Text = txtName.Text = string.Empty; }
public static VisaTask DeSerialize(string filePath) { VisaTask task = null; if (File.Exists(filePath)) { using (FileStream fs = new FileStream(filePath, FileMode.Open)) { XmlSerializer xs = new XmlSerializer(typeof(VisaTask)); task = (VisaTask)xs.Deserialize(fs); } } return(task); }
private void WriteReportFile(VisaTask task) { var repPath = Path.Combine(AssemblyDirectory, "Reports"); if (!Directory.Exists(repPath)) { Directory.CreateDirectory(repPath); } File.WriteAllLines(Path.Combine(repPath, task.GetFullNameAsFileName()), new[] { task.LastName + " " + task.Name, "Password: "******" " + task.Password, task.RegistrationInfo }); }
void restoreButton_Click(object sender, System.EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = Path.Combine(AssemblyDirectory, Const.DELETEDTASKS); dlg.Multiselect = false; if (dlg.ShowDialog(this) == DialogResult.OK) { try { VisaTask vt = VisaTask.DeSerialize(dlg.FileName); _visaTasks.Add(vt); VisaTask.Save(_visaTasks, VisaEntityType.New); _engine.RefreshViewTabs(); } catch (Exception ex) { Logger.Error(ex.ToString()); MessageBox.Show(ex.ToString(), "Ошибка!"); } } }
private void startProcess(string city, string newDir, BindingList <VisaTask> tasks) { if (!Directory.Exists(newDir)) { Directory.CreateDirectory(newDir); } File.Copy(Path.Combine(AssemblyDirectory, "PolandVisaAuto.exe"), Path.Combine(newDir, "PolandVisaAuto.exe"), true); File.Copy(Path.Combine(AssemblyDirectory, "PolandVisaAuto.exe.Config"), Path.Combine(newDir, "PolandVisaAuto.exe.Config"), true); File.Copy(Path.Combine(AssemblyDirectory, "pvhelper.dll"), Path.Combine(newDir, "pvhelper.dll"), true); File.Copy(Path.Combine(AssemblyDirectory, "DecaptcherLib.dll"), Path.Combine(newDir, "DecaptcherLib.dll"), true); File.Copy(Path.Combine(AssemblyDirectory, "log4net.dll"), Path.Combine(newDir, "log4net.dll"), true); if (File.Exists(Path.Combine(newDir, "data.xml"))) { File.Delete(Path.Combine(newDir, "data.xml")); } VisaTask.SaveDataToFolder(tasks, Path.Combine(newDir, "data.xml")); Process process = new Process(); process.StartInfo.FileName = Path.Combine(newDir, "PolandVisaAuto.exe"); process.StartInfo.Arguments = "isMain 0 city " + city; process.Start(); }
private void PvAutoLoad(object sender, EventArgs e) { _commFolder = Path.Combine(AssemblyDirectory, COMM); if (!Directory.Exists(_commFolder)) { Directory.CreateDirectory(_commFolder); } if (!_isMain) { _parentFolder = Path.Combine(Environment.CurrentDirectory, COMM); } Logger.Info("_commFolder " + _commFolder + " _parentFolder " + _parentFolder); ImageResolver.Instance.ChangeUseProxy += Instance_ChangeUseProxy; UpdateHeader(); chbAutoResolveImage.Checked = ImageResolver.Instance.AutoResolveImage; radiocom.Checked = ImageResolver.Instance.Host == radiocom.Text; radioinfo.Checked = ImageResolver.Instance.Host == radioinfo.Text; chbProxy.Checked = ImageResolver.Instance.UseProxy; chkAsk.Checked = ImageResolver.Instance.AskMaster; cbxCity.DataSource = Const.GetListFromDict(Const.SettingsCities); cbxNation.DataSource = Const.GetListFromDict(Const.FillNations()); cbxStatus.DataSource = Const.GetListFromDict(Const.FillStatus()); cbxPurpose.DataSource = Const.GetListFromDict(Const.FillPurpose()); cbxCategory.DataSource = Const.GetListFromDict(Const.GetCategoryType()); cbxPriority.DataSource = Const.GetListPriority(); cityDataGridViewComboBoxColumn.DataSource = Const.GetListFromDict(Const.SettingsCities); priorityComboBoxColumn.DataSource = Const.GetDataTablePriority(); cbxStatus.SelectedItem = "Mr."; cbxNation.SelectedItem = "UKRAINE"; _visaTasks = VisaTask.DeSerialize(VisaEntityType.New); dataGridView1.DataSource = _visaTasks; dataGridView1.Columns["deleteColumn"].DisplayIndex = 0; dataGridView1.Columns["duplColumn"].DisplayIndex = 1; dataGridView1.Columns["City"].DisplayIndex = 2; dataGridView1.Columns["LastName"].DisplayIndex = 3; dataGridView1.Columns["Name"].DisplayIndex = 4; dataGridView1.Columns["Status"].DisplayIndex = 5; dataGridView1.Refresh(); _completedVisaTasks = VisaTask.DeSerialize(VisaEntityType.Completed); dataGridView2.DataSource = _completedVisaTasks; dataGridView2.Columns["deleteColumn2"].DisplayIndex = 0; dataGridView2.Columns["restoreColumn"].DisplayIndex = 1; dataGridView2.Columns["City2"].DisplayIndex = 2; dataGridView2.Columns["LastName2"].DisplayIndex = 3; dataGridView2.Columns["Name2"].DisplayIndex = 4; dataGridView2.Columns["RegistrationInfo"].DisplayIndex = 5; dataGridView2.Columns["Purpose"].DisplayIndex = 8; dataGridView2.Refresh(); foreach (TabPage tabPage in tabControl1.TabPages) { Engine.TabColors.Add(tabPage, Color.White); } _engine = new Engine(_visaTasks, tabControl1, _isMain);//, _completedVisaTasks); _engine.RefreshViewTabs(); _engine.ETaskEvent += _engine_ETaskEvent; }
void _timer_Tick(object sender, System.EventArgs e) { var files = Directory.GetFiles(_commFolder); foreach (string file in files) { Logger.Info("Processing file " + file); try { Message mess = Message.DeSerialize(file); Logger.Info("Action " + mess.Action); switch (mess.Action) { case Actions.Create: if (mess.Task != null) { _visaTasks.Add(mess.Task); VisaTask.Save(_visaTasks, VisaEntityType.New); _engine.RefreshViewTabs(); } else { Logger.Error("mess.Task is null"); } break; case Actions.Delete: VisaTask taskToDelete = null; foreach (VisaTask visaTask in _visaTasks) { if (visaTask.Receipt == mess.Task.Receipt) { taskToDelete = visaTask; break; } } if (taskToDelete != null) { _engine.DeleteTask(taskToDelete); DeleteTask(taskToDelete); } else { Logger.Error("Can't Delete task"); } break; case Actions.Restore: VisaTask taskTorestore = null; foreach (VisaTask visaTask in _completedVisaTasks) { if (visaTask.Receipt == mess.Task.Receipt) { taskTorestore = visaTask; break; } } if (taskTorestore != null) { _completedVisaTasks.Remove(taskTorestore); VisaTask.Save(_completedVisaTasks, VisaEntityType.Completed); _visaTasks.Add(taskTorestore); VisaTask.Save(_visaTasks, VisaEntityType.New); Logger.Info("_engine.RefreshViewTabs()"); _engine.RefreshViewTabs(); } else { _visaTasks.Add(mess.Task); Logger.Error("Can't Restore task"); } break; case Actions.Remove: VisaTask taskToremove = null; foreach (VisaTask visaTask in _completedVisaTasks) { if (visaTask.Receipt == mess.Task.Receipt) { taskToremove = visaTask; break; } } if (taskToremove != null) { _completedVisaTasks.Remove(taskToremove); VisaTask.Save(_completedVisaTasks, VisaEntityType.Completed); } else { Logger.Error("Can't Remove task"); } break; } File.Delete(file); } catch (Exception ex) { Logger.Error(ex); } } }
void _engine_ETaskEvent(VisaTask task) { WriteReportFile(task); DeleteTask(task); SendMessage(task, Actions.Delete); }