Ejemplo n.º 1
0
        public PreferredSupplierPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator, ISupplierService supplierService, ILocationService locationService)
        {
            this._navigationService = navigationService;
            this._eventAggregator   = eventAggregator;
            this.PoolofSupplier     = new ObservableCollection <Supplier>();
            this._supplierService   = supplierService;
            this._locationService   = locationService;

            this.NextPageCommand = DelegateCommand.FromAsyncHandler(
                async() =>
            {
                try
                {
                    if (this.SelectedSupplier != null)
                    {
                        this.TaskProgressBar = Visibility.Visible;
                        var supplier         = new SupplierSelection()
                        {
                            CaseNumber = this.SelectedTask.CaseNumber, CaseServiceRecID = this.SelectedTask.CaseServiceRecID, SelectedSupplier = this.SelectedSupplier
                        };
                        var response = await this._supplierService.InsertSelectedSupplierAsync(supplier, this.UserInfo);
                        if (response)
                        {
                            navigationService.Navigate("SubmittedDetail", string.Empty);
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.TaskProgressBar = Visibility.Collapsed;
                }
                finally
                {
                }
            },

                () => { return(this.SelectedSupplier != null); });


            _eventAggregator.GetEvent <SupplierFilterEvent>().Subscribe(poolofSupplier =>
            {
                this.PoolofSupplier = poolofSupplier;
            });
        }
Ejemplo n.º 2
0
        public async Task <bool> InsertSelectedSupplierAsync(SupplierSelection supplierSelection, UserInfo userInfo)
        {
            try
            {
                var postData = new { target = "ServiceScheduling", method = "save", parameters = new[] { "InsertSelectedSupplier", Newtonsoft.Json.JsonConvert.SerializeObject(supplierSelection), Newtonsoft.Json.JsonConvert.SerializeObject(userInfo) } };
                var response = await _httpFactory.PostAsync(new HttpStringContent(JsonConvert.SerializeObject(postData), Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json"));

                response.EnsureSuccessStatusCode();
                if (response.IsSuccessStatusCode)
                {
                    return(JsonConvert.DeserializeObject <bool>(await response.Content.ReadAsStringAsync()));
                }
            }
            catch (Exception ex)
            {
                new MessageDialog(ex.Message).ShowAsync();
            }
            return(false);
        }
Ejemplo n.º 3
0
        private bool InsertSelectedSupplier(SupplierSelection supplierSelection, UserInfo userInfo)
        {
            try
            {
                _client.insertVendDet(new CallContext()
                {
                }, supplierSelection.CaseNumber, supplierSelection.CaseServiceRecID, default(long), new MzkServiceDetailsContract
                {
                    parmContactPersonName  = supplierSelection.SelectedSupplier.SupplierContactName,
                    parmSupplierName       = supplierSelection.SelectedSupplier.SupplierName,
                    parmContactPersonPhone = supplierSelection.SelectedSupplier.SupplierContactNumber,
                    parmSupplierId         = supplierSelection.SelectedSupplier.AccountNum
                }, new MzkAddressContract(), userInfo.CompanyId);

                return(true);
            }

            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        async public System.Threading.Tasks.Task <bool> InsertSelectedSupplierToSvcAsync(SupplierSelection supplierSelection, string caseNumber, long caseServiceRecId)
        {
            try
            {
                var connectionProfile = NetworkInformation.GetInternetConnectionProfile();
                if (connectionProfile == null || supplierSelection.SelectedSupplier == null || connectionProfile.GetNetworkConnectivityLevel() != NetworkConnectivityLevel.InternetAccess)
                {
                    return(false);
                }

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

                var result = await client.insertVendDetAsync(caseNumber, caseServiceRecId, default(long), new MzkServiceDetailsContract
                {
                    parmContactPersonName  = supplierSelection.SelectedSupplier.SupplierContactName,
                    parmSupplierName       = supplierSelection.SelectedSupplier.SupplierName,
                    parmContactPersonPhone = supplierSelection.SelectedSupplier.SupplierContactNumber,
                    parmSupplierId         = supplierSelection.SelectedSupplier.AccountNum
                }, new MzkAddressContract(), _userInfo.CompanyId);

                return(result != null);
            }


            catch (Exception ex)
            {
                AppSettings.Instance.ErrorMessage = ex.Message;
                return(false);
            }
        }
Ejemplo n.º 5
0
        public ServiceSchedulingPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator, ILocationService locationService, IServiceDetailService serviceDetailService, ISupplierService supplierService, ITaskService taskService)
        {
            this._navigationService    = navigationService;
            this._serviceDetailService = serviceDetailService;
            this._taskService          = taskService;
            this._eventAggregator      = eventAggregator;
            this._locationService      = locationService;
            this._supplierService      = supplierService;
            this.Model            = new ServiceSchedulingDetail();
            _busyIndicator        = new BusyIndicator();
            IsEnabledDesType      = true;
            this.Address          = new BusinessLogic.Portable.SSModels.Address();
            this.applicationTheme = Application.Current.RequestedTheme;
            this.SpBorderBrush    = this.applicationTheme == ApplicationTheme.Dark ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black);
            this.LtBorderBrush    = this.applicationTheme == ApplicationTheme.Dark ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black);
            this.DtBorderBrush    = this.applicationTheme == ApplicationTheme.Dark ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black);
            this.StBorderBrush    = this.applicationTheme == ApplicationTheme.Dark ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black);
            this.IsLiftRequired   = false;
            this.AddVisibility    = Visibility.Collapsed;
            BoundWidth            = Window.Current.Bounds.Width - 30;
            BoundMinWidth         = Window.Current.Bounds.Width - 80;

            this.NextPageCommand = DelegateCommand.FromAsyncHandler(
                async() =>
            {
                try
                {
                    if (this.Validate())
                    {
                        _busyIndicator.Open("Please wait, Saving ...");

                        this.Model.ServiceDateOption1 = this.Model.ServiceDateOpt1.ToString("MM/dd/yyyy HH:mm");
                        this.Model.ServiceDateOption2 = this.Model.ServiceDateOpt2.ToString("MM/dd/yyyy HH:mm");
                        this.Model.ODOReadingDate     = this.Model.ODOReadingDt.ToString("MM/dd/yyyy HH:mm");
                        bool response = await _serviceDetailService.InsertServiceDetailsAsync(this.Model, this.Address, this.UserInfo);
                        if (response)
                        {
                            var caseStatus = await this._taskService.UpdateStatusListAsync(this.SelectedTask, this.UserInfo);
                            var supplier   = new SupplierSelection()
                            {
                                CaseNumber = this.SelectedTask.CaseNumber, CaseServiceRecID = this.SelectedTask.CaseServiceRecID, SelectedSupplier = this.SelectedSupplier
                            };
                            var res = await this._supplierService.InsertSelectedSupplierAsync(supplier, this.UserInfo);
                            if (res)
                            {
                                this.SelectedTask.Status = caseStatus.Status;
                                await this._taskService.UpdateStatusListAsync(this.SelectedTask, this.UserInfo);
                                PersistentData.RefreshInstance();
                                navigationService.Navigate("Main", string.Empty);
                            }
                        }
                        _busyIndicator.Close();
                    }
                }
                catch (Exception ex)
                {
                    _busyIndicator.Close();
                }
                finally
                {
                }
            },

                () => { return(this.Model != null); });


            this.TakePictureCommand = DelegateCommand <ImageCapture> .FromAsyncHandler(async (param) =>
            {
                FileOpenPicker openPicker = new FileOpenPicker();
                openPicker.ViewMode       = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
                openPicker.FileTypeFilter.Add(".bmp");
                openPicker.FileTypeFilter.Add(".png");
                openPicker.FileTypeFilter.Add(".jpeg");
                openPicker.FileTypeFilter.Add(".jpg");
                PersistentData.Instance.ServiceSchedulingDetail = this.Model;

                openPicker.PickSingleFileAndContinue();

                this._eventAggregator.GetEvent <ServiceSchedulingDetailEvent>().Subscribe(model =>
                {
                    this.Model = model;
                });
                this._eventAggregator.GetEvent <ImageCaptureEvent>().Subscribe(imageCapture =>
                {
                    this.Model.OdoReadingImageCapture = imageCapture;
                });
            });

            this.OpenImageViewerCommand = new DelegateCommand(
                async() =>
            {
                if (_imageViewer == null)
                {
                    _imageViewer = new ImageViewerPopup(this._eventAggregator, this.Model);
                }
                else
                {
                    _imageViewer      = null;
                    this._imageViewer = new ImageViewerPopup(this._eventAggregator, this.Model);
                }

                _imageViewer.DataContext = this.Model.OdoReadingImageCapture;
                await _imageViewer.ShowAsync();
            });


            this.VoiceCommand = new DelegateCommand(async() =>
            {
                try
                {
                    SpeechRecognizer recognizer = new SpeechRecognizer();

                    SpeechRecognitionTopicConstraint topicConstraint = new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.Dictation, "Development");

                    recognizer.Constraints.Add(topicConstraint);
                    await recognizer.CompileConstraintsAsync();

                    var results = await recognizer.RecognizeWithUIAsync();
                    if (results != null & (results.Confidence != SpeechRecognitionConfidence.Rejected))
                    {
                        this.Model.AdditionalWork = results.Text;
                    }
                    else
                    {
                        await new MessageDialog("Sorry, I did not get that.").ShowAsync();
                    }
                }
                catch (Exception)
                {
                }
            });


            this.AddCommand = new DelegateCommand(async() =>
            {
                _addressDialog = new AddressDialog(this._locationService, this._eventAggregator, this.Address);
                this.Model.SelectedDestinationType = new DestinationType();
                await _addressDialog.ShowAsync();
            });

            this.DetailCommand = new DelegateCommand(async() =>
            {
                moreInfo             = new DetailsDialog();
                moreInfo.DataContext = this.SelectedTask;
                await moreInfo.ShowAsync();
            });

            this.SupplierFilterCommand = new DelegateCommand(async() =>
            {
                sp = new SearchSupplierDialog(this._locationService, this._eventAggregator, this._supplierService);
                await sp.ShowAsync();
            });

            this._eventAggregator.GetEvent <AddressFilterEvent>().Subscribe((address) =>
            {
                if (address != null)
                {
                    this.Address     = address;
                    StringBuilder sb = new StringBuilder();

                    sb.Append(address.Street).Append(",").Append(Environment.NewLine);

                    if ((address.SelectedSuburb != null) && !String.IsNullOrEmpty(address.SelectedSuburb.Name))
                    {
                        sb.Append(address.SelectedSuburb.Name).Append(",").Append(Environment.NewLine);
                    }
                    if (address.SelectedRegion != null)
                    {
                        sb.Append(address.SelectedRegion.Name).Append(",").Append(Environment.NewLine);
                    }
                    if ((address.SelectedCity != null) && !String.IsNullOrEmpty(address.SelectedCity.Name))
                    {
                        sb.Append(address.SelectedCity.Name).Append(",").Append(Environment.NewLine);
                    }
                    if ((address.Selectedprovince != null) && !String.IsNullOrEmpty(address.Selectedprovince.Name))
                    {
                        sb.Append(address.Selectedprovince.Name).Append(",").Append(Environment.NewLine);
                    }

                    if ((address.SelectedCountry != null) && !String.IsNullOrEmpty(address.SelectedCountry.Name))
                    {
                        sb.Append(address.SelectedCountry.Name).Append(",").Append(Environment.NewLine);
                    }

                    sb.Append(address.SelectedZip);


                    this.Model.Address = sb.ToString();
                }
            });

            _eventAggregator.GetEvent <SupplierFilterEvent>().Subscribe(poolofSupplier =>
            {
                this.PoolofSupplier = poolofSupplier;
            });
        }