I can not pass values to the report.
This is my code:
public void GLRPT()
{
try
{
ReportClass rptH = new ReportClass();
rptH.FileName = Server.MapPath("~/Rpts/G1.rpt");
rptH.Load();
string df = Session["fromdate"].ToString();
string dt = Session["todate"].ToString();
DateTime fromdate = DateTime.Parse(df);
DateTime todate = DateTime.Parse(dt);
rptH.SetParameterValue("?Date_From", fromdate);
rptH.SetParameterValue("?Date_To", todate);
rptH.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "GL");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
I don't know why I see this error:
Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
We should pass the parameter value like this:
rptH.SetParameterValue("Date_From", fromdate); //correct
NOT
rptH.SetParameterValue("?Date_From", fromdate); //incorrect
Then we we must give database access to the report because without login to database the report will not be opened.
and here is the code:
ReportDocument rptH = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
rptH.Load(Server.MapPath("~/Rpts/G1.rpt"));
string df = Session["fromdate"].ToString();
string dt = Session["todate"].ToString();
DateTime fromdate = DateTime.Parse(df);
DateTime todate = DateTime.Parse(dt);
rptH.SetParameterValue("Date_From", fromdate);
rptH.SetParameterValue("Date_To", todate);
crConnectionInfo.ServerName = "YOUR SERVER NAME";
crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
crConnectionInfo.Password = "YOUR DATABASE PASSWORD";
CrTables = rptH.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
rptH.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "GL");
We must call the parameter's name without any additional character such as
# or ?, just only the parameter's name itself.
I know the topic a little bit old, but it might help for someone if I share my experience.
As we can read in many topics, "the parameters name are different in the report file and the code". Yes this is true, but it is also happens if you added or removed parameters from the report file and forgot to copy the new file into your application location.
It would be the Visual Studio job, but sometimes the VS forget to copy the modified report file to the "Debug" folder, I think.
The point of this writing, after you modified your report file, regarding parameters, copy it into your compiled location.
Related
When I programmatically create a new bug and set the area path to this:
VssBasicCredential credentials = new VssBasicCredential(string.Empty, personalAccessToken);
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.AreaPath",
Value = "Project"
},
WorkItem bug = await workItemTrackingHttpClient.CreateWorkItemAsync(patchDocument, project, "Bug").ConfigureAwait(false);
I get this error:
TF401346: Invalid Area/Iteration id given for work item -1, field 'System.AreaId'.
I think this is a bug, this area path exists in ADO.
The issue was not the area path but another field, for whatever reason ADO pointed to the area path as the issue. Try adding each field one by one, or area field alone to see if it fixes the issue. This is the trimmed down version of my code.
JsonPatchDocument patchDocument = new JsonPatchDocument
{
//add fields and their values to your patch document
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.Title",
Value = $"{tag} for PR #{pullRequest.PullRequestId} changes in build {buildNumber} PlannerBuildArtifact."
},
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.AreaPath",
Value = "Project\\Planner\\Service"
}
};
try
{
using VssConnection connection = new VssConnection(Uri, this._credentials);
using WorkItemTrackingHttpClient workItemTrackingHttpClient = connection.GetClient<WorkItemTrackingHttpClient>();
return await workItemTrackingHttpClient.CreateWorkItemAsync(patchDocument, Project, "Bug").ConfigureAwait(false);
}
catch (VssException e)
{
_log.LogError("Unable to create work item", e);
throw;
}
I have an error occurring that I can't seem to find anything about. When I run my code I get the following error. I am not setting oDataType so I assume this is something done by the api itself.
ServiceException: Code: RequestBodyRead Message: The property 'oDataType' does not exist on type microsoft.graph.itemBody'. Make sure to only use property names that are defined by the type or mark the type as open type.
My code is mostly copied from microsoft samples.
var confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantId)
.WithClientSecret(clientSecret)
.WithAuthority(new Uri(authority))
.Build();
ClientCredentialProvider authenticationProvider = new ClientCredentialProvider(confidentialClientApplication);
client = new GraphServiceClient(authenticationProvider);
var message = new Microsoft.Graph.Message()
{
Subject = "Test email",
Body = new ItemBody
{
ContentType = BodyType.Text,
Content = "Test email."
},
HasAttachments = false,
ToRecipients = new List<Recipient>()
{
new Recipient
{
EmailAddress = new EmailAddress
{
Address = "myemail#mydomain.com"
}
}
}
};
var saveToSentItems = false;
await client.Users[userID].SendMail(message, saveToSentItems).Request().PostAsync();
Any help would be greatly appreciated.
Thank you
I suspect, you're using a older library/build. I remember the related issue and it's fixed last year itself.
Please update it with the latest one , try testing the same and let us know if you can still repro the issue or not.
I'm able to copy most test cases with this code (trying to copy shared steps to be part of the test case itself) but this one will not copy but I can not see any error message as to why - could anyone suggest anything else to try. See output from Immediate windows. Thanks John.
?targetTestCase.Error
null
?targetTestCase.InvalidProperties
Count = 0
?targetTestCase.IsDirty
true
?targetTestCase.State
"Ready"
?targetTestCase.Reason
"New"
foreach (ITestAction step in testSteps)
{
if (step is ITestStep)
{
ITestStep sourceStep = (ITestStep)step;
ITestStep targetStep = targetTestCase.CreateTestStep();
targetStep.Title = sourceStep.Title;
targetStep.Description = sourceStep.Description;
targetStep.ExpectedResult = sourceStep.ExpectedResult;
//Copy Attachments
if (sourceStep.Attachments.Count > 0)
{
string attachmentRootFolder = _tfsServiceUtilities.GetAttachmentsFolderPath();
string testCaseFolder = _tfsServiceUtilities.CreateDirectory(attachmentRootFolder, "TestCase_" + targetTestCase.Id);
//Unique folder path for test step
string TestStepAttachementFolder = _tfsServiceUtilities.CreateDirectory(testCaseFolder, "TestStep_" + sourceStep.Id);
using (var client = new WebClient())
{
client.UseDefaultCredentials = true;
foreach (ITestAttachment attachment in sourceStep.Attachments)
{
string attachmentPath = TestStepAttachementFolder + "\\" + attachment.Name;
client.DownloadFile(attachment.Uri, attachmentPath);
ITestAttachment newAttachment = targetTestCase.CreateAttachment(attachmentPath);
newAttachment.Comment = attachment.Comment;
targetStep.Attachments.Add(newAttachment);
}
}
}
targetTestCase.Actions.Add(targetStep);
targetTestCase.Save();
}
Since this code works for most test cases, this issue may come from the particular test case. In order to narrow down the issue, please try the following items:
Run the code on another client machine to see whether it works.
Try to modify this particular test case using the account API uses, to see whether it can be saved successfully.
Try validate the WorkItem prior to save. The validate() method will return an arraylist of invalid fields.
Could someone please help what does this error means
is it some connection issue?
operation performed on onpremise tfs server
here i am using TFS personal access token to do authorize operations.
Here is a code snippet creating a Bug work item in DevOps using HttpClient library, for your reference:
public class CreateBug
{
readonly string _uri;
readonly string _personalAccessToken;
readonly string _project;
public CreateBug()
{
_uri = "https://xxx.visualstudio.com";
_personalAccessToken = "xxx";
_project = "xxxxx";
}
public WorkItem CreateBugUsingClientLib()
{
Uri uri = new Uri(_uri);
string personalAccessToken = _personalAccessToken;
string project = _project;
VssBasicCredential credentials = new VssBasicCredential("", _personalAccessToken);
JsonPatchDocument patchDocument = new JsonPatchDocument();
//add fields and thier values to your patch document
patchDocument.Add(
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.Title",
Value = "Authorization Errors"
}
);
patchDocument.Add(
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/Microsoft.VSTS.Common.Priority",
Value = "1"
}
);
VssConnection connection = new VssConnection(uri, credentials);
WorkItemTrackingHttpClient workItemTrackingHttpClient = connection.GetClient<WorkItemTrackingHttpClient>();
try
{
WorkItem result = workItemTrackingHttpClient.CreateWorkItemAsync(patchDocument, project, "Bug").Result;
Console.WriteLine("Bug Successfully Created: Bug #{0}", result.Id);
return result;
}
catch (AggregateException ex)
{
Console.WriteLine("Error creating bug: {0}", ex.InnerException.Message);
return null;
}
}
}
Due to error message text was having encoding issue, was not able to figure out the issue, Did debug on server and found out TTFS url with collection was not forming properly hence it was giving "page not found" error message, after that we fixed it by updating the tfs api url.
I am creating a pst from message files which are located in another machine on a same network. But when I loaded the pst, messages are not rendered. I have added a screenshot. And code is below:
Issue do not occur when message files are imported from my local machine.
private static void GeneratePST(string [] messageFiles, string outputPstPath)
{
RDOSession pstSession = null;
RDOPstStore store = null;
RDOFolder folder = null;
RDOMail rdo_Mail = null;
RDOItems items = null;
try
{
pstSession = new RDOSession();
store = pstSession.LogonPstStore(outputPstPath, 1, Path.GetFileNameWithoutExtension(outputPstPath));
folder = store.IPMRootFolder;
folder = folder.Folders.Add("Loose Messages");
foreach (string messages in messageFiles)
{
items = folder.Items;
rdo_Mail = items.Add("IPM.NOTE");
rdo_Mail.Import(messages, rdoSaveAsType.olMSG);
rdo_Mail.Save();
}
}
catch (Exception ex)
{
//log exception
}
finally
{
Marshal.ReleaseComObject(rdo_Mail);
Marshal.ReleaseComObject(folder);
Marshal.ReleaseComObject(store);
Marshal.ReleaseComObject(items);
pstSession.Logoff();
Marshal.ReleaseComObject(pstSession);
GC.Collect();
}
}
I have also impersonated the network machine before importing message file. But still the issue persist.
The problem only exists for files in another machine. Messages are rendered for msg file located in my machine. Also, I noticed issue is only with message files. Eml file are rendered. So, it might not be the issue of impersonation.
Any help please.
Microsoft does not support accessing PST files on network drives. They must be on a local machine.
Also, there is no reason to continuously retrieve the RDOItems object - you never release on the old value, so those objects stay alive until your app exits. Ditto for the rdo_Mail object:
folder = folder.Folders.Add("Loose Messages");
items = folder.Items;
foreach (string messages in messageFiles)
{
if (rdo_Mail != null) Marshal.ReleaseComObject(rdo_Mail);
rdo_Mail = items.Add("IPM.NOTE");
rdo_Mail.Import(messages, rdoSaveAsType.olMSG);
rdo_Mail.Save();
}