Exemplo n.º 1
0
        public virtual async Task <ActionResult <bool> > RemoveLog([FromRoute] long logId)
        {
            var user = CurrentUser;

            if (!table.Access.GetFlag(AccessType.Admin, user))
            {
                return(Forbid());
            }

            var logItem = (DBLogItem)table.LogTable.LoadItemById(logId);

            if (logItem == null)
            {
                return(false);
            }
            using (var transaction = new DBTransaction(table.Connection, user))
            {
                try
                {
                    await logItem.Delete(transaction);

                    transaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    return(BadRequest(ex));
                }
            }
        }
Exemplo n.º 2
0
        public static DataTable GetGestionesEventos(int eventoId)
        {
            DBTransaction db = new DBTransaction();
            DataTable     dt = db.GetDataView(string.Format("vGetDeportes WHERE v.Activo = 1 AND v.DependienteId > 0 AND v.DisciplinaId not in (SELECT e.DisciplinaId FROM [EventoDeportivoDisciplinas] e WHERE e.EventoDeportivoId = {0})", eventoId));

            return(dt);
        }
Exemplo n.º 3
0
        public static DataTable GetGolpes(int competidorJornadaId, int hoyoParId)
        {
            DBTransaction db = new DBTransaction();

            return(db.GetDataView(string.Format("[golfJugadas] WHERE [CompetidorJornadaId] = {0} and [HoyoParId] = {1}", competidorJornadaId, hoyoParId)));
            //dbTools.Sql = string.Format("SELECT [Golpes] FROM [golfJugadas] WHERE [CompetidorJornadaId] = {0} and [HoyoParId] = {1}", competidorJornadaId, hoyoParId);
        }
Exemplo n.º 4
0
        private bool ExecuteTransaction(string procedureName, List <SqlParameter> ps)
        {
            DBTransaction db = new DBTransaction();

            db.ExecStoreProcedure(procedureName, ps);
            return(db.RowAffected > 0);
        }
Exemplo n.º 5
0
        public async Task pickQuoteNoArg()
        {
            //pass no user so it can pick from any
            string response = DBTransaction.pickQuote(Context.Guild.Id, 0);

            await ReplyAsync(response);
        }
Exemplo n.º 6
0
        public static void LoadBooks()
        {
            Helper.Logs.Add(new StateInfo("Flow Synchronization", "Start", "", StatusType.Information));
            Stopwatch watch = new Stopwatch();

            watch.Start();
            using (var transaction = new DBTransaction(Book.DBTable.Schema.Connection)
            {
                ReaderParam = DBLoadParam.Synchronize | DBLoadParam.CheckDeleted
            })
            {
                Book.DBTable.Load();
                //cache groups
                UserGroup.DBTable.Load();
                Location.DBTable.Load();
                User.DBTable.Load();
                Template.DBTable.Load();
                TemplateData.DBTable.Load();
                Work.DBTable.Load();
                Stage.DBTable.Load();
                StageParam.DBTable.Load();
                GroupPermission.DBTable.Load();
                Scheduler.DBTable.Load();
            }
            watch.Stop();

            Helper.Logs.Add(new StateInfo("Flow Synchronization", "Complete", "in " + watch.ElapsedMilliseconds + " ms", StatusType.Information));

            DocumentWork.DBTable.DefaultComparer = new DBComparer <DocumentWork, long?>(DocumentWork.DBTable.PrimaryKey)
            {
                Hash = true
            };
            //Logs.Add(new StateInfo("Flow Check", "Config Falil", "AccountInfo", StatusType.Warning));
        }
Exemplo n.º 7
0
        public async Task RemWitty(string name)
        {
            string DBresponse = DBTransaction.removeWitty(name, Context.Guild.Id);

            //only reaches this point if entire list does not match.
            await ReplyAsync(DBresponse);
        }
