예제 #1
0
        /// <summary>
        /// 取得帳號所有角色
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public List <RoleCheck> GetRoleByAdminId(Guid?id)
        {
            IEnumerable <Role> data = null;

            if (id != null)
            {
                // 帳號所有角色
                data = Db.Admins.Find(id).Roles.Where(x => x.IsDelete == false).ToList();
            }

            var roleList  = Db.Roles.Where(x => x.IsDelete == false).OrderBy(x => x.Sort);
            var checkList = new List <RoleCheck>();

            // 全部角色
            foreach (var role in roleList)
            {
                var check = new RoleCheck
                {
                    Id   = role.Id,
                    Name = role.Name,
                    // 帳號是否包含角色
                    IsChecked = (id != null) && data.Any(x => x.Id == role.Id)
                };
                checkList.Add(check);
            }

            return(checkList);
        }
        public async Task DebateRules(SocketGuildUser user = null)
        {
            if (!RoleCheck.HasInvestmentStaffRole((SocketGuildUser)Context.User) || !RoleCheck.HasChiefRole((SocketGuildUser)Context.User) || Context.User.Id != Context.Guild.Owner.Id)
            {
                return;
            }
            var debateTC = Global.Client.GetGuild(Context.Guild.Id).GetTextChannel(ChannelIds.channels.debateTCID);
            var rules    = new EmbedBuilder();

            rules.WithTitle("**Rules for the Debate Channels!**")
            .WithDescription("The rules are for debates/meetings using the Debate Channels. This are enforced with bans from the debate channels to keep them as inviting as possible. If you have been banned please talk to the Owner about being able to rejoin through DMs.")
            .AddField("Rule 1:", "Please be respectful at all times. Debates are to be fun and enjoyable, while meetings are there to get everyone's collective input in a voice chat.")
            .AddField("Rule 2:", "This rule is a reminder, spamming the bot is against the rules.")
            .AddField("Rule 3:", "No complaining that you didn't get the speaking stick. This is distracting for everyone not only the person with the stick.")
            .AddField("Rule 4:", "No begging for the stick. Again, this is distracting for everyone not only the person with the stick.")
            .AddField("Rule 5:", "If your hogging the speaking stick, it can be removed by admin commands.")
            .AddField("Rule 6:", "Weither you have the speaking stick or not, keep both channels on topic.")
            .AddField("Rule 7:", "Do not ask for commands(if your the speaker asking how to give the stick up or to someone is one thing!) there is a `!help debate` command.")
            .AddField("Rule 8:", "**DO NOT** argue with staff members. If it is the case of power abuse please contact the leader.");
            if (user == null)
            {
                await debateTC.SendMessageAsync("", false, rules.Build());

                return;
            }
            else if (user != null)
            {
                var dm = await user.GetOrCreateDMChannelAsync();

                await dm.SendMessageAsync("", false, rules.Build());

                return;
            }
        }
        public async Task GiveStick(SocketGuildUser user)
        {
            if (!RoleCheck.HasInvestmentStaffRole((SocketGuildUser)Context.User) || !RoleCheck.HasChiefRole((SocketGuildUser)Context.User) || Context.User.Id != Context.Guild.Owner.Id)
            {
                return;
            }
            var guild = GuildAccounts.GetAccount(Context.Guild);

            if (guild.DebateRunning == false)
            {
                await ReplyAsync("The debate is not running.");

                return;
            }
            var             currentHolderId = guild.StickHolderId;
            SocketGuildUser holder          = Global.Client.GetGuild(Config.bot.guildID).GetUser(currentHolderId);
            var             voiceChannel    = Context.Guild.GetVoiceChannel(ChannelIds.channels.debateVCID);
            await voiceChannel.RemovePermissionOverwriteAsync(holder);

            var allow = new OverwritePermissions(speak: PermValue.Allow, connect: PermValue.Allow, viewChannel: PermValue.Allow);
            await voiceChannel.AddPermissionOverwriteAsync(user, allow);

            guild.StickHolderId = user.Id;
            GuildAccounts.SaveAccounts();
        }
        public async Task CloseDebate()
        {
            if (!RoleCheck.HasInvestmentStaffRole((SocketGuildUser)Context.User) || !RoleCheck.HasChiefRole((SocketGuildUser)Context.User) || Context.User.Id != Context.Guild.Owner.Id)
            {
                return;
            }
            var guild        = GuildAccounts.GetAccount(Context.Guild);
            var voiceChannel = Context.Guild.GetVoiceChannel(ChannelIds.channels.debateVCID);
            var textChannel  = Context.Guild.GetTextChannel(ChannelIds.channels.debateTCID);

            if (guild.StickHolderId != 0)
            {
                var             currentHolderId = guild.StickHolderId;
                SocketGuildUser holder          = Global.Client.GetGuild(Config.bot.guildID).GetUser(currentHolderId);
                await voiceChannel.RemovePermissionOverwriteAsync(holder);

                guild.StickHolderId = 0;
                GuildAccounts.SaveAccounts();
            }
            //var currentHolderID =  guild.StickHolderId;
            var deny  = new OverwritePermissions(speak: PermValue.Deny, connect: PermValue.Deny, readMessageHistory: PermValue.Deny);
            var tDeny = new OverwritePermissions(connect: PermValue.Deny, readMessageHistory: PermValue.Deny, sendMessages: PermValue.Deny);
            await voiceChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.guildMemberID), deny);

            await voiceChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.townMemberID), deny);

            await textChannel.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, tDeny);

            await textChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.guildMemberID), tDeny);

            await textChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.townMemberID), tDeny);

            guild.DebateRunning = false;
            GuildAccounts.SaveAccounts();
        }
