private static string TaskCmd(Dictionary <string, object> valueList) { BUS.LIST_TASKControl ctr = new BUS.LIST_TASKControl(); if (_appConnect != "") { BUS.CommonControl.SetConnection(_appConnect); } object id = null; if (valueList.TryGetValue("id", out id)) { DTO.LIST_TASKInfo infTask = ctr.Get(_db, id.ToString(), ref sErr); if (infTask.IsUse == "N") { return("Task is suppend"); } try { if (infTask.Type != "S") { EmailNormal(valueList, infTask); } else { EmailSingle(valueList, infTask); } } catch (Exception ex) { return(ex.Message); } } return(sErr); }
private void SetDataToForm(DTO.LIST_TASKInfo inf) { txtCode.Text = inf.Code; Lookup.Text = inf.Lookup; txtDescription.Text = inf.Description; AttQD_ID.Text = inf.AttQD_ID; AttTemplate.Text = inf.AttTmp; CntQD_ID.Text = inf.CntQD_ID; Type.Text = inf.Type; CntTemplate.Text = inf.CntTmp; Password.Text = inf.Password; LoadListEmail(); SetListEmail(inf.Emails); Port.Text = inf.Port; Protocol.Text = inf.Protocol; Server.Text = inf.Server; Type.Text = inf.Type; Email.Text = inf.UserID; string[] arr = inf.ValidRange.Split(';'); if (arr.Length >= 1) { ValidRange.Text = arr[0]; } if (arr.Length >= 2) { subRange.Text = arr[1]; } ckbUse.Checked = inf.IsUse == "Y"; }
private void btnSave_Click(object sender, EventArgs e) { string sErr = ""; BUS.LIST_TASKControl ctr = new BUS.LIST_TASKControl(); DTO.LIST_TASKInfo inf = new DTO.LIST_TASKInfo(); if (_processStatus == "C") { if (!ctr.IsExist(_dtb, txtCode.Text)) { ctr.Add(GetDataFromForm(inf), ref sErr); } else { sErr = txtCode.Text.Trim() + " is exist!"; } } else if (_processStatus == "A") { sErr = ctr.InsertUpdate(GetDataFromForm(inf)); } if (sErr == "") { _processStatus = "V"; EnableForm(false); } else { lbErr.Text = sErr; } }
private void FrmTransferOut_Load(object sender, EventArgs e) { if (_type == "QD") { BUS.LIST_QDControl control = new BUS.LIST_QDControl(); dt = control.GetTransferOut_LIST_QD(_db, QD_CODE, ref sErr); } else if (_type == "QDADD") { BUS.LIST_QD_SCHEMAControl control = new BUS.LIST_QD_SCHEMAControl(); if (QD_CODE != "") { DTO.LIST_QD_SCHEMAInfo inf = control.Get(_db, QD_CODE, ref sErr); dt = inf.ToDataTable(); dt.Rows.Add(inf.ToDataRow(dt)); dt.TableName = "Table"; } else { dt = control.GetAll(_db, ref sErr); } } else if (_type == "TASK") { BUS.LIST_TASKControl control = new BUS.LIST_TASKControl(); if (QD_CODE != "") { DTO.LIST_TASKInfo inf = control.Get(_db, QD_CODE, ref sErr); dt = DTO.LIST_TASKInfo.ToDataTable(); dt.Rows.Add(inf.ToDataRow(dt)); dt.TableName = "Table"; } else { dt = control.GetAll(_db, ref sErr); } } else if (_type == "POD") { BUS.PODControl control = new BUS.PODControl(); if (QD_CODE != "") { DTO.PODInfo inf = control.Get(QD_CODE, ref sErr); dt = DTO.PODInfo.ToDataTable(); dt.Rows.Add(inf.ToDataRow(dt)); dt.TableName = "Table"; } else { dt = control.GetAll(ref sErr); } } dtEnd = dt.Copy(); radGridView1.DataSource = dtEnd; radGridView1.RetrieveStructure(); }
private void btnRun_Click(object sender, EventArgs e) { BUS.LIST_TASKControl ctr = new BUS.LIST_TASKControl(); if (ctr.IsExist(_dtb, txtCode.Text)) { DTO.LIST_TASKInfo inf = new DTO.LIST_TASKInfo(); inf = GetDataFromForm(inf); frmTestMail frm = new frmTestMail(GetDataFromForm(inf)); frm.ShowDialog(); } }
private void toolStripButton1_Click(object sender, EventArgs e) { frmEmail frm = new frmEmail(_dtb); if (frm.ShowDialog() == DialogResult.OK) { LoadListEmail(); BUS.LIST_TASKControl ctr = new BUS.LIST_TASKControl(); if (ctr.IsExist(_dtb, txtCode.Text)) { DTO.LIST_TASKInfo inf = new DTO.LIST_TASKInfo(); inf = GetDataFromForm(inf); SetListEmail(inf.Emails); } } }
private DTO.LIST_TASKInfo GetDataFromForm(DTO.LIST_TASKInfo inf) { inf.Code = txtCode.Text; inf.DTB = _dtb; inf.Lookup = Lookup.Text; inf.Description = txtDescription.Text; inf.AttQD_ID = AttQD_ID.Text; inf.AttTmp = AttTemplate.Text; inf.CntQD_ID = CntQD_ID.Text; inf.CntTmp = CntTemplate.Text; inf.Password = Password.Text; inf.Emails = GetListEmail(); inf.Port = Port.Text; inf.Protocol = Protocol.Text; inf.Server = Server.Text; inf.UserID = Email.Text; inf.ValidRange = ValidRange.Text + ";" + subRange.Text; inf.IsUse = ckbUse.Checked ? "Y" : "N"; inf.Type = Type.Text; return(inf); }
private void btnView_Click(object sender, EventArgs e) { string sErr = ""; _processStatus = "V"; frmTaskView frm = new frmTaskView(_dtb, _user); //frm.Connect = Form_QD._dtb; if (frm.ShowDialog() == DialogResult.OK) { if (frm.returnValue != null) { BUS.LIST_TASKControl ctr = new BUS.LIST_TASKControl(); DTO.LIST_TASKInfo inf = ctr.Get(_dtb, ((object[])frm.returnValue)[0].ToString(), ref sErr); SetDataToForm(inf); } } if (sErr == "") { EnableForm(false); _processStatus = "V"; } }
private static void EmailNormal(Dictionary <string, object> valueList, DTO.LIST_TASKInfo infTask) { ReportGenerator rgAtt = null; ReportGenerator rgCnt = null; if (infTask.AttQD_ID != "") { QueryBuilder.SQLBuilder sqlBuiderA = QueryBuilder.SQLBuilder.LoadSQLBuilderFromDataBase(infTask.AttQD_ID, _db, ""); rgAtt = new ReportGenerator(sqlBuiderA, infTask.AttQD_ID, "", _repConnect, _tempPath, _reptPath, __documentDirectory); } else { DataSet ds = new DataSet(); rgAtt = new ReportGenerator(ds, infTask.AttTmp, _db, _reptPath, _tempPath, _reptPath, __documentDirectory); } if (infTask.CntQD_ID != "") { QueryBuilder.SQLBuilder sqlBuiderC = QueryBuilder.SQLBuilder.LoadSQLBuilderFromDataBase(infTask.CntQD_ID, _db, ""); rgCnt = new ReportGenerator(sqlBuiderC, infTask.CntQD_ID, "", _repConnect, _tempPath, _reptPath, __documentDirectory); } else { DataSet ds = new DataSet(); rgCnt = new ReportGenerator(ds, infTask.CntTmp, _db, _repConnect, _tempPath, _reptPath, __documentDirectory); } rgAtt.ValueList = valueList; rgCnt.ValueList = valueList; ExcelFile xls = rgAtt.CreateReport(); rgAtt.UserID = _userID; rgCnt.Close(); bool flagRun = false; string[] arrVRange = infTask.ValidRange.Split(';'); if (arrVRange.Length >= 1) { for (int i = 1; i <= xls.SheetCount; i++) { TXlsNamedRange range = xls.GetNamedRange(arrVRange[0], 0); if (range != null) { xls.ActiveSheet = range.SheetIndex; object flag = xls.GetCellValue(range.Top, range.Left); if (flag != null && !String.IsNullOrEmpty(flag.ToString().Trim()) && flag.ToString().Trim() != "0") { flagRun = true; break; } } } } string title = infTask.Description; if (flagRun) { try { using (TextWriter wt = rgCnt.ExportHTML(_reptPath)) { ExcelFile xls1 = rgCnt.XlsFile; if (arrVRange.Length >= 2) { for (int i = 1; i <= xls1.SheetCount; i++) { TXlsNamedRange range = xls1.GetNamedRange(arrVRange[1], 0); if (range != null) { xls1.ActiveSheet = range.SheetIndex; object flag = xls1.GetCellValue(range.Top, range.Left); if (flag != null && !String.IsNullOrEmpty(flag.ToString())) { title = flag.ToString(); break; } } } } string content = wt.ToString(); string filename = rgAtt.ExportExcelToFile(_reptPath, infTask.Description + ".xls"); Sendmail sendMail = new Sendmail(infTask.UserID, infTask.Password, infTask.Server, infTask.Protocol, Convert.ToInt32(infTask.Port)); string[] emails = infTask.Emails.Split(','); Dictionary <string, string> arrayMail = new Dictionary <string, string>(); for (int i = 0; i < emails.Length; i++) { Match name = Regex.Match(emails[i], "\".+\""); Match mail = Regex.Match(emails[i], "<.+>"); arrayMail.Add(mail.Value.Substring(1, mail.Value.Length - 2), name.Value.Substring(1, name.Value.Length - 2)); } sErr = sendMail.SendMail(title, content, arrayMail, filename, true, true); } } catch (Exception ex) { sErr = ex.Message; } } }
public frmTestMail(DTO.LIST_TASKInfo info) { InitializeComponent(); _info = info; }