public async Task <MethodReturnResult <DataSet> > GetDataAsync(DataAcquisitionTransGetParameter p)
 {
     return(await Task.Run <MethodReturnResult <DataSet> >(() =>
     {
         return base.Channel.GetData(ref p);
     }));
 }
Beispiel #2
0
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            MethodReturnResult result          = new MethodReturnResult();
            DataAcquisitionTransGetParameter p = new DataAcquisitionTransGetParameter();

            try
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;

                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }

                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                //初始化参数
                //p.StartDate = GetValueDataByString(where, "StartDate", "=", ";");              //开始日期
                //p.EndDate = GetValueDataByString(where, "EndDate", "=", ";");                  //结束日期
                p.ItemCode      = GetValueDataByString(where, "ItemCode", "=", ";");           //项目代码
                p.LocationName  = GetValueDataByString(where, "LocationName", "=", ";");       //车间
                p.LineCode      = GetValueDataByString(where, "LineCode", "=", ";");           //线别
                p.EquipmentCode = GetValueDataByString(where, "EquipmentCode", "=", ";");      //设备代码
                p.PageSize      = pageSize;
                p.PageNo        = pageNo + 1;

                await Task.Run(() =>
                {
                    using (DataAcquisitionTransServiceClient client = new DataAcquisitionTransServiceClient())
                    {
                        DataTable dt = new DataTable();                     //采集结果集

                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };

                        MethodReturnResult <DataSet> rst = client.GetData(ref p);

                        if (rst.Code > 0)               //产生错误
                        {
                            result.Code    = rst.Code;
                            result.Message = rst.Message;
                            result.Detail  = rst.Detail;

                            //return result;
                        }
                        else
                        {
                            cfg.Records = p.Records;    //总记录数

                            //根据报表格式及数据清单组合数据列表
                            result = CreateTableList(rst, ref dt);

                            if (result.Code > 0)       //产生错误
                            {
                                //return Json(result);
                            }
                        }

                        ViewBag.PagingConfig = cfg;
                        ViewBag.ListData     = dt;
                    }
                });

                return(PartialView("_ListPartial"));
            }
            catch (Exception e)
            {
                result.Code    = 1002;
                result.Message = e.Message;
                result.Detail  = e.ToString();
            }

            return(Json(result));
        }
