예제 #1
0
 /// <summary>
 /// 添加成功处理数据
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="sourceData"></param>
 /// <param name="successData"></param>
 public static void AddSuccessData <T>(this ExcelAnalysisResultData <T> sourceData, T successData)
 {
     lock (sourceData)
         sourceData.Success = sourceData.Success + 1;
     //不保存成功数据,如需保存,在这里取消掉注释
     //if (sourceData.SuccessDatas == null)
     //    sourceData.SuccessDatas = new List<T>();
     //lock(sourceData.SuccessDatas)
     //    sourceData.SuccessDatas.Add(successData);
 }
예제 #2
0
 /// <summary>
 /// 添加失败处理数据
 /// </summary>
 /// <typeparam name="T">数据</typeparam>
 /// <param name="sourceData"></param>
 /// <param name="fileName">数据所在文件名</param>
 /// <param name="index">Excel行标</param>
 /// <param name="failureReason">失败原因</param>
 public static void AddFailureData <T>(this ExcelAnalysisResultData <T> sourceData, string fileName, int index, string failureReason)
 {
     lock (sourceData)
     {
         if (sourceData.FailureDatas == null)
         {
             sourceData.FailureDatas = new List <ExcelAnalysisFailureData>();
         }
         sourceData.FailureDatas.Add(new ExcelAnalysisFailureData(fileName, index, failureReason));
     }
 }
예제 #3
0
 /// <summary>
 /// 添加失败处理数据
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="sourceData"></param>
 /// <param name="failureData"></param>
 public static void AddFailureData <T>(this ExcelAnalysisResultData <T> sourceData, ExcelAnalysisFailureData failureData)
 {
     lock (sourceData)
     {
         if (sourceData.FailureDatas == null)
         {
             sourceData.FailureDatas = new List <ExcelAnalysisFailureData>();
         }
         sourceData.FailureDatas.Add(failureData);
     }
 }
예제 #4
0
 /// <summary>
 /// 添加等待处理数据
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="sourceData"></param>
 /// <param name="fileName"></param>
 /// <param name="index"></param>
 /// <param name="waitingDealData"></param>
 public static void AddWaitingDealData <T>(this ExcelAnalysisResultData <T> sourceData, string fileName, int index, T waitingDealData)
 {
     lock (sourceData)
     {
         if (sourceData.WaitingDealDatas == null)
         {
             sourceData.WaitingDealDatas = new Queue <ExcelAnalysisWaitingDealData <T> >(1000);
         }
         ExcelAnalysisWaitingDealData <T> data = new ExcelAnalysisWaitingDealData <T>();
         data.SourceFileName = fileName;
         data.Index          = index;
         data.Data           = waitingDealData;
         sourceData.WaitingDealDatas.Enqueue(data);
     }
 }
예제 #5
0
 /// <summary>
 /// 添加缓存
 /// </summary>
 /// <param name="id">缓存标识,使用用户ID</param>
 public static ExcelAnalysisResultData <T> Add(string id)
 {
     lock (Cache)
     {
         if (Cache.ContainsKey(id))
         {
             if (Cache[id] != null && !Cache[id].IsOver)
             {
                 throw new ArgumentException("您已经创建了一个导入过程,并且尚未结束,过程ID:" + Cache[id].ID);
             }
             Cache[id] = new ExcelAnalysisResultData <T>(id);
         }
         else
         {
             Cache.Add(id, new ExcelAnalysisResultData <T>(id));
         }
         return(Cache[id]);
     }
 }