Latest Inquiries - Data Extraction Software

C# Console API WrExportData always give old data

Submitted: 12/1/2016

Hi we are using follow code at C# console and trying to read input from SP which give different input search field value list, that i am changing at database storeprocedure each time different. but API run gives always same old data that we run & get via VWR IDE.


publicstaticvoid StartVerify(string projectFilePath, string logPath)

{

try

{

_logPath = logPath;

WrProject project = WrProject.Load(projectFilePath);

project.Restart = RestartMethod.EntireProcess;

project.DataConfiguration.DataSource.DataSourceType = WrDataSourceTypeEnum.SqlDatabase;

project.DataConfiguration.DataSource.SqlDatabase.Server = @"localhost";

project.DataConfiguration.DataSource.SqlDatabase.UseWindowsAuthentication = false;

project.DataConfiguration.DataSource.SqlDatabase.UserName = "sa";

project.DataConfiguration.DataSource.SqlDatabase.Password = "triple";

project.DataConfiguration.DataSource.SqlDatabase.Database = "AgileDBAGSProduction";

project.DataConfiguration.DataSource.IsResetData = true;

project.DataConfiguration.DataSource.DataExtractionMethod = WrDataExtractionMethod.ReplaceExistingData;

project.IsResetData = true;

project.CacheMinutes = 0;

//project.DeleteDataOutput();

//project.DeleteDataOutputWithOptions();

//project.DeleteDuplicateReferenceData();

project.Template.InputDataSource.DataSourceType = WrInputDataSourceTypeEnum.SqlDatabase;

project.Template.InputDataSource.SqlDatabase.Server = @"localhost";

project.Template.InputDataSource.SqlDatabase.Database = "AgileDBAGSProduction";

project.Template.InputDataSource.SqlDatabase.UseWindowsAuthentication = false;

project.Template.InputDataSource.SqlDatabase.UserName = "sa";

project.Template.InputDataSource.SqlDatabase.Password = "triple";

project.Template.InputDataSource.Sql = "EXEC [uspVWRPGetGuardCardToEverify] @StateId = 31";

IAgent agent = WrAgent.RunProject(project, true);

//IAgent agent = WrAgent.RunProject(new WrProcessPars(project, true, false, true, project.DefaultCollector, project.LogLevel), true);

WrExportData data = project.OpenExportedData();

WrExportArguments exportArgs = newWrExportArguments(data, project);

ExportData(exportArgs);

}

catch (Exception ex)

{

ScrapLogger.LogError("Error at method: StartVerify() CAGuardCardVerify Process ", ex.Message, _logPath);

}

}

publicstaticvoid ExportData(WrExportArguments args)

{

//First we set the SQL we'll use to insert data into the database table.

//The Database connection has already been set by defining a shared script

//database. Visual Web Ripper will automatically open and close the

//database connection.

args.Database.SetSql("INSERT INTO dbo.vwrp_exported_guard_licenses(lic_no,client_name,license_type,license_status,expiry_date,issue_date)VALUES(@licNumber,@GuardName,@LicenseType,@LicenseStatus,@LicExpiryDate,@LicIssueDate)");

args.Database.PrepareSql();

//Loop htough all eth export tables

foreach (WrExportTableDefinition table in args.ExportData.TablesDefinitions.Tables)

{

//Open a data reader for the current table

WrExportTableReader reader = args.ExportData.GetTableReader(table.TableName);

try

{

//Loop though all rows in the current data table and write them to the target database.

while (reader.Read())

{

args.Database.SetParameterTextValue("@licNumber", reader.GetStringValue("licNumber"));

//GuardName

if (reader.GetStringValue("GuardName") != string.Empty)

{

args.Database.SetParameterTextValue("@GuardName", reader.GetStringValue("GuardName"));

}

else

{

args.Database.SetParameterNullValue("@GuardName");

}

//LicenseType

if (reader.GetStringValue("LicenseType") != string.Empty)

{

args.Database.SetParameterTextValue("@LicenseType", reader.GetStringValue("LicenseType"));

}

else

{

args.Database.SetParameterNullValue("@LicenseType");

}

//LicenseStatus

if (reader.GetStringValue("LicenseStatus") != string.Empty)

{

args.Database.SetParameterTextValue("@LicenseStatus", reader.GetStringValue("LicenseStatus"));

}

else

{

args.Database.SetParameterNullValue("@LicenseStatus");

}

//LicExpiryDate

if (reader.GetStringValue("LicExpiryDate") != string.Empty)

{

args.Database.SetParameterDateTimeValue("@LicExpiryDate", reader.GetStringValue("LicExpiryDate"));

}

else

{

args.Database.SetParameterNullValue("@LicExpiryDate");

}

//LicIssueDate

if (reader.GetStringValue("LicIssueDate") != string.Empty)

{

args.Database.SetParameterDateTimeValue("@LicIssueDate", reader.GetStringValue("LicIssueDate"));

}

else

{

args.Database.SetParameterNullValue("@LicIssueDate");

}

args.Database.ExecuteNonQuery();

}

}

catch

{

}

finally

{

reader.Close();

}

}

}


Please help me so that i can get fresh data via API as I get on each run of VWR while changing

InputDataSource SQLServer-Storeprocedure each time. It is working perfect and we are getting fresh & different data via VWR IDE on each run but above API run always give first VWR IDE run data.

Replied: 12/2/2016 5:01:17 AM

Answered at:

http://support.visualwebripper.com/Display.aspx?si=da1c6360-3dc6-435c-9a72-a73efb9b9d11 

Please avoiding to post same or similar inquiry for twice that will be respond for a delay.

For the inquiry, I read your description again, seems that you now moved the export script to API method that you customized, that could be bad, normally, you should execute the custom export scripts in rip project instead of API method.