Beispiel #1
0
        public async Task <AppEntity> ProcessAsync(
            AppEntity appEntity, IReadOnlyDictionary <int, AppPriceInfo> priceInfos, Guid loopId)
        {
            if (!priceInfos.TryGetValue(appEntity.Id, out var priceInfo) ||
                !priceInfo.Success ||
                priceInfo.Data?.PriceOverview is null)
            {
                return(appEntity with
                {
                    PriceFetchId = loopId,
                    LastDiscountPercentage = double.NaN,
                });
            }

            if (priceInfo.Data.PriceOverview.DiscountPercent == 100 &&
                appEntity.LastDiscountPercentage != 100)
            {
                await OnFreePromotionDetectedAsync(appEntity);
            }

            return(appEntity with
            {
                PriceFetchId = loopId,
                LastDiscountPercentage = priceInfo.Data.PriceOverview.DiscountPercent,
            });
        }
Beispiel #2
0
        private static void UpdateFromImputedValues(
            AppEntity appEntity, int imputedMain, int imputedExtras, int imputedCompletionist, TtbRatios ratios, out bool imputationZero, out bool imputationMiss)
        {
            HandleOverridenTtb(appEntity, "main", appEntity.MainTtb, appEntity.MainTtbImputed, ref imputedMain);
            HandleOverridenTtb(appEntity, "extras", appEntity.ExtrasTtb, appEntity.ExtrasTtbImputed, ref imputedExtras);
            HandleOverridenTtb(appEntity, "completionist", appEntity.CompletionistTtb, appEntity.CompletionistTtbImputed, ref imputedCompletionist);

            if (imputedMain == 0 || imputedExtras == 0 || imputedCompletionist == 0)
            {
                imputationZero = true;
                FixImputationZeroes(appEntity, ratios, ref imputedMain, ref imputedExtras, ref imputedCompletionist);
            }
            else
            {
                imputationZero = false;
            }

            if (imputedMain > imputedExtras || imputedExtras > imputedCompletionist)
            {
                imputationMiss = true;
                FixImputationMiss(appEntity, ratios, ref imputedMain, ref imputedExtras, ref imputedCompletionist);
            }
            else
            {
                imputationMiss = false;
            }

            appEntity.FixTtbs(imputedMain, imputedExtras, imputedCompletionist);
        }
