Пример #1
0
 public commonresponse getScrapDoneList(string startdate = "2000-1-1", string enddate = "2222-2-2",
                                        CarType carType  = CarType.unknown,
                                        int startnum     = 1, int endnum = -1)
 {
     try
     {
         var token      = Request.Headers["Token"].First();
         var found      = false;
         var scrapplace = ScrapPlace.unknown;
         foreach (var a in tokens)
         {
             if (a.Token == token)
             {
                 scrapplace = a.scrapPlace;
                 found      = true;
                 break;
             }
         }
         _log.LogInformation("DeleteScrap,{0},,", 111);
         if (!found)
         {
             _log.LogInformation("DeleteScrap,{0}", responseStatus.tokenerror);
             return(new commonresponse
             {
                 status = responseStatus.tokenerror
             });
         }
         var start = DateTime.Now;
         if (string.IsNullOrEmpty(startdate) || !DateTime.TryParse(startdate, out start))
         {
             return(new commonresponse {
                 status = responseStatus.startdateerror, content = responseStatus.startdateerror.ToString()
             });
         }
         var end = DateTime.Now;
         if (string.IsNullOrEmpty(enddate) || !DateTime.TryParse(enddate, out end))
         {
             return(new commonresponse {
                 status = responseStatus.enddateerror, content = responseStatus.enddateerror.ToString()
             });
         }
         var scraps = new List <Scrap>();
         var count  = 0;
         using (var db = new carsContext())
         {
             var ss = db.Carbusinesshis.Where(a => a.Businesstype == (short)businessType.scrap &&
                                              a.Time.CompareTo(start) >= 0 &&
                                              a.Time.CompareTo(end) <= 0 &&
                                              a.Scrapplace == (short)scrapplace
                                              // && a.Cartype==(short)carType
                                              );
             if (carType != CarType.unknown)
             {
                 ss = ss.Where(c => c.Cartype == (short)carType);
             }
             count = ss.Count();
             if (endnum != -1)
             {
                 ss = ss.Take(endnum);
             }
             ss = ss.Skip(startnum - 1);
             //  var index = 1;
             foreach (var s in ss)
             {
                 //  if (index++ < startnum) continue;
                 var user = db.Caruser.FirstOrDefault(a => a.Identity == s.Identity);
                 if (user == null)
                 {
                     continue;
                 }
                 scraps.Add(new Scrap
                 {
                     id      = CryptographyHelpers.StudyDecrypt(s.Identity),
                     name    = user.Name,
                     phone   = user.Phone,
                     address = s.Postaddr,
                     cartype = (CarType)s.Cartype,
                     time    = s.Time,
                 });
             }
         }
         Task.Run(() => highlevel.LogRequest("getScrapDoneList",
                                             "getScrapDoneList", Request.HttpContext.Connection.RemoteIpAddress.ToString(), 0));
         return(new ScrapListRes {
             status = responseStatus.ok, scraps = scraps, count = count
         });
     }
     catch (Exception ex)
     {
         _log.LogError("{0}-{1}-{2}", DateTime.Now, "getScrapDoneList", ex.Message);
         return(new commonresponse {
             status = responseStatus.processerror, content = ex.Message
         });
     }
 }
Пример #2
0
        public commonresponse getScrapTodoList()
        {
            try
            {
                var token      = Request.Headers["Token"].First();
                var found      = false;
                var scrapplace = ScrapPlace.unknown;
                foreach (var a in tokens)
                {
                    if (a.Token == token)
                    {
                        scrapplace = a.scrapPlace;
                        found      = true;
                        break;
                    }
                }
                _log.LogInformation("DeleteScrap,{0},,", 111);
                if (!found)
                {
                    _log.LogInformation("DeleteScrap,{0}", responseStatus.tokenerror);
                    return(new commonresponse
                    {
                        status = responseStatus.tokenerror
                    });
                }
                var scraps = new List <Scrap>();
                using (var db = new carsContext())
                {
                    var ss = db.Carbusiness.Where(a => a.Businesstype == (short)businessType.scrap &&
                                                  a.Scrapplace == (short)scrapplace
                                                  );

                    foreach (var s in ss)
                    {
                        var user = db.Caruser.FirstOrDefault(a => a.Identity == s.Identity);
                        if (user == null)
                        {
                            continue;
                        }
                        scraps.Add(new Scrap
                        {
                            id      = CryptographyHelpers.StudyDecrypt(s.Identity),
                            name    = user.Name,
                            phone   = user.Phone,
                            address = s.Postaddr,
                            cartype = (CarType)s.Cartype,
                            time    = s.Time,
                        });
                    }
                }
                Task.Run(() => highlevel.LogRequest("getScrapTodoList",
                                                    "getScrapTodoList", Request.HttpContext.Connection.RemoteIpAddress.ToString(), 0));
                return(new ScrapListRes {
                    status = responseStatus.ok, scraps = scraps
                });
            }
            catch (Exception ex)
            {
                _log.LogError("{0}-{1}-{2}", DateTime.Now, "getScrapTodoList", ex.Message);
                return(new commonresponse {
                    status = responseStatus.processerror, content = ex.Message
                });
            }
        }