Exemplo n.º 8
0
        public static DataTable GetGestionesEventos()
        {
            DBTransaction db = new DBTransaction();
            DataTable     dt = db.GetDataView("SELECT DISTINCT Gestion from EventosDeportivo");

            return(dt);
        }
Exemplo n.º 9
0
        public static DataTable GetDeportesEvento(int eventoId)
        {
            DBTransaction db = new DBTransaction();
            DataTable     dt = db.GetDataView(string.Format("SELECT EventoDeportivoId, DisciplinaId, Nombre, Color, DependienteId from vGetDeportesEvento WHERE EventoDeportivoId = {0}", eventoId));

            return(dt);
        }
Exemplo n.º 10
0
        public async Task editWelcomeMessage(string choice, [Remainder] string msg)
        {
            int affectedRows = 0;

            if (choice == "welcome")
            {
                affectedRows = DBTransaction.setWelcomeMessage(Context.Guild.Id, msg);
                if (affectedRows == 1)
                {
                    await ReplyAsync("Changed welcome message!");
                }
                else
                {
                    await ReplyAsync("No message was changed, try running ~wm setup!");
                }
                return;
            }
            else if (choice == "confirmation")
            {
                affectedRows = DBTransaction.setConfirmationMessage(Context.Guild.Id, msg);
                if (affectedRows == 1)
                {
                    await ReplyAsync("Changed confirmation message!");
                }
                else
                {
                    await ReplyAsync("No message was changed, try running ~wm setup!");
                }
                return;
            }

            await ReplyAsync("Invalid choice! Choose to edit the **welcome** or **confirmation** message!");

            return;
        }
Exemplo n.º 11
0
        public async Task e621SearchSort(int sort, [Remainder] string srch)
        {
            await Context.Channel.TriggerTypingAsync();

            if (srch.Contains("loli") || srch.Contains("foalcon") || srch.Contains("cub"))
            {
                await ReplyAsync("Those search terms(loli, foalcon, or cub) are not allowed! Try again!");

                return;
            }
            //if sort integer is too small or big, give help
            if (sort - 1 > sortingOptions.Length || sort < 0)
            {
                await ReplyAsync("Sorting integers are: \n```0:Default, newest to oldest. \n1:Oldest to newest. \n2:Score. \n3:FavCount. \n4:Random.```" +
                                 "\nManual sorting can be done by using this chart https://e621.net/help/show/cheatsheet#sorting and inserting it into a search as a tag. " +
                                 "\nEx: Overriding default search order with mpixels order.```~e order:mpixels horse```");

                return;
            }
            //url for use, explicit images and inserts provided tags straight in.
            string url;

            //if channel is not on the explicit channels list,
            if (!DBTransaction.isChannelWhitelisted(Context.Channel.Id) && !Context.IsPrivate)
            {
                url = $"https://e621.net/posts.json?tags=order:{sortingOptions[sort]}+{srch}+rating:s&limit=50";
            }
            else
            {
                url = $"https://e621.net/posts.json?tags=order:{sortingOptions[sort]}+{srch}+-cub+-loli+-foalcon&limit=50";
            }
            string respond = e621.getJSON(url).Result;

            if (respond == "failure")
            {
                await ReplyAsync("An error occurred! " + url);

                return;
            }
            ImageList responseList = JsonConvert.DeserializeObject <ImageRoot>(respond).posts;

            if (responseList.Count == 0)
            {
                await ReplyAsync("No results! The tag may be misspelled, or the results could be filtered out due to channel!");
            }
            else
            {
                Global.e621Searches[Context.Channel.Id] = respond;
                Random rand = new Random();
                Global.e621SearchIndex[Context.Channel.Id] = rand.Next(0, responseList.Count);
                e621.Post       chosenImage = responseList[Global.e621SearchIndex[Context.Channel.Id]];
                RestUserMessage msg         = await Context.Channel.SendMessageAsync(chosenImage.file.url + "\n" + string.Join(",", chosenImage.tags.artist));

                await msg.AddReactionAsync(new Emoji("▶"));

                //set random info for running ~enext through emoji reactions.
                Global.e621Context[Context.Channel.Id]        = Context;
                Global.e621MessageToTrack[Context.Channel.Id] = msg.Id;
            }
        }
