private string GenerateBatchId(ref long prefix, string lastCharOfYear, int dayOfYear, int secondsInDayTillNow, int millisecond)
        {
            string barCode;
            var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
            var preference = RealmDb.All<Preference>().Where(x => x.PreferenceName == "DashboardPreferences").ToList();

            foreach (var item in preference)
            {
                if (item.PreferenceValue.Contains("OldestKegs"))
                {
                    var preferenceValue = JsonConvert.DeserializeObject<PreferenceValueResponseModel>(item.PreferenceValue);
                    var value = preferenceValue.SelectedWidgets.Where(x => x.Id == "OldestKegs").FirstOrDefault();
                    prefix = value.Pos.Y;
                }
            }
            barCode = prefix.ToString().PadLeft(9, '0') + lastCharOfYear + dayOfYear + secondsInDayTillNow + (millisecond / 100);
            var checksumDigit = _calcCheckDigitMngr.CalculateCheckDigit(barCode);
            BatchId = barCode + checksumDigit;
            Title = "Pallet #" + BatchId;
            return barCode;
        }
        public void GenerateManifestIdAsync(PalletModel palletModel)
        {
            var            RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
            DateTimeOffset now     = DateTimeOffset.Now;
            string         barCode;
            long           prefix              = 0;
            var            lastCharOfYear      = now.Year.ToString().ToCharArray().LastOrDefault().ToString();
            var            dayOfYear           = now.DayOfYear;
            var            secondsInDayTillNow = SecondsInDayTillNow();
            var            millisecond         = now.Millisecond;

            var preference = RealmDb.All <Preference>().Where(x => x.PreferenceName == "DashboardPreferences").ToList();

            try
            {
                foreach (var item in preference)
                {
                    if (item.PreferenceValue.Contains("OldestKegs"))
                    {
                        var preferenceValue = JsonConvert.DeserializeObject <PreferenceValueResponseModel>(item.PreferenceValue);
                        var value           = preferenceValue.SelectedWidgets.Where(x => x.Id == "OldestKegs").FirstOrDefault();
                        prefix = value.Pos.Y;
                    }
                }
                barCode = prefix.ToString().PadLeft(9, '0') + lastCharOfYear + dayOfYear + secondsInDayTillNow + (millisecond / 100);
                var checksumDigit = _calcCheckDigitMngr.CalculateCheckDigit(barCode);
                ManifestId = barCode + checksumDigit;
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
            finally
            {
                preference = null;
            }
        }