Beispiel #3
0
        //insert
        //menerima view model dari view
        public static bool insert(MMenuVM model)
        {
            bool result = false;

            //simpan datanya ke model
            using (AppEntity db = new AppEntity())
            {
                m_menu item = new m_menu()
                {
                    id           = model.id,
                    code         = model.code,
                    name         = model.name,
                    controller   = model.controller,
                    parent_id    = model.parent_id,
                    is_active    = true,
                    created_by   = 1,
                    created_date = DateTime.Now,
                    updated_by   = 1,
                    updated_date = DateTime.Now,
                };
                db.m_menu.Add(item);

                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(result);
        }
Beispiel #4
0
        public static bool insert(MUserVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                model.isActive = true;
                m_user data = new m_user()
                {
                    m_employee_id = model.mEmployeeId,
                    m_role_id     = model.mRoleId,
                    username      = model.username,
                    password      = model.password,
                    created_by    = model.createdBy,
                    created_date  = DateTime.Now,
                    is_active     = model.isActive
                };
                db.m_user.Add(data);
                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
Beispiel #5
0
        //insert
        //menerima view model dari view
        public static bool insert(MRoleVM model)
        {
            bool result = false;

            //simpan datanya ke model
            using (AppEntity db = new AppEntity())
            {
                m_role item = new m_role()
                {
                    id           = model.id,
                    code         = model.code,
                    name         = model.name,
                    description  = model.description,
                    is_active    = true,
                    created_by   = 1,
                    created_date = DateTime.Now,
                    updated_by   = 1,
                    updated_date = DateTime.Now,
                };
                db.m_role.Add(item);

                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(result);
        }
Beispiel #6
0
        public static bool insert(MMenuAccessVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                foreach (var item in model.listMenuId)
                {
                    var data = new m_menu_access()
                    {
                        m_role_id    = model.role.id,
                        created_by   = 2,
                        is_active    = true,
                        created_date = DateTime.Now,
                        m_menu_id    = item
                    };
                    db.m_menu_access.Add(data);
                }
                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
        public async Task <IHttpActionResult> CreateApp([FromBody] AppInfo info, CancellationToken token)
        {
            CustomTrace.TraceInformation("[CreateApp] AppId={0}", info.AppId);

            var app = await this.Database.Apps.GetSingleAsync(info.AppId, token);

            if (app == null)
            {
                // todo: currently, app name equals app id.
                app = new AppEntity
                {
                    Id        = info.AppId,
                    Name      = info.AppId,
                    AppSecret = info.AppSecret,
                };

                await this.Database.Apps.InsertAsync(app, token);
            }

            var response = new AppResponse
            {
                AppId     = info.AppId,
                AppSecret = info.AppSecret
            };

            return(this.CreateSuccessResult(response));
        }
Beispiel #8
0
        private static AppEntity ScrapeApp(string name)
        {
            var app = new AppEntity(0, name, AppEntity.GameTypeName);

            HltbScraper.ScrapeHltb(new[] { app }, (a, e) => throw new InvalidOperationException("error during scraping", e)).Wait();
            return(app);
        }
Beispiel #9
0
 public SuggestionInfo(SuggestionEntity suggestion, AppEntity app, int originalHltbId, string originalHltbName)
 {
     Suggestion       = suggestion;
     App              = app;
     OriginalHltbId   = originalHltbId;
     OriginalHltbName = originalHltbName;
 }
Beispiel #10
0
        public async Task <IHttpActionResult> Create([FromBody] AppInfo info)
        {
            Logger.Info("App.Create AppId={0}", info.AppId);

            var app = await this.DatabaseContext.Bucket.GetByEntityIdSlimAsync <AppEntity>(info.AppId, false);

            if (app == null)
            {
                var appEntity = new AppEntity
                {
                    Id        = info.AppId,
                    AppSecret = info.AppSecret
                };

                await this.DatabaseContext.Bucket.InsertSlimAsync(appEntity);
            }

            var response = new AppResponse
            {
                AppId     = info.AppId,
                AppSecret = info.AppSecret
            };

            return(CreateSuccessResult(response));
        }
Beispiel #11
0
        //Update
        public bool UpdateAppEntity(string devId, string appName, string entityName, AppEntity appEntity)
        {
            AppEntityDTO ae = GetAppEntity(devId, appName, entityName);

            try
            {
                if (ae != null)
                {
                    //Prevent user from changing references
                    appEntity.AppId    = ae.AppId;
                    appEntity.EntityId = ae.EntityId;

                    _unitOfWork.EntityRepository.Update(appEntity);
                    foreach (EntityField ef in appEntity.EntityFields)
                    {
                        _unitOfWork.FieldRepository.Update(ef);
                    }
                    _unitOfWork.Save();
                    return(true);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(false);
        }
Beispiel #12
0
        public static List <MSouvenirVM> SearchData(MSouvenirVM model)
        {
            var data = new List <MSouvenirVM>();

            using (AppEntity db = new AppEntity())
            {
                data = db.m_souvenir.Select(x => new MSouvenirVM()
                {
                    id           = x.id,
                    code         = x.code,
                    name         = x.name,
                    description  = x.description,
                    m_unit_id    = x.m_unit_id,
                    is_active    = x.is_active,
                    created_by   = x.created_by,
                    created_date = x.created_date,
                    updated_by   = x.updated_by,
                    updated_date = x.updated_date,
                    str_unit     = x.m_unit.name
                })
                       .Where(x => x.is_active == true && (x.code.Contains(model.code) || x.name.Contains(model.name) || x.m_unit_id == model.m_unit_id) || (x.created_date.Day == model.created_date.Day && x.created_date.Month == model.created_date.Month && x.created_date.Year == model.created_date.Year))
                       .ToList();
            }
            return(data);
        }
Beispiel #13
0
        public static MSouvenirVM GetId(int id)
        {
            var data = new MSouvenirVM();

            using (AppEntity db = new AppEntity())
            {
                data = db.m_souvenir.Select(x => new MSouvenirVM()
                {
                    id           = x.id,
                    code         = x.code,
                    name         = x.name,
                    description  = x.description,
                    m_unit_id    = x.m_unit_id,
                    is_active    = x.is_active,
                    created_by   = x.created_by,
                    created_date = x.created_date,
                    updated_by   = x.updated_by,
                    updated_date = x.updated_date,
                    str_unit     = x.m_unit.name
                })
                       .Where(x => x.id == id)
                       .FirstOrDefault();
            }
            return(data);
        }
Beispiel #14
0
        public static List <MSouvenirVM> GetAllData()
        {
            var data = new List <MSouvenirVM>();

            using (AppEntity db = new AppEntity())
            {
                data = db.m_souvenir.Select(x => new MSouvenirVM()
                {
                    id             = x.id,
                    code           = x.code,
                    name           = x.name,
                    description    = x.description,
                    m_unit_id      = x.m_unit_id,
                    is_active      = x.is_active,
                    created_by     = x.created_by,
                    created_date   = x.created_date,
                    updated_by     = x.updated_by,
                    updated_date   = x.updated_date,
                    str_unit       = x.m_unit.name,
                    str_created_by = "Administrator"
                })
                       .Where(x => x.is_active == true)
                       .ToList();
            }
            return(data);
        }
Beispiel #15
0
        public static List <MEmployeeVM> get()
        {
            List <MEmployeeVM> result = new List <MEmployeeVM>();

            using (AppEntity db = new AppEntity())
            {
                result = db.m_employee
                         .Include("Company")
                         .Select(x => new MEmployeeVM()
                {
                    id = x.id,
                    employee_number = x.employee_number,
                    first_name      = x.first_name,
                    last_name       = x.last_name,
                    m_company_id    = x.m_company_id,
                    email           = x.email,
                    is_active       = x.is_active,
                    created_by      = x.created_by,
                    created_date    = x.created_date,
                    updated_by      = x.updated_by,
                    updated_date    = x.updated_date,
                    NmCompany       = x.m_company.name,
                    FullName        = x.first_name + " " + x.last_name
                }).Where(x => x.is_active == true)
                         .ToList();
            }
            return(result);
        }
Beispiel #16
0
        private static async Task AcceptSuggestionInternal([NotNull] AppEntity app, [NotNull] SuggestionEntity suggestion, int retries)
        {
            var batchOperation = new TableBatchOperation
            {
                TableOperation.Delete(suggestion),
                TableOperation.InsertOrReplace(new ProcessedSuggestionEntity(suggestion))
            };

            if (suggestion.IsRetype)
            {
                batchOperation.Delete(app);
                batchOperation.Insert(new AppEntity(app.SteamAppId, app.SteamName, suggestion.AppType));
            }
            else
            {
                batchOperation.Replace(app);
            }

            var table = await GetTable(SteamToHltbTableName, retries).ConfigureAwait(false);

            CommonEventSource.Log.AcceptSuggestionStart(suggestion.SteamAppId, suggestion.HltbId);
            await table.ExecuteBatchAsync(batchOperation).ConfigureAwait(false);

            CommonEventSource.Log.AcceptSuggestionStop(suggestion.SteamAppId, suggestion.HltbId);
        }
Beispiel #17
0
        public static List <MUserVM> get()
        {
            List <MUserVM> data = new List <MUserVM>();

            using (AppEntity db = new AppEntity())
            {
                data = db.m_user
                       .Include("m_employee")
                       .Include("m_role")
                       .Select(x => new MUserVM()
                {
                    id          = x.id,
                    username    = x.username,
                    createdDate = x.created_date,
                    createdBy   = x.created_by,
                    firtsName   = x.m_employee.first_name,
                    lastName    = x.m_employee.last_name,
                    nameRole    = x.m_role.name,
                    isActive    = x.is_active,
                    company     = x.m_employee.m_company.name,
                    fullName    = x.m_employee.first_name + x.m_employee.last_name
                })
                       .ToList();
            }
            return(data);
        }
        private void StartCmdExecute(object obj)
        {
            var wlyEntity = new AppEntity("15820299689", "game1314");

            wlyEntity.Start(ProgramPath);
            entityList.Add(wlyEntity);
        }
Beispiel #19
0
        public static List <MUserVM> search(string user)
        {
            var data = new List <MUserVM>();

            using (AppEntity db = new AppEntity())
            {
                data = db.m_user.Select(x => new MUserVM()
                {
                    id          = x.id,
                    username    = x.username,
                    password    = x.password,
                    mRoleId     = x.m_role_id,
                    mEmployeeId = x.m_employee_id,
                    nameRole    = x.m_role.name,
                    isActive    = x.is_active,
                    createdBy   = x.created_by,
                    createdDate = x.created_date,
                    firtsName   = x.m_employee.first_name,
                    lastName    = x.m_employee.last_name
                })
                       .Where(x => x.username.Contains(user.ToLower()))
                       .ToList();
            }
            return(data);
        }
Beispiel #20
0
        public static MMenuAccessVM getByIdRole(int id)
        {
            var data = new MMenuAccessVM();

            using (AppEntity db = new AppEntity())
            {
                var roleAccess = db.m_role.Select(x => new MRoleVM()
                {
                    id          = x.id,
                    name        = x.name,
                    code        = x.code,
                    created_by  = x.created_by,
                    description = x.description
                })
                                 .Where(x => x.id == id)
                                 .FirstOrDefault();
                //ambil data menu dengan role id diatas
                var menuList = db.m_menu_access
                               .Where(x => x.m_role_id == id)
                               .Select(x => new MMenuVM()
                {
                    id           = x.m_menu_id,
                    name         = x.m_menu.name,
                    is_active    = x.is_active,
                    updated_by   = x.updated_by,
                    updated_date = x.updated_date
                }).ToList();
                //memasukan ke alamat yg telah disiapkan
                data.role     = roleAccess;
                data.listMenu = menuList;
            }
            return(data);
        }
Beispiel #21
0
        public static bool update(MUserVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                var data = db.m_user.Find(model.id);
                data.id            = model.id;
                data.m_employee_id = model.mEmployeeId;
                data.m_role_id     = model.mRoleId;
                data.username      = model.username;
                data.password      = model.password;
                data.updated_by    = model.updatedBy;
                data.updated_date  = DateTime.Now;
                data.is_active     = true;
                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
Beispiel #22
0
        // delete
        // update
        public static bool hiddenMenu(int id)
        {
            var result = false;

            MMenuVM data = MMenuRepo.getById(id);

            using (AppEntity db = new AppEntity())
            {
                m_menu item = db.m_menu.Find(id);

                item.is_active    = false;
                item.updated_by   = 1;
                item.updated_date = DateTime.Now;

                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(result);
        }
        public override bool FullEquals(RequestListFilterEntity other)
        {
            if (other == null)
            {
                return(false);
            }

            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }

            return(other != null &&
                   StartDateTime == other.StartDateTime &&
                   Nullable.Equals(StopDateTime, other.StopDateTime) &&
                   UserEntity.Equals(ResponseUser, other.ResponseUser) &&
                   UserEntity.Equals(CreatorUser, other.CreatorUser) &&
                   AppEntity.Equals(Application, other.Application) &&
                   OrgEntity.Equals(Organization, other.Organization) &&
                   string.Equals(StatusIdList, other.StatusIdList) &&
                   string.Equals(TagIdList, other.TagIdList) &&
                   string.Equals(Subject, other.Subject) &&
                   string.Equals(Comments, other.Comments) &&
                   string.Equals(Contact, other.Contact) &&
                   string.Equals(RequestId, other.RequestId));
        }
Beispiel #24
0
        private void InitView()
        {
            _appList = _nsiService.Applications;
            _appList.Add(AppEntity.Create());

            _orgList = _nsiService.Organizations;
            _orgList.Add(OrgEntity.Create());

            _userList = _nsiService.Users;
            _userList.Add(UserEntity.Create());

            _tagList = _nsiService.Tags;

            _dialogResult = null;
            _control      = new RequestFilterControl(this);

            _caption = string.Format("Параметри пошуку звернень", "");
            _hint    = string.Format("Параметри пошуку звернень", "");

            _image = Properties.Resources.Request;

            _filterList = new List <RequestListFilterEntity>();
            foreach (RequestListFilterEntity filter in _mainController.Filters)
            {
                _filterList.Add(filter.Clone());
            }
            if (_filterOrigin == null)
            {
                Filter = RequestListFilterEntity.Create();
            }
            else
            {
                Filter = _filterOrigin.Clone();
            }
        }
 private static void PrintGame(AppEntity app)
 {
     Console.WriteLine("{10} ({11}) / {0} ({9}): {1}/{2}/{3} ({4}/{5}/{6}) | {7} | {8}",
                       app.SteamName, app.MainTtb, app.ExtrasTtb, app.CompletionistTtb,
                       app.MainTtbImputed, app.ExtrasTtbImputed, app.CompletionistTtbImputed,
                       app.GenresFlat, app.CategoriesFlat, app.AppType, app.SteamAppId, app.HltbId);
 }
Beispiel #26
0
        RequestListFilterEntity SettingToFilter(FilterEntitySetting setting)
        {
            RequestListFilterEntity filter = RequestListFilterEntity.Create();

            filter.CloneKey      = new IdentKey(setting.CloneKey);
            filter.FilterName    = setting.FilterName;
            filter.StartDateTime = setting.StartDateTime;
            filter.StopDateTime  = setting.StopDateTime;

            UserEntity user = _nsiService.GetUserById(setting.ResponseId);

            filter.ResponseUser = user == null?UserEntity.Create() : user;

            user = _nsiService.GetUserById(setting.CreatorId);
            filter.CreatorUser = user == null?UserEntity.Create() : user;

            AppEntity app = _nsiService.GetAppById(setting.ApplicationId);

            filter.Application = app == null?AppEntity.Create() : app;

            OrgEntity org = _nsiService.GetOrgById(setting.OrganizationId);

            filter.Organization = org == null?OrgEntity.Create() : org;

            filter.Comments     = setting.Comments;
            filter.Subject      = setting.Subject;
            filter.Contact      = setting.Contact;
            filter.TagIdList    = setting.TagIdList;
            filter.StatusIdList = setting.StatusIdList;

            return(filter);
        }
 public AppDto GetByName(string Name)
 {
     using (IUnitOfWork op = _UnitFactory.GetUnit(this))
     {
         op.BeginTransaction();
         AppEntity entity = op.Query <AppEntity>().Where(x => x.Name.Equals(Name)).FirstOrDefault();
         return(ConvertEntityToDto(entity));
     }
 }
 public override AppDto GetById(Guid Id)
 {
     using (IUnitOfWork op = _UnitFactory.GetUnit(this))
     {
         op.BeginTransaction();
         AppEntity entity = op.Query <AppEntity>().Where(x => x.Id.Equals(Id)).FirstOrDefault();
         return(ConvertEntityToDto(entity));
     }
 }
Beispiel #29
0
        private static int GetTtb(AppEntity app, string ttbType, int currentTtb, bool currentTtbImputed, int scrapedTtb)
        {
            if (!currentTtbImputed && scrapedTtb == 0)
            {
                HltbScraperEventSource.Log.PreviouslyRecordedTtbNotOnHltb(app.SteamName, app.SteamAppId, ttbType, currentTtb, app.HltbName, app.HltbId);
            }

            return(scrapedTtb);
        }
Beispiel #30
0
        public static Task DeleteSuggestion([NotNull] SuggestionEntity suggestion, AppEntity app = null, int retries = -1)
        {
            if (suggestion == null)
            {
                throw new ArgumentNullException(nameof(suggestion));
            }

            return(DeleteSuggestionInternal(suggestion, app, retries));
        }