Exemplo n.º 1
0
        private void AddorUpdateManifestOffline(ManifestModel manifestPostModel, bool queue)
        {
            string manifestId = manifestPostModel.ManifestId;
            var    isNew      = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()).Find <ManifestModel>(manifestId);

            if (isNew != null)
            {
                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                RealmDb.Write(() =>
                {
                    manifestPostModel.IsQueue = false;
                    manifestPostModel.IsDraft = false;
                    RealmDb.Add(manifestPostModel, update: true);
                });
            }
            else
            {
                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                RealmDb.Write(() =>
                {
                    if (queue)
                    {
                        manifestPostModel.IsQueue = true;
                    }
                    RealmDb.Add(manifestPostModel);
                });
            }
        }
Exemplo n.º 2
0
        private XElement GenerateManifest(ManifestModel manifest, bool isUpdate = false)
        {
            var doc = new XElement("manifest",
                                   new XElement("title", manifest.Title),
                                   new XElement("isDone", manifest.IsDone));

            var guid = Guid.NewGuid();

            if (isUpdate)
            {
                guid = manifest.ID;
            }
            doc.SetAttributeValue("ID", guid);

            var contentsDoc = new XElement("contents");

            foreach (var c in manifest.Contents)
            {
                contentsDoc.Add(new XElement("content",
                                             new XElement("description", c.Description),
                                             new XElement("detail", c.Detail)));
            }

            if (manifest.Contents.Count > 0)
            {
                doc.Add(contentsDoc);
            }
            return(doc);
        }
        private void AssignInitialValue(ManifestModel manifestModel)
        {
            try
            {
                var RealmDb     = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                var maintenance = RealmDb.All <MaintainTypeReponseModel>().ToList();

                ManifestModel          = manifestModel;
                MaintainTypeCollection = maintenance.Where(x => x.ActivationMethod == "ReverseOnly").OrderBy(x => x.Name).ToList();
                foreach (var item in manifestModel.MaintenanceModels.MaintenanceDoneRequestModel.ActionsPerformed)
                {
                    var result = maintenance.Find(x => x.Id == item);
                    if (result != null)
                    {
                        MaintainTypeCollection.Where(x => x.Id == result.Id).FirstOrDefault().IsToggled = true;
                    }
                }
                Notes        = manifestModel?.MaintenanceModels?.MaintenanceDoneRequestModel?.Notes;
                PartnerModel = manifestModel?.MaintenanceModels?.MaintenanceDoneRequestModel?.PartnerModel;
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
        private void AssignInitialValue(INavigationParameters parameters)
        {
            ManifestModel model = parameters.GetValue <ManifestModel>("AssignInitialValue");

            try
            {
                if (model != null)
                {
                    foreach (var item in model.BarcodeModels)
                    {
                        ConstantManager.Barcodes.Add(item);
                    }
                }
                Barcodes   = ConstantManager.Barcodes;
                Tags       = model.Tags?.ToList();
                TagsStr    = !string.IsNullOrEmpty(model.TagsStr) ? model.TagsStr : "Add info";
                ManifestId = !string.IsNullOrEmpty(model.ManifestId) ? model.ManifestId : _uuidManager.GetUuId();
                AddKegs    = !string.IsNullOrEmpty(model.ManifestItemsCount.ToString()) ? Convert.ToUInt32(model.ManifestItemsCount.ToString()) > 1 ? string.Format("{0} Items", model.ManifestItemsCount.ToString()) : string.Format("{0} Item", model.ManifestItemsCount.ToString()) : "Add Kegs";
                if (!string.IsNullOrEmpty(model.OwnerName))
                {
                    Destination             = model.OwnerName;
                    ConstantManager.Partner = new PartnerModel
                    {
                        PartnerId = model.ReceiverId,
                        FullName  = model.OwnerName
                    };
                    IsRequiredVisible = false;
                }
                IsSaveDraftVisible = true;
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Exemplo n.º 5
0
        public IActionResult Manifest()
        {
            var model = new ManifestModel
            {
                ShortName   = _blogConfig.GeneralSettings.SiteTitle,
                Name        = _blogConfig.GeneralSettings.SiteTitle,
                Description = _blogConfig.GeneralSettings.SiteTitle,
                StartUrl    = "/",
                Icons       = new List <ManifestIcon>
                {
                    new ManifestIcon("/android-icon-{0}.png", 36, "0.75"),
                    new ManifestIcon("/android-icon-{0}.png", 48, "1.0"),
                    new ManifestIcon("/android-icon-{0}.png", 72, "1.5"),
                    new ManifestIcon("/android-icon-{0}.png", 96, "2.0"),
                    new ManifestIcon("/android-icon-{0}.png", 144, "3.0"),
                    new ManifestIcon("/android-icon-{0}.png", 192, "4.0")
                },
                BackgroundColor = "#2a579a",
                ThemeColor      = "#2a579a",
                Display         = "standalone",
                Orientation     = "portrait"
            };

            return(Json(model));
        }
        private async void ItemTappedCommandRecieverAsync(ManifestModel model)
        {
            try
            {
                if (model.IsDraft)
                {
                    switch ((EventTypeEnum)model.EventTypeId)
                    {
                    case EventTypeEnum.MOVE_MANIFEST:
                        await _navigationService.NavigateAsync("MoveView", new NavigationParameters
                        {
                            { "AssignInitialValue", model }
                        }, animated : false);

                        break;

                    case EventTypeEnum.SHIP_MANIFEST:
                        break;

                    case EventTypeEnum.RECEIVE_MANIFEST:
                        break;

                    case EventTypeEnum.FILL_MANIFEST:
                        await _navigationService.NavigateAsync("FillView", new NavigationParameters
                        {
                            { "AssignInitialValue", model }
                        }, animated : false);

                        break;

                    case EventTypeEnum.PALLETIZE_MANIFEST:
                        break;

                    case EventTypeEnum.RETURN_MANIFEST:
                        break;

                    case EventTypeEnum.REPAIR_MANIFEST:
                        await _navigationService.NavigateAsync("MaintainView", new NavigationParameters
                        {
                            { "AssignInitialValue", model }
                        }, animated : false);

                        break;

                    case EventTypeEnum.COLLECT_MANIFEST:
                        break;

                    case EventTypeEnum.ARCHIVE_MANIFEST:
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Manifest([FromServices] IWebHostEnvironment hostEnvironment)
        {
            var themeColor = await Utils.GetThemeColorAsync(hostEnvironment.WebRootPath, _blogConfig.GeneralSettings.ThemeFileName);

            var model = new ManifestModel
            {
                ShortName   = _blogConfig.GeneralSettings.SiteTitle,
                Name        = _blogConfig.GeneralSettings.SiteTitle,
                Description = _blogConfig.GeneralSettings.SiteTitle,
                StartUrl    = "/",
                Icons       = new List <ManifestIcon>
                {
                    new ManifestIcon("/android-icon-{0}.png", 36, "0.75"),
                    new ManifestIcon("/android-icon-{0}.png", 48, "1.0"),
                    new ManifestIcon("/android-icon-{0}.png", 72, "1.5"),
                    new ManifestIcon("/android-icon-{0}.png", 96, "2.0"),
                    new ManifestIcon("/android-icon-{0}.png", 144, "3.0"),
                    new ManifestIcon("/android-icon-{0}.png", 192, "4.0")
                },
                BackgroundColor = themeColor,
                ThemeColor      = themeColor,
                Display         = "standalone",
                Orientation     = "portrait"
            };

            return(Json(model));
        }
Exemplo n.º 8
0
        public async Task <HttpResponseMessage> PostManifest(ManifestModel model, string sessionId)
        {
            var cts  = new CancellationTokenSource();
            var task = RemoteRequestAsync(_moveApi.GetApi(Priority.UserInitiated).PostManifest(model, sessionId, cts.Token));

            runningTasks.Add(task.Id, cts);

            return(await task);
        }
Exemplo n.º 9
0
        public ActionResult Manifest()
        {
            var model = new ManifestModel
            {
                Date = WebConfigurationManager.AppSettings["Env"] == "debug" ? System.DateTime.Now : new System.DateTime(),

                Version = WebConfigurationManager.AppSettings["Version"]
            };

            return View(model);
        }
Exemplo n.º 10
0
        private void AssignInitialValue(ManifestModel manifestModel)
        {
            try
            {
                NewBatchModel            = manifestModel?.NewBatches.FirstOrDefault();
                SizeButtonTitle          = manifestModel?.Size;
                DestinationTitle         = manifestModel?.OwnerName;
                ManifestId               = manifestModel?.ManifestId;
                ConstantManager.Barcodes = manifestModel?.BarcodeModels;

                try
                {
                    PartnerModel partner = new PartnerModel()
                    {
                        PartnerId = manifestModel?.ReceiverId,
                        FullName  = manifestModel?.OwnerName
                    };
                    ConstantManager.Partner = partner;
                    if (manifestModel.Tags != null)
                    {
                        ConstantManager.Tags = new List <Tag>();
                        foreach (var item in manifestModel.Tags)
                        {
                            ConstantManager.Tags.Add(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }

                foreach (var item in manifestModel.NewPallets)
                {
                    PalletModel palletModel = new PalletModel
                    {
                        Count      = item.PalletItems.Count,
                        ManifestId = ManifestId,
                        BatchId    = item.PalletId
                    };
                    palletModel.Barcode = ConstantManager.Barcodes;
                    if (PalletCollection == null)
                    {
                        PalletCollection = new List <PalletModel>();
                    }
                    PalletCollection.Add(palletModel);
                    IsPalletze = item.IsPalletze;
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Exemplo n.º 11
0
        public void UpdateManifests(ManifestModel m)
        {
            var old = Manifests.Where(mm => mm.ID.Equals(m.ID)).FirstOrDefault();

            if (old != null)
            {
                Manifests.ToList().Remove(old);

                Manifests.Remove(old);
                Manifests.Insert(0, m);
            }
        }
Exemplo n.º 12
0
        public async Task <IActionResult> Manifest()
        {
            var owner = (await _userManager.GetUsersInRoleAsync(Consts.OwnerRoleName))
                        .First();
            var descriptionAttribute = Assembly.GetEntryAssembly().GetCustomAttribute <AssemblyDescriptionAttribute>().Description;
            var model = new ManifestModel
            {
                ShortName   = owner.NickName,
                Name        = owner.NickName + "'s Blog",
                Description = descriptionAttribute,
                StartUrl    = "/",
                Icons       = new List <ManifestIcon>()
                {
                    new ManifestIcon
                    {
                        Src   = _probeLocator.GetProbeOpenAddress(owner.IconFilePath) + "?w=48&square=true",
                        Sizes = "48x48",
                        Type  = "image/png"
                    },
                    new ManifestIcon
                    {
                        Src   = _probeLocator.GetProbeOpenAddress(owner.IconFilePath) + ".png?w=72&square=true",
                        Sizes = "72x72",
                        Type  = "image/png"
                    },
                    new ManifestIcon
                    {
                        Src   = _probeLocator.GetProbeOpenAddress(owner.IconFilePath) + ".png?w=144&square=true",
                        Sizes = "144x144",
                        Type  = "image/png"
                    },
                    new ManifestIcon
                    {
                        Src   = _probeLocator.GetProbeOpenAddress(owner.IconFilePath) + ".png?w=240&square=true",
                        Sizes = "240x240",
                        Type  = "image/png"
                    },
                    new ManifestIcon
                    {
                        Src   = _probeLocator.GetProbeOpenAddress(owner.IconFilePath) + ".png?w=512&square=true",
                        Sizes = "512x512",
                        Type  = "image/png"
                    }
                },
                BackgroundColor = "#3097D1",
                ThemeColor      = "#3097D1",
                Display         = "standalone",
                Orientation     = "portrait"
            };

            return(Json(model));
        }
 private void AssignColletionToManifest(List <ManifestModel> collection)
 {
     using (var db = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()).BeginWrite())
     {
         for (int i = 0; i < collection.Count; i++)
         {
             ManifestModel item = collection[i];
             item.SenderId = item.ManifestItemsCount > 1 ? item.ManifestItemsCount + " Items" : item.ManifestItemsCount + " Item";
             ManifestCollection.Add(item);
         }
         db.Commit();
     }
 }
Exemplo n.º 14
0
        public async Task <IActionResult> Manifest()
        {
            var owner = (await _userManager.GetUsersInRoleAsync(Consts.OwnerRoleName))
                        .First();
            var model = new ManifestModel
            {
                ShortName = owner.NickName,
                Name      = owner.NickName + "'s Blog",
                StartUrl  = "/",
                Icons     = new List <ManifestIcon>()
                {
                    new ManifestIcon
                    {
                        Src   = StorageService.GetProbeDownloadAddress(_serviceLocation, owner.IconFilePath) + "?w=48&h=48",
                        Sizes = "48x48",
                        Type  = "image/png"
                    },
                    new ManifestIcon
                    {
                        Src   = StorageService.GetProbeDownloadAddress(_serviceLocation, owner.IconFilePath) + ".png?w=72&h=72",
                        Sizes = "72x72",
                        Type  = "image/png"
                    },
                    new ManifestIcon
                    {
                        Src   = StorageService.GetProbeDownloadAddress(_serviceLocation, owner.IconFilePath) + ".png?w=144&h=144",
                        Sizes = "144x144",
                        Type  = "image/png"
                    },
                    new ManifestIcon
                    {
                        Src   = StorageService.GetProbeDownloadAddress(_serviceLocation, owner.IconFilePath) + ".png?w=240&h=240",
                        Sizes = "240x240",
                        Type  = "image/png"
                    },
                    new ManifestIcon
                    {
                        Src   = StorageService.GetProbeDownloadAddress(_serviceLocation, owner.IconFilePath) + ".png?w=512&h=512",
                        Sizes = "512x512",
                        Type  = "image/png"
                    }
                },
                BackgroundColor = "#3097D1",
                ThemeColor      = "#3097D1",
                Display         = "standalone",
                Orientation     = "portrait"
            };

            return(Json(model));
        }
 public AddOrUpdateManifest(ManifestModel model)
 {
     InitializeComponent();
     this.ViewModel = new VMAddOrUpdateManifest(model);
     this.ViewModel.HandleCompleted += new EventHandler<EntityEventArgs>(ViewModel_HandleCompleted);
     if (model == null)
     {
         this.Title = "添加消费明细";
     }
     else
     {
         this.Title = "编辑消费明细";
     }
 }
Exemplo n.º 16
0
        public ActionResult Manifest()
        {
            ManifestModel manifestModel = new ManifestModel
            {
                ManifestString =
                    "{\"version\": \"1.0\"," +
                    "\"name\": \"CodeGenerate\"," +
                    "\"description\": \"Generate free QR codes and Barcodes online!\"," +
                    "\"icons\": {\"16\": \"/cdn/16x16.png\",\"48\": \"/cdn/48x48.png\",\"128\": \"/cdn/128x128.png\"}," +
                    "\"developer\": {\"name\": \"Dean Hume\",\"url\": \"http://www.deanhume.com\"},\"installs_allowed_from\": [\"*\"]," +
                    "\"locales\": {\"de\": {\"description\": \"Generieren Sie gratis QR-Codes und Barcodes online!\"," +
                    "\"developer\": {\"url\": \"http://www.deanhume.com\"}}}," +
                    "\"default_locale\": \"en\"}"
            };

            return(Content(manifestModel.ManifestString, "application/x-web-app-manifest+json"));
        }
        /// <summary>
        /// Initializes a new instance of the ManifestDetailViewModel class.
        /// </summary>
        public ManifestDetailViewModel()
        {
            DeleteCommand = new RelayCommand <string>((s) =>
            {
                Debug.WriteLine(s);
                var remove = (from c in Contents where c.Description.Equals(s) select c).FirstOrDefault();
                if (remove != null)
                {
                    Contents.Remove(remove);
                }
            });
            Update();
            Messenger.Default.Register <string>(this, Contract.UpdateDetail,
                                                s =>
            {
                Update();
            });
            Messenger.Default.Register <string>(this, Contract.AddDesc,
                                                s =>
            {
                Contents.Add(new ContentModel {
                    Description = ""
                });
            });

            Messenger.Default.Register <string>(this, Contract.SaveManifest,
                                                s =>
            {
                var manifest = new ManifestModel()
                {
                    ID = this.ID, Title = this.title, Contents = this.Contents
                };
                Messenger.Default.Send(manifest, Contract.UpdateMain);
                IOManager.GetManager().UpdateManifest(manifest);
            });

            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real": Connect to service, etc...
            ////}
        }
Exemplo n.º 18
0
 public void UpdateManifest(ManifestModel manifest)
 {
     using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
     {
         XElement root = null;
         using (var stream = isoStore.OpenFile("data.xml", System.IO.FileMode.Open))
         {
             root = XElement.Load(stream);
             var removeTarget = root.Elements("manifest").Where(a => a.Attribute("ID").Value.Equals(manifest.ID.ToString())).FirstOrDefault();
             removeTarget.Remove();
             root.Add(GenerateManifest(manifest, true));
         }
         using (var stream = isoStore.OpenFile("data.xml", System.IO.FileMode.Create))
         {
             (App.Current as App).UpdateManifests(manifest);
             root.Save(stream);
         }
     }
 }
        private void AddorUpdateManifestOffline(ManifestModel manifestPostModel, bool queue)
        {
            string manifestId = manifestPostModel.ManifestId;
            var    isNew      = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()).Find <ManifestModel>(manifestId);

            if (isNew != null)
            {
                try
                {
                    manifestPostModel.IsDraft = false;
                    var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                    RealmDb.Write(() =>
                    {
                        RealmDb.Add(manifestPostModel, update: true);
                    });
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            }
            else
            {
                try
                {
                    if (queue)
                    {
                        manifestPostModel.IsQueue = true;
                    }
                    var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                    RealmDb.Write(() =>
                    {
                        RealmDb.Add(manifestPostModel);
                    });
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            }
        }
Exemplo n.º 20
0
        public ActionResult Index()
        {
            var manifest = new ManifestModel();
            //Load all files
            var fileList   = new List <string>();
            var contentDir = Request.MapPath("~/content");

            fileList.AddRange(Directory.GetFiles(contentDir, "*.*", SearchOption.AllDirectories).Select(x => "content/" + x.Substring(contentDir.Length).Replace(Path.DirectorySeparatorChar, '/').ToLowerInvariant().TrimStart('/')));
            var scriptDir = Request.MapPath("~/scripts");

            fileList.AddRange(Directory.GetFiles(scriptDir, "*.*", SearchOption.AllDirectories).Select(x => "scripts/" + x.Substring(scriptDir.Length).Replace(Path.DirectorySeparatorChar, '/').ToLowerInvariant().TrimStart('/')));

            manifest.Files = fileList.Where(x => ExcludeList.All(y => x.IndexOf(y) == -1));
            manifest.Hosts = new[]
            {
                new Uri(System.Web.HttpContext.Current.Request.GetUrlRewriter(), Url.Content("~/")).ToString(),
            };
            manifest.UniqueTs = new FileInfo(GetType().Assembly.Location).LastWriteTimeUtc.ToString();

            return(View(manifest));
        }
Exemplo n.º 21
0
        public void WriteInitial(ManifestModel first, ManifestModel second, ManifestModel third)
        {
            using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var stream = isoStore.OpenFile("data.xml", System.IO.FileMode.Create))
                {
                    var root = new XElement("root");

                    root.Add(GenerateManifest(first));
                    root.Add(GenerateManifest(second));
                    root.Add(GenerateManifest(third));
                    var app = App.Current as App;
                    app.Manifests = new List <ManifestModel>();
                    app.Manifests.Add(third);
                    app.Manifests.Add(second);
                    app.Manifests.Add(first);
                    //app.SelectedManifestID = first.ID;

                    root.Save(stream);
                }
            }
        }
Exemplo n.º 22
0
        // POST: api/Manifest
        public ManifestResponse Post(ManifestRequest datagram)
        {
            var request = Request;

            //Append the captured client IP to the datagram.
            if (request.Properties.ContainsKey("MS_HttpContext"))
            {
                datagram.ClientAddress = ((HttpContextWrapper)request.Properties["MS_HttpContext"]).Request.UserHostAddress;
            }
            else if (request.Properties.ContainsKey(RemoteEndpointMessageProperty.Name))
            {
                RemoteEndpointMessageProperty prop = (RemoteEndpointMessageProperty)this.Request.Properties[RemoteEndpointMessageProperty.Name];
                datagram.ClientAddress = prop.Address;
            }
            else if (HttpContext.Current != null)
            {
                datagram.ClientAddress = HttpContext.Current.Request.UserHostAddress;
            }
            else
            {
                datagram.ClientAddress = null;
            }
            return(ManifestModel.ProcessMessage(datagram));
        }
Exemplo n.º 23
0
        public async Task <ManifestModelGet> PostManifestAsync(ManifestModel inModel, string sessionId, string RequestType)
        {
            ManifestModelGet outModel = null;

            try
            {
                string url     = string.Format(Configuration.PostManifestUrl, sessionId);
                string content = JsonConvert.SerializeObject(inModel);
                var    value   = await App.kegIDClient.ExecuteServiceCall <KegIDResponse>(url, HttpMethodType.Send, content, RequestType : RequestType);

                outModel = !string.IsNullOrEmpty(value.Response) ? App.kegIDClient.DeserializeObject <ManifestModelGet>(value.Response) : new ManifestModelGet();
                if (outModel != null)
                {
                    outModel.Response = new KegIDResponse
                    {
                        StatusCode = value.StatusCode
                    };
                }
            }
            catch (System.Exception)
            {
            }
            return(outModel);
        }
        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();
            }
        }
        /// <summary>
        /// Initializes a new instance of the ManifestDetailViewModel class.
        /// </summary>
        public ManifestDetailViewModel()
        {
            DeleteCommand = new RelayCommand <string>((s) =>
            {
                Debug.WriteLine(s);
                var remove = (from c in Contents where c.Description.Equals(s) select c).FirstOrDefault();
                if (remove != null)
                {
                    Contents.Remove(remove);
                }
            });
            Update();
            Messenger.Default.Register <string>(this, Contract.UpdateDetail,
                                                s =>
            {
                Update();
            });
            Messenger.Default.Register <string>(this, Contract.AddDesc,
                                                s =>
            {
                Contents.Add(new ContentModel {
                    Description = ""
                });
            });

            Messenger.Default.Register <string>(this, Contract.SaveManifest,
                                                s =>
            {
                var manifest = new ManifestModel()
                {
                    ID = this.ID, Title = this.title, Contents = this.Contents, IsDone = this.IsDone
                };
                Messenger.Default.Send(manifest, Contract.UpdateMain);
                IOManager.GetManager().UpdateManifest(manifest);
            });

            Messenger.Default.Register <string>(this, Contract.ConfirmDone,
                                                s =>
            {
                var message = "達成済みにしますか?";
                if (IsDone)
                {
                    message = "未達成にしますか?";
                }
                var result = MessageBox.Show(message, "確認", MessageBoxButton.OKCancel);
                if (result == MessageBoxResult.OK)
                {
                    IsDone = !IsDone;
                    Messenger.Default.Send("", Contract.SaveManifest);
                    Messenger.Default.Send <Guid>(ID, Contract.ChangeCurrentManifest);
                }
            });

            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real": Connect to service, etc...
            ////}
        }
Exemplo n.º 26
0
        public IActionResult Manifest()
        {
            var model = new ManifestModel
            {
                ShortName = _blogConfig.GeneralSettings.SiteTitle,
                Name      = _blogConfig.GeneralSettings.SiteTitle,
                StartUrl  = "/",
                Icons     = new List <ManifestIcon>()
                {
                    // TODO: Refact code
                    new ManifestIcon
                    {
                        Src     = "/android-icon-36x36.png",
                        Sizes   = "36x36",
                        Type    = "image/png",
                        Density = "0.75"
                    },
                    new ManifestIcon
                    {
                        Src     = "/android-icon-48x48.png",
                        Sizes   = "48x48",
                        Type    = "image/png",
                        Density = "1.0"
                    },
                    new ManifestIcon
                    {
                        Src     = "/android-icon-72x72.png",
                        Sizes   = "72x72",
                        Type    = "image/png",
                        Density = "1.5"
                    },
                    new ManifestIcon
                    {
                        Src     = "/android-icon-96x96.png",
                        Sizes   = "96x96",
                        Type    = "image/png",
                        Density = "2.0"
                    },
                    new ManifestIcon
                    {
                        Src     = "/android-icon-144x144.png",
                        Sizes   = "144x144",
                        Type    = "image/png",
                        Density = "3.0"
                    },
                    new ManifestIcon
                    {
                        Src     = "/android-icon-192x192.png",
                        Sizes   = "192x192",
                        Type    = "image/png",
                        Density = "4.0"
                    }
                },
                BackgroundColor = "#2a579a",
                ThemeColor      = "#2a579a",
                Display         = "standalone",
                Orientation     = "portrait"
            };

            return(Json(model));
        }
Exemplo n.º 27
0
        public ManifestModel GetManifestDraft(EventTypeEnum eventTypeEnum, string manifestId, IList <BarcodeModel> barcodeCollection, long Latitude, long Longitude, string OriginId, string OrderId,
                                              List <Tag> tags, string tagsStr, PartnerModel partnerModel, List <NewPallet> newPallets, List <NewBatch> batches, List <string> closedBatches, MaintenanceModel maintenanceModel, long validationStatus, DateTimeOffset?EffectiveDateAllowed, string contents = "", string size = "")
        {
            List <ManifestTItem> manifestItems = new List <ManifestTItem>();

            foreach (var item in barcodeCollection)
            {
                string        barcodeId    = item.Barcode;
                ManifestTItem manifestItem = new ManifestTItem()
                {
                    Barcode  = item.Barcode,
                    ScanDate = DateTimeOffset.UtcNow.Date,
                    KegId    = item.Kegs?.Partners?.FirstOrDefault()?.Kegs?.FirstOrDefault().KegId ?? default,
                    Icon     = item.Icon,
                    TagsStr  = item.TagsStr ?? default,
                    Contents = contents,
                };
                if (item.Tags != null)
                {
                    foreach (var tag in item.Tags)
                    {
                        manifestItem.Tags.Add(tag);
                    }
                }
                manifestItems.Add(manifestItem);
                barcodeId = string.Empty;
            }

            ManifestModel manifestModel = new ManifestModel()
            {
                ManifestId         = manifestId,
                EventTypeId        = (long)eventTypeEnum,
                Latitude           = Latitude,
                Longitude          = Longitude,
                SubmittedDate      = DateTimeOffset.UtcNow.Date,
                ShipDate           = DateTimeOffset.UtcNow.Date,
                SenderId           = Settings.CompanyId,
                ReceiverId         = partnerModel?.PartnerId,
                DestinationId      = partnerModel?.PartnerId,
                EffectiveDate      = EffectiveDateAllowed ?? DateTimeOffset.UtcNow.Date,
                OriginId           = OriginId,
                OwnerName          = partnerModel?.FullName,
                ManifestItemsCount = manifestItems.Count,
                TagsStr            = tagsStr,
                Size       = size,
                KegOrderId = OrderId,
                PostedDate = DateTimeOffset.UtcNow.Date,
                SourceKey  = partnerModel.SourceKey
            };

            foreach (var item in barcodeCollection)
            {
                manifestModel.BarcodeModels.Add(item);
            }

            foreach (var item in manifestItems)
            {
                manifestModel.ManifestItems.Add(item);
            }

            foreach (var item in newPallets)
            {
                manifestModel.NewPallets.Add(item);
            }

            foreach (var item in batches)
            {
                manifestModel.NewBatches.Add(item);
            }

            if (maintenanceModel != null)
            {
                manifestModel.MaintenanceModels = maintenanceModel;
            }

            if (tags != null)
            {
                foreach (var item in tags)
                {
                    manifestModel.Tags.Add(item);
                }
            }

            foreach (var item in closedBatches)
            {
                manifestModel.ClosedBatches.Add(item);
            }

            return(manifestModel);
        }
Exemplo n.º 28
0
        private async void SaveDraftCommandRecieverAsync()
        {
            try
            {
                Loader.StartLoading();
                var location = await _geolocationService.GetLastLocationAsync();

                ManifestModel manifestModel = null;
                try
                {
                    manifestModel = GenerateManifest(location ?? new Xamarin.Essentials.Location(0, 0));
                    if (manifestModel != null)
                    {
                        manifestModel.IsDraft = true;
                        var isNew = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()).Find <ManifestModel>(manifestModel.ManifestId);
                        if (isNew != null)
                        {
                            try
                            {
                                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                                RealmDb.Write(() =>
                                {
                                    RealmDb.Add(manifestModel, update: true);
                                });
                            }
                            catch (Exception ex)
                            {
                                Crashes.TrackError(ex);
                            }
                        }
                        else
                        {
                            try
                            {
                                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                                RealmDb.Write(() =>
                                {
                                    RealmDb.Add(manifestModel);
                                });
                            }
                            catch (Exception ex)
                            {
                                Crashes.TrackError(ex);
                            }
                        }

                        Loader.StopLoading();
                        await _navigationService.NavigateAsync("ManifestsView",
                                                               new NavigationParameters
                        {
                            { "LoadDraftManifestAsync", "LoadDraftManifestAsync" }
                        }, animated : false);
                    }
                    else
                    {
                        await _dialogService.DisplayAlertAsync("Error", "Could not save manifest.", "Ok");
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
                finally
                {
                    manifestModel = null;
                    Cleanup();
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
            finally
            {
                Loader.StopLoading();
            }
        }
Exemplo n.º 29
0
        private async void SubmitCommandRecieverAsync()
        {
            try
            {
                Loader.StartLoading();
                var location = await _geolocationService.GetLastLocationAsync();

                ManifestModel manifestPostModel = null;
                try
                {
                    manifestPostModel = GenerateManifest(location ?? new Xamarin.Essentials.Location(0, 0));
                    if (manifestPostModel != null)
                    {
                        try
                        {
                            var current = Connectivity.NetworkAccess;
                            if (current == NetworkAccess.Internet)
                            {
                                var result = await _moveService.PostManifestAsync(manifestPostModel, AppSettings.SessionId, Configuration.NewManifest);

                                try
                                {
                                    AddorUpdateManifestOffline(manifestPostModel, false);
                                }
                                catch (Exception ex)
                                {
                                    Crashes.TrackError(ex);
                                }
                                await GetPostedManifestDetail();
                            }
                            else
                            {
                                try
                                {
                                    AddorUpdateManifestOffline(manifestPostModel, true);
                                }
                                catch (Exception ex)
                                {
                                    Crashes.TrackError(ex);
                                }
                                await GetPostedManifestDetail();
                            }
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                        finally
                        {
                            manifestPostModel = null;
                            Cleanup();
                        }
                    }
                    else
                    {
                        await _dialogService.DisplayAlertAsync("Alert", "Something goes wrong please check again", "Ok");
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                Loader.StopLoading();
            }
        }
        /* Maybe
         * enum MainMenuSelections
         * {
         *  R,
         *  S,
         *  X
         *
         * }*/
        static void Main(string[] args)
        {
            ManifestModel manifest = new ManifestModel();

            string rawUserInput = "";

            do
            {
                rawUserInput = MainMenuGetUserInput();
                if (rawUserInput.ToUpper() == "R")
                {
                    Console.Clear();
                    string flightClass = FlightClassPrompt();
                    if (flightClass.ToUpper() == "B")
                    {
                        Console.Clear();
                        PrintBuisnessClassGrid(manifest);
                        Console.WriteLine();
                        Console.Write("Please Select the passengers seat (ex - 1A): ");
                        string userInput = Console.ReadLine();
                        (int rowNumber, char seatLetter) = splitUserInput(userInput);
                        PassengerSeatingModel seat = GetUserSelectedSeat((rowNumber, seatLetter, manifest));// fix
                        bool seatEmpty             = VerifySeatIsAvailable((seat, manifest));
                        if (seatEmpty)
                        {
                            PassengerModel passenger = CreatePassenger();
                            manifest.AddPassenger(passenger, seat);
                            Console.WriteLine($"{passenger.FullName} was added to the manifest with seat {seat.SeatNumber}{seat.SeatLetter}");
                        }
                        else
                        {
                            Console.WriteLine($"Seat is not available.");
                        }
                        Console.WriteLine("Press any key to go back to main menu");
                        Console.ReadKey();
                    }
                    //TODO loop the selections here so it doesnt just go back to main menu
                    else if (flightClass.ToUpper() == "E")
                    {
                        PrintEconomyClassGrid(manifest);
                        Console.WriteLine();
                        Console.Write("Please Select the passengers seat (ex - 1A): ");
                        string userInput = Console.ReadLine();
                        (int rowNumber, char seatLetter) = splitUserInput(userInput);
                        PassengerSeatingModel seat = GetUserSelectedSeat((rowNumber, seatLetter, manifest));// fix
                        bool seatEmpty             = VerifySeatIsAvailable((seat, manifest));
                        if (seatEmpty)
                        {
                            PassengerModel passenger = CreatePassenger();
                            manifest.AddPassenger(passenger, seat);
                            Console.WriteLine($"Successfully added {passenger.FullName} with seat {seat.SeatNumber}{seat.SeatLetter} to the manifest");
                        }
                        else
                        {
                            Console.WriteLine("Seat is not available");
                        }
                        Console.Write("Press any key to go back to main menu");
                        Console.ReadKey();
                    }
                    else
                    {
                        Console.WriteLine("Please enter valid input");
                    }
                }
                else if (rawUserInput.ToUpper() == "S")
                {
                    Console.Clear();
                    string seatID = "";

                    Console.WriteLine("Seat Verification");
                    Console.Write("Please enter the seat id (ex - 1A): ");
                    seatID = Console.ReadLine();
                    (int seatRow, char seatLetter) = splitUserInput(seatID);
                    PassengerSeatingModel seat = GetUserSelectedTakenSeat((seatRow, seatLetter, manifest));
                    try
                    {
                        if (seat.passenger.FirstName != null)
                        {
                            Console.WriteLine();
                            Console.WriteLine("Passenger Details");
                            Console.WriteLine($"Firstname: {seat.passenger.FirstName}");
                            Console.WriteLine($"Lastname: {seat.passenger.LastName}");
                            Console.WriteLine($"Passport Number: {seat.passenger.PassportNumber}");
                            Console.WriteLine();
                            Console.Write("Please press any key to continue to main menu: ");
                            Console.ReadKey();
                        }
                    }
                    catch (NullReferenceException ex) {
                        Console.WriteLine("The seat entered was not found");
                        Console.WriteLine("Please press any key to continue to main menu: ");
                        Console.ReadKey();
                    }
                }
            } while (rawUserInput.ToUpper() != "X");
            Console.WriteLine("Thank you for using our system today");
        }
Exemplo n.º 31
0
        public ActionResult Manifest()
        {
            ManifestModel manifestModel = new ManifestModel
                                              {
                                                  ManifestString =
                                                      "{\"version\": \"1.0\"," +
                                                      "\"name\": \"CodeGenerate\"," +
                                                      "\"description\": \"Generate free QR codes and Barcodes online!\"," +
                                                      "\"icons\": {\"16\": \"/cdn/16x16.png\",\"48\": \"/cdn/48x48.png\",\"128\": \"/cdn/128x128.png\"}," +
                                                      "\"developer\": {\"name\": \"Dean Hume\",\"url\": \"http://www.deanhume.com\"},\"installs_allowed_from\": [\"*\"]," +
                                                      "\"locales\": {\"de\": {\"description\": \"Generieren Sie gratis QR-Codes und Barcodes online!\"," +
                                                      "\"developer\": {\"url\": \"http://www.deanhume.com\"}}}," +
                                                      "\"default_locale\": \"en\"}"
                                              };

            return Content(manifestModel.ManifestString, "application/x-web-app-manifest+json");
        }
        public async void SubmitCommandRecieverAsync()
        {
            try
            {
                Loader.StartLoading();

                var location = await _geolocationService.GetLastLocationAsync();

                ManifestModel manifestPostModel = null;

                var result = BarcodeCollection.Where(x => x?.Kegs?.Partners?.Count > 1).ToList();
                if (result?.Count > 0)
                {
                    await NavigateToValidatePartner(result.ToList());
                }

                else
                {
                    try
                    {
                        manifestPostModel = GenerateManifest(location ?? new Xamarin.Essentials.Location(0, 0), ManifestId);

                        var current = Connectivity.NetworkAccess;
                        if (current == NetworkAccess.Internet)
                        {
                            KegIDResponse kegIDResponse = await _maintainService.PostMaintenanceDoneAsync(manifestPostModel.MaintenanceModels.MaintenanceDoneRequestModel, AppSettings.SessionId, Configuration.PostedMaintenanceDone);

                            try
                            {
                                AddorUpdateManifestOffline(manifestPostModel, false);
                            }
                            catch (Exception ex)
                            {
                                Crashes.TrackError(ex);
                            }
                            await GetPostedManifestDetail();
                        }
                        else
                        {
                            try
                            {
                                AddorUpdateManifestOffline(manifestPostModel, true);
                            }
                            catch (Exception ex)
                            {
                                Crashes.TrackError(ex);
                            }
                            await GetPostedManifestDetail();
                        }
                    }
                    catch (Exception ex)
                    {
                        Crashes.TrackError(ex);
                    }
                    finally
                    {
                        Cleanup();
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                Loader.StopLoading();
            }
        }