예제 #5
0
        public ActionResult MyFunds(BillsSearchModel info)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int   user = PageValidate.FilterParam(User.Identity.Name);
            Bills dal  = new Bills(db);

            if (!RoleCheck.CheckHasAuthority(user, db, "经费管理"))
            {
                info.userId = user;
            }
            info.PageSize = 0;
            info.userId   = user;
            var bills = dal.GetApplyList(info).ToList();

            foreach (var bill in bills)
            {
                bill.contents         = dal.getContents(bill.reimbursementCode, 0).ToList();
                bill.attachmentsCount = dal.getAttachments(bill.reimbursementCode, 0).Count();
            }
            ViewData["Bills"] = bills;
            List <SelectOption> options = DropDownList.RespondStateSelect();

            ViewData["RState"] = DropDownList.SetDropDownList(options);
            return(View(info));
        }
예제 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string username = CurrentUser.user.UserLoginName;

            roleCheck = new RoleCheck(CurrentUser);

            bmGuid = CurrentUser.UserGroup.Guid;

            //查看本部门审核通过的项目
            bmWhere = " (StartDeptGuid='" + bmGuid + "' and ProState='申报')";

            //此处查看所有审核通过的项目
            if (roleCheck.isAdmin() || roleCheck.isSjj() || roleCheck.isZfb())
            {
                roleWhere = " ProState='申报'";
            }

            if (roleWhere != "")
            {
                sqlWhere = baseWhere + " and (" + bmWhere + " or " + roleWhere + ")";
            }
            else
            {
                sqlWhere = baseWhere + " and (" + bmWhere + ")";
            }
        }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            roleCheck = new RoleCheck(CurrentUser);

            db = Yawei.DataAccess.DatabaseFactory.CreateDatabase();

            string querysql = "";

            if (roleCheck.isAdmin() || roleCheck.isSjj() || roleCheck.isZfb())
            {
                querysql = "select * from View_tz_xmjd";
            }
            else
            {
                sqlwhere += " and StartDeptGuid='" + CurrentUser.UserGroup.Guid + "'";
                querysql  = "select * from View_tz_xmjd where StartDeptGuid='" + CurrentUser.UserGroup.Guid + "'";
            }
            dsJdtj = db.ExecuteDataSet(querysql);
            //项目申报 即提交未通过状态的
            ss[0] = dsJdtj.Tables[0].Select("prostate='提交' or prostate='退回'").Count().ToString();
            //项目立项 即审核通过后续信息未维护的
            ss[1] = dsJdtj.Tables[0].Select("prostate='申报' and jscount=0 and yscount=0 and ywcount=0").Count().ToString();
            //项目建设 即审核通过维护过项目建设信息 但没有验收和运维信息的
            ss[2] = dsJdtj.Tables[0].Select("prostate='申报' and jscount<>0 and yscount=0 and ywcount=0").Count().ToString();
            //项目验收  审核通过 有项目建设信息 也有验收信息的
            ss[3] = dsJdtj.Tables[0].Select("prostate='申报'  and yscount<>0 and ywcount=0").Count().ToString();
            //项目运维 均有
            ss[4] = dsJdtj.Tables[0].Select("prostate='申报'  and ywcount<>0").Count().ToString();
        }
