private void RecentCommandReciever()
        {
            List <ManifestModel> collection;

            try
            {
                ManifestCollection.Clear();
                Loader.StartLoading();
                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                collection = RealmDb.All <ManifestModel>().Where(x => x.SubmittedDate == DateTimeOffset.UtcNow.Date && x.IsDraft == false && x.IsQueue == false).ToList();
                AssignColletionToManifest(collection);
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
            finally
            {
                Loader.StopLoading();
                collection = null;
            }

            RecentTextColor       = "White";
            RecentBackgroundColor = "#4E6388";
            QueuedTextColor       = "#4E6388";
            QueuedBackgroundColor = "Transparent";
            DraftTextColor        = "#4E6388";
            DraftBackgroundColor  = "Transparent";
        }
Esempio n. 2
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);
                });
            }
        }
        private void QueuedCommandReciever()
        {
            List <ManifestModel> collection;

            try
            {
                ManifestCollection.Clear();
                Loader.StartLoading();
                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                collection = RealmDb.All <ManifestModel>().Where(x => x.IsDraft == false && x.IsQueue == true).ToList();
                AssignColletionToManifest(collection);
            }
            catch (Exception ex)
            {
                Debug.Write(ex.Message);
            }
            finally
            {
                Loader.StopLoading();
                collection = null;
            }

            QueuedTextColor       = "White";
            QueuedBackgroundColor = "#4E6388";
            DraftTextColor        = "#4E6388";
            DraftBackgroundColor  = "Transparent";
            RecentTextColor       = "#4E6388";
            RecentBackgroundColor = "Transparent";
        }
        public async Task LoadAssetVolumeAsync()
        {
            var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
            List <AssetVolumeModel> assetVolumeModel = null;
            var result = await ApiManager.GetAssetVolume(Settings.SessionId, false);

            if (result.IsSuccessStatusCode)
            {
                var response = await result.Content.ReadAsStringAsync();

                var model = await Task.Run(() => JsonConvert.DeserializeObject <IList <string> >(response, GetJsonSetting()));

                assetVolumeModel = new List <AssetVolumeModel>();
                foreach (var item in model)
                {
                    assetVolumeModel.Add(new AssetVolumeModel {
                        AssetVolume = item
                    });
                }

                await RealmDb.WriteAsync((realmDb) =>
                {
                    foreach (var item in assetVolumeModel)
                    {
                        realmDb.Add(item);
                    }
                });
            }
        }
