예제 #1
0
        async public System.Threading.Tasks.Task <bool> InsertServiceDetailsToSvcAsync(ServiceSchedulingDetail serviceSchedulingDetail, Address address, string caseNumber, long caseServiceRecId, long _entityRecId)
        {
            try
            {
                var connectionProfile = NetworkInformation.GetInternetConnectionProfile();
                if (connectionProfile == null || connectionProfile.GetNetworkConnectivityLevel() != NetworkConnectivityLevel.InternetAccess)
                {
                    return(false);
                }

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

                var mzkAddressContract = new MzkAddressContract
                {
                    parmCity            = address.SelectedCity != null ? address.SelectedCity.Id : string.Empty,
                    parmCountryRegionId = address.SelectedCountry != null ? address.SelectedCountry.Id : string.Empty,
                    parmProvince        = address.SelectedProvince != null ? address.SelectedProvince.Id : string.Empty,
                    parmStreet          = address.Street,
                    parmSubUrb          = address.SelectedSuburb != null ? address.SelectedSuburb.Id : string.Empty,
                    parmZipCode         = address.SelectedZip
                };
                var mzkServiceDetailsContract = new MzkServiceDetailsContract
                {
                    parmAdditionalWork            = serviceSchedulingDetail.AdditionalWork,
                    parmAddress                   = serviceSchedulingDetail.Address,
                    parmEventDesc                 = serviceSchedulingDetail.EventDesc,
                    parmLiftLocationRecId         = serviceSchedulingDetail.SelectedLocationType != null ? serviceSchedulingDetail.SelectedLocationType.RecID : default(long),
                    parmODOReading                = serviceSchedulingDetail.ODOReading,
                    parmODOReadingDate            = serviceSchedulingDetail.ODOReadingDate,
                    parmPreferredDateFirstOption  = serviceSchedulingDetail.ServiceDateOption1,
                    parmPreferredDateSecondOption = serviceSchedulingDetail.ServiceDateOption2,
                    parmServiceType               = serviceSchedulingDetail.SelectedServiceType,

                    parmSupplierId   = serviceSchedulingDetail.SelectedDestinationType != null ? serviceSchedulingDetail.SelectedDestinationType.Id : string.Empty,
                    parmLiftRequired = serviceSchedulingDetail.IsLiftRequired == true ? NoYes.Yes : NoYes.No
                };
                if (serviceSchedulingDetail.IsLiftRequired && serviceSchedulingDetail.SelectedLocationType != null)
                {
                    mzkServiceDetailsContract.parmLocationType = new MzkLocationTypeContract
                    {
                        parmLocationType = (EXDCaseServiceDestinationType)Enum.Parse(typeof(EXDCaseServiceDestinationType), serviceSchedulingDetail.SelectedLocationType.LocType)
                    };
                }

                var result = await client.insertServiceDetailsAsync(caseNumber, caseServiceRecId, _entityRecId, mzkServiceDetailsContract
                                                                    , mzkAddressContract, _userInfo.CompanyId);

                if (serviceSchedulingDetail.ODOReadingSnapshot != null && !string.IsNullOrEmpty(serviceSchedulingDetail.ODOReadingSnapshot.ImageBinary))
                {
                    await client.saveImageAsync(new ObservableCollection <Mzk_ImageContract> {
                        new Mzk_ImageContract
                        {
                            parmCaseNumber = caseNumber,
                            parmFileName   = "ServiceScheduling_ODOReading.png",
                            parmImageData  = serviceSchedulingDetail.ODOReadingSnapshot.ImageBinary
                        }
                    });
                }

                return(result.response);
            }

            catch (Exception ex)
            {
                AppSettings.Instance.ErrorMessage = ex.Message;
                return(false);
            }
        }
예제 #2
0
        private bool InsertServiceDetails(ServiceSchedulingDetail serviceSchedulingDetail, Address address, UserInfo userInfo)
        {
            try
            {
                var mzkAddressContract = new MzkAddressContract
                {
                    parmCity            = address.SelectedCity != null ? address.SelectedCity : string.Empty,
                    parmCountryRegionId = address.SelectedCountry != null ? address.SelectedCountry : string.Empty,
                    parmProvince        = address.Selectedprovince != null ? address.Selectedprovince : string.Empty,
                    parmStreet          = address.Street,
                    parmSubUrb          = address.SelectedSuburb != null ? address.SelectedSuburb : string.Empty,
                    parmZipCode         = address.SelectedZip
                };
                var mzkServiceDetailsContract = new MzkServiceDetailsContract
                {
                    parmAdditionalWork = serviceSchedulingDetail.AdditionalWork,
                    parmAddress        = serviceSchedulingDetail.Address,
                    parmEventDesc      = serviceSchedulingDetail.EventDesc,

                    parmODOReading                = serviceSchedulingDetail.ODOReading.ToString(),
                    parmODOReadingDate            = DateTime.Parse(serviceSchedulingDetail.ODOReadingDate, new CultureInfo("en-US").DateTimeFormat),
                    parmPreferredDateFirstOption  = DateTime.Parse(serviceSchedulingDetail.ServiceDateOption1, new CultureInfo("en-US").DateTimeFormat),
                    parmPreferredDateSecondOption = DateTime.Parse(serviceSchedulingDetail.ServiceDateOption2, new CultureInfo("en-US").DateTimeFormat),
                    parmServiceType               = serviceSchedulingDetail.SelectedServiceType,
                    parmLiftLocationRecId         = serviceSchedulingDetail.SelectedLocType == null ? default(long) : serviceSchedulingDetail.SelectedLocType.RecID,
                    parmSupplierId                = serviceSchedulingDetail.SelectedDestinationType == null ? string.Empty : serviceSchedulingDetail.SelectedDestinationType.Id,


                    parmLiftRequired = serviceSchedulingDetail.IsLiftRequired == true ? NoYes.Yes : NoYes.No
                };

                if (serviceSchedulingDetail.SelectedLocType != null)
                {
                    mzkServiceDetailsContract.parmLocationType = new MzkLocationTypeContract
                    {
                        parmLocationType = (EXDCaseServiceDestinationType)Enum.Parse(typeof(EXDCaseServiceDestinationType), serviceSchedulingDetail.SelectedLocType.LocType)
                    };
                }
                var recID = serviceSchedulingDetail.SelectedDestinationType == null ? default(long) : serviceSchedulingDetail.SelectedDestinationType.RecID;

                var result = _client.insertServiceDetails(new CallContext()
                {
                }, serviceSchedulingDetail.CaseNumber, serviceSchedulingDetail.CaseServiceRecID, recID, mzkServiceDetailsContract
                                                          , mzkAddressContract, userInfo.CompanyId);

                if (!string.IsNullOrEmpty(serviceSchedulingDetail.ODOReadingSnapshot))
                {
                    _client.saveImage(new CallContext {
                    }, new Mzk_ImageContract[] { new Mzk_ImageContract
                                                 {
                                                     parmCaseNumber = serviceSchedulingDetail.CaseNumber,
                                                     parmFileName   = "ServiceScheduling_ODOReading.png",
                                                     parmImageData  = serviceSchedulingDetail.ODOReadingSnapshot
                                                 } });
                }
                return(result);
            }

            catch (Exception)
            {
                throw;
            }
        }