示例#1
0
        public void RemoteApplication_ByPass()
        {
            PathMap map =
                PathMap.CreateFromFile(
                    @"MappingTest\Mapping.xml");

            RemoteApplication.Initialize(map);

            HttpContext context = HttpContextHelper.CreateHttpContext("GET", "/zmrres/images/somepicture.png",
                                                                      "name1=value1");

            RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request);
            TrafficLogger     logger            = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url);
            string            rightSideUrl      = remoteApplication.GetRightSideUrl(context.Request);

            Assert.AreEqual("https://portal.bmi.gv.at/images/somepicture.png?name1=value1", rightSideUrl,
                            "RightSideUrl");
            Assert.IsTrue(remoteApplication.ByPass(context.Request.Url.AbsolutePath));

            using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request))
            {
                HttpWebRequest request = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger);
                Assert.IsNotNull(request, "Request is null.");
                Assert.AreEqual("GET", request.Method);
            }
        }
示例#2
0
        private void TryUninstallApp(AppInfo app)
        {
            MakeSureDeviceConnectionIsEstablished();
            RemoteApplication appOnDevice = nativeDevice.GetApplication(app.AppGuid);

            appOnDevice.Uninstall();
        }
示例#3
0
        /// <summary>
        /// Starts the web browser, pointing at a given address.
        /// </summary>
        /// /// <param name="applicationProductId"></param>
        /// <param name="applicationGenre">The genre of the application being installed</param>
        /// <param name="pathToXap">The path to the local XAP file.</param>
        /// <param name="update">If true, the application will be updated if already on the device; otherwise, the application will be uninstalled before being reinstalled</param>
        public void Start(Guid applicationProductId, string applicationGenre, string pathToXap, bool update)
        {
            this.Start();

            if (currentDevice.IsApplicationInstalled(applicationProductId))
            {
                application = currentDevice.GetApplication(applicationProductId);

                if (update)
                {
                    application.UpdateApplication(applicationGenre, "", pathToXap);
                }
                else
                {
                    application.Uninstall();
                    application = currentDevice.InstallApplication(applicationProductId, applicationProductId,
                                                                   applicationGenre, "", pathToXap);
                }
            }
            else
            {
                application = currentDevice.InstallApplication(applicationProductId, applicationProductId,
                                                               applicationGenre, "", pathToXap);
            }

            application.Launch();
        }
示例#4
0
        [Ignore] // test no longer works since Framwork 3.0 installed
        public void RightSideHeader_FromCustomLeftSideHeader()
        {
            PathMap map =
                PathMap.CreateFromFile(
                    @"MappingTest\Mapping.xml");

            RemoteApplication.Initialize(map);

            HttpContext context =
                HttpContextHelper.CreateHttpContext("GET", "/localtest1/TestPage.aspx/someinfo", "name1=value1");


            RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request);

            Assert.IsNotNull(remoteApplication, "remoteApplication");

            TrafficLogger       logger  = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url);
            NameValueCollection headers = new NameValueCollection();

            headers.Add("X-Custom", "CustomValue");
            headers.Add("Range", "messages=1-20,25-30");
            HttpRequestHelper.AddHeaders(context.Request, headers);
            using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request))
            {
                HttpWebRequest webRequest = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger);
                Assert.IsNotNull(webRequest, "Request is null.");
                Assert.AreEqual("GET", webRequest.Method);
                Assert.IsNotNull(webRequest.Headers["X-Custom"], "CustomHeader");
                Assert.AreEqual("CustomValue", webRequest.Headers["X-Custom"]);
                Assert.IsNotNull(webRequest.Headers["Range"], "Range");
                Assert.AreEqual("messages=1-20,25-30", webRequest.Headers["Range"]);
            }
        }
        public void Start()
        {
            var oneTimePhoneEmulatorDialogMonitor = new OneTimePhoneEmulatorDialogMonitor(_logger);

            // Get CoreCon WP7 SDK
            _logger.Debug("Connecting to Windows Phone 7 Emulator/Device...");
            _wp7Device.Connect();
            _logger.Debug("Windows Phone 7 Emulator/Device Connected...");

            Uninstall();


            _tempFileName = Path.GetTempFileName();
            File.WriteAllBytes(_tempFileName, _xapHost());
            _logger.Debug("Loading into emulator: " + _tempFileName);
            Thread.Sleep(2000);

            _remoteApplication = _wp7Device.InstallApplication(
                _appGuid,
                _phoneGuid,
                "WindowsPhoneApplication1",
                null,
                _tempFileName);
            _logger.Debug("StatLight XAP installed to Windows Phone 7 Emulator...");

            _remoteApplication.Launch();
            _logger.Debug("Launched StatLight app on Windows Phone 7 Emulator...");
        }