예제 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (RoleCheck.hasRole("adminrole", CurrentUser))
            {
                isAdmin = true;
                //管理员能查看自己新建的项目或者 部门已提交或者通过或者退回的项目
                roleWhere = " and (StartDeptGuid='" + bm + "' or (ProState is not null and ProState!='退回'))";
            }
            else
            {
                if (RoleCheck.hasRole("checkrole", CurrentUser))
                {
                    isCheck = true;
                }
                else
                {
                    isBaseRole = true;
                    //部门只能查看本部门的项目
                    roleWhere = " and StartDeptGuid='" + bm + "'";
                }
            }

            //未删除
            baseWhere = " and sysstatus!=-1";

            sqlWhere = baseWhere + roleWhere;
        }
예제 #9
0
        public static List <SelectOption> FundsSelect(int user)
        {
            string       key   = cache_funds + user;
            List <Funds> funds = DBCaches <Funds> .getCache(cache_funds);

            List <SelectOption> options = (List <SelectOption>)DataCache.GetCache(key);

            if (options == null)
            {
                var query = from fund in funds
                            where fund.f_state == 1
                            select fund;
                if (user > 0 && !RoleCheck.CheckHasAuthority(user, db, "经费管理"))
                {
                    query = query.Where(x => x.f_manager == user);
                }
                options = (from fund in query
                           select new SelectOption
                {
                    id = fund.f_id.ToString(),
                    text = string.Format("{0}({1})", fund.f_name, fund.f_code)
                }).ToList();
                if (options.Count() > 0)
                {
                    DataCache.SetCache(key, options);
                }
            }
            return(options);
        }
        public ActionResult Responded(BillsSearchModel info)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "Index" }));
            }
            ApplyManager dal    = new ApplyManager(db);
            int          userId = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(userId, db, "批复管理", "批复"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            if (RoleCheck.CheckHasAuthority(userId, db, "批复管理"))
            {
                if (info.userId == null)
                {
                    info.userId = 0;
                }
            }
            else
            {
                info.userId = userId;
            }
            SetSelect();
            var list = getResponseDetail((int)info.userId, 1, 2, 3, 4);

            ViewData["Bills"] = list;
            return(View(info));
        }
예제 #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            roleCheck   = new RoleCheck(CurrentUser);
            strProjGuid = Request["xmguid"] != null ? Request["xmguid"] : "";

            userGuid = CurrentUser.UserGuid;
            depGuid  = CurrentUser.UserGroup.Guid;

            strGuid = Request["Guid"] != null ? Request["Guid"] : "";

            form.TableName   = "tz_xmgz"; //表名
            form.Key         = "guid";    //主键
            form.KeyValue    = strGuid;   //主键的值
            form.CurrentUser = CurrentUser;

            document = form.SetViewData(null);
            if (document["bglx"] == "建设方案")
            {
                filesign = "tz_Project_Fa";
            }
            else if (document["bglx"] == "项目申报表")
            {
                filesign = "tz_Project_Sbb";
            }
            else if (document["bglx"] == "云资源使用申请表")
            {
                filesign = "tz_Project_Yzy";
            }

            System.GC.Collect();
        }
예제 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            curYear     = DateTime.Now.Year;
            roleCheck   = new RoleCheck(CurrentUser);
            strProjGuid = Request["xmguid"] != null ? Request["xmguid"] : "";
            type        = Request["type"] != null ? Request["type"] : "";


            Yawei.DataAccess.Database db = Yawei.DataAccess.DatabaseFactory.CreateDatabase();
            //获取资金支付情况
            string zfqksql = "select * from tz_zjzf where sysstatus!=-1 and  xmguid='" + strProjGuid + "' order by createdate desc";

            dsZfqk = db.ExecuteDataSet(zfqksql);

            //获取资金支付计划
            string zfjhsql = "select * from tz_zjzfjh where sysstatus!=-1 and xmguid='" + strProjGuid + "' order by createdate desc";

            dsZfjh = db.ExecuteDataSet(zfjhsql);

            //获取项目基本信息
            string projsql = "select * from tz_project where proguid='" + strProjGuid + "'";

            dsProj = db.ExecuteDataSet(projsql);

            string   startdate = dsProj.Tables[0].Rows[0]["StartDate"].ToString();
            DateTime dt        = DateTime.Parse(startdate);

            projSbYear = dt.Year;
        }
