Ejemplo n.º 1
0
 public HistoryImport GetResultImportList(HistoryQuery import, int action)
 {
     var result = new HistoryImport { HistoryItem = new List<ResultImport>(), PageInfo = new PageInfo() };
     var cmd = new DataCommand("SearchImportData", new SqlCustomDbCommand());
     var whereStr = new StringBuilder();
     if (import.DeviceId == null || import.DeviceId==0)
     {
         if (!string.IsNullOrEmpty(import.ObjectId.ToString()))
         {
             whereStr.Append(string.Format(" and import.ObjectID={0}", import.ObjectId));
         }
     }
     else
     {
         whereStr.Append(string.Format(" and import.ObjectID={0}", import.DeviceId));
     }
     if (!string.IsNullOrEmpty(import.Starttime.ToString()))
     {
         whereStr.Append(string.Format(" and import.Starttime>='{0}'", import.Starttime));
     }
     if (!string.IsNullOrEmpty(import.Endtime.ToString()))
     {
         whereStr.Append(string.Format(" and import.Starttime<='{0}'", import.Endtime));
     }
     if (!string.IsNullOrEmpty(import.ItemCode))
     {
         whereStr.Append(string.Format(" and import.ItemCode='{0}'", import.ItemCode));
     }
     if (!string.IsNullOrEmpty(import.DateUnit.ToString(CultureInfo.InvariantCulture)))
     {
         whereStr.Append(string.Format(" and import.MonthType={0}", import.DateUnit));
     }
     cmd.SetParameterValue("@action", action);
     cmd.ReplaceParameterValue("#whereStr#", whereStr.ToString());
     cmd.ReplaceParameterValue("#pagesize#",import.PaddingInfo.PageSize.ToString(CultureInfo.InvariantCulture));
     cmd.ReplaceParameterValue("#pagenums#", ((import.PaddingInfo.Page - 1) * import.PaddingInfo.PageSize).ToString(CultureInfo.InvariantCulture));
     result.HistoryItem = cmd.ExecuteEntityList<ResultImport>();
     foreach (var item in result.HistoryItem)
     {
         item.ObjectName = GetObjectName(item.IsArea, item.ObjectId);
     }
     result.PageInfo.Total = (int)cmd.GetParameterValue("@Count");
     return result;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 显示导入的历史记录
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public HistoryImport GetResultImportList(HistoryQuery query)
 {
     var action = 0;
     if (query.ObjectId != null)
     {
         action = 1;
     }
     var dataResult = _import.GetResultImportList(query,action);
     try
     {
         dataResult.PageInfo.CuttrentPage = query.PaddingInfo.Page;
         dataResult.PageInfo.Pages = dataResult.PageInfo.Total % query.PaddingInfo.PageSize == 0
             ? dataResult.PageInfo.Total / query.PaddingInfo.PageSize
             : dataResult.PageInfo.Total / query.PaddingInfo.PageSize + 1;
         dataResult.Success = true;
         dataResult.ErrorMsg = string.Empty;
     }
     catch (Exception e)
     {
         dataResult.Success = false;
         dataResult.ErrorMsg = e.Message;
     }
     return dataResult;
 }