示例#6
0
        public void RemoteApplication_PostRequest()
        {
            PathMap map =
                PathMap.CreateFromFile(
                    @"MappingTest\Mapping.xml");

            RemoteApplication.Initialize(map);

            HttpContext context         = HttpContextHelper.CreateHttpContext("POST", "/localtest1/", null);
            HttpRequest leftSideRequest = context.Request;

            RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request);
            TrafficLogger     logger            = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url);
            string            rightSideUrl      = remoteApplication.GetRightSideUrl(context.Request);

            Assert.AreEqual("http://egoratest/PvpTestApplication/1/", rightSideUrl, "RightSideUrl");

            using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request))
            {
                HttpWebRequest rightSideRequest = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger);
                Assert.IsNotNull(rightSideRequest, "Request is null.");
                Assert.AreEqual("POST", rightSideRequest.Method);
                // currently empty collection
                foreach (HttpHeader header in leftSideRequest.Headers)
                {
                    Assert.IsNotNull(rightSideRequest.Headers[header.Name], "header");
                    Assert.AreEqual(header.Value, rightSideRequest.Headers[header.Name]);
                }
            }
        }
示例#7
0
        public void RemoteApplication_GetRequest()
        {
            PathMap map =
                PathMap.CreateFromFile(
                    @"MappingTest\Mapping.xml");

            RemoteApplication.Initialize(map);

            HttpContext context = HttpContextHelper.CreateHttpContext("GET", "/localtest1/TestPage.aspx/someinfo", "name1=value1");

            using (new TraceScope(context))
            {
                RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request);
                TrafficLogger     logger            = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url);
                string            rightSideUrl      = remoteApplication.GetRightSideUrl(context.Request);
                Assert.AreEqual("http://egoratest/PvpTestApplication/1/TestPage.aspx/someinfo?name1=value1", rightSideUrl,
                                "RightSideUrl");

                using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request))
                {
                    HttpWebRequest request = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger);
                    Assert.IsNotNull(request, "Request is null.");
                    Assert.AreEqual("GET", request.Method);
                }
            }
        }
        /// <summary>
        /// Starts the controller.
        /// </summary>
        public void Start()
        {
            if (!string.IsNullOrEmpty(this.address) && !string.IsNullOrEmpty(this.port))
            {
                return;
            }

            Device device = this.FindDevice();

            if (device == null)
            {
                throw new WindowsPhoneDriverException(string.Format(CultureInfo.InvariantCulture, "Found no matching devices for name '{0}'", this.deviceName));
            }
            else
            {
                this.SendStatusUpdate("Connecting to device {0}.", device.Name);
                string assemblyDirectory       = Path.GetDirectoryName(this.GetType().Assembly.Location);
                string xapPath                 = GetPackagePath(assemblyDirectory);
                ApplicationArchiveInfo appInfo = ApplicationArchiveInfo.ReadApplicationInfo(xapPath);
                Guid   applicationId           = appInfo.ApplicationId.Value;
                string iconPath                = appInfo.ExtractIconFile();

                bool isConnectedToDevice = false;
                try
                {
                    device.Connect();
                    isConnectedToDevice = device.IsConnected();
                }
                catch (SmartDeviceException ex)
                {
                    this.SendStatusUpdate("WARNING! Exception encountered when connecting to device. HRESULT: {0:X}, message: {1}", ex.HResult, ex.Message);
                    System.Threading.Thread.Sleep(500);
                }

                if (!isConnectedToDevice)
                {
                    // TODO: Create connection mitigation routine.
                    this.SendStatusUpdate("WARNING! Was unable to connect to device!");
                }
                else
                {
                    if (!device.IsApplicationInstalled(applicationId))
                    {
                        this.SendStatusUpdate("Installing application {0}.", xapPath);
                        this.browserApplication = device.InstallApplication(applicationId, applicationId, "WindowsPhoneDriverBrowser", iconPath, xapPath);
                    }
                    else
                    {
                        this.SendStatusUpdate("Application already installed.");
                        this.browserApplication = device.GetApplication(applicationId);
                    }
                }

                File.Delete(iconPath);
            }
        }