Exemplo n.º 12
0
        public static DataTable getNombrePersona(int PersonaId)
        {
            DBTransaction db    = new DBTransaction();
            var           tabla = db.GetDataFuncion(string.Format("select * from conj.fGetNombrePersona({0})", PersonaId));

            return(tabla);
        }
Exemplo n.º 13
0
        public static List <Grupo> GetGruposEquipos(int deporteId, int ramaId, int eventoId, int faseId)
        {
            List <Grupo>        lg = new List <Grupo>();
            List <SqlParameter> lp = new List <SqlParameter>();

            lp.Add(new SqlParameter("DeporteId", deporteId));
            lp.Add(new SqlParameter("RamaId", ramaId));
            lp.Add(new SqlParameter("EventoId", eventoId));
            lp.Add(new SqlParameter("FaseId", faseId));
            DataTable dt = ExecuteTransaction("[conj].[pGetGruposEvento]", lp);

            foreach (DataRow dr in dt.Rows)
            {
                Grupo gr = new Grupo();
                gr = gr.ConvertToGrupo(dr);
                DBTransaction db  = new DBTransaction();
                DataTable     dt1 = db.GetDataView(String.Format("[prog].[fGetEquiposGrupo] ({0})", gr.GrupoId));
                gr.GrupoEquipos = new List <GrupoEquipo>();
                foreach (DataRow dr1 in dt1.Rows)
                {
                    GrupoEquipo ge = new GrupoEquipo();
                    ge = GrupoEquipo.ConvertToGrupoEquipo(dr1);
                    gr.GrupoEquipos.Add(ge);
                }
                lg.Add(gr);
            }
            return(lg);
        }
Exemplo n.º 14
0
        public static DataTable GetGruposEvento(int pruebaEventoId)
        {
            DBTransaction db = new DBTransaction();
            var           dt = db.GetDataView($"[prog].[fGetGruposPruebasEvento] ({pruebaEventoId})");

            return(dt);
        }
Exemplo n.º 15
0
        private async Task Client_ReactionRemoved(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel chan, SocketReaction reaction)
        {
            //for role removal after user unclicks a reaction.
            ulong reactionRole = DBTransaction.reactionRoleExists(reaction.MessageId, reaction.Emote.ToString());

            if (reactionRole != 0)
            {
                var message = await cache.DownloadAsync();

                //get guild to find role!
                var chnl         = message.Channel as SocketGuildChannel;
                var reactionUser = reaction.User.Value as IGuildUser;
                Console.WriteLine("Removing role from " + reaction.User.Value.Username + "!");
                try
                {
                    await reactionUser.RemoveRoleAsync(chnl.Guild.GetRole(reactionRole));
                }
                catch
                {
                    await reactionUser.SendMessageAsync("Sorry, something went wrong, I am either unable to modify roles or the chosen role is above me in settings. Contact an admin or Hoovier#4192 for assistance!");

                    return;
                }
                await reactionUser.SendMessageAsync("Hi " + reactionUser.Username + "! I removed the " + chnl.Guild.GetRole(reactionRole).Name + " role!");
            }
        }
Exemplo n.º 16
0
        private bool Insert()
        {
            DBTransaction       db = new DBTransaction();
            List <SqlParameter> ps = LoadParameters();

            return(ExecuteTransaction("[golf].[pNuevaCategoria]", ps));
        }
