Perhaps this is expected behavior, but the programmatic launching of built-in applications in Windows 10 is scarce for anything aside from settings app, maps, and contacts, in my experience - and I could use some help on this.
I am launching the stock Windows Calculator from within the application. I took some guesses as the Uri and it appears to work - except on the first launch. When we get a new device, the first time the app is run and the calculator is attempted to be launched, it wants to get an app from the store (which the end users will not have access to) - it does not even offer the built-in calculator as a choice. If the calculator is opened manually, even once, it just works from that point on. Is there something else I could/should be doing? Any guidance or suggestions would be greatly appreciated.
I would like to have it work the first time (a setting on the device?), or at least offer the built-in calculator as a choice.
Here is the code I am using:
private async void LaunchCalculatorAsync(object sender, TappedRoutedEventArgs e)
{
var options = new Windows.System.LauncherOptions();
options.TreatAsUntrusted = false;
options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseNone;
await Windows.System.Launcher.LaunchUriAsync(new Uri("calculator:"), options);
}
From running a list of installed apps on the device, I see the calculator listed: Microsoft.WindowsCalculator_8wekyb3d8bbwe. I have been unsuccessful with attempting to provide the PreferredApplicationPackageFamilyName using options.PreferredApplicationPackageFamilyName = "WindowsCalculator";
I have tried with/without the "Microsoft." as well as with/without the odd string of characters.
You may get the demo from Microsoft in GitHub,
Association launching sample
Hope this can help you.
private async void LaunchUriWithWarning()
{
// Create the URI to launch from a string.
var uri = new Uri(UriToLaunch.Text);
// Configure the warning prompt.
var options = new LauncherOptions() { TreatAsUntrusted = true };
// Launch the URI.
bool success = await Launcher.LaunchUriAsync(uri, options);
if (success)
{
rootPage.NotifyUser("URI launched: " + uri.AbsoluteUri, NotifyType.StatusMessage);
}
else
{
rootPage.NotifyUser("URI launch failed.", NotifyType.ErrorMessage);
}
}
Related
I have two questions here. One, I am not able to run my appium tests against the sauce labs driver url specified in my account settings https://xxxxx:xxxxxxx#ondemand.eu-central-1.saucelabs.com:443/wd/hub. I do not get any error too..
But, i am able to run my tests against http://appium.testobject.com/wd/hub url. But i am not sure where to see my test results. If i try https://app.testobject.com, I am not able to login even though i give the correct credentials and am already logged in sauce labs. Please help.
I noticed a few things that could be doing wrong here. First, you are trying to run the tests on the European datacenter and port 443, which is an https connection. See which endpoint you should connect to. Some possible solutions:
Make sure you are using the endpoint for US West (if you are in the US and that is the data center you signed up for)
All your capabilities are up to date
You used your sauce username and access key when connecting to the driver.
It's hard to know what is wrong without capabilities and knowing if you want to connect to a virtual device or a real device, testing an app or browser. Here is an example configuration for an app test on RDC:
#BeforeMethod
public void setup(Method method) throws MalformedURLException {
System.out.println("Sauce iOS Native - BeforeMethod hook");
String username = System.getenv("SAUCE_USERNAME");
String accesskey = System.getenv("SAUCE_ACCESS_KEY");
String sauceUrl;
if (region.equalsIgnoreCase("eu")) {
sauceUrl = "#ondemand.eu-central-1.saucelabs.com:443";
} else {
sauceUrl = "#ondemand.us-west-1.saucelabs.com:443";
}
String SAUCE_REMOTE_URL = "https://" + username + ":" + accesskey + sauceUrl +"/wd/hub";
String appName = "iOS.RealDevice.SauceLabs.Mobile.Sample.app.2.7.1.ipa";
String methodName = method.getName();
URL url = new URL(SAUCE_REMOTE_URL);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "iPhone 8.*");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("automationName", "XCuiTest");
capabilities.setCapability("app", "storage:filename="+appName);
try {
iosDriver.set(new IOSDriver(url, capabilities));
} catch (Exception e) {
System.out.println("*** Problem to create the iOS driver " + e.getMessage());
throw new RuntimeException(e);
}
}
I found out how to view my test results while using http://appium.testobject.com/wd/hub url. Navigate to saucelabs as usual. Then select "legacy rdc" under Sauce Apps in the displayed page. You can view the results in the displayed window.
I am following the example in the link https://github.com/microsoftgraph/msgraph-training-changenotifications and creating and updating the notification subscription using a timer class.
[HttpGet]
public ActionResult<string> Get()
{
var graphServiceClient = GetGraphClient();
var sub = new Microsoft.Graph.Subscription();
sub.ChangeType = "updated";
sub.NotificationUrl = config.Ngrok + "/api/notifications";
sub.Resource = "/users";
sub.ExpirationDateTime = DateTime.UtcNow.AddMinutes(5);
sub.ClientState = "SecretClientState";
var newSubscription = graphServiceClient
.Subscriptions
.Request()
.AddAsync(sub).Result;
Subscriptions[newSubscription.Id] = newSubscription;
if(subscriptionTimer == null)
{
subscriptionTimer = new Timer(CheckSubscriptions, null, 5000, 15000);
}
return $"Subscribed. Id: {newSubscription.Id}, Expiration: {newSubscription.ExpirationDateTime}";
}
But I have noticed the timer does not always get triggered(eg: network related issue/ after a fresh deployment of the code).
Is there a better way to replace this timer?
I have heard about webjobs in azure, is it possible to replace this timer with azure webjobs? If so can someone point me to some documentation on how?
I noticed you're using ASPNET, if you're using the ASPNETCORE version, since 2.x, you can have background services that you could run every X hours to resubscribe (update) the subscriptions. That's what we're using (and we're on Azure). I would guess webjobs could do the trick, but I have not used them yet. You could also have an external service that calls one of your endpoints every X hours (like a CRON job) .
hope this helps!
JS
I am trying to create a service that will update an external list of Service Endpoints for applications running in my service fabric cluster. (Basically I need to replicate the Azure Load Balancer in my on premises F5 Load Balancer.)
During last month's Service Fabric Q&A, the team pointed me at RegisterServiceNotificationFilterAsync.
I made a stateless service using this method, and deployed it to my development cluster. I then made a new service by running the ASP.NET Core Stateless service template.
I expected that when I deployed the second service, the break point would hit in my first service, indicating that a service had been added. But no breakpoint was hit.
I have found very little in the way of examples for this kind of thing on the internet, so I am asking here hopping that someone else has done this and can tell me where I went wrong.
Here is the code for my service that is trying to catch the application changes:
protected override async Task RunAsync(CancellationToken cancellationToken)
{
var fabricClient = new FabricClient();
long? filterId = null;
try
{
var filterDescription = new ServiceNotificationFilterDescription
{
Name = new Uri("fabric:")
};
fabricClient.ServiceManager.ServiceNotificationFilterMatched += ServiceManager_ServiceNotificationFilterMatched;
filterId = await fabricClient.ServiceManager.RegisterServiceNotificationFilterAsync(filterDescription);
long iterations = 0;
while (true)
{
cancellationToken.ThrowIfCancellationRequested();
ServiceEventSource.Current.ServiceMessage(this.Context, "Working-{0}", ++iterations);
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
}
}
finally
{
if (filterId != null)
await fabricClient.ServiceManager.UnregisterServiceNotificationFilterAsync(filterId.Value);
}
}
private void ServiceManager_ServiceNotificationFilterMatched(object sender, EventArgs e)
{
Debug.WriteLine("Change Occured");
}
If you have any tips on how to get this going, I would love to see them.
You need to set the MatchNamePrefix to true, like this:
var filterDescription = new ServiceNotificationFilterDescription
{
Name = new Uri("fabric:"),
MatchNamePrefix = true
};
otherwise it will only match specific services. In my application I can catch cluster wide events when this parameter is set to true.
I have created a web page where users can upload a file which contains data that are inserted into the Lead table in Microsoft Dynamics CRM 2011.
The weird thing now is that when I deploy to our test environment the application runs fine seemingly but absolutely no rows are imported. In my dev environment it works just fine.
After a while when trying to find the error I created a setting that runs the application without using threading (Thread.Run basically) and then it inserts all the Leads. If I switch back to using threads it inserts no leads at all although I get no application errors.
When using SQL Server Profiler I can see in dev (where it works with threading) that all of the insert statements run. When profiling in test environment no insert statements at all are run.
I sort of get the feeling that there is some server issue or setting that is causing this behaviour but when googling I don't really get any results that have helped me.
I was sort of hoping that someone recognizes this problem. I haven't got much experience in using threading so maybe this is some road bump that I need to go over.
I cannot show my code completely but this is basically how I start the threads:
for (int i = 0; i < _numberOfThreads; i++)
{
MultipleRequestObject mpObject = new MultipleRequestObject() { insertType = insertType, listOfEntities = leadsForInsertionOrUpdate[i].ToList<Entity>() };
Thread thread = new Thread(delegate()
{
insertErrors.AddRange(leadBusinessLogic.SaveToCRMMultipleRequest(mpObject));
});
thread.Start();
activeThreads.Add(thread);
}
// Wait for threads to complete
foreach (Thread t in activeThreads)
t.Join();
I initialize my crm connection like this (it reads the connectionstring from web.config -> connectionstrings)
public CrmConnection connection { get; set; }
private IOrganizationService service { get; set; }
public CrmContext crmContext { get; set; }
public CrmGateway()
{
connection = new CrmConnection("Crm");
service = (IOrganizationService)new OrganizationService(connection);
crmContext = new CrmContext(service);
}
I've been using Autoscale to shift between 2 and 1 instances of a cloud service in a bid to reduce costs. This mostly works except that from time to time (not sure what the pattern seems to be here), the act of scaling up (1->2) causes both instances to recycle, generating a service outage for users.
Assuming nothing fancy is going on in RoleEntry in response to topology changes, why would scaling from 1->2 restart the already running instance?
Additional notes:
It's clear both instances are recycling by looking at the Instances
tab in Management Portal. Outage can also be confirmed by hitting the
public site.
It doesn't happen consistently but I'm not sure what the pattern is. It feels like when the 1-instance configuration has been running for multiple days, attempts to scale up recycle both. But if the 1-instance configuration has only been running for a few hours, you can scale up and down without outages.
The first instance always comes back much faster than the 2nd instance being introduced.
This has always been this way. When you have 1 server running and you go to 2+, the initial server is restarted. In order to have a full SLA, you need to have 2+ servers at all time.
Nariman, see my comment on Brent's post for some information about what is happening. You should be able to resolve this with the following code:
public class WebRole : RoleEntryPoint
{
public override bool OnStart()
{
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName());
string ip = null;
foreach (IPAddress ipaddress in ipEntry.AddressList)
{
if (ipaddress.AddressFamily.ToString() == "InterNetwork")
{
ip = ipaddress.ToString();
}
}
string urlToPing = "http://" + ip;
HttpWebRequest req = HttpWebRequest.Create(urlToPing) as HttpWebRequest;
WebResponse resp = req.GetResponse();
return base.OnStart();
}
}
You should be able to control this behavior. In the roleEntrypoint, there's an event you can trap for, RoleEnvironmentChanging.
A shell of some code to put into your solution will look like...
RoleEnvironment.Changing += RoleEnvironmentChanging;
private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
{
}
RoleEnvironment.Changed += RoleEnvironmentChanged;
private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e)
{
}
Then, inside the RoleEnvironmentChanged method, we can detect what the change is and tell Azure if we want to restart or not.
if ((e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange)))
{
e.Cancel = true; // don't recycle the role
}