public static async Task <Screenshot> GetAppScreenshotAsync(Guid appGuid, AppScreenshotType screenshotType, AppScreenshotSize screenshotSize, int screenshotIndex)
        {
            //var rootFilter = new HttpBaseProtocolFilter();
            //rootFilter.CacheControl.ReadBehavior = Windows.Web.Http.Filters.HttpCacheReadBehavior.MostRecent;
            //rootFilter.CacheControl.WriteBehavior = Windows.Web.Http.Filters.HttpCacheWriteBehavior.NoCache;
            var client = new HttpClient();

            client.DefaultRequestHeaders.Add("appGuid", appGuid.ToString());
            client.DefaultRequestHeaders.Add("screenshotType", screenshotType.ToString());
            client.DefaultRequestHeaders.Add("screenshotSize", screenshotSize.ToString());
            client.DefaultRequestHeaders.Add("screenshotIndex", screenshotIndex.ToString());
            var response = await client.GetAsync(ServerUri.GetScreenshotDownloadUri(appGuid, screenshotIndex, (ScreenshotType)screenshotType, (ScreenshotSize)screenshotSize));

            var buffer = await response.Content.ReadAsBufferAsync().AsTask();

            var image = await buffer.ToArray().ConvertToBitmapImageAsync();

            return(new Screenshot()
            {
                AppGuid = appGuid,
                OriginalImage = screenshotSize == AppScreenshotSize.Original ? image : null,
                ThumbnailImage = screenshotSize == AppScreenshotSize.Thumbnail ? image : null,
                Index = screenshotIndex
            });
        }
        public async Task StartDownloadAsync(AppDownloadItem appDownloadItem)
        {
            await InitializeAsync();

            if (FindAppInCurrentDownloads(appDownloadItem.AppGuid) != null)
            {
                return;
            }

            // Start Download
            CurrentDownloads.Add(appDownloadItem);
            appDownloadItem.StorageFile = await CurrentApplication.AppDownloadFolder.CreateFileAsync(
                $"{appDownloadItem.AppGuid}.pstl",
                CreationCollisionOption.ReplaceExisting);

            var downloadOperation = await _downloader.StartDownloadAsync(
                ServerUri.GetAppDownloadUri(appDownloadItem.AppGuid),
                appDownloadItem.StorageFile);

            appDownloadItem.StartDate    = DateTime.Now;
            appDownloadItem.DownloadGuid = downloadOperation.Guid;
            appDownloadItem.Tag          = downloadOperation;

            // update collections
            _downloadsHistory.Add(appDownloadItem);
            await SaveDownloadsHistoryToFileAsync();
        }