Exemplo n.º 17
0
        public static List <Ticket> GetTickets()
        {
            int           x   = -1;
            List <Ticket> lcp = new List <Ticket>();
            DBTransaction db  = new DBTransaction();
            DataTable     dt  = db.GetDataView("erp.vTicket");

            foreach (DataRow dr in dt.Rows)
            {
                Ticket cp = ConvertToTicket(dr);
                if (cp.estado == "False" && (cp.fecha.CompareTo(DateTime.Now.ToShortDateString())) == 1)
                {
                    lcp.Add(cp);
                    x++;
                }
            }
            if (x == -1)
            {
                return(null);
            }
            else
            {
                return(lcp);
            }
        }
        public async Task <bool> UpdateTransaction(Guid guid, decimal sum, string currency, DateTime dateTime, string description, Guid userId, Guid walletId)
        {
            DBTransaction wallet = new DBTransaction(guid, sum, currency, dateTime, description, userId, walletId);
            await _storage.AddOrUpdateAsync(wallet);

            return(true);
        }
Exemplo n.º 19
0
        public async Task addWitty(string name, string match, double probability, params String[] responses)
        {
            //Makes sure probability, when multiplied by 100, will be valid.
            //EX. .40 * 100 = 40% chance of happening.
            if (probability > 1.0 || probability < 0.0)
            {
                await ReplyAsync("Pick a probability between 1.0 and 0");

                return;
            }
            try
            {
                string dbResponse = DBTransaction.addWitty(name, match, Context.Guild.Id, probability, responses.ToList());
                await ReplyAsync(dbResponse);
            }
            catch (SQLiteException ex)
            {
                switch (ex.ErrorCode)
                {
                case 19:
                    Console.WriteLine("Attempted to add Witty, server already had one witty with that name! Server: " + Context.Guild.Name);
                    await ReplyAsync("You already have a witty with that name!");

                    break;

                default:
                    Console.WriteLine("SQL Error: " + ex.Message + "\nErrorNum:" + ex.ErrorCode);
                    await ReplyAsync("Something went wrong, contact Hoovier with error code: " + ex.ErrorCode);

                    break;
                }
            }
        }
Exemplo n.º 20
0
        public async Task parsequote(SocketGuildUser user, [Remainder] string quotes)
        {
            if (!checkUserPermission((SocketGuildUser)Context.User))
            {
                await ReplyAsync("You are not allowed to do that! Have an admin give you permission by using ```~authorize <User>```");

                return;
            }

            int    counter = 0;
            string response = " Responses Added: \n", currString;

            string[] chosen = quotes.Split("\n");
            //look for a number and a "." I.E ("26." or "5.")
            Regex rx = new Regex(@"\d+\.", RegexOptions.Compiled | RegexOptions.IgnoreCase);

            foreach (string res in chosen)
            {
                MatchCollection matches = rx.Matches(res);
                if (matches.Count > 0)
                {
                    counter++;
                    //delete the number and . from quote and then stick it into DB
                    currString = res.Replace(matches[0].Groups[0].Value, "");
                    DBTransaction.addQuote(user.Id, currString, Context.Guild.Id);
                    response = response + currString + "\n";
                }
            }
            await ReplyAsync(counter + response);
        }
Exemplo n.º 21
0
        private bool Insert()
        {
            DBTransaction       db = new DBTransaction();
            List <SqlParameter> ps = LoadParameters();

            return(ExecuteTransaction("[indv].[pInsCronogramaCompetidor]", ps));
        }
Exemplo n.º 22
0
        public async Task <ActionResult <T> > UndoLog([FromRoute] long logId)
        {
            var user    = CurrentUser;
            var logItem = (DBLogItem)table.LogTable.LoadItemById(logId);

            if (logItem == null)
            {
                return(BadRequest($"Not Found!"));
            }

            if (!table.Access.GetFlag(AccessType.Update, user))
            {
                return(Forbid());
            }
            using (var transaction = new DBTransaction(table.Connection, user))
            {
                try
                {
                    var data = (T)await logItem.Undo(transaction);

                    transaction.Commit();
                    return(data);
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    return(BadRequest(ex));
                }
            }
        }
