I am trying to Print multiple file Using google cloud printer api.
I have integrate local printer to chrome://devices/
and try to implement Printer api from beloved link
https://github.com/lppkarl/GoogleCloudPrintApi
var provider = new GoogleCloudPrintOAuth2Provider(ClientId, SecreteKey);
var url = provider.BuildAuthorizationUrl(redirectUri);
var token = provider.GenerateRefreshTokenAsync(url, redirectUri);
var client = new GoogleCloudPrintClient(provider, token);
var request = new ListRequest { Proxy = proxy };
var response = client.ListPrinterAsync(request);
In this method I am not getting token or Authorization code from request url
and also try to implement print using Print to Google Cloud Print with dynamic URL
for (var i = 0; i < url.length; i++) {
var currenturl = url[i]
var gadget = new cloudprint.gadget();
gadget.setprintdocument("application/pdf", "pdf");
gadget.setprintdocument("url", "document title1", currenturl);
gadget.openprintdialog();
}
Above code is working fine for multiple files.
But it's asking for print for every files.
I want to print multiple file but it should be ask only first time and rest of queued file automatically add in queue for print.
I tried many ways, but no one give me success.
If anyone have any idea than it'll helpfull. Thank you
Related
Programming would be much easier without users...
What I really need to be able to do is:
Put the content of a web page (including styles) into the body of an email and also set the subject.
OR
Send the current user an email containing the body of a web page.
I really don't care how this is implemented -- server or client side. I've not come up with any good way of client side besides trying to push the web page into the clipboard for the users to then paste into their email.
App Background
I wrote a web site using c#, ts, angular. The site manages xml documents.
The users can select a document and click the "Human Readable" button or the "XML" button. The "Human Readable" is xml with xsl to make it look pretty for the humans. The XML button is apparently for non-humans.
The "Human Readable" version opens in another browser tab.
The users want a new "email" button for emailing the human readable. The person clicking the email button has access to my web site but the recipient may not.
I've attempted educating my users to do Ctrl+A, Ctrl+C, open email, Ctrl+V but this is beyond most of their capabilities.
I have tried so many different ways to accomplish this and all have failed.
I currently do a mailto link which opens their email and the body contains a link to the Human Readable.
Here's what I've tried so far -- this may not be a conclusive list of my attempts as I've been at this for a few days now.
I've tried putting a button in the human readable (xsl with javascript) in an attempt to copy the resulting html into the clipboard for the users to paste.
A button on the web site to scrape an iFrame into the clipboard
Many iterations of javascript copy/paste techniques
a c# controller that does a ReadAsStringAsync().Result function (which I will post below because I like that solution the best so far...
Option #4 I'm partial to and I got almost working -- if it weren't for that pesky xsl not getting formatted it would probably work. My results are the data being presented without xml tags and no styles.
[ActionName("PostEmailHumanReadable")]
public void EmailHumanReadable(List<DocumentVM> documents)
{
foreach (var document in documents)
{
var docId = document.document.DocId;
var docTypeId = document.document.DocTypeId;
var co = string.Empty;
var order = string.Empty;
var name = string.Empty;
var po = string.Empty;
// get the data for the subject line
using (var efUoW = new EFUnitOfWork(EDIEnvironment.EDIEnvironment.Instance.ConnectionString))
{
var doc = efUoW.DocumentRepository.GetById(docId);
co = doc.CompanyId.ToString();
var orders = efUoW.DocumentOrderRepository.GetByDocumentID(docId).ToList();
if (!string.IsNullOrEmpty(doc.Source_Order))
order = doc.Source_Order;
else
order = "n/a";
foreach (var o in orders)
order += string.Format("{0} ", o.OrderId);
//order = string.Join(",", doc.DocumentOrders.Select(q => q.OrderId).ToList());
name = doc.BillToName;
name = doc.PurchaseOrder;
}
var subject = string.Format("{0}, {1}, {2}, {3}", co, order, name, po);
// get the human readable
var hrResponse = GetFile(docId, docTypeId);
var hrText = hrResponse.Content.ReadAsStringAsync().Result;
// format the url
var url = string.Format("<a href='/api/Documents/Getfile?DocId={0}&DocTypeId={1}'>click here to open the jEDI Human Readable</a><br><br>", docId, docTypeId);
// find the current user's email address
var users = new List<string>();
users.Add(AppUser.ADUserName);
//var to = EmailUtility.GetEmailID(users);
// and finally send the email
EmailUtility.SendEmail(EmailUtility.GetEmailID(users), null, subject, url + hrText);
}
}
[ActionName("GetFile")]
public HttpResponseMessage GetFile(int DocId, int DocTypeId)
{
if (DocTypeId == (int)DocumentTypeEnum.EDI850)
{
using (var efUoW = new Factory_UOW().EF_UOW())
{
var doc = efUoW.DocumentRepository.GetById(DocId);
var xdoc = XDocument.Parse(doc.Message);
var proc = new XProcessingInstruction("xml-stylesheet", "type='text/xsl' href='/EDI850.xsl'");
xdoc.Root.AddBeforeSelf(proc);
var response = new HttpResponseMessage();
response.Content = new System.Net.Http.StringContent(xdoc.ToString());
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/xml");
response.Content.Headers.Add("X-UA-Compatible", "IE=edge");
return response;
}
I would be very grateful for any assistance in getting this to work.
And, yes, I know I shouldn't do the Async().Result -- blocking and all that... Let's just get this working first, shall we?
Im trying to move a file from one folder to another using the Google Drive API v3. I found documentation how to this here. I used the .NET sample code from the documentation page and created a method that looks like this:
public ActionResult MoveFile(string fileToMove, string destination)
{
DriveService service = new DriveService(new BaseClientService.Initializer
{
HttpClientInitializer = <USER CREDENTIAL>,
ApplicationName = "APPNAME"
});
var searchFiles = service.Files.List();
searchFiles.Corpus = FilesResource.ListRequest.CorpusEnum.User;
searchFiles.Q = "name = '" + fileToMove + "'";
searchFiles.Fields = "files(*)";
string fileToMoveId = searchFiles.Execute().Files[0].Id;
searchFiles.Q = "name = '" + destination + "'";
string destinationId = searchFiles.Execute().Files[0].Id;
//Code used from documentation
// Retrieve the existing parents to remove
var getRequest = service.Files.Get(fileToMoveId);
getRequest.Fields = "parents";
var file = getRequest.Execute();
var previousParents = String.Join(",", file.Parents);
// Move the file to the new folder
var updateRequest = service.Files.Update(file, fileToMoveId);
updateRequest.Fields = "id, parents";
updateRequest.AddParents = destinationId;
updateRequest.RemoveParents = previousParents;
file = updateRequest.Execute();
return RedirectToAction("Files", new {folderId = destinationId});
}
When I execute this code I get the following error:
The parents field is not directly writable in update requests. Use the
addParents and removeParents parameters instead.
The error doesn't really makes sense to me because this code sample came from the documentation page itself. I can't figure out what other paramters they mean. What addParents and removeParents parameters do they mean? Are updateRequest.AddParents and updateRequest.RemoveParents not the right parameters?
Ok here is the problem.
var updateRequest = service.Files.Update(file, fileToMoveId);
The method is requiring that you send a body of a file to be updated. This normally makes sense as any changes you want to make you can add to the body.
Now the problem you are having is that you got your file from a file.get. Which is totally normal. This is how you should be doing it. THe problem is there are some fields in that file that you cant update. So by sending the full file the API is rejecting your update. If you check Files: update under Request body you will see which fiends are updateable.
Issue:
Now this is either a problem with the client library or the API I am going to have to track down a few people at Google to see which is the case.
Fix:
I did some testing and sending an empty file object as the body works just fine. The file is moved.
var updateRequest = service.Files.Update(new Google.Apis.Drive.v3.Data.File(), fileToMove.Id);
updateRequest.AddParents = directoryToMove.Id;
updateRequest.RemoveParents = fileToMove.Parents[0];
var movedFile = updateRequest.Execute();
This method works well when working in your own drive, but not in a team drive where a file (folder) can only have 1 parent strictly. I do not have the solution in a team drive
I'm using TLSharp for dealing with really complicated Telegram API.
it's hard to understand how xxxAbswww types can be converted to xxxwww types which contains the real usable information!
I have the code below:
TLUser user = client.MakeAuthAsync("<user_number>", hash, code).Result;
how can I get the photo of authenticated user?
Agha Hamed,
Users' photo is accessible using 'userProfilePhoto' Telegram method and TLSharp didn't implemented this method.
But TLSharp provided some fascilities to implement other Telegram API methods. They says:
You can call any method with help of SendRequestAsync function. For
example, send user typing method:
//Create request
var req = new TLRequestSetTyping()
{
action = new TLSendMessageTypingAction(),
peer = peer
};
//run request, and deserialize response to Boolean
return await SendRequestAsync<Boolean>(req);
Unfortunately I don't know how to use SendRequestAsync function to do this.
try this:
var photo = ((TLUserProfilePhoto)user.Photo);
var photoLocation = (TLFileLocation)photo.PhotoBig;
TLFile file = await client.GetFile(new TLInputFileLocation()
{
LocalId = photoLocation.LocalId,
Secret = photoLocation.Secret,
VolumeId = photoLocation.VolumeId
}, 1024 * 256);
//address to save pic
string fileName = "D:\\Project\\user_profile.jpg";
using (var m = new MemoryStream(file.Bytes))
{
var img = Image.FromStream(m);
//pictureBox1.Image = img; //make a preview
img.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
I dotn know why there is no example for TLSharp!
i am a newbe like you if you found the solution please post it here
i just discovered that TLUser has a method named "photo"
I'm trying to connect to an SSRS server and get report data via .NET webClient. I'm doing this because I can't use forms and I don't want to just send the user to the report server. I'd rather keep everything in my web application.
So I have this bit of code in a controller:
public IHttpActionResult GetSpecs(int Id)
{
var client = new WebClient();
client.Credentials = new System.Net.NetworkCredential("username", "pw", "domain");
var data = client.DownloadString(ReportServerUrl + "?%2fFactory+Specs+Reports%2fSpecs_Stats_Matrix&rs:Command=Render&a=" + Id + "&b=" + CurrentUser.Id);
return Ok(data)
}
It successfully connects to the SSRS server, and it does get data. Inspecting the data, it looks like it's the report I need, but it's just one giant string of html and javascript that the SSRS server spits out.
My question is, is there a good way of handling this data?
I'm in unfamiliar territory, and it doesn't seem like a lot of people interact with SSRS in this way.
I'm not quite sure how to display all the data the end user.
Thanks!
Thats quite easy. :)
First you need some assemblies to access the reporting service.
All these assemblies are easy to include in your project via Nuget,
After this you need to connect to your SSRS service instance like this:
using Microsoft.Reporting.WebForms;
CustomReportCredentials reportServerCredentials = new CustomReportCredentials("User", "Password", "REPORTINGSERVER");
ServerReport report = new ServerReport()
{
ReportServerUrl = new Uri("https://reporting.xxxx.com/ReportServer"),
ReportServerCredentials = reportServerCredentials,
ReportPath = "/Reports/MyReport",
Timeout = 200000
};
Ask the service for supported render extentions and generate the report:
var renderExtentions = report.ListRenderingExtensions();
report.SetParameters(new ReportParameter[]
{
new ReportParameter("parameter1", dcStringID.ToString()),
new ReportParameter("parameter2", begin.ToString()),
new ReportParameter("parameter3", end.ToString())
});
String mineType = String.Empty;
String fileNameExtention = String.Empty;
Stream stream = report.Render(renderExtentions.First(), null, null, out mineType, out fileNameExtention);
At this point you will have all you need. Stream, mine type, file extention.
Using C# , I want to read the Shares , Comments and Likes of a Google + post like this https://plus.google.com/107200121064812799857/posts/GkyGQPLi6KD
That post is an activity. This page includes infomation on how to get infomation about activities. This page gives some examples of using the API. This page has downloads for the Google API .NET library, which you can use to access the Google+ APIs, with XML documentation etc.
You'll need to use the API Console to get an API key and manage your API usage.
Also take a look at the API Explorer.
Here's a working example:
Referencing Google.Apis.dll and Google.Apis.Plus.v1.dll
PlusService plus = new PlusService();
plus.Key = "YOURAPIKEYGOESHERE";
ActivitiesResource ar = new ActivitiesResource(plus);
ActivitiesResource.Collection collection = new ActivitiesResource.Collection();
//107... is the poster's id
ActivitiesResource.ListRequest list = ar.List("107200121064812799857", collection);
ActivityFeed feed = list.Fetch();
//You'll obviously want to use a _much_ better way to get
// the activity id, but you aren't normally searching for a
// specific URL like this.
string activityKey = "";
foreach (var a in feed.Items)
if (a.Url == "https://plus.google.com/107200121064812799857/posts/GkyGQPLi6KD")
{
activityKey = a.Id;
break;
}
ActivitiesResource.GetRequest get = ar.Get(activityKey);
Activity act = get.Fetch();
Console.WriteLine("Title: "+act.Title);
Console.WriteLine("URL:"+act.Url);
Console.WriteLine("Published:"+act.Published);
Console.WriteLine("By:"+act.Actor.DisplayName);
Console.WriteLine("Annotation:"+act.Annotation);
Console.WriteLine("Content:"+act.Object.Content);
Console.WriteLine("Type:"+act.Object.ObjectType);
Console.WriteLine("# of +1s:"+act.Object.Plusoners.TotalItems);
Console.WriteLine("# of reshares:"+act.Object.Resharers.TotalItems);
Console.ReadLine();
Output:
Title: Wow Awesome creativity...!!!!!
URL:http://plus.google.com/107200121064812799857/posts/GkyGQPLi6KD
Published:2012-04-07T05:11:22.000Z
By:Funny Pictures & Videos
Annotation:
Content: Wow Awesome creativity...!!!!!
Type:note
# of +1s:210
# of reshares:158