예제 #13
0
        public JsonResult SetRoleAuth(List <ViewRoleAuthority> auths)
        {
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。";
                json.msg_code = "notLogin";
                goto next;
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                json.msg_text = "没有权限。";
                json.msg_code = "NoPower";
                goto next;
            }
            if (auths == null || auths.Count() == 0)
            {
                json.msg_text = "没有接收任何数据。";
                json.msg_code = "NoReceive";
                goto next;
            }
            bool firstIn = true;

            foreach (ViewRoleAuthority item in auths)
            {
                if (firstIn)
                {
                    db.Role_vs_Authority.RemoveRange(db.Role_vs_Authority.Where(x => x.rva_role_id == item.roleId));
                    firstIn = false;
                }
                Role_vs_Authority rva = new Role_vs_Authority()
                {
                    rva_auth_id = item.authId,
                    rva_role_id = item.roleId
                };
                db.Role_vs_Authority.Add(rva);
            }
            try
            {
                db.SaveChanges();
                json.state    = 1;
                json.msg_text = "角色的权限修改成功。";
                json.msg_code = "success";
            }
            catch (Exception ex)
            {
                json.msg_text = "角色权限修改出错。";
                json.msg_code = "error";
                Common.ErrorUnit.WriteErrorLog(ex.ToString(), this.GetType().ToString());
            }
            SysLog.WriteLog(user, "重置角色的权限", IpHelper.GetIP(), "", 5, "", db);
            //重设置角色权限后,必需清除缓存
            DataCache.RemoveCacheBySearch("user_vs_roles");
next:
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #14
0
        public JsonResult ContrlModule(EditModules models)
        {
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。";
                json.msg_code = "notLogin";
                goto next;
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                json.msg_text = "没有权限。";
                json.msg_code = "NoPower";
                goto next;
            }
            if (ModelState.IsValid)
            {
                string ctrl_name;
                foreach (ModuleInfo info in models.modules)
                {
                    ctrl_name = info.name;
                    var no1 = db.Role_vs_Controller.Where(x => x.rvc_role_id != 1 && x.rvc_controller == ctrl_name);
                    if (no1.Count() > 0)
                    {
                        db.Role_vs_Controller.RemoveRange(no1);
                        db.SaveChanges();
                    }
                    if (info.roles != null && info.roles.Length > 0)
                    {
                        foreach (RoleInfo rinfo in info.roles)
                        {
                            Role_vs_Controller rvc = new Role_vs_Controller();
                            rvc.rvc_role_id    = rinfo.id;
                            rvc.rvc_controller = ctrl_name;
                            if (db.Role_vs_Controller.Find(rvc.rvc_role_id, rvc.rvc_controller) == null)
                            {
                                db.Role_vs_Controller.Add(rvc);
                            }
                        }
                    }
                }
                db.SaveChanges();
                SysLog.WriteLog(user, "修改系统模块", IpHelper.GetIP(), "", 5, "", db);
                json.state    = 1;
                json.msg_code = "success";
                json.msg_text = "数据更新成功。";
                DBCaches2.ClearCache("dic-module");
            }
            else
            {
                json.msg_code = "error";
                json.msg_text = "数据接收错误。";
            }
next:
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #15
0
        public TransactionRoles(ClientServicePartitionValidator validator, IClientFactory factory, MyRegistry reg)
        {
            this.factory   = factory;
            this.validator = validator;
            this.reg       = reg;

            roleCheck = EnumHelper.EnumPrompt <RoleCheck>();
        }
