public async Task <ActionResult <ItemDTO> > NextItem([FromHeader(Name = "PPAuthorization")] string authToken, string sessionKey)
        {
            if (!SecurityFilter.RequestIsValid(authToken, sessionKey, this.userStateManager))
            {
                return(this.Unauthorized());
            }

            var session = await this.sessionRepository.FindByKeyAsync(sessionKey);

            if (session == null)
            {
                return(this.NotFound());
            }

            var nextItem = session.Items.FirstOrDefault(item => item.Rounds.Count == 0);

            // If there are no more items without any rounds, the session is complete
            // TODO: Generate summary when this happens
            if (nextItem == default(ItemDTO))
            {
                await this.summaryRepository.BuildSummary(session);

                return(this.BadRequest());
            }

            var newRound = this.sessionRepository.AddRoundToSessionItem(nextItem.Id);

            nextItem.Rounds.Add(newRound);
            return(nextItem);
        }
        public async Task <ActionResult <RoundDTO> > NextRound([FromHeader(Name = "PPAuthorization")] string authToken, string sessionKey)
        {
            if (!SecurityFilter.RequestIsValid(authToken, sessionKey, this.userStateManager))
            {
                return(this.Unauthorized());
            }

            var session = await this.sessionRepository.FindByKeyAsync(sessionKey);

            if (session == null)
            {
                return(this.NotFound());
            }

            var currentItem = SessionUtils.GetCurrentActiveItem(session.Items, session.Users.Count);

            if (!currentItem.HasValue)
            {
                return(this.BadRequest());
            }

            var newRound = this.sessionRepository.AddRoundToSessionItem(currentItem.ValueOrDefault().Id);

            return(newRound);
        }
Beispiel #3
0
        public ViewResult List(int?StaffId)
        {
            ViewBag.StaffId = StaffId;
            IQueryable <DayOffViewModel> q = DayOffRepository.GetAllvwDayOff().Where(x => x.StaffId == StaffId)
                                             .Select(item => new DayOffViewModel
            {
                Id            = item.Id,
                CreatedUserId = item.CreatedUserId,
                //CreatedUserName = item.CreatedUserName,
                CreatedDate    = item.CreatedDate,
                ModifiedUserId = item.ModifiedUserId,
                //ModifiedUserName = item.ModifiedUserName,
                ModifiedDate    = item.ModifiedDate,
                DayEnd          = item.DayEnd,
                DayStart        = item.DayStart,
                Quantity        = item.Quantity,
                QuantityNotUsed = item.QuantityNotUsed,
                StaffId         = item.StaffId,
                TypeDayOffId    = item.TypeDayOffId,
                NameSymbol      = item.NameSymbol,
                //Pay=item.Pay,
                TypeDayOffQuantity = item.TypeDayOffQuantity,
                Code       = item.Code,
                CodeStaff  = item.CodeStaff,
                CodeSymbol = item.CodeSymbol
            }).OrderByDescending(m => m.ModifiedDate);


            ViewBag.AccessRightCreate = SecurityFilter.AccessRight("Create", "DayOff", "Staff");
            return(View(q));
        }
Beispiel #4
0
        public ViewResult Index(int?StaffId)
        {
            ViewBag.StaffId = StaffId;
            IQueryable <TechniqueViewModel> q = TechniqueRepository.GetAllTechnique().Where(x => x.StaffId == StaffId)
                                                .Select(item => new TechniqueViewModel
            {
                Id            = item.Id,
                CreatedUserId = item.CreatedUserId,
                //CreatedUserName = item.CreatedUserName,
                CreatedDate    = item.CreatedDate,
                ModifiedUserId = item.ModifiedUserId,
                //ModifiedUserName = item.ModifiedUserName,
                ModifiedDate = item.ModifiedDate,
                Name         = item.Name,
                IdCardDate   = item.IdCardDate,
                IdCardIssued = item.IdCardIssued,
                Rank         = item.Rank,
                StaffId      = item.StaffId
            }).OrderByDescending(m => m.ModifiedDate);

            ViewBag.SuccessMessage    = TempData["SuccessMessage"];
            ViewBag.FailedMessage     = TempData["FailedMessage"];
            ViewBag.AlertMessage      = TempData["AlertMessage"];
            ViewBag.AccessRightCreate = SecurityFilter.AccessRight("Create", "Technique", "Staff");
            //ViewBag.AccessRightEdit = SecurityFilter.AccessRight("Edit", "Technique", "Staff");
            //ViewBag.AccessRightDelete = SecurityFilter.AccessRight("Delete", "Technique", "Staff");
            return(View(q));
        }
        public ActionResult DetailList(int?staffId)
        {
            ViewBag.AccessRightCreate = SecurityFilter.AccessRight("Create", "StaffFamily", "Staff");
            if (staffId != null)
            {
                ViewBag.Staff = staffsRepository.GetvwStaffsById(staffId.Value);

                IEnumerable <StaffFamilyViewModel> q = StaffFamilyRepository.GetAllStaffFamily().Where(x => x.StaffId == staffId)
                                                       .Select(item => new StaffFamilyViewModel
                {
                    Id             = item.Id,
                    CreatedUserId  = item.CreatedUserId,
                    CreatedDate    = item.CreatedDate,
                    ModifiedUserId = item.ModifiedUserId,
                    ModifiedDate   = item.ModifiedDate,
                    Name           = item.Name,
                    StaffId        = item.StaffId,
                    Address        = item.Address,
                    Birthday       = item.Birthday,
                    Correlative    = item.Correlative,
                    Gender         = item.Gender,
                    Phone          = item.Phone,
                    IsDependencies = item.IsDependencies
                }).OrderByDescending(m => m.ModifiedDate).ToList();

                return(View(q));
            }
            return(View());
        }