示例#9
0
 public bool SetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users)
 {
     try
     {
         Log.WriteStart("'{0}' SetApplicationUsers", ProviderSettings.ProviderName);
         var result = RDSProvider.SetApplicationUsers(collectionName, remoteApp, users);
         Log.WriteEnd("'{0}' SetApplicationUsers", ProviderSettings.ProviderName);
         return(result);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("'{0}' SetApplicationUsers", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
示例#10
0
 public bool RemoveRemoteApplication(string collectionName, RemoteApplication remoteApp)
 {
     try
     {
         Log.WriteStart("'{0}' RemoveRemoteApplication", ProviderSettings.ProviderName);
         var result = RDSProvider.RemoveRemoteApplication(collectionName, remoteApp);
         Log.WriteEnd("'{0}' RemoveRemoteApplication", ProviderSettings.ProviderName);
         return(result);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("'{0}' RemoveRemoteApplication", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
        private void WriteApplicationAgentLogToTestLogger(string applicationName, RemoteApplication application)
        {
            TestLogger?.WriteLine("");
            TestLogger?.WriteLine($"===== Begin {applicationName} log file =====");

            try
            {
                TestLogger?.WriteLine(application.AgentLog.GetFullLogAsString());
            }
            catch (Exception)
            {
                TestLogger?.WriteLine($"No log file found for {applicationName}.");
            }

            TestLogger?.WriteLine("----- End of Agent log file -----");
        }
示例#12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <ServicePoint> servicePoints = new List <ServicePoint>();

            foreach (RemoteApplication app in RemoteApplication.GetApplications())
            {
                ServicePoint servicePoint = ServicePointManager.FindServicePoint(new Uri(app.RootUrl));
                if (!servicePoints.Contains(servicePoint))
                {
                    servicePoints.Add(servicePoint);
                }
            }

            ConnectionGridView.DataSource = servicePoints;
            ConnectionGridView.DataBind();
        }
        public void Stop()
        {
            if (File.Exists(_tempFileName))
            {
                File.Delete(_tempFileName);
            }

            if (_remoteApplication != null)
            {
                _remoteApplication.TerminateRunningInstances();
            }

            Uninstall();

            _wp7Device.Disconnect();
            _remoteApplication = null;
        }
示例#14
0
        public ConsoleDynamicMethodFixture(string applicationDirectoryName, string executableName, string targetFramework, bool isCoreApp, TimeSpan timeout)
            : base(new RemoteConsoleApplication(applicationDirectoryName, executableName, targetFramework, ApplicationType.Bounded, isCoreApp, isCoreApp)
                   .SetTimeout(timeout)
                   .ExposeStandardInput(true))
        {
            Actions(exerciseApplication: () =>
            {
                foreach (var cmd in _commands)
                {
                    if (!RemoteApplication.IsRunning)
                    {
                        throw new Exception($"Remote Process has exited, Cannot execute command: {cmd}");
                    }

                    RemoteApplication.WriteToStandardInput(cmd);
                }
                RemoteApplication.WriteToStandardInput("exit");
            });
        }
        private void Uninstall()
        {
            if (_wp7Device.IsConnected())
            {
                if (_wp7Device.IsApplicationInstalled(_appGuid))
                {
                    _logger.Debug("Uninstalling StatLight XAP to Windows Phone 7 Emulator/Device...");

                    _remoteApplication = _wp7Device.GetApplication(_appGuid);

                    if (_remoteApplication != null)
                    {
                        _remoteApplication.Uninstall();
                    }

                    _logger.Debug("StatLight XAP Uninstalled from Windows Phone 7 Emulator/Device...");
                }
            }
        }
示例#16
0
        public void RemoteApplication_GetRemoteApplication()
        {
            PathMap map =
                PathMap.CreateFromFile(
                    @"MappingTest\Mapping.xml");

            RemoteApplication.Initialize(map);

            HttpContext context1 = HttpContextHelper.CreateHttpContext("GET", "/localtest/TestPage.aspx/someinfo",
                                                                       "name1=value1");

            RemoteApplication app1 = RemoteApplication.GetRemoteApplication(context1.Request);

            Assert.IsNotNull(app1, "RemoteApplication");

            HttpContext context2 = HttpContextHelper.CreateHttpContext("GET", "/somepath/TestPage.aspx/someinfo",
                                                                       "name1=value1");
            RemoteApplication app2 = RemoteApplication.GetRemoteApplication(context2.Request);

            Assert.IsNotNull(app2);
            Assert.AreEqual("https://someserver/", app2.RootUrl);
        }
示例#17
0
        public MockNewRelicFixture(RemoteApplication remoteApplication) : base(remoteApplication)
        {
            MockNewRelicApplication = new RemoteService(ApplicationDirectoryName, ExecutableName, ApplicationType.Bounded, true, true, true);

            Actions(
                setupConfiguration: () =>
            {
                //Always restore the New Relic config settings even if the mock collector is already running
                CommonUtils.ModifyOrCreateXmlAttributeInNewRelicConfig(DestinationNewRelicConfigFilePath, new[] { "configuration", "service" }, "host", "localhost");
                CommonUtils.ModifyOrCreateXmlAttributeInNewRelicConfig(DestinationNewRelicConfigFilePath, new[] { "configuration", "service" }, "port", MockNewRelicApplication.Port.ToString(CultureInfo.InvariantCulture));

                //Increase the timeout for requests to the mock collector to 5 seconds - default is 2 seconds.
                //This assists in timing issues when spinning up both the mock collector and test application.
                CommonUtils.ModifyOrCreateXmlAttributeInNewRelicConfig(DestinationNewRelicConfigFilePath, new[] { "configuration", "service" }, "requestTimeout", "5000");

                if (MockNewRelicApplication.IsRunning)
                {
                    return;
                }

                MockNewRelicApplication.TestLogger = new XUnitTestLogger(TestLogger);
                MockNewRelicApplication.DeleteWorkingSpace();
                MockNewRelicApplication.CopyToRemote();
                MockNewRelicApplication.Start(string.Empty, doProfile: false);

                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
                ServicePointManager.ServerCertificateValidationCallback = delegate
                {
                    //force trust on all certificates for simplicity
                    return(true);
                };

                //Core apps need the collector warmed up before the core app is started so we cannot
                //wait until exerciseApplication is called to call these methods
                WarmUpCollector();
                LogSslNegotiationMessage();
            }
                );
        }
示例#18
0
        protected List <RemoteApplication> GetGridViewApps(SelectedState state)
        {
            List <RemoteApplication> apps = new List <RemoteApplication>();

            for (int i = 0; i < gvApps.Rows.Count; i++)
            {
                GridViewRow row       = gvApps.Rows[i];
                CheckBox    chkSelect = (CheckBox)row.FindControl("chkSelect");
                if (chkSelect == null)
                {
                    continue;
                }

                RemoteApplication app = new RemoteApplication();
                app.Alias               = (string)gvApps.DataKeys[i][0];
                app.DisplayName         = ((LinkButton)row.FindControl("lnkDisplayName")).Text;
                app.FilePath            = ((HiddenField)row.FindControl("hfFilePath")).Value;
                app.RequiredCommandLine = ((HiddenField)row.FindControl("hfRequiredCommandLine")).Value;
                var users = ((HiddenField)row.FindControl("hfUsers")).Value;

                if (!string.IsNullOrEmpty(users))
                {
                    app.Users = new string[] { "New" };
                }


                if (state == SelectedState.All ||
                    (state == SelectedState.Selected && chkSelect.Checked) ||
                    (state == SelectedState.Unselected && !chkSelect.Checked))
                {
                    apps.Add(app);
                }
            }

            return(apps);
        }
示例#19
0
        protected override void LaunchApp(AppInfo app)
        {
            RemoteApplication appOnDevice = nativeDevice.GetApplication(app.AppGuid);

            appOnDevice.Launch();
        }
示例#20
0
 internal static XapDeployer.DeployResult InstallApplication(XapDeployer.DeviceInfoClass DeviceInfoClass, Guid appGuid, Version appVersion, string applicationGenre, string iconFile, string xapFile, XapDeployer.DeployBehaviourType DeployBehaviourType, ref Exception Exception)
 {
     Exception = null;
     try
     {
         DatastoreManager datastoreManager1 = new DatastoreManager(CultureInfo.CurrentUICulture.LCID);
         if (datastoreManager1 != null)
         {
             Platform platform1 = datastoreManager1.GetPlatform(new ObjectId(DeviceInfoClass.PlatformId));
             if (platform1 != null)
             {
                 Device device1 = platform1.GetDevice(new ObjectId(DeviceInfoClass.DeviceId));
                 if (device1 != null)
                 {
                     device1.Connect();
                     SystemInfo systemInfo1 = device1.GetSystemInfo();
                     Version    version1    = new Version(systemInfo1.OSMajor, systemInfo1.OSMinor);
                     bool       flag1       = appVersion.CompareTo(version1) > 0;
                     if (flag1)
                     {
                         device1.Disconnect();
                         return(XapDeployer.DeployResult.NotSupported);
                     }
                     flag1 = device1.IsApplicationInstalled(appGuid);
                     if (flag1)
                     {
                         bool flag2 = DeployBehaviourType == XapDeployer.DeployBehaviourType.SkipApplication;
                         if (flag2)
                         {
                             device1.Disconnect();
                             return(XapDeployer.DeployResult.Success);
                         }
                         else
                         {
                             RemoteApplication remoteApplication1 = device1.GetApplication(appGuid);
                             flag2 = DeployBehaviourType == XapDeployer.DeployBehaviourType.ForceUninstall;
                             if (flag2)
                             {
                                 remoteApplication1.Uninstall();
                             }
                             else
                             {
                                 flag2 = DeployBehaviourType == XapDeployer.DeployBehaviourType.UpdateApplication;
                                 if (flag2)
                                 {
                                     remoteApplication1.UpdateApplication(applicationGenre, iconFile, xapFile);
                                     device1.Disconnect();
                                     return(XapDeployer.DeployResult.Success);
                                 }
                             }
                         }
                     }
                     device1.InstallApplication(appGuid, appGuid, applicationGenre, iconFile, xapFile);
                     device1.Disconnect();
                     return(XapDeployer.DeployResult.Success);
                 }
             }
         }
     }
     catch (Exception e)
     {
         return(XapDeployer.DeployResult.DeployError);
     }
     return(XapDeployer.DeployResult.DeployError);
 }
 public RejitMvcApplicationFixture(RemoteApplication remoteApplication) : base(remoteApplication)
 {
 }
 private void bgThread_GetApplications(object sender, DoWorkEventArgs e)
 {
     e.Result = RemoteApplication.GetInstalledApplications();
 }
示例#23
0
 public ResultObject RemoveRemoteApplicationFromCollection(int itemId, RdsCollection collection, RemoteApplication application)
 {
     return(RemoteDesktopServicesController.RemoveRemoteApplicationFromCollection(itemId, collection, application));
 }
示例#24
0
 public List <string> GetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp)
 {
     return(RemoteDesktopServicesController.GetApplicationUsers(itemId, collectionId, remoteApp));
 }
示例#25
0
        private static Dictionary <string, object> GetExpectedTransactionAttributesFromPreviousApp(RemoteApplication application, int index)
        {
            var parentAccountId   = application.AgentLog.GetAccountId();
            var transactionEvents = application.AgentLog.GetTransactionEvents()
                                    .OrderBy(evt => evt.IntrinsicAttributes["timestamp"])
                                    .ToList();

            Assert.True(transactionEvents.Count > index, $"Previous app does not have enough Transaction Events for the provided index. Events: {transactionEvents.Count} | index: {index}");

            var transactionEvent = transactionEvents[index];

            var failedKeys = new List <string>();
            var attributes = new Dictionary <string, object>();

            if (transactionEvent.IntrinsicAttributes.ContainsKey("priority"))
            {
                attributes.Add("priority", transactionEvent.IntrinsicAttributes["priority"]);
            }
            else
            {
                failedKeys.Add("priority");
            }

            if (transactionEvent.IntrinsicAttributes.ContainsKey("sampled"))
            {
                attributes.Add("sampled", transactionEvent.IntrinsicAttributes["sampled"]);
            }
            else
            {
                failedKeys.Add("sampled");
            }

            Assert.True(failedKeys.Count == 0, $"Previous app's first Transaction Event did not contain the keys: \"{string.Join(", ", failedKeys)}\"");

            return(attributes);
        }
示例#26
0
        /// <summary>
        /// Starts the web browser, pointing at a given address.
        /// </summary>
        /// /// <param name="applicationProductId"></param>
        /// <param name="applicationGenre">The genre of the application being installed</param>
        /// <param name="pathToXap">The path to the local XAP file.</param>
        /// <param name="update">If true, the application will be updated if already on the device; otherwise, the application will be uninstalled before being reinstalled</param>
        public void Start(Guid applicationProductId, string applicationGenre, string pathToXap, bool update)
        {
            this.Start();

            if (currentDevice.IsApplicationInstalled(applicationProductId))
            {
                application = currentDevice.GetApplication(applicationProductId);

                if (update)
                {
                    application.UpdateApplication(applicationGenre, "", pathToXap);
                }
                else
                {
                    application.Uninstall();
                    application = currentDevice.InstallApplication(applicationProductId, applicationProductId,
                        applicationGenre, "", pathToXap);
                }
            }
            else
            {
                application = currentDevice.InstallApplication(applicationProductId, applicationProductId,
                        applicationGenre, "", pathToXap);
            }

            application.Launch();
        }
        /// <summary>
        /// Starts the controller.
        /// </summary>
        public void Start()
        {
            if (!string.IsNullOrEmpty(this.address) && !string.IsNullOrEmpty(this.port))
            {
                return;
            }

            Device device = this.FindDevice();

            if (device == null)
            {
                throw new ConsoleDriverException(string.Format("Found no matching devices for {0}", this.deviceName));
            }
            else
            {
                Console.WriteLine("Found device {0}.", device.Name);
                string assemblyDirectory = Path.GetDirectoryName(this.GetType().Assembly.Location);
                string xapPath = GetPackagePath(assemblyDirectory);
                XapInfo appInfo = XapInfo.ReadApplicationInfo(xapPath);
                Guid applicationId = appInfo.ApplicationId.Value;
                string iconPath = appInfo.ExtractIconFile();

                bool isConnectedToDevice = false;
                try
                {
                    device.Connect();
                    isConnectedToDevice = device.IsConnected();
                }
                catch (SmartDeviceException ex)
                {
                    Console.WriteLine("WARNING! Exception encountered when connecting to device. HRESULT: {0:X}, message: {1}", ex.HResult, ex.Message);
                    System.Threading.Thread.Sleep(500);
                }

                if (!isConnectedToDevice)
                {
                    // TODO: Create connection mitigation routine.
                    Console.WriteLine("WARNING! Was unable to connect to device!");
                }
                else
                {
                    if (!device.IsApplicationInstalled(applicationId))
                    {
                        var apps = device.GetInstalledApplications();
                        Console.WriteLine("Installing application {0}.", xapPath);
                        this.browserApplication = device.InstallApplication(applicationId, applicationId, "WindowsPhoneDriverBrowser", iconPath, xapPath);
                    }
                    else
                    {
                        Console.WriteLine("Application already installed.");
                        this.browserApplication = device.GetApplication(applicationId);
                    }
                }

                File.Delete(iconPath);
            }
        }
示例#28
0
        public override bool Execute(RunInput input)
        {
            string runnerDirectory = Assembly.GetExecutingAssembly().Location.ParentDirectory();

            Task bottling = Task.Factory.StartNew(() => {
                if (!input.NoBottlingFlag)
                {
                    new BottleCommand().Execute(new BottleInput {
                        NoZipFlag = true
                    });
                }
            });

            Task cleaning     = Task.Factory.StartNew(() => cleanExplodedBottleContents(runnerDirectory));
            var  hostCleaning = Task.Factory.StartNew(() =>
            {
                if (input.HostFlag.IsNotEmpty())
                {
                    input.TryToCleanOutFubuContentFolder();
                }
            });

            Task.WaitAll(bottling, cleaning, hostCleaning);

            var directories = input.ToDirectories();

            var currentDirectory = Environment.CurrentDirectory;

            try
            {
                _application = new RemoteApplication(x => {
                    x.Setup.AppDomainInitializerArguments = new[] { JsonUtil.ToJson(directories) };
                    x.Setup.ApplicationBase = runnerDirectory;
                });

                _application.Start(input.ToRequest());

                tellUserWhatToDo();
                ConsoleKeyInfo key = Console.ReadKey();
                while (key.Key != ConsoleKey.Q)
                {
                    if (key.Key == ConsoleKey.R)
                    {
                        Environment.CurrentDirectory = currentDirectory;
                        new SnippetsCommand().Execute(new SnippetsInput());
                        _application.RecycleAppDomain();

                        ConsoleWriter.Write(ConsoleColor.Green, "Recycling successful!");

                        tellUserWhatToDo();
                    }

                    key = Console.ReadKey();

                    Console.WriteLine();
                    Console.WriteLine();
                }

                _application.Shutdown();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(true);
        }
示例#29
0
 protected void Page_Load(object sender, EventArgs e)
 {
     apps = RemoteApplication.GetApplications();
     ApplicationsGridView.DataSource = apps;
     ApplicationsGridView.DataBind();
 }
示例#30
0
        /// <summary>
        /// Starts the controller.
        /// </summary>
        public void Start()
        {
            if (!string.IsNullOrEmpty(this.address) && !string.IsNullOrEmpty(this.port))
            {
                return;
            }

            Device device = this.FindDevice();

            if (device == null)
            {
                throw new WindowsPhoneDriverException(string.Format(CultureInfo.InvariantCulture, "Found no matching devices for name '{0}'", this.deviceName));
            }
            else
            {
                this.SendStatusUpdate("Connecting to device {0}.", device.Name);

                List <string> fileNames = new List <string>();
                if (!this.appPath.Equals(string.Empty))
                {
                    this.assemblyDirectory = Path.GetDirectoryName(this.appPath);
                    fileNames.Add(Path.GetFileName(this.appPath));
                }
                else
                {
                    this.assemblyDirectory = Path.GetDirectoryName(this.GetType().Assembly.Location);
                    fileNames.Add("WindowsPhoneDriverBrowser.xap");
                }
                string path = GetPackagePath(this.assemblyDirectory, fileNames);

                this.SendStatusUpdate("path: " + path);
                ApplicationArchiveInfo appInfo = ApplicationArchiveInfo.ReadApplicationInfo(path);

                Guid   applicationId = appInfo.ApplicationId.Value;
                string iconPath      = appInfo.ExtractIconFile();

                bool isConnectedToDevice = false;
                try
                {
                    device.Connect();
                    isConnectedToDevice = device.IsConnected();
                }
                catch (SmartDeviceException ex)
                {
                    this.SendStatusUpdate("WARNING! Exception encountered when connecting to device. HRESULT: {0:X}, message: {1}", ex.HResult, ex.Message);
                    System.Threading.Thread.Sleep(500);
                }

                if (!isConnectedToDevice)
                {
                    // TODO: Create connection mitigation routine.
                    this.SendStatusUpdate("WARNING! Was unable to connect to device!");
                }
                else
                {
                    if (path.EndsWith("xap"))
                    {
                        if (device.IsApplicationInstalled(applicationId))
                        {
                            this.SendStatusUpdate("Application already installed. Uninstalling..");
                            device.GetApplication(applicationId).Uninstall();
                        }
                        this.SendStatusUpdate("Installing application {0}.", path);
                        this.browserApplication = device.InstallApplication(applicationId, applicationId, "WindowsPhoneDriverBrowser", iconPath, path);
                    }
                    else
                    {
                        if (device.IsApplicationInstalled(applicationId))
                        {
                            this.SendStatusUpdate("Application already installed. Uninstalling..");
                            device.GetApplication(applicationId).Uninstall();
                        }
                        this.SendStatusUpdate("Installing application {0}.", path);
                        IAppManifestInfo  manifestInfo      = Utils.ReadAppManifestInfoFromPackage(this.appPath);
                        DeploymentOptions deploymentOptions = DeploymentOptions.None;
                        var devices    = Utils.GetDevices();
                        var utilDevice = devices.FirstOrDefault(d => d.ToString() == "Device");
                        Utils.InstallApplication(utilDevice, manifestInfo, deploymentOptions, this.appPath);
                    }
                }

                File.Delete(iconPath);
            }
        }
示例#31
0
 public ResultObject SetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, List <string> users)
 {
     return(RemoteDesktopServicesController.SetApplicationUsers(itemId, collectionId, remoteApp, users));
 }