예제 #16
0
        public JsonResult UpdateRole(Dic_Role model)
        {
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。";
                json.msg_code = "notLogin";
                goto next;
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                json.msg_text = "没有权限。";
                json.msg_code = "NoPower";
                goto next;
            }
            if (model.role_id == 0)
            {
                json.msg_text = "获取角色的ID出错。";
                json.msg_code = "IDError";
                goto next;
            }
            if (model.role_id == 1)
            {
                json.msg_text = "该角色不允许修改。";
                json.msg_code = "CanNotUpdate";
                goto next;
            }
            var same = db.Dic_Role.Where(x => x.role_name == model.role_name && x.role_id != model.role_id);

            if (same.Count() > 0)
            {
                json.msg_text = "该名称已存在。";
                json.msg_code = "NameExists";
                goto next;
            }
            db.Entry(model).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
                DBCaches <Dic_Role> .ClearCache("cache_role");
            }
            catch
            {
                json.msg_text = "更新,请重新操作。";
                json.msg_code = "UpdateErr";
                goto next;
            }
            json.state    = 1;
            json.msg_code = "success";
            json.msg_text = "更新成功!";
            SysLog.WriteLog(user, string.Format("更新角色[{0}]名称", model.role_name), IpHelper.GetIP(), "", 5, "", db);
next:
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 接受参数
            roleCheck = new RoleCheck(CurrentUser);
            strGuid   = Request["xmguid"] != null ? Request["xmguid"] : "";
            userGuid  = CurrentUser.UserGuid;
            depGuid   = CurrentUser.UserGroup.Guid;

            checkReturnHistory();
            #endregion

            #region 初始化信息

            form.TableName   = "tz_zftz_Project"; //表名
            form.Key         = "ProGuid";         //主键
            form.KeyValue    = strGuid;           //主键的值
            form.CurrentUser = CurrentUser;
            document         = form.SetViewData(null);

            //管理员用户编辑权限一直开放
            //其他部门用户在未提交或者被退回状态下可以编辑
            if (roleCheck.isAdmin() || (document["ProState"] == "" || document["ProState"] == "退回"))
            {
                isEditable = true;
            }
            //可退回状态,生成唯一退回标识码
            if (document["ProState"] == "提交" && (roleCheck.isAdmin() || roleCheck.isZfb() || roleCheck.isFgwAdmin()))
            {
                returnGuid  = System.Guid.NewGuid().ToString();
                successGuid = System.Guid.NewGuid().ToString();
                holdGuid    = System.Guid.NewGuid().ToString();
                mergeGuid   = System.Guid.NewGuid().ToString();
            }

            //if (!UserCheck.checkIsAdmin(CurrentUser.user.UserLoginName))
            //{
            //    isAdmin = false;
            //    DataSet ds = db.ExecuteDataSet(" select * from tz_Project where ProGuid='" + strGuid + "'");
            //    prostate = ds.Tables[0].Rows[0]["ProState"].ToString();
            //    //未提交或者退回的项目申请提供编辑功能
            //    if (prostate == "" || prostate == "退回")
            //    {
            //        isEditable = true;
            //    }

            //}
            //else
            //{
            //    isAdmin = true;
            //    isEditable = true;
            //}

            #endregion

            System.GC.Collect();
        }
예제 #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                getData();

                var userRoles = ((wcf_auth.GeneralUserProfile)SessionCheck.Check(Response, Session["userprofile"])).mRoleList;
                btnUpload.Visible = RoleCheck.CheckRoleView(userRoles, "PK.Penerimaan.Edit");
            }
        }
예제 #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                initCombo();
            }
            GetData();

            btnSubmit.Visible = RoleCheck.CheckRoleView(((wcf_auth.GeneralUserProfile)SessionCheck.Check(Response, Session["userprofile"])).mRoleList, "PK.Penilaian.Edit");
        }
예제 #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            roleCheck   = new RoleCheck(CurrentUser);
            strProjGuid = Request["xmguid"] == null ? "" : Request["xmguid"];

            if (strProjGuid != "")
            {
                strOtherSql = " and xmguid='" + strProjGuid + "'";
            }
        }
예제 #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rbConfirm.SelectedValue = "0";
                InitCombo();
            }

            btnSubmit.Visible = RoleCheck.CheckRoleView(((wcf_auth.GeneralUserProfile)SessionCheck.Check(Response, Session["userprofile"])).mRoleList, "BL.Permohonan.Edit");
        }