Exemplo n.º 23
0
        public async void AddNewTransaction()
        {
            try
            {
                IsWalletPanelEnabled = false;
                DBTransaction tr = new DBTransaction(Guid.NewGuid(), 0m, "UAH", DateTime.Now, "default", Guid.NewGuid(), _currentWallet.Guid);
                await _serviceTransaction.AddTransactionAsync(tr);

                Transactions.Add(new TransactionDetailsViewModel(tr, _serviceTransaction, _serviceWallet, _currentWallet, DeleteCurrentTransaction));

                _currentWallet.AddTransaction(_currentUser.Guid, tr);
                await _serviceWallet.UpdateWallet(_currentWallet.Guid.ToString(), _currentWallet.Name, _currentWallet.Balance, _currentWallet.Currency, _currentWallet.Owner, _currentWallet.Description, _currentWallet.Transactions);

                RaisePropertyChanged(nameof(Transactions));
                RaisePropertyChanged(nameof(CurrentWallet));
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Transaction add was failed: {ex.Message}");
                return;
            }
            finally
            {
                IsWalletPanelEnabled = true;
            }
            MessageBox.Show($"Transaction was added successfully!");
        }
Exemplo n.º 24
0
        public static DataTable GetInscripcionEvento(int EventoId)
        {
            DBTransaction db = new DBTransaction();
            DataTable     dt = db.GetDataView(string.Format("[acre].[vAcreditacionDetallePersona] where [EventoId]= {0}", EventoId));

            return(dt);
        }
Exemplo n.º 25
0
        public async Task buyStonk(string stonk, int amount)
        {
            stonk = stonk.ToUpper();
            //0 = MaxNumOfShares
            //1 = stonkPrice
            //2 = OwnedShares
            List <int> stonkInfo = DBTransaction.getMaxShares(stonk, Context.Guild.Id);
            long       balance   = long.Parse(DBTransaction.getMoneyBalance(Context.User.Id, Context.Guild.Id));

            if (stonkInfo.Count == 0)
            {
                await ReplyAsync("Sorry, there is no stock with that name on the market right now!");
            }
            else if (stonkInfo[2] + amount > stonkInfo[0])
            {
                await ReplyAsync("Sorry! Not enough stonks to complete your purchase!");
            }
            else if (stonkInfo[1] * amount > balance)
            {
                await ReplyAsync("Sorry! You don't have enough Bits for this. The price for " + amount + " shares of this stonk is " + stonkInfo[1] *amount);
            }
            else
            {
                DateTime localDate  = DateTime.Now;
                string   dateString = localDate.ToString("yyyy-MM-dd.HH:mm:ss");
                DBTransaction.addStonkPurchase(stonk, amount, Context.User.Id, Context.Guild.Id, dateString);
                long totalPrice = stonkInfo[1] * amount;
                DBTransaction.payMoney(Context.User.Id, -totalPrice, Context.Guild.Id);
                await ReplyAsync("Stonks purchased! Your new balance is " + (balance - (stonkInfo[1] * amount)) + " Bits!");
            }
        }
Exemplo n.º 26
0
        private DataTable ExecuteTransaction(string procedureName, List <SqlParameter> ps)
        {
            DBTransaction db = new DBTransaction();
            DataTable     dt = db.GetStoreProcedure(procedureName, ps);

            return(dt);
        }
Exemplo n.º 27
0
        public static DataTable GetDetalleAcreditacionPersona(int PersonaId)
        {
            DBTransaction db = new DBTransaction();
            DataTable     dt = db.GetDataView(string.Format("[acre].[vAcreditacionDetallePersona] where [PersonaId]= {0}", PersonaId));

            return(dt);
        }
Exemplo n.º 28
0
        public static DataTable GetGolfCompetidorByPersonaId(int personaId)
        {
            DBTransaction db = new DBTransaction();
            DataTable     dt = db.GetDataView(string.Format("[golf].[vPersonas] where [PersonaId] = {0}", personaId));

            return(dt);
        }
