protected void btnSave_OnClick(object sender, EventArgs e) { var perform = PerformServices.GetById(Parameters.Id); if (perform != null) { var report = new Report { RequestID = perform.RequestID, ReporterName = Sessions.DisplayName, ReportContent = BaoCaoThucHien.Text.Trim(), Status = TrangThai.SelectedValue.ToInteger(), PerformOnDate = NgayHoanThanh.Text.ToDateTime(), DepartmentID = perform.DepartmentID }; ReportServices.Create(report: report, performIds: new List <int> { Parameters.Id }, fileContent: null, fileName: "", uploadFolder: AppSettings.UploadFolder, isStaffReport: true, isSendToAgency: true); ExceptionlessClient.Default.SubmitEvent(new Event { Message = $"Chuyển trạng thái thực hiện của {perform.DepartmentName} thành {TrangThai.SelectedItem.Text.ToUpper()} ({Sessions.DisplayName})", Type = "Chuyển trạng thái YKCD", Source = AppSettings.AGENCY_NAME }); Redirector.Redirect(ViewNames.SubAgency.ThongTinYKCD, "id", perform.RequestID); } }
public void SetRequestSynced(long performID) { var perform = PerformServices.GetById(performID); if (perform != null) { perform.IsSynced = true; PerformServices.Update(perform); } }
public bool ReceiveReportFromSubAgency(string xmlDoc) { try { var serializer = new XmlSerializer(typeof(ReportList)); using (var reader = new StringReader(xmlDoc)) { var xmlObj = (ReportList)serializer.Deserialize(reader); foreach (var reportXml in xmlObj.Reports) { var perform = PerformServices.GetById(reportXml.PerformID); if (reportXml != null) { var report = new Report { ReportContent = reportXml.ReportContent, PerformOnDate = reportXml.PerformOnDate, RequestID = reportXml.RequestID, Status = reportXml.Status, ReporterName = reportXml.ReporterName, DepartmentID = perform.DepartmentID }; if (reportXml.DanhSachFile != null && reportXml.DanhSachFile.Count() > 0) { ReportServices.Create(report, new List <int> { reportXml.PerformID.ToInteger() }, reportXml.DanhSachFile[0]?.Content, reportXml.DanhSachFile[0]?.FileName, AppSettings.UploadFolder); } else { ReportServices.Create(report, new List <int> { reportXml.PerformID.ToInteger() }, null, null, AppSettings.UploadFolder); } } } } return(true); } catch (Exception ex) { LogHelper.WriteLog(ex); return(false); } }
public static Request SaveRequest(this RequestElement requestElement, string uploadFolder) { var request = RequestServices.GetByProvinceID(requestElement.RequestID); if (request == null || request.RequestID <= 0) { var document = requestElement.SaveDocument(uploadFolder); request = requestElement.ToRequest(); request.DocumentID = document.DocumentID; RequestServices.Create(request); } else { if (requestElement.IsDeleted) { RequestServices.Delete(request.RequestID, shiftDelete: true); } else { request.Status = requestElement.Status; request.RequiredDate = requestElement.RequiredDate; request.FinishedOnDate = requestElement.FinishedOnDate; request.RequestContent = requestElement.RequestContent; request.IsDeleted = requestElement.IsDeleted; RequestServices.Update(request); if (request.IsAssignPerform) { foreach (Perform perform in request.Performs) { if (request.Status <= 1 && perform.Status == 2) { perform.Status = request.Status; PerformServices.Update(perform); } else if (request.Status == 2 && perform.Status != 2) { perform.Status = 2; perform.FinishedOnDate = request.FinishedOnDate; PerformServices.Update(perform); } } } } } return(request); }
public void DeleteRequest(long requestID) { var request = RequestServices.GetByProvinceID(requestID); if (request != null) { request.IsDeleted = true; foreach (var perform in request.Performs) { PerformServices.Delete(perform); } RequestServices.Update(request); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { NgayHoanThanh.Text = DateTime.Now.ToDateString(); if (PerformServices.GetById(Parameters.Id).Status == 3) { TrangThai.SelectByValue(2); } else { TrangThai.SelectByValue(PerformServices.GetById(Parameters.Id).Status); } } }
public void SetRequestStatus(long performID, int status, DateTime date) { var perform = PerformServices.GetById(performID); if (perform != null) { perform.Status = status; if (status == 2 || status == 3) { perform.Status = 3; perform.FinishedOnDate = date; } perform.IsSynced = false; PerformServices.Update(perform); RequestServices.CapNhatTrangThaiYKCD(perform.RequestID); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var perform = PerformServices.GetById(Parameters.Id); if (perform.Status == 3) { TrangThai.SelectByValue(2); NgayHoanThanh.Text = perform.FinishedOnDate.ToDateString(); } else { TrangThai.SelectByValue(PerformServices.GetById(Parameters.Id).Status); NgayHoanThanh.Text = DateTime.Now.ToDateString(); } } btnSave.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btnSave, null) + ";"); }
protected void btnSave_OnClick(object sender, EventArgs e) { var perform = PerformServices.GetById(Parameters.Id); var report = new Report(); if (!string.IsNullOrEmpty(BaoCaoThucHien.Text.Trim())) { report = new Report { RequestID = perform.RequestID, CreatedByName = Sessions.DisplayName, ReportContent = BaoCaoThucHien.Text.Trim(), Status = TrangThai.SelectedValue.ToInteger(), PerformOnDate = NgayHoanThanh.Text.ToDateTime(), AgencyID = perform.AgencyID }; } else if (TrangThai.SelectedValue.ToInteger() != 2 && string.IsNullOrEmpty(BaoCaoThucHien.Text.Trim())) { report = new Report { RequestID = perform.RequestID, CreatedByName = Sessions.DisplayName, ReportContent = $"Chuyển trạng thái thực hiện của {perform.AgencyName} thành {TrangThai.SelectedItem.Text.ToUpper()}", Status = TrangThai.SelectedValue.ToInteger(), PerformOnDate = NgayHoanThanh.Text.ToDateTime(), AgencyID = perform.AgencyID }; } else if (perform.Status == 3 && TrangThai.SelectedValue.ToInteger() == 2 && string.IsNullOrEmpty(BaoCaoThucHien.Text.Trim())) { report = new Report { RequestID = perform.RequestID, CreatedByName = Sessions.DisplayName, ReportContent = $"Xác nhận trạng thái thực hiện của {perform.AgencyName} thành {TrangThai.SelectedItem.Text.ToUpper()}", Status = TrangThai.SelectedValue.ToInteger(), PerformOnDate = NgayHoanThanh.Text.ToDateTime(), AgencyID = perform.AgencyID }; } else { report = new Report { RequestID = perform.RequestID, CreatedByName = Sessions.DisplayName, ReportContent = BaoCaoThucHien.Text.Trim(), Status = TrangThai.SelectedValue.ToInteger(), PerformOnDate = NgayHoanThanh.Text.ToDateTime(), AgencyID = perform.AgencyID }; } ReportServices.Create(report: report, performIds: new List <long> { Parameters.Id }, fileContent: null, fileName: "", uploadFolder: AppSettings.UploadFolder, isStaffReport: true); ExceptionlessClient.Default.SubmitEvent(new Event { Message = $"Chuyển trạng thái thực hiện của {perform.AgencyName} thành {TrangThai.SelectedItem.Text.ToUpper()} ({Sessions.DisplayName})", Type = "Chuyển trạng thái YKCD", Source = "YKCD_UBND" }); Redirector.Redirect(ViewNames.Province.ThongTinYKCD, "id", perform.RequestID); }
public bool ReceiveReport(string xmlDoc) { try { var serializer = new XmlSerializer(typeof(ReportList)); using (var reader = new StringReader(xmlDoc)) { var xmlObj = (ReportList)serializer.Deserialize(reader); foreach (var reportXml in xmlObj.Reports) { var perform = PerformServices.GetById(reportXml.PerformID); if (!string.IsNullOrEmpty(reportXml.ReportContent)) { var report = new Report { ReportContent = reportXml.ReportContent, PerformOnDate = reportXml.PerformOnDate, RequestID = reportXml.RequestID, Status = reportXml.Status, CreatedByName = reportXml.ReporterName, AgencyID = perform.AgencyID }; ReportServices.Create(report); foreach (var reportFile in reportXml.DanhSachFile) { try { ReportFileServices.CreateReportFile(report, fileContent: reportFile.Content, fileName: reportFile.FileName, uploadFolder: AppSettings.UploadFolder); } catch (Exception ex) { LogHelper.WriteLog(ex); continue; } } } if (perform.Status != 2) { perform.Status = reportXml.Status; if (perform.Status == 2 || perform.Status == 3) { perform.Status = 3; perform.FinishedOnDate = reportXml.PerformOnDate; } perform.IsSynced = false; PerformServices.Update(perform); RequestServices.CapNhatTrangThaiYKCD(reportXml.RequestID); } } } return(true); } catch (Exception ex) { LogHelper.WriteLog(ex); return(false); } }