예제 #22
0
        protected void prosesButton_Click(object sender, EventArgs e)
        {
            string id = Session["proposal_number"].ToString();

            ActivityLog    log       = new ActivityLog();
            ActivityLogBll logBll    = new ActivityLogBll();
            string         host      = Request.UserHostName;
            string         ipaddress = Request.UserHostAddress;
            string         userName  = Session["user"].ToString();

            if (String.IsNullOrEmpty(ipaddress))
            {
                ipaddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            }
            log.HostName  = host;
            log.IPAddress = ipaddress;
            log.Action    = "get preview jadwal pembayaran";
            log.UserName  = userName;

            try
            {
                DataTable dt = bll.getPreviewData(id);
                gvDetailAngsur.DataSource = dt;
                gvDetailAngsur.DataBind();

                int row   = 0;
                int tagih = int.Parse(txtTagihan.Text);
                int grace = int.Parse(txtGrace.Text);

                row = tagih > grace ? tagih : grace;

                txtAngsur.Text       = dt.Rows[row - 1]["jumlah"].ToString();
                txtHutang.Text       = dt.Rows[row - 1]["HutangPokok"].ToString();
                txtBungaPokok.Text   = dt.Rows[row - 1]["Bunga"].ToString();
                txtTanggalTempo.Date = DateTime.Parse(dt.Rows[int.Parse(txtJangkaWaktu.Text) - 1]["TglJatuhTempo"].ToString());

                SAVE.Visible  = true;
                BATAL.Visible = true;

                SAVE.Visible  = RoleCheck.CheckRoleView(((wcf_auth.GeneralUserProfile)SessionCheck.Check(Response, Session["userprofile"])).mRoleList, "PK.Penilaian.Edit");
                BATAL.Visible = RoleCheck.CheckRoleView(((wcf_auth.GeneralUserProfile)SessionCheck.Check(Response, Session["userprofile"])).mRoleList, "PK.Penilaian.Edit");

                log.Type        = "S";
                log.Description = log.Action + " sukses oleh " + userName;
            }
            catch (Exception Ex)
            {
                log.Type        = "E";
                log.Description = log.Action + " error :" + Ex.Message;
            }
            finally {
                logBll.InsertActivity(log);
            }
        }
예제 #23
0
        public ActionResult Index(BasePagerModel pager)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int uid = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(uid, db, "用户管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            if (pager == null)
            {
                pager = new BasePagerModel();
            }
            ViewData["search"] = pager;
            var list = (from user in db.User_Info
                        join uvr in db.User_vs_Role
                        on user.user_id equals uvr.uvr_user_id into T1
                        from t1 in T1.DefaultIfEmpty()
                        join role in db.Dic_Role
                        on t1.uvr_role_id equals role.role_id into T2
                        from t2 in T2.DefaultIfEmpty()
                        join ue in db.User_Extend
                        on user.user_id equals ue.user_id into T3
                        from t3 in T3.DefaultIfEmpty()
                        join dept in db.Dic_Department
                        on t3.user_dept_id equals dept.dept_id into T4
                        from t4 in T4.DefaultIfEmpty()
                        join post in db.Dic_Post
                        on t3.user_post_id equals post.post_id into T5
                        from t5 in T5.DefaultIfEmpty()
                        orderby user.user_id ascending
                        select new UserListModel
            {
                id = user.user_id,
                name = user.user_name,
                roleName = t2.role_name == null?"":t2.role_name,
                stateTxt = user.user_state == 1 ? "正常" : (user.user_state == 2 ? "锁定" : (user.user_state == 0 ? "未启用" : "未知")),
                realName = user.real_name,
                times = user.user_login_times,
                deptName = t4.dept_name == null?"":t4.dept_name,
                postName = t5.post_name == null?"":t5.post_name,
                picture = t3.user_picture == null?"default.jpg":t3.user_picture,
                loginTimes = user.user_login_times
            }).Skip((pager.PageIndex - 1) * pager.PageSize).Take(pager.PageSize).ToList();

            foreach (var item in list)
            {
                item.realName = Common.DEncrypt.AESEncrypt.Decrypt(item.realName);
            }
            return(View(list));
        }
