Exemplo n.º 1
0
        public async Task ShowAsync()
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var team = await _twitchTeamMemberRepository.GetTeamAsync(guild.Id);

            if (team.Count == 0)
            {
                await ReplyAsync("No team members yet");

                return;
            }

            var embed = new EmbedBuilder()
                        .WithTitle("Twitch Team Members")
                        .AddField("Id", string.Join("\r\n", team.Select(x => x.TwitchId)), true)
                        .AddField("Display Name", string.Join("\r\n", team.Select(x => x.TwitchDisplayName)), true)
                        .Build();


            await ReplyAsync(embed : embed);
        }
Exemplo n.º 2
0
        public async Task AddCredentialsAsync()
        {
            var guild = ((SocketGuildChannel)Context.Channel).Guild;

            if (!await CheckPermission.CheckOwnerPermission(
                    guild.OwnerId,
                    Context.User.Id))
            {
                await ReplyAsync("You are not the owner of this discord so cannot add credentials");

                return;
            }

            var state = new StateModel
            {
                UserId    = Context.User.Id,
                ChannelId = Context.Channel.Id,
                GuildId   = guild.Id
            };

            var serialisedState = System.Text.Json.JsonSerializer.Serialize(state);

            var encryptedSerialisedState = _cypher.Encrypt(serialisedState);

            var dmChannel = await Context.User.GetOrCreateDMChannelAsync();

            await dmChannel.SendMessageAsync("To add your user credentials so we can access bits & subscriber " +
                                             "information use the following link to get access " +
                                             $"https://id.twitch.tv/oauth2/authorize?client_id={_config.TwitchClientId}&response_type=code&redirect_uri={_config.TwitchRedirectUrl}&scope=channel:read:subscriptions+bits:read+user:read:email&state={encryptedSerialisedState}");

            await ReplyAsync("I sent you a DM, better go check!");
        }
Exemplo n.º 3
0
        public async Task InstallGitHubCredentialsAsync()
        {
            var guild = ((SocketGuildChannel)Context.Channel).Guild;

            if (!await CheckPermission.CheckOwnerPermission(
                    guild.OwnerId,
                    Context.User.Id))
            {
                await ReplyAsync("You are not the owner of this discord so cannot add credentials");

                return;
            }

            var state = new StateModel
            {
                UserId    = Context.User.Id,
                ChannelId = Context.Channel.Id,
                GuildId   = guild.Id
            };

            var serialisedState = System.Text.Json.JsonSerializer.Serialize(state);

            var encryptedSerialisedState = _cypher.Encrypt(serialisedState);

            //var authLink = await _gitHubService.GetAuthUrlAsync(encryptedSerialisedState);
            var dmChannel = await Context.User.GetOrCreateDMChannelAsync();

            await dmChannel.SendMessageAsync("To add your user credentials so we can access bits & subscriber " +
                                             "information use the following link to get access " +
                                             $"https://github.com/apps/alfred-discord/installations/new?state={encryptedSerialisedState}");

            await ReplyAsync("I sent you a DM, better go check!");
        }
        public ActionResult SetPermission([FromBody] UserPermissions[] permission)
        {
            var a = permission[0].UserId;
            //string query = $@"UPDATE USERPERMISSIONS SET ACCES = 0 WHERE USERID = {Convert.ToInt32(permission[0].UserId)}";

            SqlTransaction transaction = null;
            var            connection  = new SqlConnection(CheckPermission.GetConnection());

            connection.Open();

            transaction = connection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted, "Excell import");
            var command = connection.CreateCommand();

            command.CommandTimeout = 0;
            command.Transaction    = transaction;
            command.CommandText    = $@"UPDATE USERPERMISSIONS SET ACCES = 0 WHERE USERID = {Convert.ToInt32(permission[0].UserId)}";
            for (int i = 0; i < permission.Count(); i++)
            {
                command.CommandText += $@"UPDATE UserPermissions SET Acces = 1 WHERE Id = {permission[i].Id} AND USERID = {permission[0].UserId}";
            }
            command.ExecuteNonQuery();
            transaction.Commit();

            return(View());
        }