Beispiel #6
0
        public void RequestIsValid_given_null_token_returns_false()
        {
            var cache        = new MemoryCache(new MemoryCacheOptions());
            var stateManager = new UserStateManager(cache);

            Assert.False(SecurityFilter.RequestIsValid(null, null, stateManager));
        }
        public ViewResult Index(int?StaffId)
        {
            ViewBag.StaffId = StaffId;
            IQueryable <StaffFamilyViewModel> q = StaffFamilyRepository.GetAllStaffFamily().Where(x => x.StaffId == StaffId)
                                                  .Select(item => new StaffFamilyViewModel
            {
                Id            = item.Id,
                CreatedUserId = item.CreatedUserId,
                //CreatedUserName = item.CreatedUserName,
                CreatedDate    = item.CreatedDate,
                ModifiedUserId = item.ModifiedUserId,
                //ModifiedUserName = item.ModifiedUserName,
                ModifiedDate   = item.ModifiedDate,
                Name           = item.Name,
                StaffId        = item.StaffId,
                Address        = item.Address,
                Birthday       = item.Birthday,
                Correlative    = item.Correlative,
                Gender         = item.Gender,
                Phone          = item.Phone,
                IsDependencies = item.IsDependencies
            }).OrderByDescending(m => m.ModifiedDate);

            ViewBag.SuccessMessage    = TempData["SuccessMessage"];
            ViewBag.FailedMessage     = TempData["FailedMessage"];
            ViewBag.AlertMessage      = TempData["AlertMessage"];
            ViewBag.AccessRightCreate = SecurityFilter.AccessRight("Create", "StaffFamily", "Staff");
            //ViewBag.AccessRightEdit = SecurityFilter.AccessRight("Edit", "Technique", "Staff");
            //ViewBag.AccessRightDelete = SecurityFilter.AccessRight("Delete", "Technique", "Staff");
            return(View(q));
        }
Beispiel #8
0
        public void RequestIsValid_given_invalid_token_returns_true()
        {
            var cache        = new MemoryCache(new MemoryCacheOptions());
            var stateManager = new UserStateManager(cache);

            Assert.False(SecurityFilter.RequestIsValid("invalidtoken123123", "ABC1234", stateManager));
        }
Beispiel #9
0
        public void RequestIsValid_given_valid_token_returns_true()
        {
            var cache        = new MemoryCache(new MemoryCacheOptions());
            var stateManager = new UserStateManager(cache);

            var token = stateManager.CreateState(1, "ABC1234");

            Assert.True(SecurityFilter.RequestIsValid(token, "ABC1234", stateManager));
        }
        public ActionResult <UserState> WhoAmI([FromHeader(Name = "PPAuthorization")] string authToken, string sessionKey)
        {
            if (!SecurityFilter.RequestIsValid(authToken, sessionKey, this.userStateManager))
            {
                return(this.Unauthorized());
            }

            var state = this.userStateManager.GetState(authToken.Replace("Bearer ", string.Empty));

            return(state.ValueOrDefault());
        }
        public async Task <ActionResult <SessionDTO> > GetByKey([FromHeader(Name = "PPAuthorization")] string authToken, string sessionKey)
        {
            if (!SecurityFilter.RequestIsValid(authToken, sessionKey, this.userStateManager))
            {
                return(this.Unauthorized());
            }

            var session = await this.sessionRepository.FindByKeyAsync(sessionKey);

            if (session == null)
            {
                return(this.NotFound());
            }

            return(session);
        }
