Пример #1
0
        public object Any(DCSInfRequest request)
        {
            DTOResponseLayUI dtoResponseLayUi = new DTOResponseLayUI();
            DCSInfService    dcsInfService    = new DCSInfService();
            DTOResponse      list;

            if (request.ACTION == 101)
            {
                list = dcsInfService.GetList <INF_EQUIPMENTREQUESTEntity>(request);
            }
            else if (request.ACTION == 102)
            {
                list = dcsInfService.GetList <INF_JOBDOWNLOADEntity>(request);
            }
            else if (request.ACTION == 103)
            {
                list = dcsInfService.GetList <INF_JOBFEEDBACKEntity>(request);
            }
            else if (request.ACTION == 104)
            {
                list = dcsInfService.GetList <INF_EQUIPMENTSTATUSEntity>(request);
            }
            else
            {
                dtoResponseLayUi.code = -1;
                dtoResponseLayUi.msg  = "未定义的操作类型:" + request.ACTION.ToString();
                return(dtoResponseLayUi);
            }
            return(this.ConvertTo(list));
        }
Пример #2
0
        public DTOResponse GetList <T>(DCSInfRequest request)
        {
            DTOResponse dtoResponse = new DTOResponse();

            try
            {
                using (IDbConnection dbConn = HelperConnection.GetConnectionFactory().OpenDbConnection())
                {
                    string str1 = typeof(T).Name.Replace("Entity", "");
                    string str2 = "SELECT * FROM " + str1;
                    string str3 = " WHERE 1=1";
                    if (!string.IsNullOrEmpty(request.EQUIPMENTID) && str1 != "INF_JOBFEEDBACK")
                    {
                        str3 += string.Format(" AND EQUIPMENTID='{0}'", (object)request.EQUIPMENTID);
                    }
                    if (!string.IsNullOrEmpty(request.STATUS))
                    {
                        str3 += string.Format(" AND STATUS={0}", (object)request.STATUS);
                    }
                    if (!string.IsNullOrEmpty(request.JOBID))
                    {
                        str3 += string.Format(" AND JOBID='{0}'", (object)request.JOBID);
                    }
                    if (!string.IsNullOrEmpty(request.CREATEDATE))
                    {
                        DateTime dt1;
                        if (DateTime.TryParse(request.CREATEDATE, out dt1))
                        {
                            str3 += string.Format(" AND CREATEDATE LIKE '{0}%'", dt1.ToString("yyyy-MM-dd"));
                        }
                        else
                        {
                            dt1   = System.DateTime.Today;
                            str3 += string.Format(" AND CREATEDATE LIKE '{0}%'", dt1.ToString("yyyy-MM-dd"));
                        }
                    }

                    string str4 = " ORDER BY AUTOID DESC,CREATEDATE DESC";
                    long   num  = dbConn.Count <T>();
                    string sql  = str2 + str3 + str4;
                    DCSInfService.logger.Debug((object)sql);
                    List <T> list = Enumerable.ToList <T>(Enumerable.Take <T>(Enumerable.Skip <T>(dbConn.Select <T>(sql), (request.page - 1) * request.limit), request.limit));
                    dtoResponse.TotalCount   = num;
                    dtoResponse.ResultObject = (object)list;
                    dtoResponse.IsSuccess    = true;
                    dtoResponse.MessageText  = "查询操作成功!";
                    return(dtoResponse);
                }
            }
            catch (Exception ex)
            {
                dtoResponse.IsSuccess   = false;
                dtoResponse.MessageText = ex.Message;
                DCSInfService.logger.Error((object)ex);
                return(dtoResponse);
            }
        }