public void TestAuthenticateUltra()
        {
            if (!ServerUrl.Contains("api-internal.braincloudservers.com") &&
                !ServerUrl.Contains("internala.braincloudservers.com") &&
                !ServerUrl.Contains("api.internalg.braincloudservers.com"))
            {
                Console.WriteLine("This env doesn't support Ultra authentication type");
                Assert.True(true);
                return;
            }

            TestResult tr = new TestResult(_bc);

            _bc.Client.AuthenticationService.AuthenticateUniversal(
                GetUser(Users.UserA).Id,
                GetUser(Users.UserA).Password,
                true,
                tr.ApiSuccess, tr.ApiError);
            tr.Run();

            _bc.ScriptService.RunScript("getUltraToken", "{}", tr.ApiSuccess, tr.ApiError);
            tr.Run();

            var    data     = tr.m_response["data"] as Dictionary <string, object>;
            var    response = data["response"] as Dictionary <string, object>;
            var    data2    = response["data"] as Dictionary <string, object>;
            var    json     = data2["json"] as Dictionary <string, object>;
            string idToken  = json["id_token"] as string;

            _bc.PlayerStateService.Logout();

            _bc.AuthenticateUltra("braincloud1", idToken, true, tr.ApiSuccess, tr.ApiError);
            tr.Run();
        }
예제 #2
0
        private string CreateUrl(string path, params string[] pathParams)
        {
            var url = new StringBuilder();

            url.Append(ServerUrl);

            if (!ServerUrl.EndsWith("/"))
            {
                url.Append("/");
            }

            url.Append("api/v4");

            if (!path.StartsWith("/"))
            {
                url.Append("/");
            }

            var escapedPathParams = pathParams
                                    .Select(x => Uri.EscapeDataString(x))
                                    .ToArray();

            url.Append(string.Format(path, escapedPathParams));

            return(url.ToString());
        }
예제 #3
0
 public bool CanValidate()
 {
     return
         (false == ServerUrl.IsNullOrWhiteSpace() &&
          false == Email.IsNullOrWhiteSpace() &&
          false == Password.IsNullOrWhiteSpace());
 }