Beispiel #3
0
        public ActionResult Query(DataAcquisitionTransQueryViewModel model)
        {
            MethodReturnResult result          = new MethodReturnResult();
            DataAcquisitionTransGetParameter p = new DataAcquisitionTransGetParameter();

            try
            {
                #region 取得数据
                DataTable    dt  = new DataTable();                 //采集结果集
                PagingConfig cfg = new PagingConfig()
                {
                    OrderBy = "",
                    Where   = ""
                };

                using (DataAcquisitionTransServiceClient client = new DataAcquisitionTransServiceClient())
                {
                    //初始化参数
                    p.EDCTime       = model.EDCTime;            //采集时间
                    p.ItemCode      = model.ItemCode;           //项目代码
                    p.LocationName  = model.LocationName;       //车间
                    p.LineCode      = model.LineCode;           //线别
                    p.EquipmentCode = model.EquipmentCode;      //设备代码
                    p.PageSize      = model.PageSize;
                    p.PageNo        = model.PageNo;

                    MethodReturnResult <DataSet> rst = client.GetData(ref p);

                    if (rst.Code > 0)                   //产生错误
                    {
                        result.Code    = rst.Code;
                        result.Message = rst.Message;
                        result.Detail  = rst.Detail;

                        return(Json(result));
                    }
                    else
                    {
                        ViewBag.FieldData = rst.Data.Tables[0];     //采集字段数据
                        cfg.Records       = p.Records;              //总记录数

                        //根据报表格式及数据清单组合数据列表
                        result = CreateTableList(rst, ref dt);

                        if (result.Code > 0)            //产生错误
                        {
                            return(Json(result));
                        }
                    }
                }
                #endregion

                //回传参数
                //创建Where条件
                cfg.Where = "?ItemCode=" + model.ItemCode + ";" +
                            "EDCTime=" + model.EDCTime + ";" +
                            "LocationName=" + model.LocationName + ";" +
                            "LineCode=" + model.LineCode + ";" +
                            "EquipmentCode=" + model.EquipmentCode;

                ViewBag.PagingConfig = cfg;
                ViewBag.ListData     = dt;

                if (Request.IsAjaxRequest())
                {
                    return(PartialView("_ListPartial", model));
                }
                else
                {
                    return(View(model));
                }
            }
            catch (Exception e)
            {
                result.Code    = 1002;
                result.Message = e.Message;
                result.Detail  = e.ToString();
            }

            return(Json(result));
        }
        /// <summary>
        /// 通过存储过程取得采集数据事务结果列表
        /// </summary>
        /// <param name="p">参数。</param>
        /// <returns>方法执行结果。</returns>
        public MethodReturnResult <DataSet> GetData(ref DataAcquisitionTransGetParameter p)
        {
            MethodReturnResult <DataSet> result = new MethodReturnResult <DataSet>();

            try
            {
                DataSet   dsResult = new DataSet();
                DataTable dt       = new DataTable();

                using (DbConnection con = this._db.CreateConnection())
                {
                    int       iReturn;
                    string    strErrorMessage = string.Empty;
                    DbCommand cmd             = con.CreateCommand();

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "sp_EDC_DataAcquisitionTrans_list";
                    this._db.AddInParameter(cmd, "EDCTime", DbType.DateTime, p.EDCTime);                                                        //采集时间
                    this._db.AddInParameter(cmd, "ItemCode", DbType.String, string.IsNullOrEmpty(p.ItemCode) ? "%" : p.ItemCode);               //项目代码
                    this._db.AddInParameter(cmd, "LocationName", DbType.String, string.IsNullOrEmpty(p.LocationName) ? "" : p.LocationName);    //车间
                    this._db.AddInParameter(cmd, "LineCode", DbType.String, string.IsNullOrEmpty(p.LineCode) ? "" : p.LineCode);                //线别
                    this._db.AddInParameter(cmd, "EquipmentCode", DbType.String, string.IsNullOrEmpty(p.EquipmentCode) ? "" : p.EquipmentCode); //设备代码

                    this._db.AddInParameter(cmd, "@pageSize", DbType.Int32, p.PageSize);                                                        //单页数据大小
                    this._db.AddInParameter(cmd, "@pageNo", DbType.Int32, p.PageNo);                                                            //页号
                    this._db.AddOutParameter(cmd, "@Records", DbType.Int32, int.MaxValue);                                                      //数据总记录数

                    //设置返回错误信息
                    cmd.Parameters.Add(new SqlParameter("@ErrorMsg", SqlDbType.NVarChar, 512));
                    cmd.Parameters["@ErrorMsg"].Direction = ParameterDirection.Output;

                    //设置返回值
                    SqlParameter parReturn = new SqlParameter("@return", SqlDbType.Int);
                    parReturn.Direction = ParameterDirection.ReturnValue;
                    cmd.Parameters.Add(parReturn);

                    //执行存储过程
                    dsResult = this._db.ExecuteDataSet(cmd);

                    //取得返回值
                    iReturn = (int)cmd.Parameters["@return"].Value;

                    if (iReturn == -1)  //调用失败返回错误信息
                    {
                        strErrorMessage = cmd.Parameters["@ErrorMsg"].Value.ToString();
                        result.Code     = 1000;
                        result.Message  = strErrorMessage;
                        result.Detail   = strErrorMessage;

                        return(result);
                    }

                    //返回总记录数
                    p.Records = Convert.ToInt32(cmd.Parameters["@Records"].Value);
                }

                result.Data = dsResult;
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();
            }
            return(result);
        }
 public MethodReturnResult <DataSet> GetData(ref DataAcquisitionTransGetParameter p)
 {
     return(base.Channel.GetData(ref p));
 }