Exemplo n.º 5
0
        public async Task RemoveModRole(IRole role)
        {
            var guild = ((SocketGuildChannel)Context.Channel).Guild;

            if (!await CheckPermission.CheckOwnerPermission(
                    guild.OwnerId,
                    Context.User.Id))
            {
                await ReplyAsync("You are not the owner of this discord so cannot add credentials");

                return;
            }
            var currentSettings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (currentSettings == null)
            {
                currentSettings = new Bot.Core.GuildSettings
                {
                    GuildId  = guild.Id.ToString(),
                    ModRoles = new List <string>()
                };
            }

            currentSettings.ModRoles.Remove(role.Id.ToString());
            await _guildSettingsRepoistory.SaveAsync(currentSettings);

            await ReplyAsync("Role removed as moderator");
        }
Exemplo n.º 6
0
        public async Task <ActionResult <IEnumerable <Sys_Dm_Company> > > r1GetListData(Options options)
        {
            try
            {
                var userId           = Convert.ToInt32(User.Claims.First(c => c.Type == "UserId").Value);
                int groupRoleDeFault = CheckPermission.getGroupRoleDefault(_context, userId);
                int perMission       = CheckPermission.CheckPer(_context, userId, options.groupId);
                switch (perMission)
                {
                case 0:
                    var tables = _context.Sys_Dm_Company.Select(a => new
                    {
                        Name = a.Code + " " + a.Name,
                        a.Id,
                        a.IsOrder
                    });
                    var qrs = await tables.OrderBy(x => x.IsOrder).ToListAsync();

                    return(new ObjectResult(new { error = 0, data = qrs }));

                default:
                    return(new ObjectResult(new { error = 0, data = new List <Sys_Dm_Company>() }));
                }
            }
            catch (Exception e)
            {
                bool success = SaveLog.SaveLogEx(_context, "api/Common/r1GetListCompany", e.Message, "Danh sách công ty");
                return(new ObjectResult(new { error = 1 }));
            }
        }
Exemplo n.º 7
0
        protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, OperationAuthorizationRequirement requirement, string resource)
        {
            var roles = await _userConnectAPI.GetListRoleOfUserByUserName(context.User.Identity.Name);

            if (roles != null)
            {
                var listRole = roles;
                var request  = new CheckPermission()
                {
                    FunctionId = resource,
                    Action     = requirement.Name,
                    Roles      = roles
                };
                var hasPermission = await _roleConnectAPI.CheckPermission(request);

                if (hasPermission || listRole.Contains(CommonConstants.AppRole.AdminRole))
                {
                    context.Succeed(requirement);
                }
                else
                {
                    context.Fail();
                }
            }
            else
            {
                context.Fail();
            }
        }
Exemplo n.º 8
0
            public BackendPage(string title, CheckPermission check, params string[] fileNames)
            {
                Title             = title;
                FileNames         = fileNames;
                m_CheckPermission = check;
                _index++;
                this._id = _index;

                Queries = new List <NameValueCollection>();

                FileName = fileNames[0];

                for (int i = 0; i < FileNames.Length; i++)
                {
                    string fileName = FileNames[i];

                    int indexOfQuery = fileName.IndexOf('?');

                    if (indexOfQuery >= 0)
                    {
                        Queries.Add(HttpUtility.ParseQueryString(fileName.Substring(indexOfQuery + 1)));

                        FileNames[i] = fileName.Substring(0, indexOfQuery);
                    }
                    else
                    {
                        Queries.Add(null);
                    }
                }
            }
Exemplo n.º 9
0
        public async Task SetChannelAsync(IChannel channel)
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var current = await _singleStreamerSettingsRepository.GetAsync(guild.Id);

            if (current == null)
            {
                current = new Bot.Core.SingleStreamerSettings
                {
                    GuildId = guild.Id.ToString()
                };
            }
            current.ChannelId = channel.Id.ToString();

            await _singleStreamerSettingsRepository.SaveAsync(current);

            await ReplyAsync("Channel Set");
        }
Exemplo n.º 10
0
        public async Task SetTeamAsync(string teamName)
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }
            var current = await _twitchTeamSettingsRepository.GetAsync(guild.Id);

            if (current == null)
            {
                current = new Bot.Core.TwitchTeamSettings
                {
                    GuildId   = guild.Id.ToString(),
                    ChannelId = ""
                };
            }
            current.TeamName = teamName;

            await _twitchTeamSettingsRepository.SaveAsync(current);

            await ReplyAsync("Team Name Set");
        }