예제 #24
0
        public async Task OpenDebate(string target = "guild")
        {
            if (!RoleCheck.HasInvestmentStaffRole((SocketGuildUser)Context.User) || !RoleCheck.HasChiefRole((SocketGuildUser)Context.User) || Context.User.Id != Context.Guild.Owner.Id)
            {
                return;
            }
            var vAllow       = new OverwritePermissions(speak: PermValue.Deny, connect: PermValue.Allow, readMessageHistory: PermValue.Allow);
            var vDeny        = new OverwritePermissions(speak: PermValue.Deny, connect: PermValue.Deny, readMessageHistory: PermValue.Deny);
            var tAllow       = new OverwritePermissions(connect: PermValue.Allow, readMessageHistory: PermValue.Allow, sendMessages: PermValue.Allow);
            var tDeny        = new OverwritePermissions(connect: PermValue.Deny, readMessageHistory: PermValue.Deny, sendMessages: PermValue.Deny);
            var voiceChannel = Context.Guild.GetVoiceChannel(ChannelIds.channels.debateVCID);
            var textChannel  = Context.Guild.GetTextChannel(ChannelIds.channels.debateTCID);

            if (target == "guild")
            {
                await voiceChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.guildMemberID), vAllow);

                await textChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.guildMemberID), tAllow);
            }
            if (target == "town")
            {
                await voiceChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.townMemberID), vAllow);

                await textChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.townMemberID), tAllow);
            }
            if (target == "all")
            {
                await voiceChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.guildMemberID), vAllow);

                await textChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.guildMemberID), tAllow);

                await voiceChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.townMemberID), vAllow);

                await textChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.townMemberID), tAllow);
            }
            await voiceChannel.AddPermissionOverwriteAsync(Context.Guild.GetRole(RoleIds.roles.guildMemberID), vAllow);

            await voiceChannel.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, vDeny);

            await textChannel.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, tDeny);

            var guild = GuildAccounts.GetAccount(Context.Guild);

            Console.WriteLine(guild);
            guild.StickHolderId = 0;
            guild.DebateRunning = true;
            GuildAccounts.SaveAccounts();
            await Context.Channel.SendMessageAsync("Guild stick holder id: " + guild.StickHolderId);

            await Context.Channel.SendMessageAsync("Debate running: " + guild.DebateRunning);

            GuildAccounts.SaveAccounts();
            await Context.Channel.SendMessageAsync("Both debate channels should be open.");
        }
예제 #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                deTglPersetujuan.Value = DateTime.Today;
                InitCombo();
                GetData();

                var userRoles = ((wcf_auth.GeneralUserProfile)SessionCheck.Check(Response, Session["userprofile"])).mRoleList;
                btnSimpan.Visible = RoleCheck.CheckRoleView(userRoles, "PK.Persetujuan.Edit");
            }
        }
예제 #26
0
        private void roleAuth()
        {
            var  userRoles = ((wcf_auth.GeneralUserProfile)SessionCheck.Check(Response, Session["userprofile"])).mRoleList;
            bool view      = RoleCheck.CheckRoleView(userRoles, "RPT.BinaLing.View");

            //((GridViewCommandColumn)gvPermohonan.Columns["opr"]).ShowNewButton = insert;

            if (view == false)
            {
                Response.Redirect("~/Default.aspx");
            }
        }
예제 #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            roleCheck = new RoleCheck(CurrentUser);


            Database db      = DatabaseFactory.CreateDatabase();
            string   projSql = "";

            if (roleCheck.isAdmin() || roleCheck.isSjj() || roleCheck.isZfb())
            {
                projSql = "select a.*,year(startdate) as xmyear,year(b.YsDate) as ysyear,b.ysresult as ysresult,b.ysdate as ysdate  from V_TZ_ProjectOverview a left join tz_xmys b on a.proguid=b.xmguid";
            }
            else
            {
                projSql = "select a.*,year(startdate) as xmyear,year(b.YsDate) as ysyear,b.ysresult as ysresult,b.ysdate as ysdate  from V_TZ_ProjectOverview a left join tz_xmys b on a.proguid=b.xmguid where startdeptguid='" + CurrentUser.UserGroup.Guid + "' order by  startdate desc,createdate desc";
            }
            dsProj = db.ExecuteDataSet(projSql);



            //DataSet ds = db.ExecuteDataSet("select *,year(startdate) as st,year(ysdate) as yt from View_Ys_tz_Project where sysstatus<>-1 order by ysdate desc");
            YSCount = "[" + dsProj.Tables[0].Rows.Count + "," + dsProj.Tables[0].Select("yscount<>0").Length + "]";

            for (int i = DateTime.Now.Year - 4; i <= DateTime.Now.Year; i++)
            {
                Year += i + ",";
                s    += dsProj.Tables[0].Select("xmyear=" + i).Length + ",";
                es   += dsProj.Tables[0].Select("ysyear=" + i).Length + ",";
            }
            Year = "[" + Year.TrimEnd(',') + "]";
            s    = "[" + s.TrimEnd(',') + "]";
            es   = "[" + es.TrimEnd(',') + "]";

            //ds = db.ExecuteDataSet("select top 10 *,year(startdate) as st,year(ysdate) as yt from View_Ys_tz_Project where sysstatus<>-1 and ysdate is not null order by ysdate desc");

            for (int i = 0; i < dsProj.Tables[0].Select("yscount<>0").Count(); i++)
            {
                DataRow row = dsProj.Tables[0].Select("yscount<>0")[i];
                table += "<tr>";
                if (!roleCheck.isBm())
                {
                    table += "<td>" + row["StartDeptName"] + "</td>";
                }

                table += "<td>" + row["ProName"] + "</td>";
                table += "<td>" + row["Quota"] + "</td>";
                table += "<td>" + row["MoneySource"] + "</td>";
                table += "<td>" + row["ProType"] + "</td>";
                table += "<td>" + row["ysdate"].ToString().Substring(0, row["ysdate"].ToString().Length - 7) + "</td>";
                table += "<td>" + row["ysresult"] + "</td>";
                table += "</tr>";
            }
        }