예제 #4
0
        public bool InitBackup()
        {
            ServerUrl = ServerUrl.TrimEnd('/');

            store = new DocumentStore {
                Url = ServerUrl, DefaultDatabase = Database, ApiKey = ApiKey
            };
            store.Initialize();

            var json = @"{ ""BackupLocation"": """ + BackupPath.Replace("\\", "\\\\") + @""" }";

            var url = "/admin/backup";

            if (Incremental)
            {
                url += "?incremental=true";
            }
            var req = CreateRequest(url, "POST");

            req.Write(json);
            try
            {
                Console.WriteLine("Sending json {0} to {1}", json, ServerUrl);

                var response = req.ReadResponseJson();
                Console.WriteLine(response);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                return(false);
            }

            return(true);
        }
예제 #5
0
        public IEnumerator TestAuthenticateUltra()
        {
            if (!ServerUrl.Contains("api-internal.braincloudservers.com") &&
                !ServerUrl.Contains("internala.braincloudservers.com") &&
                !ServerUrl.Contains("api.internalg.braincloudservers.com"))
            {
                Debug.Log("This env doesn't support Ultra authentication type");
                Assert.True(true);
            }
            else
            {
                yield return(_tc.StartCoroutine(_tc.SetUpNewUser(Users.UserA)));

                _tc.bcWrapper.ScriptService.RunScript("getUltraToken", "{}", _tc.ApiSuccess, _tc.ApiError);
                yield return(_tc.StartCoroutine(_tc.Run()));

                var    data     = _tc.m_response["data"] as Dictionary <string, object>;
                var    response = data["response"] as Dictionary <string, object>;
                var    data2    = response["data"] as Dictionary <string, object>;
                var    json     = data2["json"] as Dictionary <string, object>;
                string idToken  = json["id_token"] as string;

                _tc.bcWrapper.PlayerStateService.Logout();
                yield return(_tc.StartCoroutine(_tc.Spin()));

                _tc.bcWrapper.AuthenticateUltra("braincloud1", idToken, true, _tc.ApiSuccess, _tc.ApiError);
                yield return(_tc.StartCoroutine(_tc.Run()));

                LogResults("Failed to authenticate ultra", _tc.successCount == 2);
            }
        }
예제 #6
0
        protected int CompareTo(ChorusUrl other)
        {
            // Culture specific sorting desirable in file paths
// ReSharper disable StringCompareToIsCultureSpecific
            int result = ServerUrl.CompareTo(other.ServerUrl);

            if (result != 0)
            {
                return(result);
            }
            if (FileId.HasValue)
            {
                result = FileId.Value.CompareTo(other.FileId);
                if (result != 0)
                {
                    return(result);
                }
            }
            else if (other.FileId.HasValue)
            {
                return(-1);
            }
            return(Path.CompareTo(other.Path));
// ReSharper restore StringCompareToIsCultureSpecific
        }
예제 #7
0
        private void CopyCommandLineArgs()
        {
            if (CommandLineParser.CommandLineArgs.TryGetValue("organizationid", out var orgID))
            {
                OrganizationID = orgID;
            }

            if (CommandLineParser.CommandLineArgs.TryGetValue("serverurl", out var serverUrl))
            {
                ServerUrl = serverUrl;
            }

            if (CommandLineParser.CommandLineArgs.TryGetValue("devicegroup", out var deviceGroup))
            {
                DeviceGroup = deviceGroup;
            }

            if (CommandLineParser.CommandLineArgs.TryGetValue("devicealias", out var deviceAlias))
            {
                DeviceAlias = deviceAlias;
            }

            if (CommandLineParser.CommandLineArgs.TryGetValue("deviceuuid", out var deviceUuid))
            {
                DeviceUuid = deviceUuid;
            }

            if (ServerUrl?.EndsWith("/") == true)
            {
                ServerUrl = ServerUrl.Substring(0, ServerUrl.LastIndexOf("/"));
            }
        }
예제 #8
0
        public ServerUrl GetUrlPort(ServerUrl defaultVal)
        {
            string urlPortDefault = JsonSerializer.Serialize(defaultVal);
            string urlPortJson    = CrossSettings.Current.GetValueOrDefault("url:port", urlPortDefault);

            return(JsonSerializer.Deserialize <ServerUrl>(urlPortJson));
        }
        /// <summary>
        /// Generates the ControlSpecific JavaScript. This script is safe to
        /// allow multiple callbacks to run simultaneously.
        /// </summary>
        private void GenerateControlSpecificJavaScript()
        {
            // Figure out the initial URL we're going to
            // Either it's the provided URL from the control or
            // we're posting back to the current page
            string Url = null;

            if (string.IsNullOrEmpty(ServerUrl))
            {
                Url = Context.Request.Path;
            }
            else
            {
                Url = ResolveUrl(ServerUrl);
            }

            Uri ExistingUrl = Context.Request.Url;

            // Must fix up URL into fully qualified URL for XmlHttp
            if (!ServerUrl.ToLower().StartsWith("http"))
            {
                Url = ExistingUrl.Scheme + "://" + ExistingUrl.Authority + Url;
            }

            GenerateClassWrapperForCallbackMethods();
        }
예제 #10
0
        public Crawler Fetch()
        {
            if (!IsExternalIPAddress(SourceUrl))
            {
                State = "INVALID_URL";
                return(this);
            }
            var request = new HttpClient();

            try
            {
                ServerUrl = PathFormatter.Format(Path.GetFileName(SourceUrl), Config.GetString("catcherPathFormat"));
                var savePath = Path.Combine(WebRootPath, ServerUrl.Replace('/', Path.DirectorySeparatorChar));
                if (!Directory.Exists(Path.GetDirectoryName(savePath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(savePath));
                }
                var stream = request.GetStreamAsync(SourceUrl).Result;
                using (var fs = new FileStream(savePath, FileMode.OpenOrCreate))
                {
                    stream.CopyToAsync(fs).Wait();
                }
                State = "SUCCESS";
                return(this);
            }
            catch (Exception e)
            {
                State = e.Message;
                return(this);
            }
        }
예제 #11
0
        public bool InitBackup()
        {
            ServerUrl = ServerUrl.TrimEnd('/');

            var json = @"{ ""BackupLocation"": """ + BackupPath.Replace("\\", "\\\\") + @""" }";

            var uriString = ServerUrl + "/admin/backup";

            if (Incremental)
            {
                uriString += "?incremental=true";
            }
            var req = WebRequest.Create(uriString);

            req.Method = "POST";
            req.UseDefaultCredentials = true;
            req.PreAuthenticate       = true;
            req.Credentials           = CredentialCache.DefaultCredentials;

            using (var streamWriter = new StreamWriter(req.GetRequestStream()))
            {
                streamWriter.WriteLine(json);
                streamWriter.Flush();
            }

            try
            {
                Console.WriteLine("Sending json {0} to {1}", json, ServerUrl);

                using (var resp = req.GetResponse())
                    using (var reader = new StreamReader(resp.GetResponseStream()))
                    {
                        var response = reader.ReadToEnd();
                        Console.WriteLine(response);
                    }
            }
            catch (WebException we)
            {
                var response = we.Response as HttpWebResponse;
                if (response == null)
                {
                    Console.WriteLine(we.Message);
                    return(false);
                }
                Console.WriteLine(response.StatusCode + " " + response.StatusDescription);
                using (var reader = new StreamReader(response.GetResponseStream()))
                {
                    Console.WriteLine(reader.ReadToEnd());
                    return(false);
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                return(false);
            }

            return(true);
        }
예제 #12
0
        public Crawler Fetch()
        {
            if (!IsExternalIPAddress(this.SourceUrl))
            {
                State = "INVALID_URL";
                return(this);
            }
            var request = HttpWebRequest.Create(this.SourceUrl) as HttpWebRequest;

            using (var response = request.GetResponseAsync().Result as HttpWebResponse)
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    State = "Url returns " + response.StatusCode + ", " + response.StatusDescription;
                    return(this);
                }
                if (response.ContentType.IndexOf("image") == -1)
                {
                    State = "Url is not an image";
                    return(this);
                }
                ServerUrl = PathFormatter.Format(Path.GetFileName(this.SourceUrl), Config.GetString("catcherPathFormat"), _userid);
                if (!ServerUrl.StartsWith("/upFiles"))
                {
                    State = "Url is invalid!";
                    return(this);
                }
                var savePath = _context.MapPath(ServerUrl);
                var folder   = Path.GetDirectoryName(savePath);
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                try
                {
                    var    stream = response.GetResponseStream();
                    var    reader = new BinaryReader(stream);
                    byte[] bytes;
                    using (var ms = new MemoryStream())
                    {
                        byte[] buffer = new byte[4096];
                        int    count;
                        while ((count = reader.Read(buffer, 0, buffer.Length)) != 0)
                        {
                            ms.Write(buffer, 0, count);
                        }
                        bytes = ms.ToArray();
                    }
                    File.WriteAllBytes(savePath, bytes);
                    State = "SUCCESS";
                }
                catch (Exception e)
                {
                    State = "抓取错误:" + e.Message;
                }
                return(this);
            }
        }
예제 #13
0
        public void Copy(string copyWhat, string copyTo)
        {
            string fullCopyToUrl = ServerUrl.TrimEnd("/".ToCharArray()) + copyTo.TrimEnd("/".ToCharArray()) + "/" + Path.GetFileName(copyWhat);
            IDictionary <string, string> headers = new Dictionary <string, string> {
                { "Destination", fullCopyToUrl }
            };

            SendRequest(copyWhat, "COPY", null, null, headers);
        }
예제 #14
0
        public void Move(string moveWhat, string moveTo)
        {
            string fullMoveTo = ServerUrl.TrimEnd("/".ToCharArray()) + moveTo.TrimEnd("/".ToCharArray()) + "/" + Path.GetFileName(moveWhat);
            IDictionary <string, string> headers = new Dictionary <string, string> {
                { "Destination", fullMoveTo }
            };

            SendRequest(moveWhat, "MOVE", null, null, headers);
        }
예제 #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="subfield"></param>
 /// <param name="getParameter"></param>
 /// <returns></returns>
 public string GetUrlWithServer(string subfield, string getParameter = "")
 {
     return(ServerUrl.CombinePath(string.Format("{0}?mt={1}&ver={2}&token={3}&userid={4}{5}",
                                                subfield,            //
                                                App.YxPlatForm,      //平台
                                                Application.version, //版本
                                                LoginInfo.Instance.ctoken,
                                                LoginInfo.Instance.user_id,
                                                getParameter)));//其他
 }
예제 #16
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (ServerUrl != null ? ServerUrl.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Username != null ? Username.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Password != null ? Password.GetHashCode() : 0);
         return(hashCode);
     }
 }
예제 #17
0
        public Crawler2 Fetch()
        {
            if (!IsExternalIPAddress(SourceUrl))
            {
                State = "INVALID_URL";

                return(this);
            }
            var request = HttpWebRequest.Create(SourceUrl) as HttpWebRequest;

            using (var response = request.GetResponse() as HttpWebResponse)
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    State = "Url returns " + response.StatusCode + ", " + response.StatusDescription;
                    return(this);
                }
                if (response.ContentType.IndexOf("image") == -1)
                {
                    State = "Url is not an image";
                    return(this);
                }
                ServerUrl = Uploader.Format(Path.GetFileName(SourceUrl), PathFormat);
                var savePath = ServerUrl.GetFullPath();
                savePath.EnsureDirectory();
                //if (!Directory.Exists(Path.GetDirectoryName(savePath)))
                //{
                //    Directory.CreateDirectory(Path.GetDirectoryName(savePath));
                //}
                try
                {
                    var    stream = response.GetResponseStream();
                    var    reader = new BinaryReader(stream);
                    Byte[] bytes;
                    using (var ms = new MemoryStream())
                    {
                        var   buffer = new Byte[4096];
                        Int32 count;
                        while ((count = reader.Read(buffer, 0, buffer.Length)) != 0)
                        {
                            ms.Write(buffer, 0, count);
                        }
                        bytes = ms.ToArray();
                    }
                    File.WriteAllBytes(savePath, bytes);
                    State = "SUCCESS";
                }
                catch (Exception e)
                {
                    State = "抓取错误:" + e.Message;
                }
                return(this);
            }
        }
예제 #18
0
        /// <summary>
        /// Creates a new factory parameter by splitting the specified service URI into ServerUrl and BasePath
        /// </summary>
        public FactoryParameters(Uri serviceUri)
        {
            serviceUri.ThrowIfNull("serviceUri");

            // Retrieve Scheme and Host
            ServerUrl = serviceUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.UriEscaped);
            ServerUrl.ThrowIfNullOrEmpty("ServerUrl");

            // Retrieve the remaining right part
            BasePath = serviceUri.GetComponents(UriComponents.PathAndQuery, UriFormat.UriEscaped);
            BasePath.ThrowIfNullOrEmpty("BasePath");
        }
예제 #19
0
        private bool CanLogin(object parameter)
        {
            bool validServerUrl =
                !string.IsNullOrWhiteSpace(ServerUrl) &&
                Uri.IsWellFormedUriString(ServerUrl, UriKind.Absolute) &&
                ServerUrl.StartsWith("http", StringComparison.InvariantCultureIgnoreCase);

            return
                (validServerUrl &&
                 !string.IsNullOrWhiteSpace(Username) &&
                 !string.IsNullOrWhiteSpace(_getPasswordDelegate?.Invoke()));
        }
예제 #20
0
 static int set__serverUrl(IntPtr L)
 {
     try
     {
         ServerUrl arg0 = (ServerUrl)ToLua.CheckObject(L, 2, typeof(ServerUrl));
         NetWorkManage._serverUrl = arg0;
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #21
0
        public void PreviousDirectory()
        {
            if (ServerUrl.Substring(ServerUrl.Length - 1) == "/")
            {
                ServerUrl = ServerUrl.Substring(0, ServerUrl.Length - 1);
            }
            var index = ServerUrl.LastIndexOf("/");

            if (index > 0)
            {
                ServerUrl = ServerUrl.Substring(0, index + 1);
            }
        }
예제 #22
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (ServerUrl != null ? ServerUrl.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ApiKey != null ? ApiKey.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Domain != null ? Domain.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Password != null ? Password.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Username != null ? Username.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CounterStorageName != null ? CounterStorageName.GetHashCode() : 0);
         return(hashCode);
     }
 }
예제 #23
0
        private string GetFullPath(string cloudPath, string cloudFileName)
        {
            string serverUrl = ServerUrl.Replace("/dispatcherv2", "");

            return(serverUrl +
                   "/downloader/bc/g/" +
                   _bc.Client.AppId +
                   "/u/" +
                   _bc.Client.AuthenticationService.ProfileId +
                   "/f/" +
                   cloudPath +
                   "/" +
                   cloudFileName);
        }
예제 #24
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = (ServerUrl != null ? ServerUrl.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ ProjectId.GetHashCode();
         hashCode = (hashCode * 397) ^ ExperimentId.GetHashCode();
         hashCode = (hashCode * 397) ^ FileId.GetHashCode();
         hashCode = (hashCode * 397) ^ (Path != null ? Path.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Username != null ? Username.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ RunStartTime.GetHashCode();
         return(hashCode);
     }
 }
예제 #25
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = CentroidMs1.GetHashCode();
         hashCode = (hashCode * 397) ^ CentroidMs2.GetHashCode();
         hashCode = (hashCode * 397) ^ (LockMassParameters != null ? LockMassParameters.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ServerUrl != null ? ServerUrl.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Username != null ? Username.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ ModifiedTime.GetHashCode();
         hashCode = (hashCode * 397) ^ (EncodedPath != null ? EncodedPath.GetHashCode() : 0);
         return(hashCode);
     }
 }
예제 #26
0
        static async void ConnectNatServer()
        {
            try
            {
                if (!IsReConnect)
                {
                    return;
                }
                isLock = true;
                LogHelper.Info($"正在连接服务器...");
                //解析主机名
                var serverIp = ServerUrl;
                var ipArr    = ServerUrl.Split('.');
                //先判断是不是IP,不是IP就尝试解析域名
                if (ipArr.Where(c => int.TryParse(c, out int i) && i > 0 && i <= 255).Count() != 4)
                {
                    IPHostEntry ipInfo = Dns.GetHostEntry(ServerUrl);
                    serverIp = ipInfo.AddressList.Any() ? ipInfo.AddressList[0].ToString() : throw new Exception($"域名【{ServerUrl}】无法解析");
                }
                NatClient = new NatClient(new ClientOption()
                {
                    Ip           = serverIp,
                    Port         = NatPort,
                    NoDelay      = true,
                    ProtocolType = ProtocolType.Tcp,
                    Security     = SslProtocols.Tls12,
                    SslClientAuthenticationOptions = new SslClientAuthenticationOptions
                    {
                        EnabledSslProtocols = SslProtocols.Tls12,
                        TargetHost          = serverIp,
                        ClientCertificates  = new X509CertificateCollection()
                        {
                            new X509Certificate(CertFile, CertPassword)
                        }
                    }
                });
                NatClient.OnConnected += OnClientConnected;
                NatClient.OnReceived  += OnPackageReceived;
                NatClient.OnClosed    += OnClientClosed;

                await NatClient.ConnectAsync();
            }
            catch (Exception ex)
            {
                LogHelper.Error($"连接服务器失败:{ex}");
            }

            isLock = false;
        }
예제 #27
0
        private async Task <string> CacheTryGetServerToken(ServerUrl serverUrl, string clientName, bool killCache = false)
        {
            string tokenCacheKey = "token_for_" + serverUrl.Url;

            if (!cache.TryGetValue(tokenCacheKey, out string serverTokenJson) || killCache)
            {
                // Key not in cache, so get token.
                serverTokenJson = await GetAppLoginToken(serverUrl, clientName);

                cache.Set(tokenCacheKey, serverTokenJson, TimeSpan.FromMinutes(proxyConfigService.Config.TokenCacheMinutes));
            }

            //JObject o = JObject.Parse(serverTokenJson);
            return(serverTokenJson);//(string)o["token"];
        }
예제 #28
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = Id;
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ServerUrl != null ? ServerUrl.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TypeName != null ? TypeName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (GeometryName != null ? GeometryName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)GeometryType;
         hashCode = (hashCode * 397) ^ (Filter != null ? Filter.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Color != null ? Color.GetHashCode() : 0);
         return(hashCode);
     }
 }
예제 #29
0
    public Crawler Fetch()
    {
        var request = HttpWebRequest.Create(this.SourceUrl) as HttpWebRequest;

        using (var response = request.GetResponse() as HttpWebResponse)
        {
            if (response.StatusCode != HttpStatusCode.OK)
            {
                State = "Url returns " + response.StatusCode + ", " + response.StatusDescription;
                return(this);
            }
            if (response.ContentType.IndexOf("image") == -1)
            {
                State = "Url is not an image";
                return(this);
            }
            ServerUrl = PathFormatter.Format(Path.GetFileName(this.SourceUrl), Config.GetString("catcherPathFormat"));
            var savePath = Server.MapPath("/") + ServerUrl.Replace("/", "\\"); //Server.MapPath(ServerUrl);
            if (!Directory.Exists(Path.GetDirectoryName(savePath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(savePath));
            }
            try
            {
                var    stream = response.GetResponseStream();
                var    reader = new BinaryReader(stream);
                byte[] bytes;
                using (var ms = new MemoryStream())
                {
                    byte[] buffer = new byte[4096];
                    int    count;
                    while ((count = reader.Read(buffer, 0, buffer.Length)) != 0)
                    {
                        ms.Write(buffer, 0, count);
                    }
                    bytes = ms.ToArray();
                }
                File.WriteAllBytes(savePath, bytes);
                State = "SUCCESS";
            }
            catch (Exception e)
            {
                State = "抓取错误:" + e.Message;
            }
            return(this);
        }
    }
예제 #30
0
        public InvoiceResponse EntityToDTO()
        {
            ServerUrl = ServerUrl ?? "";
            InvoiceResponse dto = new InvoiceResponse
            {
                Id             = Id,
                OrderId        = OrderId,
                PosData        = PosData,
                CurrentTime    = DateTimeOffset.UtcNow,
                InvoiceTime    = InvoiceTime,
                ExpirationTime = ExpirationTime,
                BTCPrice       = Money.Coins((decimal)(1.0 / Rate)).ToString(),
                Status         = Status,
                Url            = ServerUrl.WithTrailingSlash() + "invoice?id=" + Id,
                Currency       = ProductInformation.Currency,
                Flags          = new Flags()
                {
                    Refundable = Refundable
                }
            };

            Populate(ProductInformation, dto);
            Populate(BuyerInformation, dto);
            dto.ExRates = new Dictionary <string, double>
            {
                { ProductInformation.Currency, Rate }
            };
            dto.PaymentUrls = new InvoicePaymentUrls()
            {
                BIP72  = $"bitcoin:{DepositAddress}?amount={GetCryptoDue()}&r={ServerUrl.WithTrailingSlash() + ($"i/{Id}")}",
                BIP72b = $"bitcoin:?r={ServerUrl.WithTrailingSlash() + ($"i/{Id}")}",
                BIP73  = ServerUrl.WithTrailingSlash() + ($"i/{Id}"),
                BIP21  = $"bitcoin:{DepositAddress}?amount={GetCryptoDue()}",
            };
            dto.BitcoinAddress = DepositAddress.ToString();
            dto.Token          = Encoders.Base58.EncodeData(RandomUtils.GetBytes(16));    //No idea what it is useful for
            dto.Guid           = Guid.NewGuid().ToString();

            var paid = Payments.Select(p => p.Output.Value).Sum();

            dto.BTCPaid = paid.ToString();
            dto.BTCDue  = GetCryptoDue().ToString();

            dto.ExceptionStatus = ExceptionStatus == null ? new JValue(false) : new JValue(ExceptionStatus);
            return(dto);
        }