Exemplo n.º 11
0
 public ChangeRemoteDesktopPort()
 {
     InitializeComponent();
     if (!CheckPermission.IsAdmin())
     {
         AdminButton.AddShieldToButton(button1);
     }
 }
Exemplo n.º 12
0
        public async Task ListOrgsAsync([Remainder] string orgName = "")
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckOwnerPermission(
                    guild.OwnerId,
                    Context.User.Id
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var current = await _ownerGitHubCredentialRepository.GetAsync(Context.User.Id);

            if (current == null)
            {
                await ReplyAsync("no github credentials set for you");

                return;
            }

            if (string.IsNullOrEmpty(orgName))
            {
                var allOrgs = await _gitHubService.GetGitHubOrgsAsync(current.AccessToken);

                if (allOrgs.Count() == 0)
                {
                    await ReplyAsync("Alfred is not installed in any of your Organisations");
                }
                var embed = new EmbedBuilder()
                            .WithTitle("GitHub Organisations")
                            .WithDescription("re-run `!github set-org` with the name of the organisation e.g. `!github set-org MyOrgName`")
                            .AddField("Organisation Names", string.Join(" \r\n", allOrgs.Select(x => x.Login)), true)
                            .Build();

                await ReplyAsync(embed : embed);
            }
            else
            {
                var installs = await _gitHubService.GetGitHubInstallationsAsync(current.AccessToken);

                var install = installs.Installations
                              .Where(x => x.TargetType == AccountType.Organization)
                              .Where(x => x.Account.Login.ToLower() == orgName.ToLower())
                              .FirstOrDefault();
                if (install == null)
                {
                    await ReplyAsync("Alfred is not installed in any of your Organisations");
                }
                settings.GitHubInstallationID = install.Id.ToString();
                await _guildSettingsRepoistory.SaveAsync(settings);
                await ReplyAsync("Organisation set!");
            }
        }
Exemplo n.º 13
0
        public CheckPermission GetAcess(int rule_id)
        {
            DataTable       dt = base.GetDataTable("select * from " + TABLE_NAME + " where rule_id='" + rule_id + "'");
            CheckPermission cp = new CheckPermission();

            foreach (DataRow row in dt.Rows)
            {
                if (row[NAME].ToString().Equals("user"))
                {
                    if (row[VALUES].ToString().Equals("1"))
                    {
                        cp.User = true;
                    }
                    else
                    {
                        cp.User = false;
                    }
                }
                if (row[NAME].ToString().Equals("item"))
                {
                    if (row[VALUES].ToString().Equals("1"))
                    {
                        cp.Item = true;
                    }
                    else
                    {
                        cp.Item = false;
                    }
                }
                if (row[NAME].ToString().Equals("store"))
                {
                    if (row[VALUES].ToString().Equals("1"))
                    {
                        cp.Store = true;
                    }
                    else
                    {
                        cp.Store = false;
                    }
                }
                if (row[NAME].ToString().Equals("rule"))
                {
                    if (row[VALUES].ToString().Equals("1"))
                    {
                        cp.Rules = true;
                    }
                    else
                    {
                        cp.Rules = false;
                    }
                }
            }

            return(cp);
        }
Exemplo n.º 14
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (CheckPermission.IsAdmin())
     {
         ChangePort();
     }
     else
     {
         AdminButton.RestartElevated();
     }
 }
