Пример #1
0
        /// <summary>
        /// Saves the Reports
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void BtnFinalizeSave_TouchUpInside(object sender, EventArgs e)
        {
            if (InspectionResult != null)
            {
                InspectionTransactionService inspectionTransactionService = new InspectionTransactionService(AppDelegate.DatabaseContext);
                if (InspectionResult != null && !string.IsNullOrEmpty(InspectionResult.pass))
                {
                    InspectionResult.IsFinalise = 1;
                }
                inspectionTransactionService.UpdateInspectionTransaction(InspectionResult);
                SaveAllReports();
            }
//			btnLogOut.Enabled = false;

            btnSync.Enabled = false;
            AppDelegate.stopAutoSync();
            UIApplication.SharedApplication.IdleTimerDisabled = true;

            syncData(false);

            AppDelegate.startAutoSync();

            ClearMemory();
            DashBoardViewController dashBoardViewController = this.Storyboard.InstantiateViewController("DashBoardViewController") as DashBoardViewController;

            this.NavigationController.PushViewController(dashBoardViewController, false);
        }
Пример #2
0
        /// <summary>
        /// Saves all reports.
        /// </summary>
        private void SaveAllReports()
        {
            ReportService reportService = new ReportService(AppDelegate.DatabaseContext);
            InspectionTransactionService InsTransservice = new InspectionTransactionService(AppDelegate.DatabaseContext);
            int inspectionTransactionID = InsTransservice.GetInspectionTransactionID(InspectionResult.projectID, InspectionResult.inspectionID);

            if (!string.IsNullOrEmpty(reportPath) && File.Exists(reportPath))
            {
                byte[] buffer;
                using (Stream stream = new FileStream(reportPath, FileMode.Open))
                {
                    buffer = new byte[stream.Length - 1];
                    stream.Read(buffer, 0, buffer.Length);
                }
                Model.Report report = new Model.Report()
                {
                    InspectionTransID = inspectionTransactionID,
                    ReportType        = InspectionResult.pass,
                    ReportDesc        = buffer
                };
                reportService.SaveReport(report);
            }

            if (!string.IsNullOrEmpty(PhotoLogReportPath) && File.Exists(PhotoLogReportPath))
            {
                byte[] photoLogbuffer;
                using (Stream stream = new FileStream(PhotoLogReportPath, FileMode.Open)) {
                    photoLogbuffer = new byte[stream.Length - 1];
                    stream.Read(photoLogbuffer, 0, photoLogbuffer.Length);
                }

                Model.Report photoLogReport = new Model.Report()
                {
                    InspectionTransID = inspectionTransactionID,
                    ReportType        = Constants.REPORTTYPE_PHOTOLOG,
                    ReportDesc        = photoLogbuffer
                };
                reportService.SaveReport(photoLogReport);
            }
        }
        private List <ReportView> ConvertToReportView(List <Report> reports)
        {
            List <ReportView> reportView = new List <ReportView> ();

            if (reports != null && reports.Count > 0)
            {
                inspectionTransactionService = new InspectionTransactionService(AppDelegate.DatabaseContext);
                pathwayService    = new PathwayService(AppDelegate.DatabaseContext);
                inspectionService = new InspectionService(AppDelegate.DatabaseContext);
                foreach (var report in reports)
                {
                    if (reportView.Where(rv => rv.InspectionTransactionID == report.InspectionTransID).Count() <= 0)
                    {
                        var inspection = inspectionTransactionService.GetInspectionProjectID(report.InspectionTransID);
                        if (inspection != null)
                        {
                            switch (inspection.PathwayTypeID)
                            {
                            case (0):
                                inspection.PathwayTypeID = 1;
                                break;

                            case (1):
                                inspection.PathwayTypeID = 2;
                                break;

                            case (2):
                                inspection.PathwayTypeID = 3;
                                break;

                            default:

                                break;
                            }


                            var pathway        = pathwayService.GetPathway(inspection.PathwayTypeID);
                            var inspectionType = inspectionService.GetInspection(Convert.ToInt32(inspection.InspectionID));

                            if ((report.ReportType.ToUpper() == ReportType.Pass.ToString().ToUpper()) || (report.ReportType.ToUpper() == ReportType.Fail.ToString().ToUpper()))
                            {
                            }
                            else
                            {
                                report.ReportType = string.Empty;
                            }

                            reportView.Add(new ReportView()
                            {
                                AppID                   = inspection.ProjectID.ToString(),
                                InspectionType          = inspectionType.InspectionType,
                                PathwayType             = (pathway != null) ? pathway.PathwayDesc : "",
                                ReportDesc              = null,
                                ReportType              = report.ReportType,
                                InspectionTransactionID = report.InspectionTransID,
                            });
                        }
                    }
                }
            }
            return(reportView);
        }
        /// <summary>
        /// Initialises the dash board.
        /// </summary>
        private async void InitialiseDashBoard()
        {
            try{
                //UIApplication.SharedApplication.IdleTimerDisabled = true;
                this.NavigationController.NavigationBarHidden = true;
                inspectionTransactionService = new InspectionTransactionService(AppDelegate.DatabaseContext);
                inspectionDetailInfo         = await Task.Run(() => inspectionTransactionService.GetServiceInspections(CrossConnectivity.Current.IsConnected, Token, IsFirstLogin));

                ShowErrorResponse();

                if (IsIntiatedFromAppDelegate)
                {
                    IsIntiatedFromAppDelegate = false;
                    //sync and notify
                    syncInit();
                    NotifyCount();

                    //btnLogout.Enabled=false;

                    syncData();
                }
                else
                {
                    syncInit();
                }
                if (!CrossConnectivity.Current.IsConnected && IsFirstLogin)
                {
                    UIAlertView alert = new UIAlertView(@"Alert", @"To get new assigned inspections please connect to the network!", null, NSBundle.MainBundle.LocalizedString("OK", "OK"));
                    alert.Show();
                }



                List <DashBoardLeftTableItem> tableItems = new List <DashBoardLeftTableItem> ()
                {
                    new DashBoardLeftTableItem()
                    {
                        Heading    = "Inspections",
                        SubHeading = "Today",
                        ImageName  = "FolderIcon.png",
                        HeaderType = HeaderType.Today
                    },
                    new DashBoardLeftTableItem()
                    {
                        Heading    = "Inspections",
                        SubHeading = "Upcoming",
                        ImageName  = "FolderIcon.png",
                        HeaderType = HeaderType.Upcoming
                    }
                };

                lblSyncNumber.Layer.CornerRadius = lblSyncNumber.Frame.Height / 2;
                lblSyncNumber.ClipsToBounds      = true;

                LblNotifyNbr.Layer.CornerRadius = LblNotifyNbr.Frame.Height / 2;
                LblNotifyNbr.ClipsToBounds      = true;
                inspectionScheduleSource        = new InspectionScheduleSource(tableItems, inspectionDetailInfo);
                DashboardView.Source            = inspectionScheduleSource;
                DashboardView.ReloadData();
                // Header View Events
                inspectionScheduleSource.DashBoardRowSelected += UpdateRightTableView;
                btnHome.TouchUpInside   -= BtnHome_TouchUpInside;
                btnHome.TouchUpInside   += BtnHome_TouchUpInside;
                btnLogout.TouchUpInside -= BtnLogout_TouchUpInside;
                btnLogout.TouchUpInside += BtnLogout_TouchUpInside;
                btnSync.TouchUpInside   -= BtnSync_TouchUpInside;
                btnSync.TouchUpInside   += BtnSync_TouchUpInside;
                reportBtn.TouchUpInside -= ReportBtn_TouchUpInside;
                reportBtn.TouchUpInside += ReportBtn_TouchUpInside;

                btnNotify.TouchUpInside -= BtnNotify_TouchUpInside;
                btnNotify.TouchUpInside += BtnNotify_TouchUpInside;

                ProjectDetailView.Hidden          = true;
                ProjectDetailView.TableFooterView = new UIView(new CGRect(0, 0, 0, 0));
                lblUserName.Text = UserName;
                lblDate.Text     = DateTime.Today.Date.ToString("MMM dd, yyyy");
            }catch (Exception ex) {
                HideOverLay();
                ShowErrorResponse();
            }
        }