예제 #28
0
        public ActionResult Index()
        {
            int uid = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(uid, db, "用户管理"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            BasePagerModel pager = new BasePagerModel();

            return(Index(pager));
        }
예제 #29
0
        private void roleAuth()
        {
            var  userRoles = ((wcf_auth.GeneralUserProfile)SessionCheck.Check(Response, Session["userprofile"])).mRoleList;
            bool insert    = RoleCheck.CheckRoleView(userRoles, "AKUN.PK.KartuPiutang.Add");
            bool edit      = RoleCheck.CheckRoleView(userRoles, "AKUN.PK.KartuPiutang.Edit");
            bool view      = RoleCheck.CheckRoleView(userRoles, "AKUN.PK.KartuPiutang.View");

            if (view == false)
            {
                Response.Redirect("~/Default.aspx");
            }
        }
예제 #30
0
        public JsonResult DeleteRole(string rid)
        {
            int          id   = PageValidate.FilterParam(rid);
            BaseJsonData json = new BaseJsonData();

            if (!User.Identity.IsAuthenticated)
            {
                json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。";
                json.msg_code = "notLogin";
                goto next;
            }
            int user = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(user, db, "系统管理"))
            {
                json.msg_text = "没有权限。";
                json.msg_code = "NoPower";
                goto next;
            }
            if (id == 1)
            {
                json.msg_text = "该角色不允许删除。";
                json.msg_code = "CanNotDel";
                goto next;
            }
            Dic_Role model = db.Dic_Role.Find(id);

            if (model == null)
            {
                json.msg_text = "没有找到该角色,该角色可能已被删除。";
                json.msg_code = "noThis";
                goto next;
            }
            db.Dic_Role.Remove(model);
            try
            {
                db.SaveChanges();
                DBCaches <Dic_Role> .ClearCache("cache_role");
            }
            catch
            {
                json.msg_text = "删除失败,请重新操作。";
                json.msg_code = "recyErr";
                goto next;
            }
            json.state    = 1;
            json.msg_code = "success";
            json.msg_text = "删除成功!";
            SysLog.WriteLog(user, string.Format("删除角色[{0}]", model.role_name), IpHelper.GetIP(), "", 5, "", db);
next:
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #31
0
        /// <summary>
        /// 取得帳號所有角色
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public List<RoleCheck> GetRoleByAdminId(Guid? id)
        {
            IEnumerable<Role> data = null;
            if (id != null)
            {
                // 帳號所有角色
                data = Db.Admins.Find(id).Roles.Where(x => x.IsDelete == false).ToList();
            }

            var roleList = Db.Roles.Where(x => x.IsDelete == false).OrderBy(x => x.Sort);
            var checkList = new List<RoleCheck>();

            // 全部角色
            foreach (var role in roleList)
            {
                var check = new RoleCheck
                {
                    Id = role.Id,
                    Name = role.Name,
                    // 帳號是否包含角色
                    IsChecked = (id != null) && data.Any(x => x.Id == role.Id)
                };
                checkList.Add(check);
            }

            return checkList;
        }