public string RenderGridUserGroup()
        {
            //variables
            UserGroupList model;
            UserInfo      usInfo = System.Web.HttpContext.Current.Session["UserInfo"] as UserInfo;

            #region Definite column
            model        = new UserGroupList();
            model.column = new List <ColumnRoleModel>();
            //ColumnRoleModel colID = new ColumnRoleModel() { title = "ID", field = "ID", template = "<div style='text-align:center;width:100%;'>#=ID#</div>" }; model.column.Add(colID);
            ColumnRoleModel colTenant = new ColumnRoleModel()
            {
                title = "Tenant", field = "TenantName", hidden = true
            }; model.column.Add(colTenant);
            ColumnRoleModel colName = new ColumnRoleModel()
            {
                title = "Name", field = "RoleName"
            }; model.column.Add(colName);
            ColumnRoleModel colDescription = new ColumnRoleModel()
            {
                title = "Description", field = "Description"
            }; model.column.Add(colDescription);
            ColumnRoleModel colActive = new ColumnRoleModel()
            {
                title = "Action", field = "Active", template = "<div style='text-align:center'><input class='multi' type='checkbox' disabled='disabled' #= Active ? checked='checked' : '' # /><span class='lbl'></span></div>"
            }; model.column.Add(colActive);
            model.total = _roleService.GetAllRoles(usInfo.IsTenant, false, usInfo.TenanID).Count();
            var _lst = _roleService.GetAllRoles(usInfo.IsTenant, false, usInfo.TenanID).Count();
            #endregion

            return(JsonConvert.SerializeObject(model));
        }
示例#2
0
        public string RenderGridUserGroup()
        {
            //variables
            CustomerList model;
            UserInfo     usInfo = System.Web.HttpContext.Current.Session["UserInfo"] as UserInfo;

            #region Definite column
            model        = new CustomerList();
            model.column = new List <ColumnRoleModel>();

            ColumnRoleModel colCustomerName = new ColumnRoleModel()
            {
                title = "Name", field = "CustomerName", template = "#=CustomerName#"
            }; model.column.Add(colCustomerName);
            ColumnRoleModel colName = new ColumnRoleModel()
            {
                title = "Contact information", field = "", template = "<div>#=FullName# | #=Email# | #=MobilePhone#</div>"
            }; model.column.Add(colName);
            ColumnRoleModel colLogo = new ColumnRoleModel()
            {
                title = "Logo", field = "CustomerLogo", template = "<div style='text-align:center'><img src='#=CustomerLogo#' width='48px' height='48px' /></div>"
            }; model.column.Add(colLogo);
            ColumnRoleModel colOrgNumber = new ColumnRoleModel()
            {
                title = "OrgNumber", field = "OrgNumber"
            }; model.column.Add(colOrgNumber);
            ColumnRoleModel colCreatedDate = new ColumnRoleModel()
            {
                title = "CreatedDate", field = "CreatedDate", template = "#=kendo.toString(new Date(CreatedDate),'yyyy.MM.dd')#"
            }; model.column.Add(colCreatedDate);

            //model.total = _roleService.GetAllRoles(usInfo.IsTenant, false, usInfo.TenanID).Count();
            //var _lst = _roleService.GetAllRoles(usInfo.IsTenant, false, usInfo.TenanID).Count();
            #endregion

            return(JsonConvert.SerializeObject(model));
        }
