I want to write capcha from this (https://file-online.taxservice.am/pages/loginPage.jsf) site and fill in textbox above.
var driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
var driver = new ChromeDriver(driverService, new ChromeOptions());
driver.Navigate().GoToUrl("https://file-online.taxservice.am/pages/loginPage.jsf");
var ocr = new IronTesseract();
IWebElement captchaImage = driver.FindElement(By.Id("mainForm:captchaImage"));
using (var input = new OcrInput(capchaImage))
{
var result = ocr.Read(input);
string result1 = Regex.Replace(result.Text, #"\s", "");
string result2 = Regex.Replace(result1, #"\B\p{Lu}", m => m.ToString().ToLower());
driver.FindElement(By.Id("userName")).SendKeys("1");
driver.FindElement(By.Id("tin")).SendKeys("2");
driver.FindElement(By.Id("password")).SendKeys("3");
driver.FindElement(By.Id("captchaEntry")).SendKeys(result2);
}
Related
I have a customer list in csv format which I'm using to send out emails. I would like to write to the CSV after each row has been executed in order to place a conditional rule. I'm using csvhelper to manipulate the file. Here's the code:
var scan = new StreamReader(myBlob);
var csvv = new CsvReader(scan, CultureInfo.InvariantCulture);
var records = csvv.GetRecords<Records>().ToList();
var scanwriter = new StreamWriter(myBlob4);
var csvwriter = new CsvWriter(scanwriter, CultureInfo.InvariantCulture);
foreach (Records record in records)
{
var from = new EmailAddress("example.com", "John");
var to = new EmailAddress(record.Email, record.Name);
var subject = "exapmple";
var msg = MailHelper.CreateSingleEmail(from, to, subject, txtf, htmlf);
StringBuilder text = new StringBuilder();
text.AppendFormat("sent", record.EmailSent);
csvwriter.WriteField(record.EmailSent);
csvwriter.NextRecord();
var response = await client.SendEmailAsync(msg);
}
However my csv is not appending the "sent" value to the file under the emailsent column. I'm using StringBuilder which might not be helpful in this scenario.
It seems like you are trying to do something more like this.
void Main()
{
var records = new List<SendEmail>
{
new SendEmail{ Email = "example.com", Name = "John" },
new SendEmail{ Email = "example2.com", Name = "Jenny" }
};
var csvwriter = new CsvWriter(Console.Out, CultureInfo.InvariantCulture);
foreach (var record in records)
{
// var from = new EmailAddress("example.com", "John");
// var to = new EmailAddress(record.Email, record.Name);
//
// var subject = "exapmple";
//
// var msg = MailHelper.CreateSingleEmail(from, to, subject, txtf, htmlf);
record.EmailSent = "sent";
csvwriter.WriteRecord(record);
csvwriter.NextRecord();
//var response = await client.SendEmailAsync(msg);
}
}
public class SendEmail
{
public string Email { get; set; }
public string Name { get; set; }
public string EmailSent { get; set; }
}
//using blocks will make sure the streams and disposed and file handles are closed properly,
// **even if an exception is thrown **
using(var scan = new StreamReader(myBlob))
using (var csvv = new CsvReader(scan, CultureInfo.InvariantCulture))
using (var scanwriter = new StreamWriter(myBlob4))
using (var csvwriter = new CsvWriter(scanwriter, CultureInfo.InvariantCulture))
{
var records = csvv.GetRecords<Records>(); //ToList() was not needed or helpful here
foreach (var record in records)
{
var from = new EmailAddress("example.com", "John");
var to = new EmailAddress(record.Email, record.Name);
var subject = "example";
var msg = MailHelper.CreateSingleEmail(from, to, subject, txtf, htmlf);
csvwriter.WriteField($"sent {record.EmailSent}");
csvwriter.NextRecord();
var response = await client.SendEmailAsync(msg);
}
}
I have been able to authenticate my app on google analytics and display some data around unique page views. Now I want to get the page views based on Traffic source but I'm not quite sure how to get the filters on the dimensions. I have written my code in c# and can't get my head around examples in other languages I've seen. i have used the api Query Explorer and got the right expressions and results. My difficulty is how to translate that into my code. My code is below
var filepath = Server.MapPath("~/jsonfile"); // path to the json file for the Service account
GoogleCredential credentials;
using (var stream = new FileStream(filepath, FileMode.Open, FileAccess.Read))
{
string[] scopes = { AnalyticsReportingService.Scope.AnalyticsReadonly };
var googleCredential = GoogleCredential.FromStream(stream);
credentials = googleCredential.CreateScoped(scopes);
}
var reportingService = new AnalyticsReportingService(
new BaseClientService.Initializer
{
HttpClientInitializer = credentials
});
var dateRange = new DateRange
{
StartDate = "2016-10-28",
EndDate = "2016-12-20"
};
var sessions = new Metric
{
Expression = "ga:uniquePageviews",
Alias = "Sessions"
};
var social = new Dimension { Name = "ga:socialNetwork" };
var reportRequest = new ReportRequest
{
DateRanges = new List<DateRange> { dateRange },
Dimensions = new List<Dimension> { social },
Metrics = new List<Metric> { sessions },
ViewId = "myviewid"
};
var getReportsRequest = new GetReportsRequest
{
ReportRequests = new List<ReportRequest> { reportRequest }
};
var batchRequest = reportingService.Reports.BatchGet(getReportsRequest);
var response = batchRequest.Execute();
foreach (var x in response.Reports.FirstOrDefault().Data.Rows)
{
Response.Write(string.Join(", ", x.Dimensions) + " " + string.Join(", ", x.Metrics.First().Values));
}
You should create a DimensionFilterClauses and pass it to the ReportRequest as follows:
//Create the Dimension Filter
var dimensionFilter = new DimensionFilter();
dimensionFilter.DimensionName = "ga:socialNetwork";
dimensionFilter.Expressions = new List<string> { "someValue" };
var dimensionFilterClause = new DimensionFilterClause();
dimensionFilterClause.Filters = new List<DimensionFilter> { dimensionFilter };
Then modify your ReportRequest:
var reportRequest = new ReportRequest
{
DateRanges = new List<DateRange> { dateRange },
Dimensions = new List<Dimension> { social },
Metrics = new List<Metric> { sessions },
ViewId = "myviewid",
DimensionFilterClauses = new List<DimensionFilterClause> { dimensionFilterClause }
};
P.S:
Furthermore, if you need to filter Metric instead of Dimension, you would need to create a MetricFilterClauses as follows and then pass it to MetricFilterClauses in your ReportRequest:
//Create the Metric Filter
var metricFilter = new MetricFilter();
metricFilter.MetricName = "someMetric";
metricFilter.ComparisonValue = "someValue";
var metricFilterClause = new MetricFilterClause();
metricFilterClause.Filters = new List<MetricFilter> { metricFilter };
When I call GetReport I only get the headers for the tab delimited response. However, when I use the scratch pad to, RequestReport, RequestReportList, using the RequestId to get GeneratedReportId and then GetReport with that Id. I get expected results.
Does anyone have an idea why my code doesn't pull the report like the scrathpad does?
RequestReportRequest request = new RequestReportRequest();
request.Merchant = settings.SellerId;
request.MarketplaceIdList = new IdList();
request.MarketplaceIdList.Id = new List<string>(new string[] { settings.MarketplaceId });
request.ReportType = "_GET_MERCHANT_LISTINGS_DATA_";
RequestReportResponse requestResponse = _mws.RequestReport(request);
Thread.Sleep(15000);
Console.WriteLine(requestResponse.RequestReportResult.ReportRequestInfo.ReportProcessingStatus);
GetReportRequestListRequest reportRequestListRequest = new GetReportRequestListRequest();
reportRequestListRequest.Merchant = settings.SellerId;
List<ReportRequestInfo> requestInfos = new List<ReportRequestInfo>();
GetReportRequestListResponse reportRequestListResponse = new GetReportRequestListResponse();
reportRequestListResponse = _mws.GetReportRequestList(reportRequestListRequest);
GetReportRequestListResult reportRequestListResult = new GetReportRequestListResult();
reportRequestListResult = reportRequestListResponse.GetReportRequestListResult;
requestInfos = reportRequestListResult.ReportRequestInfo;
while (requestInfos[0].ReportProcessingStatus.ToString() != "_DONE_")
{
Thread.Sleep(20000);
reportRequestListResponse = _mws.GetReportRequestList(reportRequestListRequest);
reportRequestListResult = reportRequestListResponse.GetReportRequestListResult;
requestInfos = reportRequestListResult.ReportRequestInfo;
}
GetReportListRequest listRequest = new GetReportListRequest();
listRequest.Merchant = settings.SellerId;
listRequest.ReportRequestIdList = new IdList();
listRequest.ReportRequestIdList.Id.Add(requestResponse.RequestReportResult.ReportRequestInfo.ReportRequestId);
GetReportListResponse listResponse = _mws.GetReportList(listRequest);
GetReportListResult getReportListResult = listResponse.GetReportListResult;
GetReportRequest reportRequest = new GetReportRequest();
reportRequest.Merchant = settings.SellerId;
reportRequest.WithReportId(getReportListResult.ReportInfo[0].ReportId);
GetReportResponse reportResponse = new GetReportResponse();
string fileName = dataPath + "\\report-" + getReportListResult.ReportInfo[0].ReportId + ".txt";
reportRequest.Report = File.Open(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
reportResponse = _mws.GetReport(reportRequest);
I removed the MarketplaceId from the ReportRequest and it works fine. I'm not sure why it didn't pull the report with it specified, but it is working without the information.
Removed these 2 lines from above code.
request.MarketplaceIdList = new IdList();
request.MarketplaceIdList.Id = new List<string>(new string[] { settings.MarketplaceId });
My question is can able to add a tag from existing one (means existing phtos).Now iam able to tag a friends in fresh upload using this code
private const string ExtendedPermissions = "user_about_me,user_photos,publish_stream";
[HttpPost]
[FacebookAuthorize(Permissions = ExtendedPermissions, LoginUrl = "/Home/LogOn?ReturnUrl=~/Home")]
public ActionResult MensagemPost(string message)
{
var fb = new FacebookWebClient();
dynamic me = fb.Get("me");
string friendId_1 = // get the first one friend id
string friendId_2 = // get the second one friend id
var tags = new[]
{
new { tag_uid = friendId_1, x = 20, y = 20 },
new { tag_uid = friendId_2, x = 40, y = 40 },
new { tag_uid = (string)me.id, x = 60, y = 60 }
};
dynamic parameters = new ExpandoObject();
parameters.message = message;
parameters.tags = tags;
parameters.url = "http://1.bp.blogspot.com/-evheT51sfeM/TlO_wZ8YDqI/AAAAAAAAA8I/fjlg0G8AgMY/s1600/The-best-top-hd-desktop-naruto-shippuden-wallpaper-naruto-shippuden-wallpapers-hd-11.jpg";
dynamic result = fb.Post("me/photos", parameters);
return RedirectToAction("Index", new { success = true });
}
but cannot i update the tags in existing one.
My try IS
var res = FbClient.Post("/4333418373210452/tags", PostInfo);
AccessToken = Properties.Settings.Default.FBAccessToken;
FacebookClient FbClient = new FacebookClient(AccessToken);
var PostInfo = new Dictionary<string, object>();
var tags = new[] { new { tag_uid = "870415313026255", tag_text = "Tag updated", x = 90, y = 110 } };
PostInfo.Add("tags", tags);
var result = FbClient.Post("/4333418373210452/tags", PostInfo);
This code is getting error from facebook.The error says
(GraphMethodException - #100) Unsupported post request. Please read
the Graph API documentation at
https://developers.facebook.com/docs/graph-api
i try to googling but cannot get the solution till now ..anyone help me out..your comments also welcome
Jagadeesh Govindaraj
Found the solution...previously i'm try to POST REQUEST Against my friend ID, But now i changed to phtoID..Its Worked.
AccessToken = Properties.Settings.Default.FBAccessToken;
FacebookClient FbClient = new FacebookClient(AccessToken);
var PostInfo = new Dictionary<string, object>();
var tags = new[] { new { tag_uid = "870415313026255", tag_text = "Tag updated", x = 90, y = 110 } };
PostInfo.Add("tags", tags);
var result = FbClient.Post("/"Existing PhotoID"/tags", PostInfo);
I am trying to pull FBA shipment data report. I have a running application that succesfully pulls Unshipped Orders from Amazon. So bascially I took that code and changed it to what I need it to do for the FBA shipment orders. I barely changed the working code to get a report and now the GetReport function is returning a null and I dont know why. I am passing in a ReportId that is coming from Amazon's system.
If someone could peruse over the code and see if maybe I'm passing in a null object or something.
RequestReportRequest reportRequestRequest = new RequestReportRequest();
reportRequestRequest.Merchant = merchantId;
reportRequestRequest.Marketplace = marketplaceId;
reportRequestRequest.ReportType = "_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_";
reportRequestRequest.StartDate = DateTime.Now.AddDays(-2);
reportRequestRequest.EndDate = DateTime.Now;
RequestReportResponse requestResponse = service.RequestReport(reportRequestRequest);
Thread.Sleep(15000);
Console.WriteLine(requestResponse.RequestReportResult.ReportRequestInfo.ReportProcessingStatus);
GetReportRequestListRequest reportRequestListRequest = new GetReportRequestListRequest();
reportRequestListRequest.Marketplace = marketplaceId;
reportRequestListRequest.Merchant = merchantId;
List<ReportRequestInfo> myListzz = new List<ReportRequestInfo>();
GetReportRequestListResponse reportRequestListResponse = new GetReportRequestListResponse();
reportRequestListResponse = service.GetReportRequestList(reportRequestListRequest);
GetReportRequestListResult reportRequestListResult = new GetReportRequestListResult();
reportRequestListResult = reportRequestListResponse.GetReportRequestListResult;
myListzz = reportRequestListResult.ReportRequestInfo;
while (myListzz[0].ReportProcessingStatus.ToString() != "_DONE_")
{
Thread.Sleep(20000);
reportRequestListResponse = service.GetReportRequestList(reportRequestListRequest);
reportRequestListResult = reportRequestListResponse.GetReportRequestListResult;
myListzz = reportRequestListResult.ReportRequestInfo;
}
GetReportListRequest listRequest = new GetReportListRequest();
listRequest.Merchant = merchantId;
listRequest.Marketplace = marketplaceId;
listRequest.ReportRequestIdList = new IdList();
listRequest.ReportRequestIdList.Id.Add(requestResponse.RequestReportResult.ReportRequestInfo.ReportRequestId);
GetReportListResponse listResponse = service.GetReportList(listRequest);
//MessageBox.Show(listResponse.GetReportListResult.ReportInfo.ToString());
GetReportListResult getReportListResult = listResponse.GetReportListResult;
GetReportRequest reportRequest = new GetReportRequest();
reportRequest.Merchant = merchantId;
reportRequest.Marketplace = marketplaceId;
reportRequest.WithReportId(getReportListResult.ReportInfo[0].ReportId);
GetReportResponse reportResponse = new GetReportResponse();
{
reportResponse = service.GetReport(reportRequest); // <=== ERROR!!!!
}
catch (MarketplaceWebServiceException e)
{
Console.WriteLine(e);
}
StreamReader sr = new StreamReader(reportRequest.Report);
Console.WriteLine(sr.ReadToEnd());
sr.Close();
After this line:
GetReportResponse reportResponse = new GetReportResponse();
You have to specify a report file, like this:
reportRequest.Report = File.Open("C:\\AmazonReport.csv", FileMode.OpenOrCreate, FileAccess.ReadWrite);
Then, it will write the report to that file.
So, you can see your report there.