Beispiel #12
0
        public ActionResult Index(string txtSearch, int?WarehouseId, int?BranchId)
        {
            IQueryable <PhysicalInventoryViewModel> list = PhysicalInventoryRepository.GetAllvwPhysicalInventory()
                                                           .Where(x => x.Type == PhysicalInventoryType.Product)
                                                           .Select(item => new PhysicalInventoryViewModel
            {
                Id                  = item.Id,
                IsDeleted           = item.IsDeleted,
                Code                = item.Code,
                CreatedDate         = item.CreatedDate,
                ModifiedDate        = item.ModifiedDate,
                Note                = item.Note,
                WarehouseId         = item.WarehouseId,
                WarehouseName       = item.WarehouseName,
                IsExchange          = item.IsExchange,
                CancelReason        = item.CancelReason,
                CreatedUserName     = item.CreatedUserName,
                ProductInboundCode  = item.ProductInboundCode,
                ProductOutboundCode = item.ProductOutboundCode,
                BranchId            = item.BranchId,
                BranchName          = item.BranchName,
            }).OrderByDescending(x => x.CreatedDate);

            if (!SecurityFilter.IsAdmin())
            {
                list = list.Where(x => x.BranchId == Helpers.Common.CurrentUser.BranchId);
            }
            else
            {
                if (BranchId != null)
                {
                    list = list.Where(x => x.BranchId == BranchId);
                }
            }

            if (!string.IsNullOrEmpty(txtSearch))
            {
                txtSearch = txtSearch.ToLower();
                list      = list.Where(x => x.Code.ToLower().Contains(txtSearch));
            }
            if (WarehouseId != null)
            {
                list = list.Where(x => x.WarehouseId == WarehouseId);
            }

            return(View(list));
        }
Beispiel #13
0
        public override void Start()
        {
            IEnumerable <SecurityRule> securityRules = SecurityRules;

            if (Iterables.count(securityRules) > 0)
            {
                _mountedFilter = new SecurityFilter(securityRules);

                _webServer.addFilter(_mountedFilter, "/*");

                foreach (SecurityRule rule in securityRules)
                {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method:
                    _log.info("Security rule [%s] installed on server", rule.GetType().FullName);
                }
            }
        }
        public ViewResult Index(int?StaffId)
        {
            ViewBag.StaffId = StaffId;
            IEnumerable <WorkingProcessViewModel> q = WorkingProcessRepository.GetAllWorkingProcess().Where(x => x.StaffId == StaffId)
                                                      .Select(item => new WorkingProcessViewModel
            {
                Id            = item.Id,
                CreatedUserId = item.CreatedUserId,
                //CreatedUserName = item.CreatedUserName,
                CreatedDate    = item.CreatedDate,
                ModifiedUserId = item.ModifiedUserId,
                //ModifiedUserName = item.ModifiedUserName,
                ModifiedDate      = item.ModifiedDate,
                Name              = item.Name,
                DayEnd            = item.DayEnd,
                DayStart          = item.DayStart,
                BonusDisciplineId = item.BonusDisciplineId,
                Email             = item.Email,
                Phone             = item.Phone,
                Position          = item.Position,
                StaffId           = item.StaffId,
                WorkPlace         = item.WorkPlace
            }).OrderByDescending(m => m.ModifiedDate).ToList();

            foreach (var item in q)
            {
                if (item.BonusDisciplineId > 0)
                {
                    var code = bonusDesciplineRepository.GetBonusDisciplineById(item.BonusDisciplineId.Value);
                    if (code != null)
                    {
                        item.BonusDiscipline = code.Code;
                    }
                    else
                    {
                        item.BonusDiscipline = "Đã xóa";
                    }
                }
                else
                {
                    item.BonusDiscipline = "Chưa có";
                }
            }
            ViewBag.AccessRightCreate = SecurityFilter.AccessRight("Create", "WorkingProcess", "Staff");
            return(View(q));
        }
        public ViewResult Index(string BranchId)
        {
            //if (BranchId != null && BranchId.Value > 0)
            //{
            //    ViewBag.BoolOffice = branchRepository.GetBranchById(BranchId.Value).IsOfficeOfAcademicAffairs;
            //}
            var list = staffRepository.GetvwAllStaffs().Where(x => ("," + BranchId + ",").Contains("," + x.DrugStore + ",") == true);
            IEnumerable <StaffsViewModel> q = list.Select(item => new StaffsViewModel
            {
                Id             = item.Id,
                CreatedUserId  = item.CreatedUserId,
                CreatedDate    = item.CreatedDate,
                ModifiedUserId = item.ModifiedUserId,
                ModifiedDate   = item.ModifiedDate,
                Phone          = item.Phone,
                Email          = item.Email,
                //BranchCode = item.BranchCode,
                //BranchName = item.BranchName,
                //Sale_BranchId = item.Sale_BranchId,
                Birthday     = item.Birthday,
                Code         = item.Code,
                Name         = item.Name,
                PositionId   = item.PositionId,
                PositionName = item.PositionName,
                PositionCode = item.PositionCode
            }).ToList();

            //var position = CategoryRepository.GetAllCategories().Where(x => x.Code == "position");
            //foreach (var item in q)
            //{
            //    if (!string.IsNullOrEmpty(item.Position))
            //    {
            //        item.PositionName = position.Where(x => x.Value == item.PositionId).FirstOrDefault().Name;
            //    }
            //}
            ViewBag.AccessRightCreate = SecurityFilter.AccessRight("Create", "Staffs", "Staff");
            ViewBag.AccessRightEdit   = SecurityFilter.AccessRight("Edit", "Staffs", "Staff");
            ViewBag.AccessRightDelete = SecurityFilter.AccessRight("Delete", "Staffs", "Staff");

            ViewBag.AlertMessage = TempData["AlertMessage"];
            ViewBag.BranchId     = BranchId;
            //ViewBag.SchoolId = SchoolId;
            return(View(q));
        }
