Exemplo n.º 1
0
        public IQueryable <DTO_CUS_DOC_File> Get()
        {
            var result = BS_CUS_DOC_File.get_CUS_DOC_File(db, PartnerID, QueryStrings, true).ToList();

            if (QueryStrings.Any(d => d.Key == "IncludeOwner"))
            {
                var query = db.tbl_CUS_DOC_File
                            .Where(d => d.IsDeleted == false && d.IsHidden != true && d.IDPartner == PartnerID && (d.ModifiedBy == Username || d.CreatedBy == Username));

                if (QueryStrings.Any(d => d.Key == "IDFolder"))
                {
                    var        IDList = QueryStrings.FirstOrDefault(d => d.Key == "IDFolder").Value.Replace("[", "").Replace("]", "").Split(',');
                    List <int> IDs    = new List <int>();
                    foreach (var item in IDList)
                    {
                        if (int.TryParse(item, out int i))
                        {
                            IDs.Add(i);
                        }
                        else if (item == "null")
                        {
                            query = query.Where(d => !d.tbl_CUS_DOC_FileInFolder.Any());
                        }
                    }
                    if (IDs.Count > 0)
                    {
                        query = query.Where(d => d.tbl_CUS_DOC_FileInFolder.Any(c => c.IDFolder.HasValue && IDs.Contains(c.IDFolder.Value)));
                    }
                }

                var result2 = BS_CUS_DOC_File.ctoDTO(query).ToList();

                if (result2.Count > 0)
                {
                    foreach (var item in result2)
                    {
                        if (!result.Any(d => d.ID == item.ID))
                        {
                            result.Add(item);
                        }
                    }
                }
            }

            return(result.AsQueryable());
        }
Exemplo n.º 2
0
        public IQueryable <DTO_CUS_DOC_File> GetMissingFile()
        {
            var result = BS_CUS_DOC_File.get_CUS_DOC_File(db, PartnerID, QueryStrings, true).ToList();
            List <DTO_CUS_DOC_File> r2 = new List <DTO_CUS_DOC_File>();

            if (QueryStrings.Any(d => d.Key == "IncludeOwner"))
            {
                var query = db.tbl_CUS_DOC_File
                            .Where(d => d.IsDeleted == false && d.IDPartner == PartnerID && (d.ModifiedBy == Username || d.CreatedBy == Username));

                if (QueryStrings.Any(d => d.Key == "IDFolder"))
                {
                    var        IDList = QueryStrings.FirstOrDefault(d => d.Key == "IDFolder").Value.Replace("[", "").Replace("]", "").Split(',');
                    List <int> IDs    = new List <int>();
                    foreach (var item in IDList)
                    {
                        if (int.TryParse(item, out int i))
                        {
                            IDs.Add(i);
                        }
                        else if (item == "null")
                        {
                            query = query.Where(d => !d.tbl_CUS_DOC_FileInFolder.Any());
                        }
                    }
                    if (IDs.Count > 0)
                    {
                        query = query.Where(d => d.tbl_CUS_DOC_FileInFolder.Any(c => c.IDFolder.HasValue && IDs.Contains(c.IDFolder.Value)));
                    }
                }

                var result2 = BS_CUS_DOC_File.ctoDTO(query).ToList();

                if (result2.Count > 0)
                {
                    foreach (var item in result2)
                    {
                        if (!result.Any(d => d.ID == item.ID))
                        {
                            result.Add(item);
                        }
                    }
                }
            }
            string mapPath = System.Web.HttpContext.Current.Server.MapPath("~/");

            foreach (var item in result)
            {
                if ((item.Extension == "doc" || item.Extension == "docx") && !File.Exists(mapPath + item.Code))
                {
                    if (File.Exists(mapPath + item.Path))
                    {
                        r2.Add(item);
                        convertWordToPDF(mapPath + item.Path, mapPath + item.Code);
                    }
                    else
                    {
                        item.Remark = "Ko file goc";
                        r2.Add(item);
                    }
                }
            }

            return(r2.AsQueryable());
        }