Beispiel #3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ForceUpdate != false)
            {
                hash ^= ForceUpdate.GetHashCode();
            }
            if (ServerUri.Length != 0)
            {
                hash ^= ServerUri.GetHashCode();
            }
            if (ActualEnvId.Length != 0)
            {
                hash ^= ActualEnvId.GetHashCode();
            }
            if (ManifestVersion.Length != 0)
            {
                hash ^= ManifestVersion.GetHashCode();
            }
            if (qualityLevel_ != null)
            {
                hash ^= QualityLevel.GetHashCode();
            }
            if (ForceUpdateUrl.Length != 0)
            {
                hash ^= ForceUpdateUrl.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Beispiel #4
0
        public void Should_allow_multiple_connections()
        {
            var requests = new List <HttpWebRequest>();

            Stopwatch connectionTimer = Stopwatch.StartNew();

            int expected = 100;

            for (int i = 0; i < expected; i++)
            {
                var webRequest = (HttpWebRequest)WebRequest.Create(ServerUri.AppendPath("Services/MyService"));
                webRequest.Method = "POST";
                using (Stream reque = webRequest.GetRequestStream())
                {
                    byte[] buffer = Encoding.UTF8.GetBytes("Hello");

                    reque.Write(buffer, 0, buffer.Length);
                }

                requests.Add(webRequest);
            }

            connectionTimer.Stop();

            Trace.WriteLine("Established {0} connections in {0}ms".FormatWith(expected, connectionTimer.ElapsedMilliseconds));

            requests.ForEach(request =>
            {
                try
                {
                    using (WebResponse webResponse = request.GetResponse())
                    {
                        using (Stream responseStream = webResponse.GetResponseStream())
                        {
                            string response = responseStream.ReadToEndAsText();
                            Trace.WriteLine(response);
                        }
                        webResponse.Close();
                    }
                }
                catch (WebException ex)
                {
                    using (WebResponse response = ex.Response)
                    {
                        var httpResponse = (HttpWebResponse)response;

                        Trace.WriteLine("HttpStatusCode: " + httpResponse.StatusCode);
                        using (Stream data = response.GetResponseStream())
                        {
                            string r = data.ReadToEndAsText();
                            Trace.WriteLine(r);
                        }
                    }
                }
            });

            requests.Clear();
        }
 private Native.SyncConfiguration ToNative()
 {
     return(new Native.SyncConfiguration
     {
         SyncUserHandle = User.Handle,
         Url = ServerUri.ToString(),
         client_validate_ssl = EnableSSLValidation
     });
 }
        public static async Task <BitmapImage> GetAppBackgroundImageAsync(Guid appGuid)
        {
            var client   = new HttpClient();
            var response = await client.GetAsync(ServerUri.GetAppBackgroundImageUri(appGuid));

            var buffer = await response.Content.ReadAsBufferAsync().AsTask();

            return(await buffer.ToArray().ConvertToBitmapImageAsync());
        }
Beispiel #7
0
        private IUserService CreateUserService()
        {
            string         serviceUrl = ServerUri.GetUserWcfServiceUri().OriginalString;
            NetHttpBinding binding    = new NetHttpBinding();

            binding.MaxReceivedMessageSize = 500 * 1024;
            _channelFactory = new ChannelFactory <IUserService>(binding, new EndpointAddress(serviceUrl));
            return(_channelFactory.CreateChannel());
        }
        public async Task AddPlayerStatsAsync(string uuid)
        {
            var stats = new PlayerStatModel($"{ServerUri.TrimEnd('/')}/{uuid.TrimStart('/').TrimEnd('/')}.json");

            if (await stats.ReadStatsAsync())
            {
                PlayerStats.Add(stats);
            }
        }
 private void OnPermissionsUpdated(Uri updatedUrl, Permissions oldPermissions, Permissions newPermissions)
 {
     // updated URI matches protocol, hostname, and port, and if it has a path, that matches too
     if (updatedUrl.Scheme == ServerUri.Scheme && updatedUrl.Authority == ServerUri.Authority &&
         (updatedUrl.AbsolutePath == "/" || updatedUrl.AbsolutePath == ServerUri.AbsolutePath) &&
         _appState != AppState.Stopped)
     {
         Startup(ServerUri.ToString(), SessionId);
     }
 }
        protected override void EstablishContext()
        {
            SubscriptionServiceUri = SubscriptionServiceUri.Replace("loopback", "msmq");
            ClientControlUri       = ClientControlUri.Replace("loopback", "msmq");
            ServerControlUri       = ServerControlUri.Replace("loopback", "msmq");
            ClientUri = ClientUri.Replace("loopback", "msmq");
            ServerUri = ServerUri.Replace("loopback", "msmq");

            base.EstablishContext();
        }
Beispiel #11
0
 /// <summary>创建连接,单工连接或者双工连接,适用于高级的Channel</summary>
 public virtual RpcConnection CreateConnection(ServerUri serverUri, RpcConnectionMode mode)
 {
     if (mode == RpcConnectionMode.Simplex)
     {
         return(new RpcSimplexConnection(this, serverUri));
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Beispiel #12
0
 public void Connecting_to_a_socket_server()
 {
     _webRequest = (HttpWebRequest)WebRequest.Create(ServerUri.AppendPath("version"));
     try
     {
         _webResponse = (HttpWebResponse)_webRequest.GetResponse();
     }
     catch (WebException ex)
     {
         _webResponse = (HttpWebResponse)ex.Response;
     }
 }
Beispiel #13
0
        /// <summary>
        /// Returns true if this connection info has the same
        ///     data field values (server URL, project, and team)
        ///     as the other object. Ignores LastUsage
        /// </summary>
        /// <param name="other">The other object to compare</param>
        /// <returns>true iff data fields match (ignores LastUsage field)</returns>
        public bool DataEquals(ConnectionInfo other)
        {
            if (other == null)
            {
                return(false);
            }

            // crash was reported over watson.
            // make sure Project and Team are not null first.
            return(ServerUri != null && ServerUri.Equals(other.ServerUri) &&
                   Project != null && Project.Equals(other.Project) &&
                   Team != null && Team.Equals(other.Team));
        }
Beispiel #14
0
        private void SetUriModel()
        {
            ServerUri.TojsonFile();
            FileStream   fileStream = new FileStream(Jsonpath, FileMode.Open);
            StreamReader sw         = new StreamReader(fileStream);
            var          jsonvar    = sw.ReadToEnd();

            sw.Close();
            sw.Dispose();
            fileStream.Close();
            fileStream.Dispose();
            ServerUri = JsonConvert.DeserializeObject <ServerUriModel>(jsonvar);
        }
Beispiel #15
0
        private Uri GetRequestUri(string query)
        {
            var uri = ServerUri.ToString();

            if (!uri.EndsWith("?") && !uri.EndsWith("&"))
            {
                uri += "?";
            }

            uri += "SERVICE=WMS&VERSION=" + Version + "&REQUEST=" + query;

            return(new Uri(uri.Replace(" ", "%20")));
        }
Beispiel #16
0
        /// <summary>
        ///		创建连接
        /// </summary>
        /// <param name="serverUri"></param>
        /// <param name="mode">单工或是双工连接</param>
        /// <returns></returns>
        public override RpcConnection CreateConnection(ServerUri serverUri, RpcConnectionMode mode)
        {
            switch (mode)
            {
            case RpcConnectionMode.Simplex:
                return(new RpcTcpSimplexConnection(this, (TcpUri)serverUri, p_channelSettings.ConcurrentConnection));

            case RpcConnectionMode.Duplex:
                return(new RpcTcpDuplexConnection(this, (TcpUri)serverUri));

            default:
                throw new NotSupportedException();
            }
        }
Beispiel #17
0
        /// <summary>
        ///		创建一个Transaction
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        /// <remarks>这个事务会建立在单工的Tcp连接上</remarks>
        public override RpcClientTransaction CreateTransaction(ServerUri uri, RpcRequest request)
        {
            RpcTcpSimplexConnection conn;

            lock (_syncRoot) {
                if (!_simplexConnections.TryGetValue(uri, out conn))
                {
                    conn = new RpcTcpSimplexConnection(this, (TcpUri)uri, p_channelSettings.ConcurrentConnection);
                    conn.Disconnected += new Action <RpcConnection>(conn_Disconnected);
                    _simplexConnections.Add(uri, conn);
                }
            }
            return(conn.CreateTransaction(request));
        }
        private Native.SyncConfiguration ToNative()
        {
            if (!string.IsNullOrEmpty(TrustedCAPath) &&
                !File.Exists(TrustedCAPath))
            {
                throw new FileNotFoundException($"{nameof(TrustedCAPath)} has been specified, but the file was not found.", TrustedCAPath);
            }

            return(new Native.SyncConfiguration
            {
                SyncUserHandle = User.Handle,
                Url = ServerUri.ToString(),
                client_validate_ssl = EnableSSLValidation,
                TrustedCAPath = TrustedCAPath
            });
        }
        internal override Realm CreateRealm(RealmSchema schema)
        {
            var configuration = new Realms.Native.Configuration
            {
                schema_version = SchemaVersion
            };

            var syncConfiguration = new Native.SyncConfiguration
            {
                SyncUserHandle = User.Handle,
                Url            = ServerUri.ToString()
            };

            var srHandle = SharedRealmHandleExtensions.OpenWithSync(configuration, syncConfiguration, schema, EncryptionKey);

            return(new Realm(srHandle, this, schema));
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (serverUri_ != null)
            {
                hash ^= ServerUri.GetHashCode();
            }
            if (PathPrefix.Length != 0)
            {
                hash ^= PathPrefix.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Beispiel #21
0
        static void Main(string[] args)
        {
            try
            {
                WriteLine("Starting");

                WriteLine("Please enter user name");
                var userName = ReadLine();
                WriteLine("Please enter password");
                var password = ReadLine();
                var uri      = new ServerUri("todo");

                uri.SetUser(userName, password);

                var actions = new GdmActions(uri);


                var modelUri = "model://CHMI_W_FLOW_FCT/EU.WATER_OUT.CHMI.BECHYNE.FCT";
                WriteLine($"Getting model for {modelUri}");
                var model = actions.GetModel(modelUri);


                var firstCuve = model.Curves.First(c => c.Name == "CURVE");
                var firstOd   = firstCuve.CurveDates.First();
                var versions  = firstOd.Versions.Select(v => $"{modelUri}/CURVE/{firstOd.OnDateAsString}/{v.Name}").ToArray();
                WriteLine($"Found {versions.Length} ondates");

                // One by one, slow but only for demo
                versions.ForEach(v =>
                {
                    WriteLine($"Getting data for {v}");
                    (double[] data, string fullRange) = actions.GetGenicData(v, "range://default");
                    WriteLine($"Found {data.Length} items for full range: {fullRange}");
                });
            }
            catch (Exception exp)
            {
                WriteLine(exp.Message);
            }

            WriteLine("Press any key to exit");
            ReadKey();
        }
Beispiel #22
0
        internal override Realm CreateRealm(RealmSchema schema)
        {
            var configuration = new Realms.Native.Configuration
            {
                Path           = DatabasePath,
                schema_version = SchemaVersion
            };

            var syncConfiguration = new Native.SyncConfiguration
            {
                SyncUserHandle      = User.Handle,
                Url                 = ServerUri.ToString(),
                client_validate_ssl = EnableSSLValidation,
            };

            var srHandle = SharedRealmHandleExtensions.OpenWithSync(configuration, syncConfiguration, schema, EncryptionKey);

            return(new Realm(srHandle, this, schema));
        }
 public void MergeFrom(HttpService other)
 {
     if (other == null)
     {
         return;
     }
     if (other.serverUri_ != null)
     {
         if (serverUri_ == null)
         {
             serverUri_ = new global::Envoy.Api.V2.Core.HttpUri();
         }
         ServerUri.MergeFrom(other.ServerUri);
     }
     if (other.PathPrefix.Length != 0)
     {
         PathPrefix = other.PathPrefix;
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
Beispiel #24
0
        private static void Branch_SetServerEnabled(XmlDocument doc, Object parameters)
        {
            ServerUri uri     = (ServerUri)(parameters as Object[])[0];
            bool      blValue = (bool)(parameters as Object[])[1];

            if (uri is ArcIMSServerUri)
            {
                SetArcIMSServerEnabled(doc, uri as ArcIMSServerUri, blValue);
            }
            else if (uri is DapServerUri)
            {
                SetDAPServerEnabled(doc, uri as DapServerUri, blValue);
            }
            else if (uri is WMSServerUri)
            {
                SetWMSServerEnabled(doc, uri as WMSServerUri, blValue);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Beispiel #25
0
        public RpcDuplexClient(ServerUri serverUri)
        {
            _serverUri = serverUri;

            _channel = RpcProxyFactory.GetChannel(serverUri);
            _timeout = _channel.Timeout;

            _connection = _channel.CreateConnection(serverUri, RpcConnectionMode.Duplex);
            _connection.Disconnected += new Action <RpcConnection>(
                (c) =>
            {
                OnDisconnected();
            }
                );
            _connection.TransactionCreated += new Action <RpcConnection, RpcServerTransaction>(
                (c, tx) =>
            {
                _dispatcher.ProcessTransaction(tx);
            }
                );

            _dispatcher = new RpcServiceDispather("duplex");
        }
Beispiel #26
0
 internal static void SetFavourite(ServerUri oUri)
 {
     ExecuteUpdate(new UpdateDelegate(Branch_SetFavourite), oUri);
 }
Beispiel #27
0
 internal static void RemoveServer(ServerUri oUri)
 {
     ExecuteUpdate(new UpdateDelegate(Branch_RemoveServer), oUri);
 }
Beispiel #28
0
 internal static void SetServerEnabled(ServerUri oUri, bool blEnabled)
 {
     ExecuteUpdate(new UpdateDelegate(Branch_SetServerEnabled), new Object[] { oUri, blEnabled });
 }
Beispiel #29
0
 internal static bool ContainsServer(ServerUri oUri)
 {
     return(ExecuteQuery(new QueryDelegate(Branch_ContainsServer), oUri));
 }
Beispiel #30
0
 public bool IsUrl()
 {
     return(ServerUri.IsUrl());
 }