Beispiel #16
0
        public ViewResult List(int?StaffId)
        {
            ViewBag.StaffId = StaffId;
            IQueryable <BonusDisciplineViewModel> q = BonusDisciplineRepository.GetAllvwBonusDiscipline().Where(x => x.StaffId == StaffId)
                                                      .Select(item => new BonusDisciplineViewModel
            {
                Id              = item.Id,
                CreatedUserId   = item.CreatedUserId,
                CreatedUserName = item.CreatedUserName,
                CreatedDate     = item.CreatedDate,
                ModifiedUserId  = item.ModifiedUserId,
                //ModifiedUserName = item.ModifiedUserName,
                ModifiedDate       = item.ModifiedDate,
                Category           = item.Category,
                DayDecision        = item.DayDecision,
                DayEffective       = item.DayEffective,
                Formality          = item.Formality,
                Note               = item.Note,
                PlaceDecisions     = item.PlaceDecisions,
                Reason             = item.Reason,
                StaffId            = item.StaffId,
                Code               = item.Code,
                BranchDepartmentId = item.BranchDepartmentId,
                BranchName         = item.BranchName,
                CodeName           = item.CodeName,
                Name               = item.Name,
                Position           = item.Position,
                Sale_BranchId      = item.Sale_BranchId,
                Staff_DepartmentId = item.Staff_DepartmentId,
                Gender             = item.Gender,
                ProfileImage       = item.ProfileImage,
                StaffCode          = item.StaffCode,
                Birthday           = item.Birthday,
                PlaceDecisionsName = item.PlaceDecisionsName
            }).OrderByDescending(m => m.ModifiedDate);

            ViewBag.AccessRightCreate = SecurityFilter.AccessRight("Create", "BonusDiscipline", "Staff");
            return(View(q));
        }
        public async Task <ActionResult> Vote([FromHeader(Name = "PPAuthorization")] string authToken, string sessionKey, [FromBody] VoteCreateUpdateDTO vote)
        {
            if (!SecurityFilter.RequestIsValid(authToken, sessionKey, this.userStateManager))
            {
                return(this.Unauthorized());
            }

            var session = await this.sessionRepository.FindByKeyAsync(sessionKey);

            if (session == null)
            {
                return(this.StatusCode(404, "Session not found"));
            }

            var currentItem = SessionUtils.GetCurrentActiveItem(session.Items, session.Users.Count);

            if (!currentItem.HasValue)
            {
                return(this.StatusCode(404, "Active Item not found"));
            }

            var currentRound = SessionUtils.GetCurrentActiveRound(currentItem.ValueOrDefault().Rounds.ToList(), session.Users.Count);

            if (!currentRound.HasValue)
            {
                return(this.StatusCode(404, "Active Round not found"));
            }

            var userState = this.userStateManager.GetState(authToken.Replace("Bearer ", string.Empty)).ValueOrDefault();

            this.sessionRepository.AddVoteToRound(
                new VoteCreateUpdateDTO {
                Estimate = vote.Estimate, UserId = userState.Id
            },
                currentRound.ValueOrDefault().Id);

            return(this.Ok());
        }
