public void UpdateState()
        {
            using (ISession session = SessionCreator.OpenSession()) {
                using (ITransaction transaction = session.BeginTransaction()) {
                    Populate(session);

                    IList <AugmentationItem> items = session.CreateCriteria <AugmentationItem>().List <AugmentationItem>();
                    var stats = _databaseItemStatDao.GetStats(session, StatFetch.AugmentItems);

                    foreach (var item in items)
                    {
                        var rarity       = ItemOperationsUtility.GetRarityForRecord(stats, item.BaseRecord);
                        var minimumLevel = ItemOperationsUtility.GetMinimumLevelForRecord(stats, item.BaseRecord);
                        var name         = ItemOperationsUtility.GetItemName(session, stats, item);

                        item.Rarity       = rarity;
                        item.MinimumLevel = minimumLevel;
                        item.Name         = name;
                        session.Update(item);
                    }

                    transaction.Commit();
                }
            }
        }
Example #2
0
        private void UpdateItemDetails(ISession session, PlayerItem item, Dictionary <String, List <DBStatRow> > stats)
        {
            var table         = nameof(PlayerItem);
            var rarity        = nameof(PlayerItem.Rarity);
            var levelReq      = nameof(PlayerItem.LevelRequirement);
            var name          = nameof(PlayerItem.Name);
            var id            = nameof(PlayerItem.Id);
            var prefixRarity  = PlayerItemTable.PrefixRarity;
            var nameLowercase = nameof(PlayerItem.NameLowercase);


            var itemName = ItemOperationsUtility.GetItemName(session, stats, item);
            var records  = GetRecordsForItem(item);

            session.CreateQuery($@"UPDATE {table} 
                    SET {name} = :name, {nameLowercase} = :namelowercase, {rarity} = :rarity, {levelReq} = :levelreq, {prefixRarity} = :prefixrarity 
                    WHERE {id} = :id"
                                )
            .SetParameter("name", itemName)
            .SetParameter("namelowercase", itemName.ToLowerInvariant())
            .SetParameter("prefixrarity", GetGreenQualityLevelForRecords(stats, records))
            .SetParameter("rarity", ItemOperationsUtility.GetRarityForRecords(stats, records))
            .SetParameter("levelreq", ItemOperationsUtility.GetMinimumLevelForRecords(stats, records))
            .SetParameter("id", item.Id)
            .ExecuteUpdate();
        }