예제 #1
0
        async public override void OnNavigatedTo(object navigationParameter, Windows.UI.Xaml.Navigation.NavigationMode navigationMode, Dictionary <string, object> viewModelState)
        {
            base.OnNavigatedTo(navigationParameter, navigationMode, viewModelState);
            _task = JsonConvert.DeserializeObject <Eqstra.BusinessLogic.TITask>(navigationParameter.ToString());
            await GetCustomerDetailsAsync();

            PersistentData.RefreshInstance();
            PersistentData.Instance.CustomerDetails = this.CustomerDetails;
            PersistentData.Instance.Task            = this._task;

            LoadAppointments();
            var dd = await SqliteHelper.Storage.GetSingleRecordAsync <DrivingDuration>(x => x.VehicleInsRecID == _task.VehicleInsRecId);

            if (dd != null)
            {
                this.IsArrived         = dd.StopDateTime == DateTime.MinValue;
                this.IsStartInspection = !this.IsArrived;
            }
            else
            {
                this.IsStartDriving    = true;
                this.IsArrived         = false;
                this.IsStartInspection = false;
            }
            //_eventAggregator.GetEvent<CustFetchedEvent>().Subscribe(async b =>
            //{
            //    await GetCustomerDetailsAsync();
            //});
        }
예제 #2
0
        async public override void OnNavigatedTo(object navigationParameter, Windows.UI.Xaml.Navigation.NavigationMode navigationMode, Dictionary <string, object> viewModelState)
        {
            try
            {
                base.OnNavigatedTo(navigationParameter, navigationMode, viewModelState);
                this.InspectionHistList = new ObservableCollection <InspectionHistory> {
                    new InspectionHistory {
                        InspectionResult = new List <string> {
                            "Engine and brake oil replacement", "Wheel alignment"
                        }, CustomerId = "1", InspectedBy = "Jon Tabor", InspectedOn = DateTime.Now
                    },
                    new InspectionHistory {
                        InspectionResult = new List <string> {
                            "Vehicle coolant replacement", "Few dent repairs"
                        }, CustomerId = "1", InspectedBy = "Robert Green", InspectedOn = DateTime.Now
                    },
                    new InspectionHistory {
                        InspectionResult = new List <string> {
                            "Vehicle is in perfect condition"
                        }, CustomerId = "1", InspectedBy = "Christopher", InspectedOn = DateTime.Now
                    },
                };
                _task    = JsonConvert.DeserializeObject <Eqstra.BusinessLogic.TITask>(navigationParameter.ToString());
                App.Task = _task;

                ApplicationData.Current.LocalSettings.Values["CaseNumber"] = _task.CaseNumber;
                LoadAppointments();
                GetCustomerDetailsAsync();

                _eventAggregator.GetEvent <CustFetchedEvent>().Subscribe(b =>
                {
                    GetCustomerDetailsAsync();
                });

                await this.LoadModelFromDbAsync(this._task.CaseServiceRecID);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #3
0
        public async System.Threading.Tasks.Task <List <Eqstra.BusinessLogic.TITask> > SyncTasksFromAXAsync()
        {
            var insertList = new List <Eqstra.BusinessLogic.TITask>();

            try
            {
                if (_userInfo == null)
                {
                    _userInfo = JsonConvert.DeserializeObject <UserInfo>(ApplicationData.Current.RoamingSettings.Values[Constants.UserInfo].ToString());
                }

                var subCompUpdateList = new List <MaintenanceRepair>();
                var subCompInsertList = new List <MaintenanceRepair>();

                var result = await client.getTasksAsync(_userInfo.UserId, _userInfo.CompanyId);

                if (result != null)
                {
                    foreach (var task in result.response)
                    {
                        var tiTask = new Eqstra.BusinessLogic.TITask
                        {
                            CaseServiceRecID = task.parmCaseServiceRecID,
                            ServiceRecID     = task.parmCaseRecID,
                            CaseNumber       = task.parmCaseId,
                            CaseCategory     = task.parmCaseCategory,
                            ContactName      = task.parmContactPersonName,
                            ContactNumber    = task.parmContactPersonPhone,
                            CustPhone        = task.parmCustPhone,
                            CustomerName     = task.parmCustName,
                            Status           = task.parmStatus,
                            StatusDueDate    = task.parmStatusDueDate,
                            UserId           = task.parmUserID,
                            Address          = task.parmContactPersonAddress,
                            CustomerId       = task.parmCustAccount,
                            VehicleInsRecId  = task.parmCaseServiceRecID,
                            ConfirmedDate    = task.parmInspectionDueDate,
                            AllocatedTo      = _userInfo.Name,
                            Email            = task.parmEmail
                        };


                        var subComponents = await client.getSubComponentsAsync(new ObservableCollection <long> {
                            tiTask.CaseServiceRecID
                        }, _userInfo.CompanyId);

                        var allSubComponents = await SqliteHelper.Storage.LoadTableAsync <MaintenanceRepair>();

                        if (subComponents != null)
                        {
                            foreach (var item in subComponents.response)
                            {
                                var subComponent = new MaintenanceRepair
                                {
                                    SubComponent     = item.parmSubComponent,
                                    MajorComponent   = item.parmMajorComponent,
                                    Action           = item.parmAction,
                                    Cause            = item.parmCause,
                                    CaseServiceRecId = tiTask.CaseServiceRecID,
                                    Repairid         = item.parmRecID
                                };

                                if (!allSubComponents.Any(x => x.Repairid == item.parmRecID))
                                {
                                    await SqliteHelper.Storage.InsertSingleRecordAsync(subComponent);
                                }
                            }
                        }

                        insertList.Add(tiTask);
                    }
                    await SqliteHelper.Storage.DropnCreateTableAsync <Eqstra.BusinessLogic.TITask>();

                    await SqliteHelper.Storage.InsertAllAsync(insertList);
                }
            }
            catch (Exception ex)
            {
                Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    AppSettings.Instance.IsSynchronizing = 0;
                    AppSettings.Instance.ErrorMessage    = ex.Message + ex.InnerException;
                });
            }
            return(insertList);
        }