Exemplo n.º 15
0
        public async Task End()
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var current = await _transcriberRepository.GetAsync(guild.Id, Context.Channel.Id);

            if (current == null || current.Ended != DateTime.MinValue)
            {
                await ReplyAsync("Transcriber not currently running on this channel");

                return;
            }

            //Process Log
            current.Ended = DateTime.Now;

            var             messageCount = 0;
            List <IMessage> messages     = (await Context.Channel.GetMessagesAsync(ulong.Parse(current.MessageId), Direction.After).FlattenAsync()).ToList();

            messageCount = messages.Count();
            while (messageCount == 100)
            {
                var top     = messages.OrderByDescending(x => x.CreatedAt).FirstOrDefault();
                var nextSet = await Context.Channel.GetMessagesAsync(top.Id, Direction.After).FlattenAsync();

                messages.AddRange(nextSet);
                messageCount = nextSet.Count();
            }

            await _transcriberRepository.SaveAsync(current);

            byte[] buffer;

            using (var ms = new MemoryStream())
            {
                HtmlConverter.ConvertToPdf(@$ "<html>
											<style>
												body {{
													font-family: Arial, Helvetica, sans-serif;
												}}
Exemplo n.º 16
0
        public List <CheckPermission> GetAccess(object obj)
        {
            Permission             pt  = (Permission)obj;
            List <CheckPermission> cps = new List <CheckPermission>();
            DataTable dt = base.GetDataTable("select * from " + TABLE_NAME + " where rule_id='" + pt.Rule_id + "'");

            foreach (DataRow row in dt.Rows)
            {
                CheckPermission cp = new CheckPermission();
            }
            return(cps);
        }
Exemplo n.º 17
0
 public BackendPage(string title, int width, CheckPermission check, params BackendPage[] subPages)
 {
     Width             = width;
     Title             = title;
     SubPages          = subPages;
     m_CheckPermission = check;
     _index++;
     this._id = _index;
     foreach (BackendPage subPage in SubPages)
     {
         subPage.ParentPage = this;
     }
 }
Exemplo n.º 18
0
        public bool Start(int interval = 1000)
        {
            #region 启动系统性能计数器统计

            bool isSucceed;
            try
            {
                isSucceed = NetFlow.Start(interval);
                NetFlow.DataMonitorEvent += DataMonitorEvent;
                IsNetFlowRun              = true;
            }
            catch
            {
                return(false);
            }

            if (!isSucceed)
            {
                return(false);
            }

            #endregion

            #region 启动Socket包统计
            if (CheckPermission.IsAdmin())
            {
                var hosts = NetCardInfoTool.GetIPv4Address();
                AllIPv4Address = NetCardInfoTool.GetAllIPv4Address();
                foreach (var host in hosts)
                {
                    try
                    {
                        var p = new NetPacketTool(host);
                        p.NewPacket += NewPacketEvent;
                        p.Start();
                        NetPacketList.Add(p);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                if (ListTool.HasElements(NetPacketList))
                {
                    IsNetPacketRun = true;
                }
            }
            #endregion

            return(true);
        }
Exemplo n.º 19
0
        public IActionResult Download()
        {
            List <Employee> employees = new List <Employee>();
            string          query     = $@"SELECT '' AS Məbləğ,'4' AS HərəkətTipi,'2' AS ƏməliyyatNövü,'3' AS Kassa,ContractDetail.Id AS Xidmət,Customers.Name+' '+Customers.Surname as İşçi FROM Customers 
                              INNER JOIN Contract ON Contract.CustomersId = Customers.Id 
                              INNER JOIN ContractDetail ON ContractDetail.ContractId = Contract.Id";
            //WHERE Customers.CustomerTypeId = 2004";

            SqlConnection con = new SqlConnection(CheckPermission.GetConnection());
            SqlCommand    cmd = new SqlCommand(query, con);

            con.Open();
            var dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                employees.Add(new Employee
                {
                    Amount          = dr.GetValue(0).ToString(),
                    TransactionType = dr.GetValue(1).ToString(),
                    SignTypes       = dr.GetValue(2).ToString(),
                    Cashes          = dr.GetValue(3).ToString(),
                    ContractDetails = dr.GetValue(4).ToString(),
                    Persons         = dr.GetValue(5).ToString()
                });
            }

            DataTable dt = new DataTable();

            using (var reader = ObjectReader.Create(employees))
            {
                dt.Load(reader);
            }

            byte[] fileContents;
            using (var package = new ExcelPackage())
            {
                var worksheet = package.Workbook.Worksheets.Add("employees");
                worksheet.Cells["A1"].LoadFromDataTable(dt, true);
                fileContents = package.GetAsByteArray();
            }



            con.Close();

            return(File(fileContents: fileContents,
                        contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                        fileDownloadName: "Şablon(Əmək haqqı).xlsx"));
        }
Exemplo n.º 20
0
        public ActionResult UserPartial()
        {
            var currentUserId = CheckPermission.GetCurrentUserId();
            var user          = db.Users.FirstOrDefault(u => u.Id == currentUserId);
            var userVm        = new UserPartialViewModel();

            userVm.Id         = user.Id;
            userVm.FirstName  = user.FirstName;
            userVm.LastName   = user.LastName;
            userVm.Email      = user.Email;
            userVm.RoleName   = db.Roles.FirstOrDefault(r => r.Id == db.UserRoles.FirstOrDefault(ur => ur.UserId == user.Id).RoleId).Name;
            userVm.UserAvatar = user.Avatar;
            return(PartialView(userVm));
        }
Exemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the PacketMonitor class.
 /// </summary>
 /// <param name="ip">The interface on which to listen for IP packets.</param>
 /// <exception cref="NotSupportedException">The operating system does not support intercepting packets.</exception>
 public NetPacketTool(IPAddress ip)
 {
     // make sure the user runs this program on Windows NT 5.0 or higher
     if (Environment.OSVersion.Platform != PlatformID.Win32NT || Environment.OSVersion.Version.Major < 5)
     {
         throw new NotSupportedException(@"This program requires Windows 2000, Windows XP or Windows .NET Server!");
     }
     // make sure the user is an Administrator
     if (!CheckPermission.IsAdmin())
     {
         throw new NotSupportedException(@"This program can only be run by administrators!");
     }
     IP     = ip;
     Buffer = new byte[65535];
 }
Exemplo n.º 22
0
        public async Task <bool> CheckPermission(CheckPermission request)
        {
            var json       = JsonConvert.SerializeObject(request);
            var jsonstring = new StringContent(json, Encoding.UTF8, "application/json");
            var creat      = _httpClientFactory.CreateClient();

            creat.BaseAddress = new Uri("https://localhost:44318");
            var post = await creat.PostAsync("api/Role/CheckPermission", jsonstring);

            var readpost = await post.Content.ReadAsStringAsync();

            var product = JsonConvert.DeserializeObject <bool>(readpost);

            return(product);
        }
Exemplo n.º 23
0
        public ActionResult EditMyProfile()
        {
            var currentUserId = CheckPermission.GetCurrentUserId();

            if (currentUserId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var user = _repo.GetUser(currentUserId);

            if (user == null)
            {
                return(HttpNotFound());
            }
            return(View(user));
        }
Exemplo n.º 24
0
        public async Task Start()
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }
            var current = await _transcriberRepository.GetAsync(guild.Id, Context.Channel.Id);

            if (current == null)
            {
                current = new Bot.Core.Transcriber
                {
                    GuildId   = guild.Id.ToString(),
                    ChannelId = Context.Channel.Id.ToString(),
                    Started   = DateTime.Now,
                    Ended     = DateTime.MinValue,
                    MessageId = Context.Message.Id.ToString()
                };
            }
            else if (current.Ended != DateTime.MinValue)
            {
                current.Started   = DateTime.Now;
                current.Ended     = DateTime.MinValue;
                current.MessageId = Context.Message.Id.ToString();
            }
            else
            {
                await ReplyAsync("Transcriber already running on this channel");

                return;
            }

            await _transcriberRepository.SaveAsync(current);

            await ReplyAsync("Started transcriber on this channel");
        }
Exemplo n.º 25
0
        public static void ChangeFiles(InputData input)
        {
            var files   = Dir.GetFiles(input);
            var changer = ChangingFile.GetChange(input.Modifier);

            Action act = new FileChanger(changer);

            act = new TimeMeasurer(act);
            act = new CheckPermission(act);

            foreach (var file in files)
            {
                changer.FileForChange = file;

                act.Act();

                file.Save();
            }
        }
Exemplo n.º 26
0
        public async Task RemoveMenu(CheckPermission check)
        {
            await _unit.BeginAsync();

            try
            {
                var db = _unit.DbContext;
                //删除所有菜单
                await db.Database.ExecuteSqlRawAsync($"delete from T_RoleMenu where RoleId={check.RoleId}");

                //新增角色的菜单权限
                check.Menus.ForEach(f => {
                    var roleMenu = new RoleMenu
                    {
                        RoleId = check.RoleId,
                        MenuId = f
                    };
                    db.RoleMenus.Add(roleMenu);
                });
                //删除所有权限
                await db.Database.ExecuteSqlRawAsync($" delete from T_RolePermission where RoleId={check.RoleId} ");

                if (check.Permissions.IsNullOrEmpty())
                {
                    check.Permissions.ForEach(f =>
                    {
                        db.RolePermissions.Add(new RolePermission
                        {
                            RoleId = check.RoleId,
                            Pid    = f
                        });
                    });
                }
                await _unit.CommitAsync();
            }
            catch (Exception ex)
            {
                await _unit.RollbackAsync();

                Console.WriteLine(ex);
            }
        }
Exemplo n.º 27
0
        public async Task AddAsync(string twitchUsername)
        {
            var guild    = ((SocketGuildChannel)Context.Channel).Guild;
            var settings = await _guildSettingsRepoistory.GetAsync(guild.Id);

            if (!await CheckPermission.CheckModPermission(
                    guild.OwnerId,
                    Context.User.Id,
                    settings.ModRoles,
                    ((SocketGuildUser)Context.User).Roles.Select(x => x.Id).ToList()
                    ))
            {
                await ReplyAsync("You don't have permission to do this!");

                return;
            }

            var team = await _twitchTeamMemberRepository.GetTeamAsync(guild.Id);

            var user = await _twitchService.GetUserByLoginAsync(twitchUsername);

            if (user == null)
            {
                return;
            }

            if (!team.Any(x => x.TwitchId == user.Id))
            {
                await _twitchTeamMemberRepository.SaveAsync(new Bot.Core.TwitchTeamMember
                {
                    GuildId           = guild.Id.ToString(),
                    TwitchId          = user.Id,
                    TwitchDisplayName = user.DisplayName
                });
                await ReplyAsync("Team member added");
            }
            else
            {
                await ReplyAsync("Team member already exists");
            }
        }
Exemplo n.º 28
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session[Constants.SES_USER_CONFIG] != null)
     {
         if (!Page.IsPostBack)
         {
             InitializeData();
             //This is for Page Permission
             CheckPermission chkPer  = new CheckPermission();
             Config          oConfig = (Config)Session[Constants.SES_USER_CONFIG];
             if (!chkPer.CheckPagePermission((Control)this.Page, oConfig, (int)Constants.PAGEINDEX_CLAIM.COMMISSION))
             {
                 Response.Redirect(Constants.PAGE_ERROR, false);
             }
             //End Of Page Permission
         }
     }
     else
     {
         Response.Redirect(Constants.PAGE_LOGIN, false);
     }
 }
