/// <summary>
        /// 
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        public void dataBind(int pageIndex = 1, int pageSize = 10, string startTime = null, string endTime = null)
        {
            PetaPoco.Sql sql = new PetaPoco.Sql();
            sql.Select("m.[description] as name,a.*").From("t_MachineStop_rd a");
            sql.LeftJoin("Point_Machine_Map m").On("m.pointname=a.pointname");
            if (!String.IsNullOrEmpty(startTime))
            {
                sql.Where("a.starttime>@0", startTime);
            }
            if (!String.IsNullOrEmpty(endTime))
            {
                sql.Where("a.starttime<@0", endTime);
            }
            List<int> machineids = new List<int>();
            for (int i = 0; i < chkboxlist.Items.Count; i++)
            {
                if (chkboxlist.Items[i].Selected)
                {
                    machineids.Add(int.Parse(chkboxlist.Items[i].Value));
                }
            }
            if (machineids.Count > 1)
                sql.Where("m.machineid in (@0)", machineids);
            else if (machineids.Count == 1)
                sql.Where("m.machineid=@0", machineids[0]);

            sql.OrderBy("a.starttime desc");

            var db = new PetaPoco.Database("dbconn");
            PetaPoco.Page<BootRecordSelect> pageitems = db.Page<BootRecordSelect>(pageIndex, pageSize, sql);
            rpt_RulelogS_Des.DataSource = pageitems.Items;
            rpt_RulelogS_Des.DataBind();
            AspNetPager1.RecordCount = (int)pageitems.TotalItems;
        }
Beispiel #2
0
        void HandleListIdlersCommand(string msg, SteamID sender)
        {
#if DATABASE
            var    sql   = new PetaPoco.Sql().Select("*").From("idle_account");
            string order = "id";

            string[] args = msg.Split(' ');
            if (args.Length == 2)
            {
                if (args[1].StartsWith("w"))
                {
                    order = "weapon_count";
                }
                else if (args[1].StartsWith("i"))
                {
                    order = "item_count";
                }
                else if (args[1].StartsWith("h"))
                {
                    order = "hat_count";
                }
                else if (args[1].StartsWith("t"))
                {
                    order = "weapon_count";
                }
                else if (args[1].StartsWith("c"))
                {
                    order = "crate_count";
                }
            }

            sql = sql.OrderBy(order);

            var accounts = Database.Query <IdleAccount>(sql);

            var sb = new StringBuilder();
            sb.AppendLine("Idlers:");

            foreach (var account in accounts)
            {
                sb.AppendLine(string.Format("{0} {1} | {2} weapons",
                                            account.id, account.username, account.weapon_count));
            }

            SteamFriends.SendChatMessage(sender, EChatEntryType.ChatMsg,
                                         sb.ToString());
#else
            SteamFriends.SendChatMessage(sender, EChatEntryType.ChatMsg,
                                         "No database support in this build.");
#endif
        }
        public List <Todo> GetFilteredTodosPage(string page, string count, [FromBody] Todo filter)
        {
            using (var db = GetDb())
            {
                int pageIndex = Int32.Parse(page);
                int itemCount = Int32.Parse(count);

                PetaPoco.Sql sql = new PetaPoco.Sql("SELECT * FROM Todos");

                if (filter.userid != null)
                {
                    sql.Append("WHERE userid=@0", filter.userid);
                }

                if (filter.modified != null)
                {
                    sql.Append("WHERE modified >= @0", filter.modified);
                }

                if (filter.completed != null)
                {
                    sql.Append("WHERE completed=@0", filter.completed);
                }

                if (filter.urgent != null)
                {
                    sql.Append("WHERE urgent=@0", filter.urgent);
                }

                if (filter.title != null)
                {
                    sql.Append("WHERE title like @0", "%" + filter.title + "%");
                }

                if (filter.tags != null)
                {
                    sql.Append("WHERE tags like @0", "%" + filter.tags + "%");
                }

                if (filter.content != null)
                {
                    sql.Append("WHERE content like @0", "%" + filter.content + "%");
                }

                sql.OrderBy("modified DESC");

                return(db.Fetch <Todo>(pageIndex, itemCount, sql.SQL, sql.Arguments));
            }
        }