示例#3
0
        public string RenderGridRole()
        {
            #region Variables
            List <crm_Roles>       listRole     = new List <crm_Roles>();
            List <ColumnRoleModel> listColModel = new List <ColumnRoleModel>();
            BitMaskOfUser          listBitMask  = new BitMaskOfUser()
            {
                View = new List <bool>(), Add = new List <bool>(), Edit = new List <bool>(), Delete = new List <bool>(), NumberOfBitMask = new List <int>()
            };
            //Json string to define row data
            string strRowRecord = "\"row\":[";
            //Json string to define column data
            string strColRecord = "\"column\":";
            //Json string to combine 2 json above
            string strJSON  = "{";
            string bitmask  = "";
            string selected = "";
            //Set temp id
            int userLoginID = 3;
            List <RoleUserModel> LoggedInUserRole;
            int      bitMaskUser  = 0;
            bool     disabledGrid = false;
            bool     hideColumn   = false;
            UserInfo userInfo;
            #endregion

            try
            {
                userInfo    = System.Web.HttpContext.Current.Session["UserInfo"] as UserInfo;
                userLoginID = userInfo.ID;
                //Get max permission of current user
                int maxPerm = userInfo.BitMask.Max();
                switch (maxPerm)
                {
                case (int)UserGroupEnum.TenantAdmin: listRole = _roleService.GetAccessRight(true, maxPerm, userInfo.TenanID).ToList(); break;

                default: listRole = _roleService.GetAccessRight(false, maxPerm, 0).ToList(); break;
                }
                //Check bitmask user to hide or disable edit permision
                LoggedInUserRole = _roleService.GetUserGroupRoles(userLoginID).ToList();
                foreach (RoleUserModel item in LoggedInUserRole)
                {
                    long maskPerm = item.MaskPermission.HasValue ? item.MaskPermission.Value : 0;
                    int  temp     = GlobalFunctions.GetBitMaskOfUser(maskPerm);
                    if (bitMaskUser < temp)
                    {
                        bitMaskUser = temp;
                    }
                }

                //Check authorization to view information

                /*if (userInfo.IsTenant && !userInfo.IsSA && !userInfo.IsOperator )
                 *  hideColumn = true;
                 * else */
                //if (bitMaskUser == (int)UserGroupEnum.Operator)
                //    disabledGrid = true;

                //if user group has data
                if (listRole.Count > 0)
                {
                    #region Column
                    //first column in data grid
                    ColumnRoleModel firstCol = new ColumnRoleModel()
                    {
                        field = string.Empty, title = "", template = "#= TypePermission #"
                    };
                    listColModel.Add(firstCol);
                    //loop all role record in db to render data into column of grid
                    for (int j = 0; j < listRole.Count; j++)
                    {
                        //Get infor of CRUID perm of user
                        long maskPerm = listRole[j].MaskPermission.HasValue ? listRole[j].MaskPermission.Value : 0;
                        ParseBitMaskToObject(maskPerm, ref listBitMask);
                        //Render columns of grid
                        int bitMaskCurrentUser = GlobalFunctions.GetBitMaskOfUser(listRole[j].MaskPermission.HasValue ? listRole[j].MaskPermission.Value : 0);
                        //bool tempHidden = false;
                        //if ((bitMaskCurrentUser == (int)UserGroupEnum.SA || bitMaskCurrentUser == (int)UserGroupEnum.Operator) && hideColumn)
                        //    tempHidden = true;
                        listColModel.Add(new ColumnRoleModel()
                        {
                            title = listRole[j].RoleName, field = "Selected" + j, template = "<div style='text-align:center'><input type='checkbox' " + (disabledGrid ? "disabled='disabled'" : "") + " class='multi check_row' rowIDX='#=rowIndex#' id='Selected" + j + "' #= JSON.parse(Selected" + j + ") ? checked='checked' : '' # /><span class='lbl'></span><span style='display:none'>#=bitMaskUser" + j + "#</span><span style='display:none'>#=idx" + j + "#</span></div>"                                     /*,hidden=tempHidden*/
                        });
                    }

                    strColRecord += JsonConvert.SerializeObject(listColModel);
                    #endregion

                    #region Row
                    //loop 4 row equal to view,add,edit,delete record of grid
                    for (int i = 0; i < 4; i++)
                    {
                        strRowRecord += "{";

                        //Render data of first column
                        switch (i)
                        {
                        case 0: strRowRecord += "\"TypePermission\": \"<i class='multi-icon fa icon_menu-square_alt2 bigger-120'></i> View\","; break;

                        case 1: strRowRecord += "\"TypePermission\": \"<i class='multi-icon fa icon_plus_alt bigger-120'></i> Add\","; break;

                        case 2: strRowRecord += "\"TypePermission\": \"<i class='multi-icon fa icon_pencil bigger-120'></i> Edit\","; break;

                        case 3: strRowRecord += "\"TypePermission\": \"<i class='multi-icon fa icon_trash bigger-120'></i> Delete\","; break;
                        }
                        //Render data of all users
                        for (int j = 0; j < listRole.Count; j++)
                        {
                            //--------------data for checkbox--------//
                            switch (i)
                            {
                            case 0: selected = listBitMask.View[j].ToString(); break;

                            case 1: selected = listBitMask.Add[j].ToString(); break;

                            case 2: selected = listBitMask.Edit[j].ToString(); break;

                            case 3: selected = listBitMask.Delete[j].ToString(); break;
                            }
                            strRowRecord += "\"Selected" + j + "\": \"" + selected.ToString().ToLower() + "\",";
                            //--------------data for checkbox--------//
                            //Bit mask to identity user
                            strRowRecord += "\"bitMaskUser" + j + "\": \"" + listBitMask.NumberOfBitMask[j] + "\",";
                            //Id of role
                            strRowRecord += "\"idx" + j + "\": \"" + listRole[j].ID + "\",";
                        }
                        strRowRecord += "\"rowIndex\":\"" + i + "\"";
                        strRowRecord += i == 3 ? "}" : "},";
                    }
                    strRowRecord += "]";
                    #endregion
                    strJSON += strColRecord + "," + strRowRecord;
                    strJSON += disabledGrid ? ",\"Editable\":\"false\"" : ",\"Editable\":\"true\"";
                }
                strJSON += "}";
                return(strJSON);
            }
            catch
            {
                return(JsonConvert.SerializeObject(""));
            }
        }