Exemplo n.º 29
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session[Constants.SES_USER_CONFIG] != null)
     {
         if (!Page.IsPostBack)
         {
             Util.InvalidateSession();
             InitializeData();
             CheckPermission chkPer  = new CheckPermission();
             Config          oConfig = (Config)Session[Constants.SES_USER_CONFIG];
             if (!chkPer.CheckPagePermission((Control)this.Page, oConfig, (int)Constants.PAGEINDEX_TRANS.SP_ISSUE))
             {
                 Response.Redirect(Constants.PAGE_ERROR, false);
             }
             //End Of Page Permission
         }
     }
     else
     {
         Response.Redirect(Constants.PAGE_LOGIN, false);
     }
 }
Exemplo n.º 30
0
        void SettingLoad(object sender, EventArgs e)
        {
            PermissionTableC ptc = new PermissionTableC();
            CheckPermission  cp  = ptc.GetAcess(_user.Rule_id);

            if (!cp.User)
            {
                tControl.TabPages.Remove(tabUser);
            }
            if (!cp.Store)
            {
                tControl.TabPages.Remove(tabStock);
            }
            if (!cp.Item)
            {
                tControl.TabPages.Remove(tabItem);
            }
            if (!cp.Rules)
            {
                tControl.TabPages.Remove(tabRule);
            }
        }
Exemplo n.º 31
0
 public BackendPage(string title, int width, CheckPermission check, params BackendPage[] subPages)
 {
     Width = width;
     Title = title;
     SubPages = subPages;
     m_CheckPermission = check;
     _index++;
     this._id = _index;
     foreach (BackendPage subPage in SubPages)
     {
         subPage.ParentPage = this;
     }
 }
Exemplo n.º 32
0
            public BackendPage(string title, CheckPermission check, params string[] fileNames)
            {
                Title = title;
                FileNames = fileNames;
                m_CheckPermission = check;
                _index++;
                this._id = _index;

				Queries = new List<NameValueCollection>();

                FileName = fileNames[0];

				for(int i=0; i<FileNames.Length; i++)
                {
                    string fileName = FileNames[i];
					
                    int indexOfQuery = fileName.IndexOf('?');

					if (indexOfQuery >= 0)
					{
						Queries.Add(HttpUtility.ParseQueryString(fileName.Substring(indexOfQuery + 1)));

                        FileNames[i] = fileName.Substring(0, indexOfQuery);
                    }
					else
					{
						Queries.Add(null);
					}
				}
            }