Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
bchan1357 Absent Member.
Absent Member.
732 views

[API] Object reference not set to an instance of an object.

Here is the event code. Could anyone have a check? Thank you very much.

 

DateTime before, after;
TimeSpan diff;
double timediff = 0;

int rowcount = 0;
string rowcontent = null;

public void HTTPActivity5_OnBeforeExecuteStepEvent(object sender, STActivityBaseEventArgs args)
{
GetDataSource("api!Result").ImportFromExcelFile(@"C:\Users\uft\Desktop\api.xls", "Result", true);
rowcontent = GetDataSource("api!Result").GetValue(rowcount, "recipient").ToString();
while (String.IsNullOrWhiteSpace(rowcontent) == false)
   {
   rowcount++;
   rowcontent = GetDataSource("api!Result").GetValue(rowcount, "recipient").ToString();
   }
before = DateTime.UtcNow;
}

 

public void HTTPActivity5_OnCodeCheckPointEvent(object sender, CheckpointEventArgs args)
{
if (this.HTTPActivity5.StatusCode == 200)
GetDataSource("api!Result").SetValue(rowcount, "checkpoint", "TRUE");
else
GetDataSource("api!Result").SetValue(rowcount, "checkpoint", "FALSE");
}

public void HTTPActivity5_OnAfterExecuteStepEvent(object sender, STActivityBaseEventArgs args)
{
after = DateTime.UtcNow;
diff = after.Subtract(before);
timediff = diff.TotalMilliseconds;
this.HTTPActivity5.Report("timediff", timediff.ToString());
this.HTTPActivity5.Report("before", before.ToString("MM/dd/yyyy HH:mm:ss"));

GetDataSource("api!Result").SetValue(rowcount, "date", before.ToString("MM/dd/yyyy"));
GetDataSource("api!Result").SetValue(rowcount, "time", before.ToString("HH:mm:ss"));
GetDataSource("api!Result").SetValue(rowcount, "login_transaction", timediff.ToString());

GetDataSource("api!Result").ExportToExcelFile(@"C:\Users\uft\Desktop\api.xls");
}

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.