示例#4
0
        public string RenderGridUserGroup()
        {
            //variables
            LcLImpList model;
            UserInfo   usInfo = System.Web.HttpContext.Current.Session["UserInfo"] as UserInfo;

            #region Definite column
            model        = new LcLImpList();
            model.column = new List <ColumnRoleModel>();

            ColumnRoleModel colJobNo = new ColumnRoleModel()
            {
                title = "JobNo", field = "JobNo", template = "#=JobNo#"
            }; model.column.Add(colJobNo);
            ColumnRoleModel colCreated = new ColumnRoleModel()
            {
                title = "Created", field = "Created", template = "#=kendo.toString(new Date(Created),'yyyy.MM.dd')#"
            }; model.column.Add(colCreated);
            ColumnRoleModel colEta = new ColumnRoleModel()
            {
                title = "Eta", field = "Eta", template = "#=kendo.toString(new Date(Eta),'yyyy.MM.dd')#"
            }; model.column.Add(colEta);
            ColumnRoleModel colMBLNo = new ColumnRoleModel()
            {
                title = "M-B/L No", field = "JobNo", template = "#=MBLNo#"
            }; model.column.Add(colMBLNo);
            ColumnRoleModel colPOLId = new ColumnRoleModel()
            {
                title = "POLId", field = "POLId", template = "#=POLId#"
            }; model.column.Add(colPOLId);
            //ColumnRoleModel colCommodity = new ColumnRoleModel() { title = "Commodity", field = "Commodity", template = "#=Commodity#" }; model.column.Add(colCommodity);
            //ColumnRoleModel colMBLType = new ColumnRoleModel() { title = "MBLType", field = "MBLType", template = "#=MBLType#" }; model.column.Add(colMBLType);
            //ColumnRoleModel colETDDate = new ColumnRoleModel() { title = "ETDDate", field = "ETDDate", template = "#=ETDDate#" }; model.column.Add(colETDDate);
            //ColumnRoleModel colETDType = new ColumnRoleModel() { title = "ETDType", field = "ETDType", template = "#=ETDType#" }; model.column.Add(colETDType);
            //ColumnRoleModel colContactId = new ColumnRoleModel() { title = "ContactId", field = "ContactId", template = "#=ContactId#" }; model.column.Add(colContactId);
            //ColumnRoleModel colSCName = new ColumnRoleModel() { title = "SCName", field = "SCName", template = "#=SCName#" }; model.column.Add(colSCName);
            //ColumnRoleModel colVessel = new ColumnRoleModel() { title = "Vessel", field = "Vessel", template = "#=Vessel#" }; model.column.Add(colVessel);
            //ColumnRoleModel colPODId = new ColumnRoleModel() { title = "PODId", field = "PODId", template = "#=PODId#" }; model.column.Add(colPODId);
            //ColumnRoleModel colPackageAmount = new ColumnRoleModel() { title = "PackageAmount", field = "PackageAmount", template = "#=PackageAmount#" }; model.column.Add(colPackageAmount);
            //ColumnRoleModel colPackageType = new ColumnRoleModel() { title = "PackageType", field = "PackageType", template = "#=PackageType#" }; model.column.Add(colPackageType);
            //ColumnRoleModel colService = new ColumnRoleModel() { title = "Service", field = "Service", template = "#=Service#" }; model.column.Add(colService);
            //ColumnRoleModel colisFinish = new ColumnRoleModel() { title = "isFinish", field = "isFinish", template = "#=isFinish#" }; model.column.Add(colisFinish);
            //ColumnRoleModel colCoLoaderId = new ColumnRoleModel() { title = "CoLoaderId", field = "CoLoaderId", template = "#=CoLoaderId#" }; model.column.Add(colCoLoaderId);
            //ColumnRoleModel colAgentId = new ColumnRoleModel() { title = "AgentId", field = "AgentId", template = "#=AgentId#" }; model.column.Add(colAgentId);
            //ColumnRoleModel colVoyage = new ColumnRoleModel() { title = "Voyage", field = "Voyage", template = "#=Voyage#" }; model.column.Add(colVoyage);
            //ColumnRoleModel colDelivery = new ColumnRoleModel() { title = "Delivery", field = "Delivery", template = "#=Delivery#" }; model.column.Add(colMBLNo);
            //ColumnRoleModel colGW = new ColumnRoleModel() { title = "GW", field = "GW", template = "#=GW#" }; model.column.Add(colGW);
            //ColumnRoleModel colCBM = new ColumnRoleModel() { title = "CBM", field = "CBM", template = "#=CBM#" }; model.column.Add(colCBM);
            //ColumnRoleModel colNote = new ColumnRoleModel() { title = "Note", field = "Note", template = "#=Note#" }; model.column.Add(colNote);

            //ColumnRoleModel colCreatedDate = new ColumnRoleModel() { title = "CreatedDate", field = "CreatedDate", template = "#=kendo.toString(new Date(CreatedDate),'yyyy.MM.dd')#" }; model.column.Add(colCreatedDate);

            //ColumnRoleModel colLogo = new ColumnRoleModel() { title = "Logo", field = "CustomerLogo", template = "<div style='text-align:center'><img src='#=CustomerLogo#' width='48px' height='48px' /></div>" }; model.column.Add(colLogo);
            //ColumnRoleModel colOrgNumber = new ColumnRoleModel() { title = "OrgNumber", field = "OrgNumber" }; model.column.Add(colOrgNumber);
            //ColumnRoleModel colCreatedDate = new ColumnRoleModel() { title = "CreatedDate", field = "CreatedDate", template = "#=kendo.toString(new Date(CreatedDate),'yyyy.MM.dd')#" }; model.column.Add(colCreatedDate);

            //model.total = _roleService.GetAllRoles(usInfo.IsTenant, false, usInfo.TenanID).Count();
            //var _lst = _roleService.GetAllRoles(usInfo.IsTenant, false, usInfo.TenanID).Count();
            #endregion

            return(JsonConvert.SerializeObject(model));
        }