private async void DoneCommandRecieverAsync() { try { //NewBatchModel.Tags = Tags; NewBatchModel.Abv = AlcoholContent; NewBatchModel.BatchCode = BatchCode; NewBatchModel.BatchId = _uuidManager.GetUuId(); NewBatchModel.BestBeforeDate = BestByDate; NewBatchModel.BrandName = BrandButtonTitle; NewBatchModel.BrewDate = BrewDate; NewBatchModel.BrewedVolume = VolumeDigit; NewBatchModel.BrewedVolumeUom = VolumeChar; NewBatchModel.CompanyId = AppSettings.CompanyId; NewBatchModel.CompletedDate = DateTime.Today; NewBatchModel.IsCompleted = true; NewBatchModel.PackageDate = PackageDate; NewBatchModel.PackagedVolume = 12; NewBatchModel.PackagedVolumeUom = ""; NewBatchModel.RecipeId = AppSettings.CompanyId; NewBatchModel.SourceKey = ""; await _navigationService.GoBackAsync(new NavigationParameters { { "NewBatchModel", NewBatchModel } }, animated : false); } catch (Exception ex) { Crashes.TrackError(ex); } }
internal void AssignInitialValue(string _kegId, IList <ManifestItem> _barcode, string _addKegs, string _destination, string _partnerId, bool isSaveDraftVisible, IList <Tag> tags, string tagsStr) { try { if (_barcode != null) { foreach (var item in _barcode) { var model = new BarcodeModel { Barcode = item?.Barcode, Icon = item?.Icon, TagsStr = item?.TagsStr }; foreach (Tag tag in item?.Tags) { model.Tags.Add(tag); } ConstantManager.Barcodes.Add(model); } } Barcodes = ConstantManager.Barcodes; Tags = tags?.ToList(); TagsStr = !string.IsNullOrEmpty(tagsStr) ? tagsStr : "Add info"; ManifestId = !string.IsNullOrEmpty(_kegId) ? _kegId : _uuidManager.GetUuId(); AddKegs = !string.IsNullOrEmpty(_addKegs) ? Convert.ToUInt32(_addKegs) > 1 ? string.Format("{0} Items", _addKegs) : string.Format("{0} Item", _addKegs) : "Add Kegs"; if (!string.IsNullOrEmpty(_destination)) { Destination = _destination; ConstantManager.Partner = new PartnerModel { PartnerId = _partnerId, FullName = _destination }; IsRequiredVisible = false; } IsSaveDraftVisible = isSaveDraftVisible; } catch (Exception ex) { Crashes.TrackError(ex); } }
private async void SaveCommandRecieverAsync() { try { if (BarcodeCollection.Count > 0) { Loader.StartLoading(); var model = new KegBulkUpdateItemRequestModel(); var MassUpdateKegKegs = new List <MassUpdateKeg>(); MassUpdateKeg MassUpdateKeg = null; var val = await _dashboardService.GetAssetVolumeAsync(AppSettings.SessionId, false); foreach (var item in BarcodeCollection) { MassUpdateKeg = new MassUpdateKeg { AssetSize = SelectedItemSize, AssetType = SelectedItemType, Barcode = item.Barcode, AssetVolume = item.TagsStr, KegId = _uuidManager.GetUuId(), OwnerId = AppSettings.CompanyId, OwnerSkuId = "", ProfileId = "", }; MassUpdateKegKegs.Add(MassUpdateKeg); } model.Kegs = MassUpdateKegKegs; var value = await _dashboardService.PostKegUploadAsync(model, AppSettings.SessionId, Configuration.MassUpdateKegList); if (value.Response.StatusCode == System.Net.HttpStatusCode.OK.ToString()) { await _navigationService.GoBackAsync(new NavigationParameters { { "AssingSuccessMsgAsync", "AssingSuccessMsgAsync" } }, animated : false); } } else { await _dialogService.DisplayAlertAsync("Alert", "Please add scan item", "Ok"); } } catch (Exception ex) { Crashes.TrackError(ex); } finally { Loader.StopLoading(); } }
private async void MoveCommandRecieverAsync() { try { await _navigationService.NavigateAsync("MoveView", new NavigationParameters { { "ManifestId", _uuidManager.GetUuId() } }, animated : false); } catch (Exception ex) { Crashes.TrackError(ex); } }
internal void LoadInfo(IList <BarcodeModel> barcodeCollection) { try { TrackingNo = _uuidManager.GetUuId(); StockLocation = ConstantManager.Partner.FullName + "\n" + ConstantManager.Partner.PartnerTypeName; ItemCount = barcodeCollection.Count; Barcodes = barcodeCollection.Select(x => x.Barcode).ToList(); Contents = string.Empty; } catch (Exception ex) { Crashes.TrackError(ex); } }
private async void MoveKegCommandRecieverAsync() { try { await _navigationService.NavigateAsync("MoveView", new NavigationParameters { { "AssignInitialValueFromKegStatus", Barcode }, { "KegId", KegId }, { "ManifestId", _uuidManager.GetUuId() } }, animated : false); } catch (Exception ex) { Crashes.TrackError(ex); } }
public ManifestModel GenerateManifest(Xamarin.Essentials.Location location, string manifestId = "") { List <MaintainKeg> kegs = new List <MaintainKeg>(); MaintainKeg keg = null; MaintenanceModel model = new MaintenanceModel { MaintenanceDoneRequestModel = new MaintenanceDoneRequestModel() }; foreach (var item in BarcodeCollection) { keg = new MaintainKeg { Barcode = item.Barcode, ScanDate = DateTimeOffset.Now, ValidationStatus = 4 }; kegs.Add(keg); model.MaintenanceDoneRequestModel.Kegs.Add(keg); } foreach (var item in ConstantManager.MaintainTypeCollection.Where(x => x.IsToggled == true).Select(y => y.Id).ToList()) { model.MaintenanceDoneRequestModel.ActionsPerformed.Add(item); } model.MaintenanceDoneRequestModel.DatePerformed = DateTimeOffset.Now.AddDays(-2); model.MaintenanceDoneRequestModel.LocationId = ConstantManager.Partner.PartnerId; model.MaintenanceDoneRequestModel.MaintenancePostingId = _uuidManager.GetUuId(); model.MaintenanceDoneRequestModel.Latitude = (long)location.Latitude; model.MaintenanceDoneRequestModel.Longitude = (long)location.Longitude; model.MaintenanceDoneRequestModel.Notes = Notes; model.MaintenanceDoneRequestModel.PartnerModel = ConstantManager.Partner; return(_manifestManager.GetManifestDraft(eventTypeEnum: EventTypeEnum.REPAIR_MANIFEST, manifestId: !string.IsNullOrEmpty(manifestId) ? manifestId : _uuidManager.GetUuId(), barcodeCollection: BarcodeCollection, (long)location.Latitude, (long)location.Longitude, tags: ConstantManager.Tags, ConstantManager.TagsStr, partnerModel: ConstantManager.Partner, newPallets: new List <NewPallet>(), batches: new List <NewBatch>(), closedBatches: new List <string>(), model, validationStatus: 4, contents: "")); }
private async void SubmitCommandRecieverAsync() { try { Loader.StartLoading(); var location = await _geolocationService.GetLastLocationAsync(); Loader.StopLoading(); var tags = ConstantManager.Tags; var partnerModel = ConstantManager.Partner; if (Barcodes.Count() == 0) { await _dialogService.DisplayAlertAsync("Error", "Error: Please add some scans.", "Ok"); return; } IEnumerable <BarcodeModel> empty = Barcodes.Where(x => x.Barcode.Count() == 0); if (empty.ToList().Count > 0) { string result = await _dialogService.DisplayActionSheetAsync("Error? \n Some pallets have 0 scans. Do you want to edit them or remove the empty pallets.", null, null, "Remove empties", "Edit"); if (result == "Remove empties") { foreach (var item in empty.Reverse()) { Barcodes.Remove(item); } if (Barcodes.Count == 0) { return; } } if (result == "Edit") { await ItemTappedCommandRecieverAsync(empty.FirstOrDefault()); return; } } List <string> closedBatches = new List <string>(); List <NewPallet> newPallets = new List <NewPallet>(); NewPallet newPallet = null; List <TItem> palletItems = new List <TItem>(); TItem palletItem = null; foreach (var pallet in Barcodes) { palletItem = new TItem { Barcode = pallet.Barcode, ScanDate = DateTimeOffset.UtcNow.Date, TagsStr = pallet.TagsStr }; if (pallet.Tags != null) { foreach (var tag in pallet.Tags) { palletItem.Tags.Add(tag); } } palletItems.Add(palletItem); newPallet = new NewPallet { Barcode = BatchId, BuildDate = DateTimeOffset.UtcNow.Date, StockLocation = partnerModel?.PartnerId, StockLocationId = partnerModel?.PartnerId, StockLocationName = partnerModel?.FullName, OwnerId = AppSettings.CompanyId, PalletId = _uuidManager.GetUuId(), ReferenceKey = "", }; if (tags != null) { foreach (var item in tags) { newPallet.Tags.Add(item); } } foreach (var item in palletItems) { newPallet.PalletItems.Add(item); } newPallets.Add(newPallet); } bool accept = await _dialogService.DisplayAlertAsync("Close batch", "Mark this batch as completed?", "Yes", "No"); if (accept) { closedBatches = Barcodes.Select(x => x.Barcode).ToList(); } Loader.StartLoading(); ManifestModel model = model = GenerateManifest(location ?? new Xamarin.Essentials.Location(0, 0), newPallets, closedBatches); if (model != null) { try { var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { ManifestModelGet manifestResult = await _moveService.PostManifestAsync(model, AppSettings.SessionId, Configuration.NewManifest); try { AddorUpdateManifestOffline(model, false); } catch (Exception ex) { Crashes.TrackError(ex); } await GetPostedManifestDetail(); } else { try { AddorUpdateManifestOffline(model, true); } catch (Exception ex) { Crashes.TrackError(ex); } await GetPostedManifestDetail(); } } catch (Exception ex) { Crashes.TrackError(ex); } finally { Loader.StopLoading(); model = null; tags = null; partnerModel = null; closedBatches = null; newPallets = null; newPallet = null; palletItems = null; Cleanup(); } } else { await _dialogService.DisplayAlertAsync("Alert", "Something goes wrong please check again", "Ok"); } } catch (Exception) { } finally { Loader.StopLoading(); } }
private async void SubmitCommandRecieverAsync() { List <PalletItem> palletItems = new List <PalletItem>(); PalletItem pallet = null; PalletRequestModel palletRequestModel = null; var barCodeCollection = ConstantManager.Barcodes; PalletResponseModel palletResponseModel = null; try { Loader.StartLoading(); foreach (var item in barCodeCollection) { pallet = new PalletItem { Barcode = item.Barcode, ScanDate = DateTimeOffset.Now, }; foreach (var tag in ConstantManager.Tags) { pallet.Tags.Add(tag); } palletItems.Add(pallet); } palletRequestModel = new PalletRequestModel { Barcode = ManifestId.Split('-').LastOrDefault(), BuildDate = DateTimeOffset.Now, OwnerId = AppSettings.CompanyId, PalletId = _uuidManager.GetUuId(), ReferenceKey = "", StockLocation = StockLocation.PartnerId, StockLocationId = StockLocation.PartnerId, StockLocationName = StockLocation.FullName, }; foreach (var item in palletItems) { palletRequestModel.PalletItems.Add(item); } foreach (var item in ConstantManager.Tags) { palletRequestModel.Tags.Add(item); } palletResponseModel = new PalletResponseModel { Barcode = ManifestId.Split('-').LastOrDefault(), BuildDate = DateTimeOffset.Now, Container = null, CreatedDate = DateTimeOffset.Now, DataInfo = new Model.PrintPDF.DateInfo { }, Location = new Owner { }, Owner = new Owner { }, PalletId = palletRequestModel.PalletId, PalletItems = palletItems, ReferenceKey = string.Empty, StockLocation = new Owner { FullName = StockLocation.FullName, PartnerTypeName = StockLocation.PartnerTypeName }, TargetLocation = new Model.PrintPDF.TargetLocation { }, Tags = ConstantManager.Tags, }; var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { var value = await _palletizeService.PostPalletAsync(palletRequestModel, AppSettings.SessionId, Configuration.NewPallet); } else { try { palletRequestModel.IsQueue = true; var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()); RealmDb.Write(() => { RealmDb.Add(palletRequestModel, update: true); }); } catch (Exception ex) { Crashes.TrackError(ex); } } PrintPallet(); await _navigationService.NavigateAsync("PalletizeDetailView", new NavigationParameters { { "LoadInfo", palletResponseModel }, { "Contents", ConstantManager.Contents } }, animated : false); } catch (Exception ex) { Crashes.TrackError(ex); } finally { Loader.StopLoading(); palletItems = null; pallet = null; barCodeCollection = null; palletRequestModel = null; Cleanup(); } }
private async void SubmitCommandRecieverAsync() { NewPartnerRequestModel newPartnerRequestModel = new NewPartnerRequestModel { AccountNumber = AccountNumber, BillAddress = BillAddress, ContactEmail = ContactEmail, ContactName = ContactName, Fax = Fax, IsInternal = IsInternalOn, IsNotify = IsNotify, IsShared = IsSharedOn, LocationCode = LocationCode, LocationStatus = LocationStatus, Notes = Notes, FirstName = PartnerName, LastName = PartnerName, ParentPartnerId = IsInternalOn ? AppSettings.CompanyId : _uuidManager.GetUuId(), PartnerId = _uuidManager.GetUuId(), PartnerName = PartnerName, PartnerTypeCode = SelectedPartnerType.Code, Phone = Phone, PrivateKey = PrivateKey, ReferenceKey = ReferenceKey, RouteName = RouteName, ShipAddress = ShipAddress, SmsAddress = SmsAddress, TimeZone = "+05:30", //PTTimeZone; Website = "" //Website; }; try { Loader.StartLoading(); var result = await _moveService.PostNewPartnerAsync(newPartnerRequestModel, AppSettings.SessionId, RequestType : Configuration.NewPartner); if (result != null) { try { PartnerModel partnerModel = new PartnerModel { Address = BillingAddress, Address1 = ShippingAddress, City = newPartnerRequestModel.BillAddress != null ? newPartnerRequestModel.BillAddress.City : string.Empty, ParentPartnerId = newPartnerRequestModel.ParentPartnerId, ParentPartnerName = newPartnerRequestModel.PartnerName, PartnerId = newPartnerRequestModel.PartnerId, PartnershipIsActive = newPartnerRequestModel.IsInternal, IsInternal = newPartnerRequestModel.IsInternal, IsShared = newPartnerRequestModel.IsShared, Lat = newPartnerRequestModel.BillAddress != null ? newPartnerRequestModel.BillAddress.Latitude : default(double), LocationCode = newPartnerRequestModel.LocationCode, LocationStatus = newPartnerRequestModel.LocationStatus, Lon = newPartnerRequestModel.BillAddress != null ? newPartnerRequestModel.BillAddress.Longitude : default(double), MasterCompanyId = newPartnerRequestModel.ParentPartnerId, PartnerTypeCode = newPartnerRequestModel.PartnerTypeCode, PartnerTypeName = newPartnerRequestModel.PartnerName, PhoneNumber = newPartnerRequestModel.PartnerName, PostalCode = newPartnerRequestModel.BillAddress != null ? newPartnerRequestModel.BillAddress.PostalCode : string.Empty, SourceKey = newPartnerRequestModel.RouteName, State = newPartnerRequestModel.BillAddress != null ? newPartnerRequestModel.BillAddress.State : string.Empty, FullName = newPartnerRequestModel.PartnerName, }; var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()); await RealmDb.WriteAsync((realmDb) => { realmDb.Add(partnerModel); }); await _navigationService.GoBackAsync(new NavigationParameters { { "partnerModel", partnerModel } }, animated : false); } catch (Exception ex) { Crashes.TrackError(ex); } } } catch (Exception ex) { Crashes.TrackError(ex); } finally { Loader.StopLoading(); } }