public int SaveReport(Report report) { int result = 0; try { var reports = GetReports().Where(r => r.InspectionTransID == report.InspectionTransID && r.ReportType == report.ReportType); if (reports.Count() > 0) { foreach (var rep in reports) { report.ReportID = rep.ReportID; ReportDO reportDO = Converter.GetReportDO(report); result = ReportRepository.UpdateEntity(reportDO); } } else { ReportDO reportDO = Converter.GetReportDO(report); result = ReportRepository.SaveEntity(reportDO); } } catch (Exception ex) { Debug.WriteLine("Exception Occured in SaveReport method due to " + ex.Message); } return(result); }
public static Report GetReport(ReportDO reportDO) { Report report = new Report() { ReportID = reportDO.ID, InspectionTransID = reportDO.InspectionTransID, ReportType = reportDO.ReportType, ReportDesc = reportDO.ReportDesc }; return(report); }
//converter for reportDO public static ReportDO GetReportDO(Report report) { ReportDO reportDO = new ReportDO() { ID = report.ReportID, InspectionTransID = report.InspectionTransID, ReportType = report.ReportType, ReportDesc = report.ReportDesc }; return(reportDO); }
public ReportDO GetReportOnInspectionTransactionID(SQLiteConnection conn, int id, string reportType) { ReportDO report = new ReportDO(); try { report = ReportDO.getReports(conn, id, reportType).FirstOrDefault(); } catch (Exception ex) { Debug.WriteLine("Exception Occured in GetReport method due to " + ex.Message); } return(report); }
public int DeleteReport(Report report) { int result = 0; try { ReportDO reportDO = Converter.GetReportDO(report); result = ReportRepository.DeleteEntity(reportDO.ID); } catch (Exception ex) { Debug.WriteLine("Exception Occured in DeleteReport method due to " + ex.Message); } return(result); }
public Report GetReport(int id) { Report report = new Report(); try { ReportDO reportDO = ReportRepository.GetEntity(id); if (reportDO != null) { report = Converter.GetReport(reportDO); } } catch (Exception ex) { Debug.WriteLine("Exception Occured in GetReport method due to " + ex.Message); } return(report); }
public int DeleteInspectionTransactionNotSync(Inspection inspection) { int inspectionTransactionResult = 0; try { IEnumerable <InspectionTransactionDO> inspections = inspectionTransactionRepository.GetEntities(); InspectionTransactionDO inspectionTransactionDO = inspections.FirstOrDefault(ins => ins.InspectionID == inspection.inspectionID && ins.ProjectID == inspection.projectID); inspectionTransactionResult = inspectionTransactionRepository.DeleteEntity(inspectionTransactionDO.ID); LocationImageDo.DeleteImage(conn, inspectionTransactionDO.ID); DocumentDO.DeleteDocument(conn, inspection.inspectionID, inspection.projectID); PunchListDO.DeletePunchList(conn, inspection.inspectionID, inspection.projectID); PunchListImageDO.DeletePunchListImageList(conn, inspection.ID); ReportDO.DeleteReports(conn, inspection.ID); using (var optService = new OptionTransactionService(conn)) { var optIds = optService.GetOptionTransactionsForInspection(inspection.ID).Select(s => s.ID); OptionTransactionDO.DeleteInspectionOptions(conn, inspection.ID); if (optIds != null && optIds.Count() > 0) { foreach (var optID in optIds) { var chkTransIDs = CheckListTransactionDO.GetCheckListTransaction(conn, optID).Select(s => s.ID); CheckListTransactionDO.DeletecheckList(conn, optID); OptionTransactionImageDO.DeleteOptionImagesSync(conn, optID); if (chkTransIDs != null && chkTransIDs.Count() > 0) { foreach (var chkId in chkTransIDs) { GuildedPhotoDO.DeleteGuidedImageList(conn, chkId); } } } } } } catch (Exception ex) { Debug.WriteLine("Exception Occured in DeleteInspectionTransaction method due to " + ex.Message); } return(inspectionTransactionResult); }
void PdfViewer(string reportType) { try { reportService = new ReportService(AppDelegate.DatabaseContext); ReportDO reports = reportService.GetReportOnInspectionTransactionID(AppDelegate.DatabaseContext, reportView.InspectionTransactionID, reportType); if (reports != null) { string appRootDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); DirectoryInfo path = Directory.CreateDirectory(appRootDir + "/LiRoSyncReports"); string pathname = path.FullName + "/" + reportType.ToUpper() + " REPORT" + ".pdf"; FileStream fs = new FileStream(pathname, FileMode.Create, FileAccess.ReadWrite, FileShare.None); foreach (byte fileByte in reports.ReportDesc) { fs.WriteByte(fileByte); } fs.Close(); if (File.Exists(pathname)) { var viewer = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(pathname)); InspectionDataTableViewController.FilePath = pathname; UIDocumentInteractionControllerDelegateDerived del = new UIDocumentInteractionControllerDelegateDerived(appDetailsController); del.doneWithPreview += Del_doneWithPreview; viewer.Delegate = del; previewdone = false; viewer.PresentPreview(true); } } else { UIAlertView alert = new UIAlertView("Alert", "Selected report is uploaded, hence not available to display", null, NSBundle.MainBundle.LocalizedString("OK", "OK")); alert.Show(); } } catch (Exception ex) { Debug.WriteLine("Exception occured method PdfViewer due to : " + ex.Message); } }
public JsonResult DBMostSale(DateTime FromDate, DateTime ToDate) { using (var Db = new ProjectWebEntities()) { var resultShow = new List <string[]>(); var result = new List <ReportDO>(); foreach (var m in Db.Tbl_OrderDetail.Where(p => p.Tbl_Order.SatusId == GlobalVariables.status_Success && p.Tbl_Order.DateCreate >= FromDate && p.Tbl_Order.DateCreate <= ToDate).GroupBy(p => p.ProductId)) { var tmp = new ReportDO(); tmp.Name = Db.Tbl_Product.Single(p => p.Id == m.Key).Name; tmp.Quantity = m.Sum(p => p.Quantity); result.Add(tmp); } var bee = result.OrderByDescending(p => p.Quantity); foreach (var m in bee) { var tmp = new string[2] { m.Name, m.Quantity.ToString() }; resultShow.Add(tmp); } return(Json(resultShow, JsonRequestBehavior.AllowGet)); } }