Пример #1
0
 // 이미지 비교
 public static int imgComp(Bitmap A, statusList b)
 {
     using (Bitmap B = new Bitmap(b.imgName))
     {
         for (int i = 0; i < A.Width; i++)
         {
             for (int j = 0; j < B.Height; j++)
             {
                 if (A.GetPixel(i, j).ToString() != B.GetPixel(i, j).ToString())
                 {
                     return(0);
                 }
             }
         }
     }
     return(1);
 }
Пример #2
0
            public async Task <List> updateStatus(long idList, statusList statusList)
            {
                var updateList = await _db.Lists.FirstOrDefaultAsync(a => a.idList == idList);

                if (updateList == null)
                {
                    return(null);
                }

                updateList.statusList = statusList == statusList.Undefined ? updateList.statusList : statusList;

                updateList.updated = DateTime.Now;

                await _db.SaveChangesAsync();

                return(updateList);
            }
Пример #3
0
        public List <statusList> GetStatus() //Get a list of all the application
        {
            List <statusList> status = new List <statusList>();

            using (SqlConnection connection = DB.GetSqlConnection())
            {
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandText = @"getStatus"; // stored procedure name
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read()) //store each line from procedure into the list
                    {
                        statusList s = new statusList();
                        s.Load(reader);
                        status.Add(s);
                    }
                }
            }
            return(status);
        }
Пример #4
0
            public async Task <List <List> > getAll(int page = 1, int size = 10, string key = "", string order = "updated", bool ascending = false, statusList statusList = statusList.Active)
            {
                var q = _db.Lists
                        .Where(a => a.idList == a.idList);

                if (!string.IsNullOrEmpty(key))
                {
                    q = q.Where(a =>
                                a.nameList.Contains(key)
                                );
                }
                if (statusList != statusList.Undefined)
                {
                    q = q.Where(a => a.statusList == statusList);
                }
                switch (order)
                {
                case "idList": if (ascending)
                    {
                        q = q.OrderBy(d => d.idList);
                    }
                    else
                    {
                        q = q.OrderByDescending(d => d.idList);
                    } break;

                case "nameList": if (ascending)
                    {
                        q = q.OrderBy(d => d.nameList);
                    }
                    else
                    {
                        q = q.OrderByDescending(d => d.nameList);
                    } break;

                case "created": if (ascending)
                    {
                        q = q.OrderBy(d => d.created);
                    }
                    else
                    {
                        q = q.OrderByDescending(d => d.created);
                    } break;

                case "updated": if (ascending)
                    {
                        q = q.OrderBy(d => d.updated);
                    }
                    else
                    {
                        q = q.OrderByDescending(d => d.updated);
                    } break;
                }

                if (size == -1)
                {
                    return(await q
                           .ToListAsync());
                }
                else
                {
                    return(await q
                           .Skip(size *(page - 1))
                           .Take(size)
                           .ToListAsync());
                }
            }
Пример #5
0
            public async Task <int> getAllCount(string key = "", string order = "updated", bool ascending = false, statusList statusList = statusList.Undefined)
            {
                var q = _db.Lists
                        .Where(a => a.idList == a.idList);

                if (!string.IsNullOrEmpty(key))
                {
                    q = q.Where(a =>
                                a.nameList.Contains(key)
                                );
                }
                if (statusList != statusList.Undefined)
                {
                    q = q.Where(a => a.statusList == statusList);
                }
                switch (order)
                {
                case "idList": if (ascending)
                    {
                        q = q.OrderBy(d => d.idList);
                    }
                    else
                    {
                        q = q.OrderByDescending(d => d.idList);
                    } break;

                case "nameList": if (ascending)
                    {
                        q = q.OrderBy(d => d.nameList);
                    }
                    else
                    {
                        q = q.OrderByDescending(d => d.nameList);
                    } break;

                case "created": if (ascending)
                    {
                        q = q.OrderBy(d => d.created);
                    }
                    else
                    {
                        q = q.OrderByDescending(d => d.created);
                    } break;

                case "updated": if (ascending)
                    {
                        q = q.OrderBy(d => d.updated);
                    }
                    else
                    {
                        q = q.OrderByDescending(d => d.updated);
                    } break;
                }

                return(await q
                       .CountAsync());
            }
        public async Task <IActionResult> get([FromQuery] string key, [FromQuery] string order, [FromQuery] bool?ascending = false, [FromQuery] int?page = 1, [FromQuery] int?size = 10, [FromQuery] statusList statusList = statusList.Active)
        {
            var lists = await _listQ.getAll(key : key, order : order, ascending : (bool)ascending, page : (int)page, size : (int)size, statusList : statusList);

            var listcount = await _listQ.getAllCount(key : key, order : order, ascending : (bool)ascending, statusList : statusList);

            return(TempRes.result(200, Request.GetDisplayUrl(), lists, null, listcount));
        }