Exemplo n.º 3
0
        public DTO_APP_UserInfo GetUserInfo()
        {
            DTO_APP_UserInfo result = new DTO_APP_UserInfo();

            result.Id             = "";
            result.Roles          = new DTO_AppRole();
            result.Roles.CUSRoles = new List <int>();
            result.Roles.SYSRoles = new List <string>();
            result.Partners       = new List <DTO_Partner>();

            result.MenuItems = new List <DTO_APP_FormGroup>();


            if (User.Identity.IsAuthenticated)
            {
                ApplicationUser user = UserManager.FindById(User.Identity.GetUserId());
                if (user != null)
                {
                    result.Id          = user.Id;
                    result.UserName    = user.UserName;
                    result.Email       = user.Email;
                    result.PartnerID   = user.PartnerID;
                    result.StaffID     = user.StaffID;
                    result.FullName    = user.FullName;
                    result.PhoneNumber = user.PhoneNumber;
                    result.Avatar      = user.Avatar;


                    var CUSRoles = db.tbl_CUS_SYS_Role.Where(d => d.tbl_CUS_HRM_STAFF_NhanSu.Any(s => s.ID == user.StaffID));

                    foreach (var ro in CUSRoles)
                    {
                        result.Roles.CUSRoles.Add(ro.ID);
                    }

                    foreach (var ro in user.Roles)
                    {
                        result.Roles.SYSRoles.Add(ro.RoleId);
                    }
                }
            }

            //if (result.Roles.SYSRoles.Count == 0 && result.Roles.CUSRoles.Count == 0)
            //{
            //    result.Roles.SYSRoles.Add("GUEST");
            //}

            if (QueryStrings.Any(d => d.Key == "GetMenu"))
            {
                var qValue = QueryStrings.FirstOrDefault(d => d.Key == "GetMenu").Value;
                if (bool.TryParse(qValue, out bool qBoolValue))
                {
                    result.MenuItems = BS_SYS_Form.get_SYS_Form(db, PartnerID, result.Roles);

                    if (result.Roles.SYSRoles.Contains("HOST"))
                    {
                        var partners = BS_PAR_Partner.get_PAR_Partner(db, QueryStrings).Select(partner => new DTO_Partner()
                        {
                            ID = partner.ID, Code = partner.Code, Name = partner.Name, LogoURL = partner.LogoURL, Remark = partner.Remark, BannerURL = partner.BannerURL, TemplateHeader = partner.TemplateHeader, TemplateFooter = partner.TemplateFooter
                        });
                        result.Partners = partners.ToList();
                    }
                    else
                    {
                        var partner = BS_PAR_Partner.get_PAR_Partner(db, result.PartnerID);
                        if (partner != null)
                        {
                            result.Partners.Add(new DTO_Partner()
                            {
                                ID = partner.ID, Code = partner.Code, Name = partner.Name, LogoURL = partner.LogoURL, Remark = partner.Remark, BannerURL = partner.BannerURL, TemplateHeader = partner.TemplateHeader, TemplateFooter = partner.TemplateFooter
                            });
                        }
                    }
                }
            }

            //if (result.MenuItems == null)
            //    result.MenuItems = new List<DTO_APP_FormGroup>();

            if (User.Identity.IsAuthenticated)
            {
                if (result.MenuItems != null && result.MenuItems.Count > 0)
                {
                    result.MenuItems.Insert(0, new DTO_APP_FormGroup
                    {
                        ID       = 0,
                        AppID    = 0,
                        Code     = "Home",
                        AppName  = "Home",
                        FormMenu = new List <DTO_APP_Form>
                        {
                            new DTO_APP_Form
                            {
                                ID           = 0,
                                Code         = "page-default",
                                Name         = "Home",
                                IsHiddenMenu = true
                            }
                        },
                        Forms = new List <DTO_APP_Form>
                        {
                            new DTO_APP_Form
                            {
                                ID           = 0,
                                Code         = "page-default",
                                Name         = "Home",
                                IsHiddenMenu = true
                            }
                        }
                    });
                }
            }

            return(result);
        }