Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Apply Business Rules to imported file records
Message
De
19/01/2012 18:16:38
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
19/01/2012 16:35:25
Kathy Schmidt
Michigan Health and Hospital Association
Michigan, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 3.0
OS:
Windows 7
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01532556
Message ID:
01533387
Vues:
49
Kathy,

Is there any reason you cannot use the strongly typed Entity and Entity List objects for this? I do not remember the details of this thread now and I can review your code for a solution, but would be better to use the Entity objects if you can.
Timothy

>Thank you for the information. Unfortunately, I haven't been able to get it to work and I have spent way too much time on this already. After initial validation, the data gets split into valid (NewData) and invalid data (InvalidData). What I need to do is run all of the rules on the NewData. Below is some of the code. Hopefully, I have included enough for someone to be able to help me. If I am missing something, please let me know. If I have totally missed the boat and am approaching this all wrong - any help would be appreciated. Thanks.
>
>Business objects:
>***************************************************************
>Sepsis.cs (this is the standard class generated by the business generator with additional default values set in HookSetDefaultValue )
>Sepsis.Partial.cs - standard class generated by the MM business generator with additional code added.
>
> // returns all field in the database Sepsis table
> public DataTable GetDetailByDateByUnit(DateTime dataMonthDate, int unitPk)
> {
> this.FillDataSet(
> this.DataSet,
> "Sepsis_GetDetailByUnitDate",
> CommandType.StoredProcedure,
> this.CreateParameter("@DataMonthDate", dataMonthDate),
> this.CreateParameter("@UnitPk", unitPk));
>
> return this.DataSet.Tables[this.TableName];
> }
>
>SepsisEntity.cs: Standard entity class generated by MM business layer generator
>SepsisImport.cs : Contains the field definitions for the file being imported
>SepsisRules.cs : Standard rules class generated by MM business layer generator; need to apply to import file before save.
>SepsisRules.Partial.cs : Additional rules needed for data entry form application; need to apply to import file before save.
>***************************************************************
>Business Logic
>SepsisImportLogic.sc
> Contains code to process initial import file validation.
>
>Partial Code in SepsisImportLogic.cs
>
> public DataTable NewData { get; set; }
>
> . . .
>
> // This call will never return any records, just want to build the datatable
> this.NewData = this.oSEPSIS.GetDetailByDateByUnit(DateTime.Now, 1); // see code above in SepsisPartial.cs
> DataColumn messageColumn = new DataColumn("Message", typeof(System.String));
> messageColumn.DefaultValue = string.Empty;
> NewData.Columns.Add(messageColumn);
>
> . . .
>
> // process each record in the imported data table
> foreach (DataRow importRow in importedDataTable.Rows)
> {
> //reset valid import data used in ValidateCurrentRow
> this.ValidRowData = new SepsisEntity();
> //Validate the row
> string errorMessage = null;
> errorMessage = this.ValidateCurrentRow(importRow, importedDataTable);
>
> if (string.IsNullOrEmpty(errorMessage))
> {
> var row = this.NewData.NewRow();
> row["UnitFk"] = this.ValidRowData.UnitFK;
> row["PatientNo"] = this.ValidRowData.PatientNo;
> row["DataMonthDateTime"] = this.ValidRowData.DataMonthDateTime;
> row["EDTriageMinutes"] = this.ValidRowData.EDTriageMinutes ?? (object)System.DBNull.Value;
> row["ICUAdmissionMinutes"] = this.ValidRowData.ICUAdmissionMinutes ?? (object)System.DBNull.Value;
> // . . . sets all of the values in the new NewData row, deleted to make shorter here
> row["SepsisTwoBloodIn3Hours"] = (object)System.DBNull.Value;
> this.NewData.Rows.Add(row);
> }
> else
> {
> // collect invalid data information
> DataRow row = this.InvalidData.NewRow();
> row["HospId"] = importRow["HospId"];
> row["PatientNo"] = importRow["PatientNo"];
> row["Message"] = errorMessage;
> this.InvalidData.Rows.Add(row);
> }
> } // done checking all the data rows
>
>***************************************************************
>Webform:
>SepsisImport.aspx
>SepsisImport.aspx.cs
>
>SepsisImport.aspx.cs
>
>Code that loads the session object after initial validation is complete:
> Session["NewData"] = this.Sepsis_Logic.NewData;
>
>Code that calls the save that runs the rules (this works)
>
> mmSaveDataResult result;
> if (Session["NewData"] != null)
> {
> var dataset = new DataSet();
> var dt = (DataTable)Session["NewData"];
> dataset.Tables.Add(dt);
> this.SepsisData.SetCurrentDataSet(dataset, "Sepsis");
> result = this.SepsisData.SaveDataSet(dataset, "Sepsis");
> if (result != mmSaveDataResult.RulesPassed)
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform