multiple print doc file on button click - asp.net

I want to print multiple doc file on button click.I am using this code
ProcessStartInfo info = new ProcessStartInfo(txtFileName.Text.Trim());
info.Verb = "Print";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
and the code is working fine in my application,but after publishing the application on the server ,i am unable to access the functionality.thanks in advance

Related

C# iText7 The process cannot access the file 'Tmp.pdf' because it is being used by another process

I'm using iText to create a PDF from a PDF template which is then emailed. The code is to be executed repeatedly. The created temporary file can't be deleted or overwritten. The error message is "The process cannot access the file 'Tmp.pdf' because it is being used by another process."
string path = Server.MapPath("files");
string tmp = path + #"\Tmp.pdf";
PdfDocument pdfDoc = new PdfDocument(new PdfReader(path + #"\Template.pdf"), new PdfWriter(tmp));
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
form.GetField("Content").SetValue(tmpItems.Text);
form.FlattenFields();
pdfDoc.Close();
// Email PDF
MailMessage mailMsg = new MailMessage();
Attachment data = new Attachment(tmp, MediaTypeNames.Application.Octet);
// Add time stamp information for the file.
ContentDisposition disposition = data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(tmp);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(tmp);
disposition.ReadDate = System.IO.File.GetLastAccessTime(tmp);
mailMsg.Attachments.Add(data);
File.Delete(tmp);
I assumed the file had been closed (pdfDoc.Close();) releasing the resource. The second time the code snippet is used (to create another version to be emailed) to overwrite the file, the error occurs at line 3. As a potential fix, I tried to delete the file but again the error occurs at the deletion point.
This is a very short snippet of code. What is the other process holding on to the file? What am I doing wrong?

Protractor Image didnt upload on dialogue box?

I want to test the image upload functionality using Protractor but my written script didnt work.
This is the image dialogue box.When we click on the dialogue box image it open the window to select desired image.After the selection of image,the box acts like this image.I want to write a script through which i can upload an image and then click on the "Save" button.This is the css of dialogue box.
Given below is the script that i tried but doesn't work. The error message that encountered is this.
var path = require('path');
var fileToUpload = '../new image.jpeg';
var absolutePath = path.resolve('__dirname', fileToUpload);
console.log(absolutePath);
var fileElem=element(by.css('label[for="cropper-file-input"]'));
browser.wait(EC.presenceOf(fileElem), 2000,);
fileElem.sendKeys(absolutePath);
Try the below method. Hope it may help you.
fileUpload(element: ElementFinder, fileElem: ElementFinder, filePath: string): promise.Promise<void> {
//We are using the setFileDetector method to let WebDriver know that we are uploading files from a local directory to a remote server.
//Having this configuration resolves the "Failed: invalid argument: File not found" error that occurs otherwise.
browser.driver.setFileDetector(new utils.remote.FileDetector);
return browser.executeScript(`arguments[0].style.visibility = 'visible'; arguments[0].style.height = '1px'; arguments[0].style.width = '1px'; arguments[0].style.opacity = 1`, element)
.then(() => fileElem.sendKeys(filePath));
}

Is it possible to programmatically call a Chrome Custom Tab, but as "incognito mode"?

In some case, a user might not want the chrome custom tab to show up in their browsing history. Is there any way the app could tell the Chrome Custom Tab to display the webpage in incognito mode, and avoid storing that URL in the user normal browsing history?
If that's currently not possible, where could someone submit a feature request for that?
Thanks!
It is possible now. For example in C#:
try
{
string dataFolder = "C:\userFolder"; // If you need to maintain your browser session, you can configure a user data directory
string urlToOpen = "https://shalliknow.com"; // replace your url to open
Process process = new Process();
process.StartInfo.FileName = #"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
process.StartInfo.Arguments = $"--new-window={urlToOpen} --start-maximized --incognito --user-data-dir=\"{ dataFolder}\""; // SSH new Chrome
process.Start();
}
catch (Exception ex)
{
Console.Writeline("Exception while opening link in browser");
}
The source of this code, as well as a list of command line arguments for chrome.exe can be found here:
https://shalliknow.com/articles/en-scs-how-to-open-chrome-in-incognito-mode-programmatically-in-csharp

How to access the properties and parts of an SSRS report at runtime

I'm using the ReportViewer control to display a server report in an ASP.NET page and I'm looking for a way to get the report into an object that I can then read and/or modify.
This kind of thing:
var rw = report.Width;
var t = ((Chart)report.Body.Item[3]).Title;
Is there a way, or am I stuck with parsing the XML file?
ETA:
I'm beginning to think I will need to access the XML file but I can't find out how to download that from the server, modify it (in memory) and then send it to the ReportViewer control.
ETA2:
Here's how to download the report definition (clean up left out for brevity):
// Download the report
var rs = new ReportingService2010();
rs.UseDefaultCredentials = true;
var reportDefinition = rs.GetItemDefinition("/DashboardReports/MyChart");
// Convert to XML
var ms = new MemoryStream(reportDefinition);
var doc = new System.Xml.XmlDocument();
doc.Load(ms);
// To load the stream into the report viewer
stream.Position = 0; // needed because we used the stream above - doc.Load(ms)
this.ReportViewer1.ServerReport.LoadReportDefinition(stream);

how can build a txt document and write in flex application?

how can build a txt document and write in flex application ?
// in an init type method
var fileRef:FileReference = new FileReference();
var text:String = "Some text I want to save";
// continue building the text String variable as desired
// in some method that responds to a user event (NOT a system event):
fileRef.save(text, "defaultFileName.txt");
This may require that the user has Flash Player 10.

Resources