Ejemplo n.º 1
0
 public void ReadData()
 {
     try
     {
         DataTable excelDataTable = excelOperator.ReadData(CalculatedFileName, CalculatedSheetName, CalculatedFilter, SelectAllRows);
         if (excelDataTable != null && excelDataTable.Rows.Count > 0)
         {
             for (int j = 0; j < excelDataTable.Rows.Count; j++)
             {
                 DataRow r = excelDataTable.Rows[j];
                 for (int i = 0; i < excelDataTable.Columns.Count; i++)
                 {
                     if (SelectAllRows)
                     {
                         AddOrUpdateReturnParamActualWithPath(excelDataTable.Columns[i].ColumnName, ((object)r[i]).ToString(), "" + (j + 1).ToString());
                     }
                     else
                     {
                         AddOrUpdateReturnParamActual(excelDataTable.Columns[i].ColumnName, ((object)r[i]).ToString());
                     }
                 }
             }
             bool isUpdated = true;
             if (SelectAllRows)
             {
                 if (!String.IsNullOrWhiteSpace(SetDataUsed))
                 {
                     isUpdated = excelOperator.UpdateExcelData(CalculatedFileName, CalculatedSheetName, CalculatedFilter, FieldsValueToTupleList(CalculatedSetDataUsed));
                 }
             }
             else
             {
                 if (!String.IsNullOrWhiteSpace(SetDataUsed))
                 {
                     if (string.IsNullOrWhiteSpace(PrimaryKeyColumn))
                     {
                         Error += "Missing or Invalid Primary Key";
                         return;
                     }
                     isUpdated = excelOperator.UpdateExcelData(CalculatedFileName, CalculatedSheetName, CalculatedFilter, FieldsValueToTupleList(CalculatedSetDataUsed), CalculatedPrimaryKeyFilter(excelDataTable.Rows[0]));
                 }
             }
             if (!isUpdated)
             {
                 Error = "Failed updated excel data: " + CalculatedSetDataUsed;
             }
         }
         else
         {
             Error = SelectAllRows ? "No Rows Found" : "No Rows Found with given filter";
         }
     }
     catch (Exception ex)
     {
         Error += eUserMsgKey.ExcelInvalidFieldData + ", " + ex.Message;
     }
 }
Ejemplo n.º 2
0
 DataTable GetExcelSheetData(bool isViewAllData)
 {
     if (!mAct.CheckMandatoryFieldsExists(new List <string>()
     {
         nameof(mAct.CalculatedFileName), nameof(mAct.CalculatedSheetName)
     }))
     {
         return(null);
     }
     if (!isViewAllData && mAct.ExcelActionType == ActExcel.eExcelActionType.ReadCellData && !string.IsNullOrWhiteSpace(mAct.CalculatedFilter))
     {
         return(mExcelOperations.ReadCellData(mAct.CalculatedFileName, mAct.CalculatedSheetName, mAct.CalculatedFilter, true));
     }
     return(mExcelOperations.ReadData(mAct.CalculatedFileName, mAct.CalculatedSheetName, isViewAllData ? null : mAct.CalculatedFilter, true));
 }