Beispiel #18
0
        public ViewResult Index(int?StaffId)
        {
            ViewBag.StaffId = StaffId;
            IQueryable <BankViewModel> q = BankRepository.GetAllBank().Where(x => x.StaffId == StaffId)
                                           .Select(item => new BankViewModel
            {
                Id            = item.Id,
                CreatedUserId = item.CreatedUserId,
                //CreatedUserName = item.CreatedUserName,
                CreatedDate    = item.CreatedDate,
                ModifiedUserId = item.ModifiedUserId,
                //ModifiedUserName = item.ModifiedUserName,
                ModifiedDate = item.ModifiedDate,
                Name         = item.Name,
                NameBank     = item.NameBank,
                BranchName   = item.BranchName,
                CodeBank     = item.CodeBank,
                StaffId      = item.StaffId
            }).OrderByDescending(m => m.ModifiedDate);

            ViewBag.AccessRightCreate = SecurityFilter.AccessRight("Create", "Bank", "Staff");
            return(View(q));
        }
Beispiel #19
0
        public ViewResult Index(int?StaffId)
        {
            ViewBag.StaffId = StaffId;
            IQueryable <ProcessPayViewModel> q = ProcessPayRepository.GetAllProcessPay().Where(x => x.StaffId == StaffId)
                                                 .Select(item => new ProcessPayViewModel
            {
                Id            = item.Id,
                CreatedUserId = item.CreatedUserId,
                //CreatedUserName = item.CreatedUserName,
                CreatedDate    = item.CreatedDate,
                ModifiedUserId = item.ModifiedUserId,
                //ModifiedUserName = item.ModifiedUserName,
                ModifiedDate = item.ModifiedDate,
                DayDecision  = item.DayDecision,
                DayEffective = item.DayEffective,
                StaffId      = item.StaffId,
                CodePay      = item.CodePay,
                BasicPay     = item.BasicPay
            }).OrderByDescending(m => m.ModifiedDate);

            ViewBag.AccessRightCreate = SecurityFilter.AccessRight("Create", "ProcessPay", "Staff");
            return(View(q));
        }
        public ViewResult Index(int?BranchId, string txtCode, string txtCusName, string startDate, string endDate)
        {
            IEnumerable <RePayPointsViewModel> q = vwRePayPointsService.Get()
                                                   .Select(item => new RePayPointsViewModel
            {
                Id                  = item.Id,
                IsDeleted           = item.IsDeleted,
                CreatedUserId       = item.CreatedUserId,
                CreatedDate         = item.CreatedDate,
                ModifiedUserId      = item.ModifiedUserId,
                ModifiedDate        = item.ModifiedDate,
                Code                = item.Code,
                Status              = item.Status,
                IsArchive           = item.IsArchive,
                CustomerId          = item.CustomerId,
                CustomerName        = item.CustomerName,
                BranchId            = item.BranchId,
                BranchName          = item.BranchName,
                Note                = item.Note,
                SaleName            = item.SaleName,
                CancelReason        = item.CancelReason,
                AvailabilityPoint   = item.AvailabilityPoint,
                TotalPoint          = item.TotalPoint,
                WarehouseSourceName = item.WarehouseSourceName
            }).OrderByDescending(m => m.ModifiedDate);

            if (!SecurityFilter.IsAdmin())
            {
                q = q.Where(x => x.BranchId == Helpers.Common.CurrentUser.BranchId);
            }
            else
            {
                if (BranchId != null)
                {
                    q = q.Where(x => x.BranchId == BranchId);
                }
            }
            //Lọc theo ngày
            DateTime d_startDate, d_endDate;

            if (DateTime.TryParseExact(startDate, "dd/MM/yyyy", new CultureInfo("vi-VN"), DateTimeStyles.None, out d_startDate))
            {
                if (DateTime.TryParseExact(endDate, "dd/MM/yyyy", new CultureInfo("vi-VN"), DateTimeStyles.None, out d_endDate))
                {
                    d_endDate = d_endDate.AddHours(23).AddMinutes(59);
                    q         = q.Where(x => x.CreatedDate >= d_startDate && x.CreatedDate <= d_endDate);
                }
            }
            if (!string.IsNullOrEmpty(txtCode))
            {
                q = q.Where(x => x.Code == txtCode);
            }
            if (!string.IsNullOrEmpty(txtCusName))
            {
                q = q.Where(x => x.CustomerName.Contains(txtCusName));
            }

            ViewBag.SuccessMessage = TempData["SuccessMessage"];
            ViewBag.FailedMessage  = TempData["FailedMessage"];
            ViewBag.AlertMessage   = TempData["AlertMessage"];
            return(View(q));
        }
        private void CmdUpdateClick(object sender, EventArgs e)
        {
            try
            {
                this.txtMessage.Text = string.Empty;
                bool error = false;

                // create a relationship
                var irel = new ItemRelationship
                {
                    RelationshipTypeId = RelationshipType.ItemToParentCategory.GetId()
                };
                int[] ids = this.parentCategoryRelationships.GetSelectedItemIds();

                // check for parent category, if none then add a relationship for Top Level Item
                if (ids.Length == 0)
                {
                    // add relationship to TLC
                    irel.RelationshipTypeId = RelationshipType.CategoryToTopLevelCategory.GetId();
                    irel.ParentItemId       = TopLevelCategoryItemType.Category.GetId();
                    this.VersionInfoObject.Relationships.Add(irel);
                }
                else
                {
                    irel.ParentItemId = ids[0];
                    this.VersionInfoObject.Relationships.Add(irel);
                }

                // check for parent category, if none then add a relationship for Top Level Item
                // foreach (int i in this.irRelated.GetSelectedItemIds())
                // {
                // ItemRelationship irco = ItemRelationship.Create();
                // irco.RelationshipTypeId = RelationshipType.ItemToRelatedCategory.GetId();
                // irco.ParentItemId = i;
                // VersionInfoObject.Relationships.Add(irco);
                // }
                if (this.itemEditControl.IsValid == false)
                {
                    error = true;
                    this.txtMessage.Text += this.itemEditControl.ErrorMessage;
                }

                if (Convert.ToInt32(this.ddlDisplayTabId.SelectedValue, CultureInfo.InvariantCulture) < -1)
                {
                    error = true;

                    this.txtMessage.Text += Localization.GetString("ChooseAPage", this.LocalResourceFile);
                }

                if (Convert.ToInt32(this.ddlChildDisplayTabId.SelectedValue, CultureInfo.InvariantCulture) == -1)
                {
                    error = true;
                    this.txtMessage.Text += Localization.GetString("ChooseChildPage", this.LocalResourceFile);
                }

                if (!this.itemApprovalStatus.IsValid)
                {
                    this.txtMessage.Text += Localization.GetString("ChooseApprovalStatus", this.LocalResourceFile);
                }

                if (error)
                {
                    this.txtMessage.Visible = true;
                    return;
                }

                this.VersionInfoObject.Description = this.itemEditControl.DescriptionText;

                // auto populate the meta description if it's not populated already
                if (!Engage.Utility.HasValue(this.VersionInfoObject.MetaDescription))
                {
                    string description = HtmlUtils.StripTags(this.VersionInfoObject.Description, false);
                    this.VersionInfoObject.MetaDescription = Utility.TrimDescription(399, description);
                }

                if (this.VersionInfoObject.IsNew)
                {
                    this.VersionInfoObject.ModuleId = this.ModuleId;
                }

                int sortCount = 0;

                foreach (int i in this.featuredArticlesRelationships.GetSelectedItemIds())
                {
                    var irArticleso = new ItemRelationship
                    {
                        RelationshipTypeId = RelationshipType.ItemToFeaturedItem.GetId(),
                        ParentItemId       = i
                    };

                    if (
                        Engage.Utility.HasValue(this.featuredArticlesRelationships.GetAdditionalSetting("startDate", i.ToString(CultureInfo.InvariantCulture))))
                    {
                        irArticleso.StartDate = this.featuredArticlesRelationships.GetAdditionalSetting(
                            "startDate", i.ToString(CultureInfo.InvariantCulture));
                    }

                    if (Engage.Utility.HasValue(this.featuredArticlesRelationships.GetAdditionalSetting("endDate", i.ToString(CultureInfo.InvariantCulture))))
                    {
                        irArticleso.EndDate = this.featuredArticlesRelationships.GetAdditionalSetting(
                            "endDate", i.ToString(CultureInfo.InvariantCulture));
                    }

                    irArticleso.SortOrder = sortCount;

                    sortCount++;
                    this.VersionInfoObject.Relationships.Add(irArticleso);
                }

                this.SaveSettings();

                // approval status
                if (this.chkUseApprovals.Checked && this.UseApprovals)
                {
                    this.VersionInfoObject.ApprovalStatusId = this.itemApprovalStatus.ApprovalStatusId;
                }
                else
                {
                    this.VersionInfoObject.ApprovalStatusId = ApprovalStatus.Approved.GetId();
                }

                this.VersionInfoObject.Save(this.UserId);

                if (SecurityFilter.IsSecurityEnabled(this.PortalId))
                {
                    this.categoryPermissions.CategoryId = this.VersionInfoObject.ItemId;
                    this.categoryPermissions.Save();
                }

                if (this.chkResetChildDisplayTabs.Checked)
                {
                    ((Category)this.VersionInfoObject).CascadeChildDisplayTab(this.UserId);
                }

                string returnUrl = this.Server.UrlDecode(this.Request.QueryString["returnUrl"]);
                if (!Engage.Utility.HasValue(returnUrl))
                {
                    this.Response.Redirect(
                        Globals.NavigateURL(
                            this.TabId,
                            string.Empty,
                            string.Empty,
                            "ctl=" + Utility.AdminContainer,
                            "mid=" + this.ModuleId,
                            "adminType=itemCreated",
                            "itemId=" + this.VersionInfoObject.ItemId),
                        true);
                }
                else
                {
                    this.Response.Redirect(returnUrl);
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        private void LoadControlType()
        {
            this.UseCache = false;
            if (this.ItemVersionId == -1)
            {
                this.BindItemData(true);
            }
            else
            {
                this.BindItemData();
            }

            // Item Edit
            this.itemEditControl = (ItemEdit)this.LoadControl(ItemControlToLoad);
            this.itemEditControl.ModuleConfiguration = this.ModuleConfiguration;
            this.itemEditControl.ID = Path.GetFileNameWithoutExtension(ItemControlToLoad);
            this.itemEditControl.VersionInfoObject = this.VersionInfoObject;
            this.phItemEdit.Controls.Add(this.itemEditControl);

            if (SecurityFilter.IsSecurityEnabled(this.PortalId))
            {
                this.trCategoryPermissions.Visible = true;

                this.categoryPermissions                     = (CategoryPermissions)this.LoadControl("../CategoryControls/CategoryPermissions.ascx");
                this.categoryPermissions.CategoryId          = this.VersionInfoObject.ItemId;
                this.categoryPermissions.ModuleConfiguration = this.ModuleConfiguration;
                this.phCategoryPermissions.Controls.Add(this.categoryPermissions);
            }

            // Parent Category
            this.parentCategoryRelationships = (ItemRelationships)this.LoadControl("../controls/ItemRelationships.ascx");
            this.parentCategoryRelationships.ExcludeCircularRelationships = true;
            this.parentCategoryRelationships.ModuleConfiguration          = this.ModuleConfiguration;
            this.parentCategoryRelationships.LocalResourceFile            = this.ItemRelationshipResourceFile;
            this.parentCategoryRelationships.VersionInfoObject            = this.VersionInfoObject;
            this.parentCategoryRelationships.ListRelationshipTypeId       = RelationshipType.ItemToParentCategory.GetId();
            this.parentCategoryRelationships.CreateRelationshipTypeId     = RelationshipType.ItemToParentCategory.GetId();
            this.parentCategoryRelationships.AvailableSelectionMode       = ListSelectionMode.Single;
            this.parentCategoryRelationships.FlatView   = true;
            this.parentCategoryRelationships.ItemTypeId = ItemType.Category.GetId();
            this.phParentCategory.Controls.Add(this.parentCategoryRelationships);

            // Related Categories
            // this.irRelated = (ItemRelationships)LoadControl("../controls/ItemRelationships.ascx");
            // this.irRelated.ModuleConfiguration = ModuleConfiguration;
            // this.irRelated.LocalResourceFile = ItemRelationshipResourceFile;
            // this.irRelated.VersionInfoObject = VersionInfoObject;
            // this.irRelated.ListRelationshipTypeId = RelationshipType.ItemToRelatedCategory.GetId();
            // this.irRelated.CreateRelationshipTypeId = RelationshipType.ItemToRelatedCategory.GetId();
            // this.irRelated.AvailableSelectionMode = ListSelectionMode.Multiple;
            // this.irRelated.FlatView = true;
            // this.irRelated.ItemTypeId = ItemType.Category.GetId();
            // this.phParentCategory.Controls.Add(this.irRelated);

            // Featured Articles
            this.featuredArticlesRelationships = (ItemRelationships)this.LoadControl("../controls/ItemRelationships.ascx");
            this.featuredArticlesRelationships.ModuleConfiguration      = this.ModuleConfiguration;
            this.featuredArticlesRelationships.VersionInfoObject        = this.VersionInfoObject;
            this.featuredArticlesRelationships.LocalResourceFile        = this.ItemRelationshipResourceFile;
            this.featuredArticlesRelationships.ListRelationshipTypeId   = RelationshipType.ItemToParentCategory.GetId();
            this.featuredArticlesRelationships.CreateRelationshipTypeId = RelationshipType.ItemToFeaturedItem.GetId();
            this.featuredArticlesRelationships.AvailableSelectionMode   = ListSelectionMode.Multiple;
            this.featuredArticlesRelationships.FlatView        = true;
            this.featuredArticlesRelationships.EnableDates     = true;
            this.featuredArticlesRelationships.AllowSearch     = true;
            this.featuredArticlesRelationships.EnableSortOrder = true;
            this.featuredArticlesRelationships.ItemTypeId      = ItemType.Article.GetId();
            this.phFeaturedArticles.Controls.Add(this.featuredArticlesRelationships);

            // load approval status
            this.itemApprovalStatus = (ItemApproval)this.LoadControl(ApprovalControlToLoad);
            this.itemApprovalStatus.ModuleConfiguration = this.ModuleConfiguration;
            this.itemApprovalStatus.ID = Path.GetFileNameWithoutExtension(ApprovalControlToLoad);
            this.itemApprovalStatus.VersionInfoObject = this.VersionInfoObject;
            this.phApproval.Controls.Add(this.itemApprovalStatus);
        }
Beispiel #23
0
 public override string WwwAuthenticateHeader()
 {
     return(SecurityFilter.BasicAuthenticationResponse(REALM));
 }
Beispiel #24
0
        public ActionResult Diagrams()
        {
            var list      = BranchRepository.GetAllBranch();
            var liststaff = staffRepository.GetAllStaffs().ToList();

            IEnumerable <BranchViewModel> q = list.Where(x => x.ParentId == null).Select(item => new BranchViewModel
            {
                Id = item.Id,
                //CreatedUserId = item.CreatedUserId,
                //CreatedDate = item.CreatedDate,
                //ModifiedUserId = item.ModifiedUserId,
                //ModifiedDate = item.ModifiedDate,
                Name = item.Name,
                Code = item.Code,
                //Address = item.Address,
                //WardId = item.WardId,
                //DistrictId = item.DistrictId,
                //CityId = item.CityId,
                //Phone = item.Phone,
                //Email = item.Email,
                Type     = item.Type,
                ParentId = item.ParentId,
                //MaxDebitAmount=item.MaxDebitAmount
            }).ToList();

            foreach (var item in q)
            {
                item.TotalDepartment = list.Where(x => x.ParentId == item.Id).Count();
                //item.TotalStaff = staffRepository.GetvwAllStaffs().Where(x => x.Sale_BranchId == item.Id).Count();
            }
            ViewBag.AccessRightCreate = SecurityFilter.AccessRight("Create", "Branch", "Staff");
            ViewBag.AccessRightEdit   = SecurityFilter.AccessRight("Edit", "Branch", "Staff");
            ViewBag.AccessRightDelete = SecurityFilter.AccessRight("Delete", "Branch", "Staff");
            ViewBag.AlertMessage      = TempData["AlertMessage"];

            //var branchDepartment = branchDepartmentRepository.GetAllBranchDepartment().ToList();

            var CongTy = settingRepository.GetAlls()
                         .Where(item => item.Code == "settingprint" && item.Key == "companyName")
                         .OrderBy(item => item.Note).ToList();

            if (CongTy.Count() > 0)
            {
                TreeNode Node = new TreeNode("");
                var      _a   = new BranchViewModel()
                {
                    Name = CongTy.Where(x => x.Key == "companyName").FirstOrDefault().Value,
                    Id   = -1
                };

                TreeNode _node = new TreeNode(_a.Name);
                _node.Id        = _a.Id;
                _node.TableName = typeof(TreeNode).Name;
                _node.GuidId    = Guid.NewGuid().ToString();
                _node.ParentId  = null;

                //FormatNode(_node, q.OrderBy(n => n.ParentId), q.Where(n => n.ParentId == null).OrderBy(n => n.IsOfficeOfAcademicAffairs), liststaff);
                //Chi nhánh
                foreach (var branch in q)
                {
                    TreeNode _node_chinhanh = new TreeNode(branch.Name);
                    _node_chinhanh.Id        = branch.Id;
                    _node_chinhanh.TableName = typeof(BranchViewModel).Name;
                    _node_chinhanh.GuidId    = Guid.NewGuid().ToString();
                    _node_chinhanh.TypeName  = "Branch";
                    _node_chinhanh.ParentId  = _node.Id;

                    //Thêm phòng ban
                    var deparmentByBranchs = list.Where(n => n.ParentId != null && n.ParentId == branch.Id).ToList();
                    if (deparmentByBranchs != null && deparmentByBranchs.Count() > 0)
                    {
                        foreach (var branchDeparment in deparmentByBranchs)
                        {
                            TreeNode _node_phongban = new TreeNode(branchDeparment.Name);
                            _node_phongban.Id        = branchDeparment.Id;
                            _node_phongban.TableName = typeof(BranchViewModel).Name;
                            _node_phongban.GuidId    = Guid.NewGuid().ToString();
                            _node_phongban.ParentId  = branch.Id;
                            _node_phongban.TypeName  = "DrugStore";
                            _node_chinhanh.ChildNode.Add(_node_phongban);
                        }
                    }

                    _node.ChildNode.Add(_node_chinhanh);
                }

                //Phòng ban (Nhân viên)
                Node.ChildNode.Add(_node);
                ViewBag.TreeNode = Node;
            }
            else
            {
                ViewBag.FailedMessage = "Chưa có thông tin khởi tạo của Công ty";
            }

            return(View(q));
        }