Example #1
0
        public static void UpdateBranch()
        {
            var db      = new SaleOnlineDbContext();
            var dbHrm   = new HrmDbContext();
            var dbApb   = new AbpHplDbContext();
            var listPbs = dbApb.HplPhongBans;

            foreach (var pb in listPbs)
            {
                var branch = db.Branches.FirstOrDefault(x => x.BranchCode == pb.MaPhongBan);
                if (branch != null)
                {
                    pb.BranchId   = branch.BranchId;
                    pb.BranchName = branch.BranchName;
                    pb.BranchCode = branch.BranchCode;
                }

                var pbHrm = dbHrm.PhongBans.FirstOrDefault(x => x.MaPhongBan == pb.MaPhongBan);
                if (pbHrm != null)
                {
                    pb.PhongBanId       = pbHrm.PhongBanId;
                    pb.PhongBanParentId = pbHrm.PhongBanChaId;
                    pb.TenPhongBan      = pbHrm.Ten;
                }

                pb.LastSyncToAd = DateTime.Now;
            }
            //SaleOnlineServices
            dbApb.SaveChanges();
            dbApb.Dispose();
            db.Dispose();
        }
Example #2
0
        public async Task <IActionResult> Post(
            [FromBody] GraphQLQuery query,
            [FromServices] HrmDbContext db,
            [FromServices] List <DateTime> holidays)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            var inputs           = query.Variables.ToInputs();
            var executionOptions = new ExecutionOptions
            {
                UserContext      = new HrmContext(db, User, holidays),
                Schema           = _schema,
                OperationName    = query.OperationName,
                Query            = query.Query,
                Inputs           = inputs,
                ExposeExceptions = true,
            };

            var result = await _documentExecuter.ExecuteAsync(executionOptions).ConfigureAwait(false);

            db.SaveChanges();

            if (result.Errors?.Count > 0)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }
Example #3
0
        public static int FlattenAllHplPhongBan()
        {
            var db    = new SaleOnlineDbContext();
            var dbHrm = new HrmDbContext();
            var dbApb = new AbpHplDbContext();

            return(dbApb.FlattenAllHplPhongBan());
        }
Example #4
0
        public static bool UserNotExist(string userName)
        {
            var db   = new HrmDbContext();
            var user = db.SysNguoiDungs.FirstOrDefault(x => x.TenDangNhap == userName);

            if (user != null)
            {
                return(false);
            }

            return(true);
        }
Example #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, HrmDbContext db, List <DateTime> Holidays)
        {
            app.UseResponseCompression();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseAuthentication();
            app.Use(async(context, next) =>
            {
                var Id = context.User.Identity;
                if (Id.IsAuthenticated)
                {
                    var dbCtx = context.RequestServices.GetService <HrmDbContext>();
                    var user  = dbCtx.Employees.Where(x => x.ADPrincipalName == Id.Name).FirstOrDefault();
                    if (user == null)
                    {
                        dbCtx.Employees.Add(new Employee()
                        {
                            ADPrincipalName = Id.Name,
                            isActive        = true
                        });
                        dbCtx.SaveChanges();
                    }
                }
                // Do work that doesn't write to the Response.
                await next.Invoke();
                // Do logging or other work that doesn't write to the Response.
            });
            //app.UseHttpsRedirection();
            app.UseGraphiQl("/GraphiQL", "/api/graphql");

            app.UseMvc();
            app.UseStaticFiles();
            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "wwwroot";
            });
            db.SeedData();
            Holidays.AddRange(db.Holidays.Select(x => x.Value).ToList());
        }
Example #6
0
        /// <summary>
        /// CHẠY MỘT LẦN DO LỖI
        /// </summary>
        /// <returns></returns>
        public static List <HplDisableUserLog> UpdateLogDis()
        {
            var db    = new AbpHplDbContext();
            var dbHrm = new HrmDbContext();

            var listNvs = db.HplDisableUserLogs;

            //foreach (var log in listNvs)
            //{
            //    var pb = dbHrm.PhongBans.FirstOrDefault(x => x.PhongBanId == log.PhongBanId);
            //    if (pb != null) log.MaPhongBan = pb.MaPhongBan;

            //    var pbCap1 = dbHrm.PhongBans.FirstOrDefault(x => x.PhongBanId == log.PhongBanCap1Id);
            //    if (pbCap1 != null) log.MaPhongBanCap1 = pbCap1.MaPhongBan;
            //}

            //db.SaveChanges();

            return(listNvs.OrderByDescending(x => x.DateCreated.Value).ToList());
        }
Example #7
0
        public static string CreateNewUsername(string userName)
        {
            var    db          = new HrmDbContext();
            string newUsername = userName;
            bool   check       = true;
            int    i           = 0;

            while (check)
            {
                var user = db.SysNguoiDungs.FirstOrDefault(x => x.TenDangNhap == newUsername);
                if (user != null)
                {
                    i++;
                    newUsername = userName + i;
                }
                else
                {
                    check = false;
                }
            }

            return(newUsername);
        }
Example #8
0
        public static List <NsQtChuyenCanBo> GetAllCanBo()
        {
            var db = new HrmDbContext();

            return(db.NsQtChuyenCanBoes.ToList());
        }