Exemplo n.º 29
0
        /// <summary>
        /// 命令执行
        /// </summary>
        public override void Execute(DBTransaction tran)
        {
            IRepository <T> r = RepositoryFactory <T> .CreateRepository(tran);

            if (keys != null && keys.Length > 0)//按主键
            {
                Result = r.FindByPK(keys);
            }
            else if (!String.IsNullOrEmpty(conditionSql))
            {
                Result = r.FindByCustom("*", conditionSql);
            }
            else
            {
                if (pageSize <= 0 || pageIndex <= 0)
                {
                    if (!String.IsNullOrEmpty(fields))
                    {
                        Result = r.FindByCustom(fields, conditions);
                    }
                    else
                    {
                        Result = r.FindByCondition(conditions);//List<T>
                    }
                }
                else
                {
                    Result = r.FindPager(pageSize, pageIndex, conditions);//Paper<T>
                }
            }
        }
Exemplo n.º 30
0
        public async Task redditInfo()
        {
            await Context.Channel.TriggerTypingAsync();

            if (!Global.redditDictionary.ContainsKey(Context.Channel.Id))
            {
                await ReplyAsync("Try running a reddit search using ~reddit <subreddit> <hot/new/top> first!");

                return;
            }
            Post chosen = Global.redditDictionary[Context.Channel.Id].getChosenPost();

            //if result is nsfw, and channel is not whitelisted, AND its not a DM, tell them and dont post anything.
            if (chosen.NSFW && !DBTransaction.isChannelWhitelisted(Context.Channel.Id) && !Context.IsPrivate)
            {
                await ReplyAsync("This result is NSFW, and this channel is not whitelisted! Try making another search or going to the next result using ~rnext");

                return;
            }
            //grab random information about post and format it for user.
            string response = "**" + chosen.Title + "** \nPoster: " + chosen.Author + "\nUpvotes: "
                              + chosen.Score + " Comments: " + chosen.Listing.NumComments + "\nhttps://www.reddit.com" + chosen.Permalink;

            await ReplyAsync(response);
        }
Exemplo n.º 31
0
        /// <summary>
        /// Create a new BulkInsert.
        /// </summary>
        /// <param name="myGraphDBSession">The DB Reference</param>
        /// <param name="myGraphFSSession">The FS reference</param>
        /// <param name="myType">The type of the ne DBObjects</param>
        public BulkInsert(IGraphDBSession myGraphDBSession, IGraphFSSession myGraphFSSession, String myType)
        {
            _GraphDBSession = myGraphDBSession;
            _GraphFSSession = myGraphFSSession;

            (_GraphFSSession.SessionToken.SessionInfo as FSSessionInfo).FSSettings.ReflushAllocationMap = false;

            _DBTransaction = _GraphDBSession.BeginTransaction(myLongRunning: true, myIsolationLevel: IsolationLevel.Serializable);
            _Type = ((DBContext)_DBTransaction.GetDBContext()).DBTypeManager.GetTypeByName(myType);
        }
Exemplo n.º 32
0
        /// <summary>
        /// Create a new BulkInsert.
        /// </summary>
        /// <param name="myGraphDBSession">The DB Reference</param>
        /// <param name="myGraphFSSession">The FS reference</param>
        /// <param name="myType">The type of the ne DBObjects</param>
        public BulkInsert(IGraphDBSession myGraphDBSession, IGraphFSSession myGraphFSSession, GraphDBType myType)
        {
            _GraphDBSession = myGraphDBSession;
            _GraphFSSession = myGraphFSSession;

            _Type = myType;

            (_GraphFSSession.SessionToken.SessionInfo as FSSessionInfo).FSSettings.ReflushAllocationMap = false;

            _DBTransaction = _GraphDBSession.BeginTransaction(myLongRunning: true, myIsolationLevel: IsolationLevel.Serializable);
        }