Esempio n. 5
0
        private async Task LoadOwnerAsync()
        {
            try
            {
                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                var value   = await _moveService.GetOwnerAsync(AppSettings.SessionId);

                await RealmDb.WriteAsync((realmDb) =>
                {
                    foreach (var item in value.OwnerModel)
                    {
                        try
                        {
                            realmDb.Add(item);
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
            finally
            {
            }
        }
Esempio n. 6
0
        private static void LoadAccounts()
        {
            var task = ExecuteQueryLight(RealmDbManager.GetDatabaseConnection(), "SELECT * FROM accounts", "Accounts",
                                         (reader) =>
            {
                while (reader.Read())
                {
                    Accounts.Add(new Account
                    {
                        Id          = reader.GetInt32("id"),
                        Username    = reader.GetString("username"),
                        Password    = reader.GetString("pass"),
                        Pseudo      = reader.GetString("pseudo"),
                        Question    = reader.GetString("question"),
                        Reponse     = reader.GetString("reponse"),
                        GmLevel     = reader.GetInt16("gmLevel"),
                        BannedUntil =
                            Convert.IsDBNull(reader["bannedUntil"])
                                    ? (DateTime?)null
                                    : reader.GetDateTime("bannedUntil"),
                        Subscription =
                            Convert.IsDBNull(reader["subscription"])
                                    ? (DateTime?)null
                                    : reader.GetDateTime("subscription"),
                    });
                }

                return(Accounts.Count);
            });

            task.Wait();
        }
        internal void AssignInitialValueAsync(List <BarcodeModel> _alerts)
        {
            try
            {
                ConstantManager.VerifiedBarcodes = _alerts;

                LoadOwnderAsync();
                LoadAssetSizeAsync();
                LoadAssetTypeAsync();
                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());

                foreach (var item in _alerts)
                {
                    AssetTypeModel selectedType  = null;
                    AssetSizeModel selectedSize  = null;
                    OwnerModel     selectedOwner = OwnerCollection.Where(x => x.FullName == item?.Kegs?.Partners?.FirstOrDefault()?.FullName).FirstOrDefault();

                    if (selectedOwner != null)
                    {
                        RealmDb.Write(() =>
                        {
                            selectedOwner.HasInitial = true;
                        });
                    }
                    if (item.Tags.Count > 2)
                    {
                        selectedType = TypeCollection.Where(x => x.AssetType == item.Tags?[2]?.Value).FirstOrDefault();

                        RealmDb.Write(() =>
                        {
                            selectedType.HasInitial = true;
                        });
                    }
                    if (item.Tags.Count > 3)
                    {
                        selectedSize = SizeCollection.Where(x => x.AssetSize == item.Tags?[3]?.Value).FirstOrDefault();
                        RealmDb.Write(() =>
                        {
                            selectedSize.HasInitial = true;
                        });
                    }

                    MaintenaceCollection.Add(
                        new MoveMaintenanceAlertModel
                    {
                        UOwnerCollection = OwnerCollection.ToList(),
                        USizeCollection  = SizeCollection.ToList(),
                        UTypeCollection  = TypeCollection.ToList(),
                        BarcodeId        = item.Barcode,
                        SelectedUOwner   = selectedOwner ?? selectedOwner,
                        SelectedUSize    = selectedSize ?? selectedSize,
                        SelectedUType    = selectedType ?? selectedType
                    });
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Esempio n. 8
0
        private async Task LoadMaintainTypeAsync()
        {
            try
            {
                var maintenance = await _maintainService.GetMaintainTypeAsync(AppSettings.SessionId);

                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());

                await RealmDb.WriteAsync((realmDb) =>
                {
                    foreach (var item in maintenance.MaintainTypeReponseModel)
                    {
                        try
                        {
                            realmDb.Add(item);
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
        public async Task LoadBrandAsync()
        {
            var RealmDb  = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
            var response = await ApiManager.GetBrandList(Settings.SessionId);

            if (response.IsSuccessStatusCode)
            {
                var json = await response.Content.ReadAsStringAsync();

                var data = JsonConvert.DeserializeObject <IList <BrandModel> >(json, GetJsonSetting());
                data.Insert(0, new BrandModel {
                    BrandName = "Add", BrandCode = "Add", BrandId = Guid.NewGuid().ToString()
                });
                data.Insert(1, new BrandModel {
                    BrandName = "'\"'", BrandCode = "'\"'", BrandId = Guid.NewGuid().ToString()
                });
                //data.Move(data.FirstOrDefault(x => x.BrandName == "Empty"), 2);

                try
                {
                    await RealmDb.WriteAsync((realmDb) =>
                    {
                        foreach (var item in data)
                        {
                            realmDb.Add(item);
                        }
                    });
                }
                catch (Exception ex)
                {
                }
            }
        }
        private void HandleReceivedMessages()
        {
            MessagingCenter.Subscribe <MaintainScanMessage>(this, "MaintainScanMessage", message =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    var value = message;
                    if (value != null)
                    {
                        using (var db = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()).BeginWrite())
                        {
                            var oldBarcode       = BarcodeCollection.Where(x => x.Barcode == value.Barcodes.Barcode).FirstOrDefault();
                            oldBarcode.Pallets   = value.Barcodes.Pallets;
                            oldBarcode.Kegs      = value.Barcodes.Kegs;
                            oldBarcode.Icon      = value?.Barcodes?.Kegs?.Partners.Count > 1 ? _getIconByPlatform.GetIcon("validationquestion.png") : value?.Barcodes?.Kegs?.Partners?.Count == 0 ? _getIconByPlatform.GetIcon("validationerror.png") : _getIconByPlatform.GetIcon("validationok.png");
                            oldBarcode.IsScanned = true;
                            db.Commit();
                        };
                    }
                });
            });

            MessagingCenter.Subscribe <CancelledMessage>(this, "CancelledMessage", message =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    var value = "Cancelled";
                    if (value == "Cancelled")
                    {
                    }
                });
            });
        }
        public async Task LoadOperators()
        {
            var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
            List <OperatorModel> operators = null;
            var result = await ApiManager.GetOperators(Settings.SessionId);

            if (result.IsSuccessStatusCode)
            {
                var response = await result.Content.ReadAsStringAsync();

                var model = await Task.Run(() => JsonConvert.DeserializeObject <IList <string> >(response, GetJsonSetting()));

                operators = new List <OperatorModel>();
                foreach (var item in model)
                {
                    operators.Add(new OperatorModel {
                        Operator = item
                    });
                }
                await RealmDb.WriteAsync((realmDb) =>
                {
                    foreach (var item in operators)
                    {
                        realmDb.Add(item);
                    }
                });
            }
        }
Esempio n. 12
0
        public async Task LoadPartnerTypeAsync()
        {
            try
            {
                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                var value   = await _moveService.GetPartnerTypeAsync(AppSettings.SessionId);

                if (value.Response.StatusCode == System.Net.HttpStatusCode.OK.ToString())
                {
                    await RealmDb.WriteAsync((realmDb) =>
                    {
                        foreach (var item in value.PartnerTypeModel)
                        {
                            try
                            {
                                realmDb.Add(item);
                            }
                            catch (Exception ex)
                            {
                                Crashes.TrackError(ex);
                            }
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
        internal void InitialAssignValueAsync(int currentPage)
        {
            try
            {
                CurrentPage = currentPage;
                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                var model   = RealmDb.All <InventoryResponseModel>().ToList();
                if (model.Count > 0)
                {
                    StockInventoryCollection = model.Where(x => x.Status != "Empty").ToList();
                    EmptyInventoryCollection = model.Where(x => x.Status == "Empty").ToList();

                    StockTotals = StockInventoryCollection.Sum(x => x.Quantity);
                    EmptyTotals = EmptyInventoryCollection.Sum(x => x.Quantity);
                }
                else
                {
                    InventoryCommandRecieverAsync();
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
        public async void InventoryCommandRecieverAsync()
        {
            InventoryDetailModel model = null;

            try
            {
                Loader.StartLoading();
                model = await _dashboardService.GetInventoryAsync(AppSettings.SessionId);

                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                RealmDb.Write(() =>
                {
                    foreach (var item in model.InventoryResponseModel)
                    {
                        RealmDb.Add(item);
                    }
                });

                StockInventoryCollection = model.InventoryResponseModel.Where(x => x.Status != "Empty").ToList();
                EmptyInventoryCollection = model.InventoryResponseModel.Where(x => x.Status == "Empty").ToList();

                StockTotals = StockInventoryCollection.Sum(x => x.Quantity);
                EmptyTotals = EmptyInventoryCollection.Sum(x => x.Quantity);
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
            finally
            {
                model = null;
                Loader.StopLoading();
            }
        }
Esempio n. 15
0
        public static void UpdateAccount(int id = 0, bool connected = true)
        {
            if (id != 0 && connected)
            {
                const string query = "INSERT INTO gameconnection SET connected = 1, accountId=@accountid, gameserverid=@gsId";

                Base.Repository.ExecuteQuery(query, RealmDbManager.GetDatabaseConnection(),
                                             (command) =>
                {
                    command.Parameters.Add(new MySqlParameter("@accountid", id));
                    command.Parameters.Add(new MySqlParameter("@gsId", DatabaseProvider.ServerId));
                });
            }
            else if (connected == false && id == 0)
            {
                const string query = "DELETE FROM gameconnection";

                Base.Repository.ExecuteQuery(query, RealmDbManager.GetDatabaseConnection(),
                                             (command) => { });
            }
            else if (connected == false && id != 0)
            {
                const string query = "DELETE FROM gameconnection WHERE accountid=@accountid AND gameserverid=@gsId";

                Base.Repository.ExecuteQuery(query, RealmDbManager.GetDatabaseConnection(),
                                             (command) =>
                {
                    command.Parameters.Add(new MySqlParameter("@accountid", id));
                    command.Parameters.Add(new MySqlParameter("@gsId", DatabaseProvider.ServerId));
                });
            }
        }
        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);
            }
        }
Esempio n. 17
0
        public async Task LoadBatchAsync()
        {
            try
            {
                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());

                var value = await _fillService.GetBatchListAsync(AppSettings.SessionId);

                if (value.Response.StatusCode == System.Net.HttpStatusCode.OK.ToString())
                {
                    var batches = value.BatchModel.Where(p => p.BrandName != string.Empty).OrderBy(x => x.BrandName).ToList();
                    await RealmDb.WriteAsync((realmDb) =>
                    {
                        foreach (var item in batches)
                        {
                            try
                            {
                                realmDb.Add(item);
                            }
                            catch (Exception ex)
                            {
                                Crashes.TrackError(ex);
                            }
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
            finally
            {
            }
        }
Esempio n. 18
0
        private static void LoadCharactersAccount()
        {
            var task = ExecuteQueryLight(RealmDbManager.GetDatabaseConnection(),
                                         "SELECT * FROM characters WHERE gameserverId =@ServerId", "Characters <<>> Account", (reader) =>
            {
                var tableResults = new List <KeyValuePair <int, int> >();

                while (reader.Read())
                {
                    tableResults.Add(new KeyValuePair <int, int>(
                                         reader.GetInt16("AccountId"),
                                         reader.GetInt16("characterId")
                                         ));
                }

                foreach (var tableResult in tableResults)
                {
                    AccountCharacters.Add(new AccountCharacters
                    {
                        Account   = Accounts.Find(x => x.Id == tableResult.Key),
                        Character = Characters.Find(x => x.Id == tableResult.Value)
                    });
                }

                return(AccountCharacters.Count);
            }, (command) => command.Parameters.Add(new MySqlParameter("@ServerId", ServerId)));

            task.Wait();
        }
Esempio n. 19
0
        private async Task LoadPartnersAsync()
        {
            var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());

            try
            {
                var value = await _moveService.GetPartnersListAsync(AppSettings.SessionId);

                if (value.Response.StatusCode == System.Net.HttpStatusCode.OK.ToString())
                {
                    var Partners = value.PartnerModel.Where(x => x.FullName != string.Empty).ToList();

                    RealmDb.Write(() =>
                    {
                        foreach (var item in Partners)
                        {
                            try
                            {
                                RealmDb.Add(item);
                            }
                            catch (Exception ex)
                            {
                                Crashes.TrackError(ex);
                            }
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Esempio n. 20
0
        private async Task LoadDashboardPartnersAsync()
        {
            var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());

            try
            {
                var value = await _dashboardService.GetDashboardPartnersListAsync(AppSettings.CompanyId, AppSettings.SessionId);

                if (value.Response.StatusCode == System.Net.HttpStatusCode.OK.ToString())
                {
                    var partners = value.PossessorResponseModel.Where(x => x.Location.FullName != string.Empty).ToList();
                    await RealmDb.WriteAsync((realmDb) =>
                    {
                        foreach (var item in partners)
                        {
                            try
                            {
                                realmDb.Add(item);
                            }
                            catch (Exception ex)
                            {
                                Crashes.TrackError(ex);
                            }
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
Esempio n. 21
0
        private async Task LoginCommandRecieverAsync()
        {
            UserDialogs.Instance.ShowLoading("Loging");
            var loginResponse = await ApiManager.GetAuthenticate(Username, Password);

            if (loginResponse.IsSuccessStatusCode)
            {
                var response = await loginResponse.Content.ReadAsStringAsync();

                var model = await Task.Run(() => JsonConvert.DeserializeObject <LoginModel>(response, GetJsonSetting())); var overDues = model.Preferences.Where(x => x.PreferenceName == "OVERDUE_DAYS").Select(x => x.PreferenceValue).FirstOrDefault();
                var atRisk = model.Preferences.Where(x => x.PreferenceName == "AT_RISK_DAYS").Select(x => x.PreferenceValue).FirstOrDefault();
                var appDataWebServiceUrl = model.Preferences.Where(x => x.PreferenceName == "AppDataWebServiceUrl").Select(x => x.PreferenceValue).FirstOrDefault();
                if (appDataWebServiceUrl != null)
                {
                    ConstantManager.BaseUrl = ConstantManager.BaseUrl;// appDataWebServiceUrl;
                }
                Settings.SessionId       = model.SessionId;
                Settings.CompanyId       = model.CompanyId;
                Settings.MasterCompanyId = model.MasterCompanyId;
                Settings.UserId          = model.UserId;
                Settings.SessionExpires  = model.SessionExpires;
                Settings.Overdue_days    = !string.IsNullOrEmpty(overDues) ? long.Parse(overDues) : 0;
                Settings.At_risk_days    = !string.IsNullOrEmpty(atRisk) ? long.Parse(atRisk) : 0;

                KegRefresh = Convert.ToDouble(model.Preferences.ToList().Find(x => x.PreferenceName == "KEG_REFRESH")?.PreferenceValue);
                await RunSafe(DeviceCheckIn());

                var versionUpdated = VersionTracking.CurrentVersion.CompareTo(VersionTracking.PreviousVersion);
                if (versionUpdated > 0 && VersionTracking.PreviousVersion != null && VersionTracking.IsFirstLaunchForCurrentVersion)
                {
                    await NavigationService.NavigateAsync("WhatIsNewView", null, useModalNavigation : true, animated : false);
                }
                else
                {
                    if (TargetIdiom.Tablet == Device.Idiom)
                    {
                        await NavigationService.NavigateAsync("MainPageTablet", null, useModalNavigation : true, animated : false);
                    }
                    else
                    {
                        await NavigationService.NavigateAsync("MainPage", null, useModalNavigation : true, animated : false);
                    }
                }
                if (!IsLogOut)
                {
                    var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                    await RealmDb.WriteAsync((realmDb) => realmDb.Add(model));
                }
            }
            else
            {
                await _dialogService.DisplayAlertAsync("Error", "Error while login please check", "Ok");

                UserDialogs.Instance.HideLoading();
            }

            Analytics.TrackEvent("Loged In");
        }
Esempio n. 22
0
        public static void Create(Character character, int accountId)
        {
            const string query =
                "INSERT INTO characters SET id=@id, name=@name, classe=@classe, sex=@sex, color1=@color1, color2=@color2," +
                "color3=@color3, skin=@skin, level=@level, alignmentId=@alignmentId, statsId=@statsId, " +
                "pdvNow=@pdvNow, mapId=@mapId, cellId=@cellId, direction=@direction, channels=@channels, statsPoints=@statsPoints, " +
                "spellsPoints=@spellsPoints, kamas=@kamas";

            Base.Repository.ExecuteQuery(query, GameDbManager.GetDatabaseConnection(),
                                         (command) =>
            {
                command.Parameters.Add(new MySqlParameter("@id", character.Id));
                command.Parameters.Add(new MySqlParameter("@name", character.Name));
                command.Parameters.Add(new MySqlParameter("@classe", (int)character.Classe));
                command.Parameters.Add(new MySqlParameter("@sex", character.Sex));
                command.Parameters.Add(new MySqlParameter("@color1", character.Color1));
                command.Parameters.Add(new MySqlParameter("@color2", character.Color2));
                command.Parameters.Add(new MySqlParameter("@color3", character.Color3));
                command.Parameters.Add(new MySqlParameter("@skin", character.Skin));
                command.Parameters.Add(new MySqlParameter("@level", character.Level));
                command.Parameters.Add(new MySqlParameter("@alignmentId", character.Alignment.Id));
                command.Parameters.Add(new MySqlParameter("@statsId", character.Stats.Id));
                command.Parameters.Add(new MySqlParameter("@pdvNow", character.PdvNow));
                command.Parameters.Add(new MySqlParameter("@mapId", character.Map.Id));
                command.Parameters.Add(new MySqlParameter("@cellId", character.MapCell));
                command.Parameters.Add(new MySqlParameter("@direction", character.Direction));
                command.Parameters.Add(new MySqlParameter("@channels", string.Join("", character.Channels)));
                command.Parameters.Add(new MySqlParameter("@statsPoints", character.StatsPoints));
                command.Parameters.Add(new MySqlParameter("@spellsPoints", character.SpellPoints));
                command.Parameters.Add(new MySqlParameter("@kamas", character.Kamas));
            });

            Logs.LogWritter(Constant.GameFolder, string.Format("Création du personnage {0}", character.Name));

            const string query2 =
                "INSERT INTO characters SET accountId=@accountId, gameserverId=@gameServer, characterId=@id";

            Base.Repository.ExecuteQuery(query2, RealmDbManager.GetDatabaseConnection(),
                                         (command) =>
            {
                command.Parameters.Add(new MySqlParameter("@accountId", accountId));
                command.Parameters.Add(new MySqlParameter("@gameServer", DatabaseProvider.ServerId));
                command.Parameters.Add(new MySqlParameter("@id", character.Id));
            });

            lock (DatabaseProvider.Characters)
                DatabaseProvider.Characters.Add(character);

            lock (DatabaseProvider.AccountCharacters)
                DatabaseProvider.AccountCharacters.Add(new AccountCharacters
                {
                    Account   = DatabaseProvider.Accounts.Find(x => x.Id == accountId),
                    Character = character
                });
        }
Esempio n. 23
0
        public static void UpdateCharactersList(int id)
        {
            const string query = "SELECT * FROM characters WHERE accountId = @accountId AND gameServerId = @gsId";

            var charactersId = new List <int>();

            using (var connection = RealmDbManager.GetDatabaseConnection())
            {
                using (var command = new MySqlCommand(query, connection))
                {
                    command.Parameters.Add(new MySqlParameter("@accountId", id));
                    command.Parameters.Add(new MySqlParameter("@gsId", DatabaseProvider.ServerId));

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            charactersId.Add(reader.GetInt16("characterId"));
                        }
                    }
                }
            }

            const string query2 = "SELECT * FROM characters WHERE FIND_IN_SET(id, @charactersId)";

            using (var connection = GameDbManager.GetDatabaseConnection())
            {
                using (var command = new MySqlCommand(query2, connection))
                {
                    command.Parameters.Add(new MySqlParameter("@charactersId", string.Join(",", charactersId)));

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var character = DatabaseProvider.Characters.Find(x => x.Id == reader.GetInt16("id"));

                            character.Name        = reader.GetString("name");
                            character.Color1      = reader.GetInt32("color1");
                            character.Color2      = reader.GetInt32("color2");
                            character.Color3      = reader.GetInt32("color3");
                            character.Kamas       = reader.GetInt32("kamas");
                            character.Level       = reader.GetInt16("level");
                            character.Sex         = reader.GetInt16("sex");
                            character.Skin        = reader.GetInt16("skin");
                            character.Map         = DatabaseProvider.Maps.Find(x => x.Id == reader.GetInt32("mapId"));
                            character.MapCell     = reader.GetInt32("cellId");
                            character.Direction   = reader.GetInt16("direction");
                            character.StatsPoints = reader.GetInt32("statsPoints");
                            character.SpellPoints = reader.GetInt32("spellsPoints");
                        }
                    }
                }
            }
        }
        public void LoadPartnerAsync(PartnerInfoResponseModel partnerInfoModel)
        {
            var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());

            PartnerTypeCollectioin = RealmDb.All <PartnerTypeModel>().ToList();

            if (partnerInfoModel != null)
            {
                AssingValueAddPartner(partnerInfoModel);
            }
        }
 private void LoadMaintenanceType()
 {
     try
     {
         var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
         MaintainTypeReponseModel = RealmDb.All <MaintainTypeReponseModel>().ToList();
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
Esempio n. 26
0
 private void LoadBrand()
 {
     try
     {
         var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
         BrandCollection = RealmDb.All <BrandModel>().ToList();
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
Esempio n. 27
0
 public void LoadBatchAsync()
 {
     try
     {
         var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
         BatchCollection = RealmDb.All <NewBatch>().ToList();
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
 private void LoadAssetTypeAsync()
 {
     try
     {
         var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
         TypeCollection = RealmDb.All <AssetTypeModel>().ToList();
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
 private void LoadOwnderAsync()
 {
     try
     {
         var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
         OwnerCollection = RealmDb.All <OwnerModel>().ToList();
         SelectedOwner   = OwnerCollection.OrderBy(x => x.FullName).FirstOrDefault();
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
 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();
     }
 }