protected async Task <DateTime?> AddProductArtifactAsync(string key, string value, Guid productId, ProductBuild productBuild)
        {
            var productArtifact = new ProductArtifact
            {
                ProductId      = productId,
                ProductBuildId = productBuild.Id,
                ArtifactType   = key,
                Url            = value
            };
            var updatedArtifact = WebRequestWrapper.GetFileInfo(productArtifact);
            await ProductArtifactRepository.CreateAsync(updatedArtifact);

#pragma warning disable RECS0061 // Warns when a culture-aware 'EndsWith' call is used by default.
            if (key == "version" && updatedArtifact.ContentType == "application/json")
#pragma warning restore RECS0061 // Warns when a culture-aware 'EndsWith' call is used by default.
            {
                var contents = WebClient.DownloadString(value);
                var version  = JsonConvert.DeserializeObject <Dictionary <string, string> >(contents);
                if (version.ContainsKey("version"))
                {
                    productBuild.Version = version["version"];
                    await ProductBuildRepository.UpdateAsync(productBuild);
                }
            }

            return(updatedArtifact.LastModified);
        }
Example #2
0
        public async Task <IActionResult> CheckPublishedFile(Guid id, String type)
        {
            var ifModifiedSince = "";

            if (HttpContext.Request.Headers.ContainsKey("If-Modified-Since"))
            {
                ifModifiedSince = HttpContext.Request.Headers["If-Modified-Since"];
            }

            var productArtifact = await ProductService.GetPublishedFile(id, type);

            if (productArtifact == null)
            {
                return(NotFound());
            }

            var updatedArtifact = WebRequestWrapper.GetFileInfo(productArtifact);

            HttpContext.Response.Headers.Add("Last-Modified", updatedArtifact.LastModified?.ToUniversalTime().ToString("r"));
            HttpContext.Response.Headers.Add("Content-Length", updatedArtifact.FileSize.ToString());

            var lastModified = updatedArtifact.LastModified?.ToUniversalTime().ToString("r");

            if (ifModifiedSince.CompareTo(lastModified) == 0)
            {
                return(StatusCode(304));
            }

            return(Ok());
        }
        /// <summary>
        ///     Downloads the update configurations from the server.
        /// </summary>
        /// <param name="configFileUri">The url of the configuration file.</param>
        /// <param name="credentials">The HTTP authentication credentials.</param>
        /// <param name="proxy">The optional proxy to use.</param>
        /// <param name="cancellationTokenSource">
        ///     The optional <see cref="CancellationTokenSource" /> to use for canceling the
        ///     operation.
        /// </param>
        /// <param name="timeout">The timeout for the download request. In milliseconds. Default 10000.</param>
        /// <returns>Returns an <see cref="IEnumerable{UpdateConfiguration}" /> containing the package configurations.</returns>
        public static async Task <IEnumerable <UpdateConfiguration> > DownloadAsync(Uri configFileUri,
                                                                                    NetworkCredential credentials,
                                                                                    WebProxy proxy, CancellationTokenSource cancellationTokenSource = null, int timeout = 10000)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = (SecurityProtocolType)3072;

            var request = (HttpWebRequest)WebRequestWrapper.Create(configFileUri);

            request.Timeout = timeout;

            if (credentials != null)
            {
                request.Credentials = credentials;
            }
            if (proxy != null)
            {
                request.Proxy = proxy;
            }

            string source;
            var    response = await request.GetResponseAsync();

            using (var sr = new StreamReader(response.GetResponseStream() ??
                                             throw new InvalidOperationException(
                                                 "The response stream of the configuration file web request is invalid."))
                   )
            {
                source = await sr.ReadToEndAsync();
            }

            return(!string.IsNullOrEmpty(source)
                ? Serializer.Deserialize <IEnumerable <UpdateConfiguration> >(source)
                : Enumerable.Empty <UpdateConfiguration>());
        }
Example #4
0
        public HttpClient(HttpClientConfiguration config)
        {
            var serializers = config.Advanced.Serializers.Concat(ContentSerializers.Defaults).ToList();

            var defaultContentType = config.Advanced.ContentType == ContentType.Unknown
                                ? ContentType.ApplicationJson
                                : config.Advanced.ContentType;

            _urlBuilder          = new UrlBuilder(config.BaseUrl);
            _requestWrapper      = new WebRequestWrapper(serializers, defaultContentType);
            _responseTransformer = new ResponseTransformer(serializers);
        }
Example #5
0
 private void getIcon(TalentItem ti, Character.CharacterClass charclass)
 {
     if (_icon == null)
     {
         WebRequestWrapper wrw      = new WebRequestWrapper();
         string            filePath = wrw.DownloadTalentIcon(charclass, ti.Tree.Replace(" ", ""), ti.Name.Replace(" ", "").Replace(":", ""));
         if (!String.IsNullOrEmpty(filePath))
         {
             _icon = new Bitmap(filePath);
         }
     }
 }
Example #6
0
 public ProductsController(
     IJsonApiContext jsonApiContext,
     ICurrentUserContext currentUserContext,
     WebRequestWrapper webRequestWrapper,
     IWebClient webClient,
     OrganizationService organizationService,
     ProductService productService,
     UserService userService)
     : base(jsonApiContext, productService, currentUserContext, organizationService, userService)
 {
     WebRequestWrapper = webRequestWrapper;
     WebClient         = webClient;
     ProductService    = productService;
 }
 public BuildEngineBuildService(
     IRecurringJobManager recurringJobManager,
     IBuildEngineApi buildEngineApi,
     WebRequestWrapper webRequestWrapper,
     IWebClient webClient,
     IJobRepository <Product, Guid> productRepository,
     IJobRepository <ProductArtifact> productArtifactRepository,
     IJobRepository <ProductBuild> productBuildRepository,
     IJobRepository <SystemStatus> systemStatusRepository
     ) : base(buildEngineApi, systemStatusRepository)
 {
     RecurringJobManager       = recurringJobManager;
     WebRequestWrapper         = webRequestWrapper;
     WebClient                 = webClient;
     ProductRepository         = productRepository;
     ProductArtifactRepository = productArtifactRepository;
     ProductBuildRepository    = productBuildRepository;
 }
Example #8
0
        private void getIcon(TalentItem ti, Character.CharacterClass charclass)
        {
            string filePath = "";

            if (_icon == null)
            {
                WebRequestWrapper wrw = new WebRequestWrapper();
                try {
                    filePath = wrw.DownloadTalentIcon(charclass, ti.Tree.Replace(" ", ""), ti.Name.Replace(" ", ""));
                }
                catch (Exception e) {
                    MessageBox.Show("Error downloading talent icon for " + ti.Name + ": " + e.ToString());
                }
                if (!String.IsNullOrEmpty(filePath))
                {
                    _icon = new Bitmap(filePath);
                }
            }
        }
Example #9
0
        private static async Task <string> WebRequest(string url, IEnumerable <string[]> parameters, bool post = false)
        {
            var oauth            = new OAuth();
            var nonce            = OAuth.Nonce();
            var timestamp        = OAuth.TimeStamp();
            var signature        = OAuth.Signature(post ? "POST" : "GET", url, nonce, timestamp, oauth.AccessToken, oauth.AccessTokenSecret, parameters);
            var authorizeHeader  = OAuth.AuthorizationHeader(nonce, timestamp, oauth.AccessToken, signature);
            var parameterStrings = parameters.Select(p => $"{OAuth.UrlEncode(p[0])}={OAuth.UrlEncode(p[1])}").ToList();

            if (!post)
            {
                url += "?" + string.Join("&", parameterStrings);
            }

            var request = WebRequestWrapper.Create(new Uri(url));

            request.Headers.Add("Authorization", authorizeHeader);
            request.Method = post ? "POST" : "GET";

            if (post)
            {
                Trace.TraceInformation(string.Join("&", parameterStrings));
                request.ContentType = "application/x-www-form-urlencoded";
                if (parameters != null)
                {
                    using (var requestStream = request.GetRequestStream())
                    {
                        WriteStream(requestStream, string.Join("&", parameterStrings));
                    }
                }
            }

            using (var response = await request.GetResponseAsync())
            {
                using (var stream = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                {
                    var result = stream.ReadToEnd();
                    return(result);
                }
            }
        }
 public BuildEngineBuildService(
     IRecurringJobManager recurringJobManager,
     IBuildEngineApi buildEngineApi,
     WebRequestWrapper webRequestWrapper,
     IWebClient webClient,
     SendNotificationService sendNotificationService,
     IJobRepository <Product, Guid> productRepository,
     IJobRepository <ProductArtifact> productArtifactRepository,
     IJobRepository <ProductBuild> productBuildRepository,
     IJobRepository <StoreLanguage> languageRepository,
     IJobRepository <SystemStatus> systemStatusRepository
     ) : base(buildEngineApi, sendNotificationService, systemStatusRepository)
 {
     RecurringJobManager       = recurringJobManager;
     WebRequestWrapper         = webRequestWrapper;
     WebClient                 = webClient;
     SendNotificationSvc       = sendNotificationService;
     ProductRepository         = productRepository;
     ProductArtifactRepository = productArtifactRepository;
     ProductBuildRepository    = productBuildRepository;
     LanguageRepository        = languageRepository;
 }
Example #11
0
        /// <summary>
        ///     Downloads the update configurations from the server.
        /// </summary>
        /// <param name="configFileUri">The url of the configuration file.</param>
        /// <param name="credentials">The HTTP authentication credentials.</param>
        /// <param name="proxy">The optional proxy to use.</param>
        /// <param name="cancellationTokenSource">
        ///     The optional <see cref="CancellationTokenSource" /> to use for canceling the
        ///     operation.
        /// </param>
        /// <param name="timeout">The timeout for the download request. In milliseconds. Default 10000.</param>
        /// <returns>Returns an <see cref="IEnumerable{UpdateConfiguration}" /> containing the package configurations.</returns>
        public static async Task <IEnumerable <UpdateConfiguration> > DownloadAsync(Uri configFileUri,
                                                                                    NetworkCredential credentials,
                                                                                    WebProxy proxy, CancellationTokenSource cancellationTokenSource = null, int timeout = 10000)
        {
            // Check for SSL and ignore it
            ServicePointManager.ServerCertificateValidationCallback += delegate { return(true); };

            var request = (HttpWebRequest)WebRequestWrapper.Create(configFileUri);

            request.Timeout = timeout;

            if (credentials != null)
            {
                request.Credentials = credentials;
            }
            if (proxy != null)
            {
                request.Proxy = proxy;
            }

            string source;
            var    response = cancellationTokenSource != null
                ? await request.GetResponseAsync(cancellationTokenSource.Token)
                : (HttpWebResponse)await request.GetResponseAsync();

            using (var sr = new StreamReader(response.GetResponseStream() ??
                                             throw new InvalidOperationException(
                                                 "The response stream of the configuration file web request is invalid."))
                   )
            {
                source = await sr.ReadToEndAsync();
            }

            return(!string.IsNullOrEmpty(source)
                ? Serializer.Deserialize <IEnumerable <UpdateConfiguration> >(source)
                : Enumerable.Empty <UpdateConfiguration>());
        }
        public CalculationOptionsDPSWarr(Character character) : this()
        {
            #region DPSWarr Talents Import
            try
            {
                WebRequestWrapper wrw = new WebRequestWrapper();

                if (character.Class == Character.CharacterClass.Warrior && character.Name != null && character.Realm != null)
                {
                    XmlDocument docTalents = wrw.DownloadCharacterTalentTree(character.Name, character.Region, character.Realm);

                    //<talentTab>
                    //  <talentTree value="2550050300230151333125100000000000000000000002030302010000000000000"/>
                    //</talentTab>
                    if (docTalents != null)
                    {
                        string talentCode = docTalents.SelectSingleNode("page/characterInfo/talentTab/talentTree").Attributes["value"].Value;
                        TalentsSaved  = true;
                        DeepWounds    = int.Parse(talentCode.Substring(8, 1));
                        TwoHandedSpec = int.Parse(talentCode.Substring(9, 1));
                        Impale        = int.Parse(talentCode.Substring(10, 1));
                        DeathWish     = int.Parse(talentCode.Substring(12, 1));
                        MortalStrike  = int.Parse(talentCode.Substring(19, 1));
                        Cruelty       = int.Parse(talentCode.Substring(24, 1));
                        ImpSlam       = int.Parse(talentCode.Substring(34, 1));
                        WeaponMastery = int.Parse(talentCode.Substring(36, 1));
                        Flurry        = int.Parse(talentCode.Substring(38, 1));
                        Precision     = int.Parse(talentCode.Substring(39, 1));
                    }
                }
            }
            catch (Exception)
            {
            }
            #endregion
        }
Example #13
0
        public CalculationOptionsTree(Character character)
        {
            #region Druid Talents Import
            try
            {
                WebRequestWrapper wrw = new WebRequestWrapper();
                if (character.Class == Character.CharacterClass.Druid && character.Name != null && character.Realm != null)
                {
                    XmlDocument docTalents = wrw.DownloadCharacterTalentTree(character.Name, character.Region, character.Realm);

                    //<talentTab>
                    //  <talentTree value="50002201050313523105100000000000000530000000000300001000030300"/>
                    //</talentTab>
                    string talentCode = docTalents.SelectSingleNode("page/characterInfo/talentTab/talentTree").Attributes["value"].Value;
                    StarlightWrath    = int.Parse(talentCode.Substring(0, 1));
                    NaturesGrasp      = int.Parse(talentCode.Substring(1, 1));
                    ImpNaturesGrasp   = int.Parse(talentCode.Substring(2, 1));
                    ControlofNature   = int.Parse(talentCode.Substring(3, 1));
                    FocusedStarlight  = int.Parse(talentCode.Substring(4, 1));
                    ImpMoonfire       = int.Parse(talentCode.Substring(5, 1));
                    Brambles          = int.Parse(talentCode.Substring(6, 1));
                    InsectSwarm       = int.Parse(talentCode.Substring(7, 1));
                    NaturesReach      = int.Parse(talentCode.Substring(8, 1));
                    Vengeance         = int.Parse(talentCode.Substring(9, 1));
                    CelestialFocus    = int.Parse(talentCode.Substring(10, 1));
                    LunarGuidance     = int.Parse(talentCode.Substring(11, 1));
                    NaturesGrace      = int.Parse(talentCode.Substring(12, 1));
                    Moonglow          = int.Parse(talentCode.Substring(13, 1));
                    Moonfury          = int.Parse(talentCode.Substring(14, 1));
                    BalanceofPower    = int.Parse(talentCode.Substring(15, 1));
                    Dreamstate        = int.Parse(talentCode.Substring(16, 1));
                    MoonkinForm       = int.Parse(talentCode.Substring(17, 1));
                    ImprovedFF        = int.Parse(talentCode.Substring(18, 1));
                    WrathofCenarius   = int.Parse(talentCode.Substring(19, 1));
                    ForceofNature     = int.Parse(talentCode.Substring(20, 1));
                    Ferocity          = int.Parse(talentCode.Substring(21, 1));
                    FeralAggression   = int.Parse(talentCode.Substring(22, 1));
                    FeralInstinct     = int.Parse(talentCode.Substring(23, 1));
                    BrutalImpact      = int.Parse(talentCode.Substring(24, 1));
                    ThickHide         = int.Parse(talentCode.Substring(25, 1));
                    FeralSwiftness    = int.Parse(talentCode.Substring(26, 1));
                    FeralCharge       = int.Parse(talentCode.Substring(27, 1));
                    SharpenedClaws    = int.Parse(talentCode.Substring(28, 1));
                    ShreddingAttacks  = int.Parse(talentCode.Substring(29, 1));
                    PredatoryStrikes  = int.Parse(talentCode.Substring(30, 1));
                    PrimalFury        = int.Parse(talentCode.Substring(31, 1));
                    SavageFury        = int.Parse(talentCode.Substring(32, 1));
                    FeralFaerieFire   = int.Parse(talentCode.Substring(33, 1));
                    NurturingInstinct = int.Parse(talentCode.Substring(34, 1));
                    HotW                  = int.Parse(talentCode.Substring(35, 1));
                    SotF                  = int.Parse(talentCode.Substring(36, 1));
                    PrimalTenacity        = int.Parse(talentCode.Substring(37, 1));
                    LotP                  = int.Parse(talentCode.Substring(38, 1));
                    ImprovedLotP          = int.Parse(talentCode.Substring(39, 1));
                    PredatoryInstincts    = int.Parse(talentCode.Substring(40, 1));
                    Mangle                = int.Parse(talentCode.Substring(41, 1));
                    ImprovedMotW          = int.Parse(talentCode.Substring(42, 1));
                    Furor                 = int.Parse(talentCode.Substring(43, 1));
                    Naturalist            = int.Parse(talentCode.Substring(44, 1));
                    NaturesFocus          = int.Parse(talentCode.Substring(45, 1));
                    NaturalShapeshifter   = int.Parse(talentCode.Substring(46, 1));
                    Intensity             = int.Parse(talentCode.Substring(47, 1));
                    Subtlety              = int.Parse(talentCode.Substring(48, 1));
                    OmenOfClarity         = int.Parse(talentCode.Substring(49, 1));
                    TranquilSpirit        = int.Parse(talentCode.Substring(50, 1));
                    ImprovedRejuvenation  = int.Parse(talentCode.Substring(51, 1));
                    NaturesSwiftness      = int.Parse(talentCode.Substring(52, 1));
                    GiftOfNature          = int.Parse(talentCode.Substring(53, 1));
                    ImpTranquility        = int.Parse(talentCode.Substring(54, 1));
                    EmpoweredTouch        = int.Parse(talentCode.Substring(55, 1));
                    ImprovedRegrowth      = int.Parse(talentCode.Substring(56, 1));
                    LivingSpirit          = int.Parse(talentCode.Substring(57, 1));
                    Swiftmend             = int.Parse(talentCode.Substring(58, 1));
                    NaturalPerfection     = int.Parse(talentCode.Substring(59, 1));
                    EmpoweredRejuvenation = int.Parse(talentCode.Substring(60, 1));
                    TreeOfLife            = int.Parse(talentCode.Substring(61, 1));
                }
            }
            catch
            {
            }
            #endregion
        }
Example #14
0
        public async Task <IActionResult> GetPublishedAppDetails(string package)
        {
            // Get the play-listing/manifest.json artifact
            var manifestArtifact = await ProductService.GetPublishedAppDetails(package);

            if (manifestArtifact == null)
            {
                return(NotFound());
            }

            // Get the size of the apk
            var apkArtifact = await ProductService.GetPublishedFile(manifestArtifact.ProductId, "apk");

            if (apkArtifact == null)
            {
                return(NotFound());
            }
            var updatedApkArtifact = WebRequestWrapper.GetFileInfo(apkArtifact);

            // Get the contents of the manifest.json
            var manifestJson = await WebClient.DownloadStringTaskAsync(manifestArtifact.Url);

            var manifest     = JsonConvert.DeserializeObject <ManifestResponse>(manifestJson);
            var url          = manifest.url;
            var titles       = new Dictionary <string, string>(manifest.languages.Count);
            var descriptions = new Dictionary <string, string>(manifest.languages.Count);

            foreach (string language in manifest.languages)
            {
                var title       = "";
                var titleSearch = $"{language}/title.txt";
                var titlePath   = manifest.files.Where(s => s.Contains(titleSearch)).FirstOrDefault();
                if (!string.IsNullOrEmpty(titlePath))
                {
                    title = await WebClient.DownloadStringTaskAsync(url + titlePath);
                }
                titles.Add(language, title.Trim());

                var description       = "";
                var descriptionSearch = $"{language}/short_description.txt";
                var descriptionPath   = manifest.files.Where(s => s.Contains(descriptionSearch)).FirstOrDefault();
                if (!string.IsNullOrEmpty(descriptionPath))
                {
                    description = await WebClient.DownloadStringTaskAsync(url + descriptionPath);
                }
                descriptions.Add(language, description);
            }

            var details = new AppDetails
            {
                Id                 = manifestArtifact.ProductId,
                Link               = $"/api/products/{manifestArtifact.ProductId}/files/published/apk",
                Size               = updatedApkArtifact.FileSize.Value,
                DefaultLanguage    = manifest.defaultLanguage,
                Color              = manifest.color,
                Icon               = url + manifest.icon,
                Languages          = manifest.languages,
                Titles             = titles,
                Descriptions       = descriptions,
                DownloadApkStrings = manifest.downloadApkStrings
            };

            return(Ok(details));
        }
Example #15
0
        private static IEnumerator DoRequest(IAsyncCompletionSource <UnityWebRequest> op, UnityWebRequest webRequest, bool inBackground)
        {
            UnityWebRequestAsyncOperation asyncRequest;
            string backgroundError = null;

#if UNITY_ANDROID || UNITY_IOS
            if (inBackground)
            {
                var webRequestWrapper = new WebRequestWrapper();
                webRequestWrapper.Failed += (wrappedRequest, error) =>
                {
                    backgroundError = error;
                };
                asyncRequest = webRequestWrapper.Send(webRequest, 100);
            }
            else
            {
                asyncRequest = webRequest.SendWebRequest();
            }
#else
            if (inBackground)
            {
                Application.runInBackground = true;
            }
            asyncRequest = webRequest.SendWebRequest();
            if (inBackground)
            {
                asyncRequest.completed += asyncOperation =>
                {
                    Application.runInBackground = false;
                };
            }
#endif

            if (webRequest.uploadHandler != null)
            {
                while (!webRequest.isDone)
                {
                    yield return(new WaitForEndOfFrame());

                    op.SetProgress(asyncRequest.progress);
                }
            }
            else
            {
                yield return(asyncRequest);
            }

            // Sometimes the webrequest is finished but the download is not
            while (!webRequest.isNetworkError && !webRequest.isHttpError && webRequest.downloadProgress != 1)
            {
                yield return(new WaitForFixedUpdate());
            }


            if (webRequest.isNetworkError || webRequest.isHttpError)
            {
                Debug.Log(webRequest.downloadHandler.text);
                op.SetException(new ApiException((int)webRequest.responseCode, webRequest.error, webRequest.downloadHandler.text));
            }
            else if (inBackground && !string.IsNullOrEmpty(backgroundError))
            {
                op.SetException(new ApiException((int)999, backgroundError));
            }
            else
            {
                op.SetResult(webRequest);
            }

            webRequest.Dispose();
        }
Example #16
0
 public FoaasAPI(WebRequestWrapper requestWrapper)
 {
     this.requestWrapper = requestWrapper;
 }
Example #17
0
 public void Init()
 {
     rest = new WebRequestWrapper();
 }
Example #18
0
        public void User(CancellationToken cancelationToken)
        {
            Task.Run(() =>
            {
                while (cancelationToken.IsCancellationRequested == false)
                {
                    //var delay = Task.Delay(30*1000, cancelationToken);
                    //delay.Wait(cancelationToken);
                    //if (delay.IsCanceled || delay.IsFaulted) break;

                    Trace.TraceInformation("{ Start Twitter User Stream }");
                    const string url    = "https://userstream.twitter.com/1.1/user.json";
                    var oauth           = new OAuth();
                    var nonce           = OAuth.Nonce();
                    var timestamp       = OAuth.TimeStamp();
                    var signature       = OAuth.Signature("GET", url, nonce, timestamp, oauth.AccessToken, oauth.AccessTokenSecret, null);
                    var authorizeHeader = OAuth.AuthorizationHeader(nonce, timestamp, oauth.AccessToken, signature);

                    var request = WebRequestWrapper.Create(new Uri(url));
                    request.Headers.Add("Authorization", authorizeHeader);

                    try
                    {
                        using (var response = request.GetResponse())
                            using (var stream = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                            {
                                stream.BaseStream.ReadTimeout = 60 * 1000;
                                while (true)
                                {
                                    var json = stream.ReadLine();
                                    if (json == null)
                                    {
                                        Trace.TraceInformation("{ null }");
                                        break;
                                    }
                                    if (cancelationToken.IsCancellationRequested)
                                    {
                                        break;
                                    }
                                    Trace.TraceInformation(string.IsNullOrWhiteSpace(json) ? "{ Blankline }" : json);

                                    var serializer = new JavaScriptSerializer();
                                    var reply      = serializer.Deserialize <Dictionary <string, object> >(json);
                                    if (reply != null && reply.ContainsKey("user"))
                                    {
                                        Trace.TraceInformation("{ tweet identified }");
                                        var statuses = Status.ParseJson("[" + json + "]");
                                        Application.Current.Dispatcher.InvokeAsync(() =>
                                        {
                                            UpdateTimelines(statuses, TweetClassification.Home);
                                        });
                                        //Application.Current.Dispatcher.InvokeAsync
                                        //    (() => UpdateStatusHomeTimelineCommand.Command.Execute(statuses, Application.Current.MainWindow));
                                    }
                                }
                            }
                    }

                    catch (WebException ex)
                    {
                        Trace.TraceError(ex.ToString());
                    }

                    catch (ArgumentNullException ex)
                    {
                        Trace.TraceError(ex.ToString());
                    }

                    catch (ArgumentException ex)
                    {
                        Trace.TraceError(ex.ToString());
                    }

                    catch (InvalidOperationException ex)
                    {
                        Trace.TraceError(ex.ToString());
                    }

                    catch (IOException ex)
                    {
                        Trace.TraceError(ex.ToString());
                    }
                }

                Trace.TraceInformation("{ Stream task ends }");
            }, cancelationToken);
        }
Example #19
0
        /// <summary>
        ///     Downloads the available update packages from the server.
        /// </summary>
        /// <seealso cref="DownloadPackagesAsync" />
        public void DownloadPackages()
        {
            if (!Directory.Exists(_applicationUpdateDirectory))
            {
                Directory.CreateDirectory(_applicationUpdateDirectory);
            }

            foreach (var updateConfiguration in PackageConfigurations)
            {
                WebResponse webResponse = null;
                try
                {
                    var webRequest = WebRequestWrapper.Create(updateConfiguration.UpdatePackageUri);
                    if (HttpAuthenticationCredentials != null)
                    {
                        webRequest.Credentials = HttpAuthenticationCredentials;
                    }
                    using (webResponse = webRequest.GetResponse())
                    {
                        var buffer = new byte[1024];
                        _packageFilePaths.Add(new UpdateVersion(updateConfiguration.LiteralVersion),
                                              Path.Combine(_applicationUpdateDirectory,
                                                           $"{updateConfiguration.LiteralVersion}.zip"));
                        using (var fileStream = File.Create(Path.Combine(_applicationUpdateDirectory,
                                                                         $"{updateConfiguration.LiteralVersion}.zip")))
                        {
                            using (var input = webResponse.GetResponseStream())
                            {
                                if (input == null)
                                {
                                    throw new Exception("The response stream couldn't be read.");
                                }

                                var size = input.Read(buffer, 0, buffer.Length);
                                while (size > 0)
                                {
                                    fileStream.Write(buffer, 0, size);
                                    size = input.Read(buffer, 0, buffer.Length);
                                }

                                if (!updateConfiguration.UseStatistics || !IncludeCurrentPcIntoStatistics)
                                {
                                    continue;
                                }

                                var response =
                                    new WebClient {
                                    Credentials = HttpAuthenticationCredentials
                                }.DownloadString(
                                    $"{updateConfiguration.UpdatePhpFileUri}?versionid={updateConfiguration.VersionId}&os={SystemInformation.OperatingSystemName}");     // Only for calling it

                                if (string.IsNullOrEmpty(response))
                                {
                                    return;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    webResponse?.Close();
                }
            }
        }
        protected async Task <DateTime?> AddProductArtifactAsync(string key, string value, Product product, ProductBuild productBuild, bool successful)
        {
            var productArtifact = new ProductArtifact
            {
                ProductId      = product.Id,
                ProductBuildId = productBuild.Id,
                ArtifactType   = key,
                Url            = value
            };
            var updatedArtifact  = WebRequestWrapper.GetFileInfo(productArtifact);
            var existingArtifact = await ProductArtifactRepository
                                   .Get().Where(a => a.ProductId == product.Id && a.ProductBuildId == productBuild.Id && a.ArtifactType == key && a.Url == value)
                                   .FirstOrDefaultAsync();

            if (existingArtifact != null)
            {
                // Not sure why we are getting multiple of these, but we don't want multiple entries.
                // Should we ignore it or update?  Ignore for now. Updating threw exceptions
                Log.Information($"Updating Artifact: Id={existingArtifact.Id}");
                updatedArtifact.Id = existingArtifact.Id;
                // await ProductArtifactRepository.UpdateAsync(updatedArtifact);
            }
            else
            {
                var newArtifact = await ProductArtifactRepository.CreateAsync(updatedArtifact);

                Log.Information($"Created Artifact: Id={newArtifact.Id}");
            }

            // On version.json, update the ProductBuild.Version
            if (key == "version" && updatedArtifact.ContentType == "application/json")
            {
                try
                {
                    var contents = WebClient.DownloadString(value);
                    var version  = JsonConvert.DeserializeObject <Dictionary <string, object> >(contents);
                    if (version.ContainsKey("version"))
                    {
                        productBuild.Version = version["version"] as String;
                        await ProductBuildRepository.UpdateAsync(productBuild);

                        if (successful)
                        {
                            product.VersionBuilt = version["version"] as String;
                            await ProductRepository.UpdateAsync(product);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex, $"Parsing {key}: {value}");
                }
            }

            // On play-listing-manifest.json, update the Project.DefaultLanguage
            if (key == "play-listing-manifest" && updatedArtifact.ContentType == "application/json")
            {
                try
                {
                    var contents = WebClient.DownloadString(value);
                    var manifest = JsonConvert.DeserializeObject <Dictionary <string, object> >(contents);
                    if (manifest.ContainsKey("default-language"))
                    {
                        var           languageName  = manifest["default-language"] as String;
                        StoreLanguage storeLanguage = await LanguageRepository.Get().Where(lang => lang.Name == languageName).FirstOrDefaultAsync();

                        if (storeLanguage != null)
                        {
                            product.StoreLanguageId = storeLanguage.Id;
                            await ProductRepository.UpdateAsync(product);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex, $"Parsing {key}: {value}");
                }
            }

            return(updatedArtifact.LastModified);
        }
        public void TestInitialize()
        {
            Logger = MockRepository.GenerateMock<ILogger>();
            Client = MockRepository.GeneratePartialMock<SimpleHttpClient>("AnAPIKey", Logger);
            Request = MockRepository.GenerateMock<WebRequestWrapper>();
            Response = MockRepository.GenerateMock<WebResponseWrapper>();

            ReqStream = new MemoryStream();
            RespStream = new MemoryStream();
        }
Example #22
0
        public CalculationOptionsMage(Character character)
            : this()
        {
            character.ItemsChanged += new EventHandler(Character_ItemsChanged);
            // pull talents
            #region Mage Talents Import
            try
            {
                WebRequestWrapper wrw = new WebRequestWrapper();

                if (character.Class == Character.CharacterClass.Mage && character.Name != null && character.Realm != null)
                {
                    XmlDocument docTalents = wrw.DownloadCharacterTalentTree(character.Name, character.Region, character.Realm);

                    //<talentTab>
                    //  <talentTree value="2550050300230151333125100000000000000000000002030302010000000000000"/>
                    //</talentTab>
                    if (docTalents != null)
                    {
                        string talentCode = docTalents.SelectSingleNode("page/characterInfo/talentTab/talentTree").Attributes["value"].Value;
                        ArcaneSubtlety          = int.Parse(talentCode.Substring(0, 1));
                        ArcaneFocus             = int.Parse(talentCode.Substring(1, 1));
                        ImprovedArcaneMissiles  = int.Parse(talentCode.Substring(2, 1));
                        WandSpecialization      = int.Parse(talentCode.Substring(3, 1));
                        MagicAbsorption         = int.Parse(talentCode.Substring(4, 1));
                        ArcaneConcentration     = int.Parse(talentCode.Substring(5, 1));
                        MagicAttunement         = int.Parse(talentCode.Substring(6, 1));
                        ArcaneImpact            = int.Parse(talentCode.Substring(7, 1));
                        ArcaneFortitude         = int.Parse(talentCode.Substring(8, 1));
                        ImprovedManaShield      = int.Parse(talentCode.Substring(9, 1));
                        ImprovedCounterspell    = int.Parse(talentCode.Substring(10, 1));
                        ArcaneMeditation        = int.Parse(talentCode.Substring(11, 1));
                        ImprovedBlink           = int.Parse(talentCode.Substring(12, 1));
                        PresenceOfMind          = int.Parse(talentCode.Substring(13, 1));
                        ArcaneMind              = int.Parse(talentCode.Substring(14, 1));
                        PrismaticCloak          = int.Parse(talentCode.Substring(15, 1));
                        ArcaneInstability       = int.Parse(talentCode.Substring(16, 1));
                        ArcanePotency           = int.Parse(talentCode.Substring(17, 1));
                        EmpoweredArcaneMissiles = int.Parse(talentCode.Substring(18, 1));
                        ArcanePower             = int.Parse(talentCode.Substring(19, 1));
                        SpellPower              = int.Parse(talentCode.Substring(20, 1));
                        MindMastery             = int.Parse(talentCode.Substring(21, 1));
                        Slow                 = int.Parse(talentCode.Substring(22, 1));
                        ImprovedFireball     = int.Parse(talentCode.Substring(23, 1));
                        Impact               = int.Parse(talentCode.Substring(24, 1));
                        Ignite               = int.Parse(talentCode.Substring(25, 1));
                        FlameThrowing        = int.Parse(talentCode.Substring(26, 1));
                        ImprovedFireBlast    = int.Parse(talentCode.Substring(27, 1));
                        Incinerate           = int.Parse(talentCode.Substring(28, 1));
                        ImprovedFlamestrike  = int.Parse(talentCode.Substring(29, 1));
                        Pyroblast            = int.Parse(talentCode.Substring(30, 1));
                        BurningSoul          = int.Parse(talentCode.Substring(31, 1));
                        ImprovedScorch       = int.Parse(talentCode.Substring(32, 1));
                        ImprovedFireWard     = int.Parse(talentCode.Substring(33, 1));
                        MasterOfElements     = int.Parse(talentCode.Substring(34, 1));
                        PlayingWithFire      = int.Parse(talentCode.Substring(35, 1));
                        CriticalMass         = int.Parse(talentCode.Substring(36, 1));
                        BlastWave            = int.Parse(talentCode.Substring(37, 1));
                        BlazingSpeed         = int.Parse(talentCode.Substring(38, 1));
                        FirePower            = int.Parse(talentCode.Substring(39, 1));
                        Pyromaniac           = int.Parse(talentCode.Substring(40, 1));
                        Combustion           = int.Parse(talentCode.Substring(41, 1));
                        MoltenFury           = int.Parse(talentCode.Substring(42, 1));
                        EmpoweredFireball    = int.Parse(talentCode.Substring(43, 1));
                        DragonsBreath        = int.Parse(talentCode.Substring(44, 1));
                        FrostWarding         = int.Parse(talentCode.Substring(45, 1));
                        ImprovedFrostbolt    = int.Parse(talentCode.Substring(46, 1));
                        ElementalPrecision   = int.Parse(talentCode.Substring(47, 1));
                        IceShards            = int.Parse(talentCode.Substring(48, 1));
                        Frostbite            = int.Parse(talentCode.Substring(49, 1));
                        ImprovedFrostNova    = int.Parse(talentCode.Substring(50, 1));
                        Permafrost           = int.Parse(talentCode.Substring(51, 1));
                        PiercingIce          = int.Parse(talentCode.Substring(52, 1));
                        IcyVeins             = int.Parse(talentCode.Substring(53, 1));
                        ImprovedBlizzard     = int.Parse(talentCode.Substring(54, 1));
                        ArcticReach          = int.Parse(talentCode.Substring(55, 1));
                        FrostChanneling      = int.Parse(talentCode.Substring(56, 1));
                        Shatter              = int.Parse(talentCode.Substring(57, 1));
                        FrozenCore           = int.Parse(talentCode.Substring(58, 1));
                        ColdSnap             = int.Parse(talentCode.Substring(59, 1));
                        ImprovedConeOfCold   = int.Parse(talentCode.Substring(60, 1));
                        IceFloes             = int.Parse(talentCode.Substring(61, 1));
                        WintersChill         = int.Parse(talentCode.Substring(62, 1));
                        IceBarrier           = int.Parse(talentCode.Substring(63, 1));
                        ArcticWinds          = int.Parse(talentCode.Substring(64, 1));
                        EmpoweredFrostbolt   = int.Parse(talentCode.Substring(65, 1));
                        SummonWaterElemental = int.Parse(talentCode.Substring(66, 1));
                    }
                }
            }
            catch (Exception)
            {
            }
            #endregion
        }
Example #23
0
        /// <summary>
        ///     Downloads the available update packages from the server.
        /// </summary>
        /// <seealso cref="DownloadPackagesAsync" />
        public void DownloadPackages()
        {
            OnUpdateDownloadStarted(this, EventArgs.Empty);

            long received = 0;
            var  total    = PackageConfigurations.Select(config => GetUpdatePackageSize(config.UpdatePackageUri))
                            .Where(updatePackageSize => updatePackageSize != null)
                            .Sum(updatePackageSize => updatePackageSize.Value);

            if (!Directory.Exists(_applicationUpdateDirectory))
            {
                Directory.CreateDirectory(_applicationUpdateDirectory);
            }

            foreach (var updateConfiguration in PackageConfigurations)
            {
                WebResponse webResponse = null;
                try
                {
                    var webRequest = WebRequestWrapper.Create(updateConfiguration.UpdatePackageUri);
                    if (HttpAuthenticationCredentials != null)
                    {
                        webRequest.Credentials = HttpAuthenticationCredentials;
                    }
                    using (webResponse = webRequest.GetResponse())
                    {
                        var buffer = new byte[1024];
                        _packageFilePaths.Add(new UpdateVersion(updateConfiguration.LiteralVersion),
                                              Path.Combine(_applicationUpdateDirectory,
                                                           $"{updateConfiguration.LiteralVersion}.zip"));
                        using (var fileStream = File.Create(Path.Combine(_applicationUpdateDirectory,
                                                                         $"{updateConfiguration.LiteralVersion}.zip")))
                        {
                            using (var input = webResponse.GetResponseStream())
                            {
                                if (input == null)
                                {
                                    throw new Exception("The response stream couldn't be read.");
                                }

                                var size = input.Read(buffer, 0, buffer.Length);
                                while (size > 0)
                                {
                                    fileStream.Write(buffer, 0, size);
                                    received += size;
                                    OnUpdateDownloadProgressChanged(received,
                                                                    (long)total, (float)(received / total) * 100);
                                    size = input.Read(buffer, 0, buffer.Length);
                                }

                                if (_downloadCancellationTokenSource.IsCancellationRequested)
                                {
                                    return;
                                }

                                if (!updateConfiguration.UseStatistics || !IncludeCurrentPcIntoStatistics)
                                {
                                    continue;
                                }

                                var response =
                                    new WebClient {
                                    Credentials = HttpAuthenticationCredentials
                                }.DownloadString(
                                    $"{updateConfiguration.UpdatePhpFileUri}?versionid={updateConfiguration.VersionId}&os={SystemInformation.OperatingSystemName}");     // Only for calling it

                                if (string.IsNullOrEmpty(response))
                                {
                                    return;
                                }
                                OnStatisticsEntryFailed(new StatisticsException(string.Format(
                                                                                    _lp.StatisticsScriptExceptionText, response)));
                            }
                        }
                    }
                }
                finally
                {
                    webResponse?.Close();
                }
            }
        }
        private void ImportTalents(Character character)
        {
            try
            {
                WebRequestWrapper wrw = new WebRequestWrapper();

                if (character.Class == Character.CharacterClass.Warlock && character.Name != null && character.Realm != null)
                {
                    XmlDocument docTalents = wrw.DownloadCharacterTalentTree(character.Name, character.Region, character.Realm);

                    if (docTalents != null)
                    {
                        string talentCode = docTalents.SelectSingleNode("page/characterInfo/talentTab/talentTree").Attributes["value"].Value;
                        Suppression             = int.Parse(talentCode.Substring(0, 1));
                        ImprovedCorruption      = int.Parse(talentCode.Substring(1, 1));
                        ImprovedCurseOfWeakness = int.Parse(talentCode.Substring(2, 1));
                        ImprovedDrainSoul       = int.Parse(talentCode.Substring(3, 1));
                        ImprovedLifeTap         = int.Parse(talentCode.Substring(4, 1));
                        SoulSiphon           = int.Parse(talentCode.Substring(5, 1));
                        ImprovedCurseOfAgony = int.Parse(talentCode.Substring(6, 1));
                        FelConcentration     = int.Parse(talentCode.Substring(7, 1));
                        AmplifyCurse         = int.Parse(talentCode.Substring(8, 1));
                        GrimReach            = int.Parse(talentCode.Substring(9, 1));
                        Nightfall            = int.Parse(talentCode.Substring(10, 1));
                        EmpoweredCorruption  = int.Parse(talentCode.Substring(11, 1));
                        ShadowEmbrace        = int.Parse(talentCode.Substring(12, 1));
                        SiphonLife           = int.Parse(talentCode.Substring(13, 1));
                        CurseOfExhaustion    = int.Parse(talentCode.Substring(14, 1));
                        ShadowMastery        = int.Parse(talentCode.Substring(15, 1));
                        Contagion            = int.Parse(talentCode.Substring(16, 1));
                        DarkPact             = int.Parse(talentCode.Substring(17, 1));
                        ImprovedHowlOfTerror = int.Parse(talentCode.Substring(18, 1));
                        Malediction          = int.Parse(talentCode.Substring(19, 1));
                        UnstableAffliction   = int.Parse(talentCode.Substring(20, 1));
                        ImprovedHealthstone  = int.Parse(talentCode.Substring(21, 1));
                        ImprovedImp          = int.Parse(talentCode.Substring(22, 1));
                        DemonicEmbrace       = int.Parse(talentCode.Substring(23, 1));
                        ImprovedHealthFunnel = int.Parse(talentCode.Substring(24, 1));
                        ImprovedVoidwalker   = int.Parse(talentCode.Substring(25, 1));
                        FelIntellect         = int.Parse(talentCode.Substring(26, 1));
                        ImprovedSuccubus     = int.Parse(talentCode.Substring(27, 1));
                        FelDomination        = int.Parse(talentCode.Substring(28, 1));
                        FelStamina           = int.Parse(talentCode.Substring(29, 1));
                        DemonicAegis         = int.Parse(talentCode.Substring(30, 1));
                        MasterSummoner       = int.Parse(talentCode.Substring(31, 1));
                        UnholyPower          = int.Parse(talentCode.Substring(32, 1));
                        ImprovedEnslaveDemon = int.Parse(talentCode.Substring(33, 1));
                        DemonicSacrifice     = int.Parse(talentCode.Substring(34, 1));
                        MasterConjuror       = int.Parse(talentCode.Substring(35, 1));
                        ManaFeed             = int.Parse(talentCode.Substring(36, 1));
                        MasterDemonologist   = int.Parse(talentCode.Substring(37, 1));
                        DemonicResilience    = int.Parse(talentCode.Substring(38, 1));
                        SoulLink             = int.Parse(talentCode.Substring(39, 1));
                        DemonicKnowledge     = int.Parse(talentCode.Substring(40, 1));
                        DemonicTactics       = int.Parse(talentCode.Substring(41, 1));
                        SummonFelguard       = int.Parse(talentCode.Substring(42, 1));
                        ImprovedShadowBolt   = int.Parse(talentCode.Substring(43, 1));
                        Cataclysm            = int.Parse(talentCode.Substring(44, 1));
                        Bane                = int.Parse(talentCode.Substring(45, 1));
                        Aftermath           = int.Parse(talentCode.Substring(46, 1));
                        ImprovedFirebolt    = int.Parse(talentCode.Substring(47, 1));
                        ImprovedLashOfPain  = int.Parse(talentCode.Substring(48, 1));
                        Devastation         = int.Parse(talentCode.Substring(49, 1));
                        Shadowburn          = int.Parse(talentCode.Substring(50, 1));
                        Intensity           = int.Parse(talentCode.Substring(51, 1));
                        DestructiveReach    = int.Parse(talentCode.Substring(52, 1));
                        ImprovedSearingPain = int.Parse(talentCode.Substring(53, 1));
                        Pyroclasm           = int.Parse(talentCode.Substring(54, 1));
                        ImprovedImmolate    = int.Parse(talentCode.Substring(55, 1));
                        Ruin                = int.Parse(talentCode.Substring(56, 1));
                        NetherProtection    = int.Parse(talentCode.Substring(57, 1));
                        Emberstorm          = int.Parse(talentCode.Substring(58, 1));
                        Backlash            = int.Parse(talentCode.Substring(59, 1));
                        Conflagrate         = int.Parse(talentCode.Substring(60, 1));
                        SoulLeech           = int.Parse(talentCode.Substring(61, 1));
                        ShadowAndFlame      = int.Parse(talentCode.Substring(62, 1));
                        Shadowfury          = int.Parse(talentCode.Substring(63, 1));
                    }
                }
            }
            catch (Exception)
            {
            }
        }
        public CalculationOptionsRogue(Character character) : this()
        {
            DPSCycle = new Cycle("4s5r");

            // talent import from DPSWarr module
            #region Rogue Talents Import
            try {
                WebRequestWrapper wrw = new WebRequestWrapper();

                if (character.Class == Character.CharacterClass.Rogue && character.Name != null && character.Realm != null)
                {
                    XmlDocument docTalents = wrw.DownloadCharacterTalentTree(character.Name, character.Region, character.Realm);

                    //<talentTab>
                    //  <talentTree value="2550050300230151333125100000000000000000000002030302010000000000000"/>
                    //</talentTab>
                    if (docTalents != null)
                    {
                        string talentCode = docTalents.SelectSingleNode("page/characterInfo/talentTab/talentTree").Attributes["value"].Value;
                        ImprovedEviscerate  = int.Parse(talentCode.Substring(0, 1));
                        RemorselessAttacks  = int.Parse(talentCode.Substring(1, 1));
                        Malice              = int.Parse(talentCode.Substring(2, 1));
                        Ruthlessness        = int.Parse(talentCode.Substring(3, 1));
                        Murder              = int.Parse(talentCode.Substring(4, 1));
                        PuncturingWounds    = int.Parse(talentCode.Substring(5, 1));
                        RelentlessStrikes   = int.Parse(talentCode.Substring(6, 1));
                        ImprovedExposeArmor = int.Parse(talentCode.Substring(7, 1));
                        Lethality           = int.Parse(talentCode.Substring(8, 1));
                        VilePoisons         = int.Parse(talentCode.Substring(9, 1));
                        ImprovedPoisons     = int.Parse(talentCode.Substring(10, 1));
                        FleetFooted         = int.Parse(talentCode.Substring(11, 1));
                        ColdBlood           = int.Parse(talentCode.Substring(12, 1));
                        ImprovedKidneyShot  = int.Parse(talentCode.Substring(13, 1));
                        QuickRecovery       = int.Parse(talentCode.Substring(14, 1));
                        SealFate            = int.Parse(talentCode.Substring(15, 1));
                        MasterPoisoner      = int.Parse(talentCode.Substring(16, 1));
                        Vigor          = int.Parse(talentCode.Substring(17, 1));
                        DeadenedNerves = int.Parse(talentCode.Substring(18, 1));
                        FindWeakness   = int.Parse(talentCode.Substring(19, 1));
                        Mutilate       = int.Parse(talentCode.Substring(20, 1));

                        ImprovedGouge          = int.Parse(talentCode.Substring(21, 1));
                        ImprovedSinisterStrike = int.Parse(talentCode.Substring(22, 1));
                        LightningReflexes      = int.Parse(talentCode.Substring(23, 1));
                        ImprovedSliceandDice   = int.Parse(talentCode.Substring(24, 1));
                        Deflection             = int.Parse(talentCode.Substring(25, 1));
                        Precision               = int.Parse(talentCode.Substring(26, 1));
                        Endurance               = int.Parse(talentCode.Substring(27, 1));
                        Riposte                 = int.Parse(talentCode.Substring(28, 1));
                        ImprovedSprint          = int.Parse(talentCode.Substring(29, 1));
                        ImprovedKick            = int.Parse(talentCode.Substring(30, 1));
                        DaggerSpecialization    = int.Parse(talentCode.Substring(31, 1));
                        DualWieldSpecialization = int.Parse(talentCode.Substring(32, 1));
                        MaceSpecialization      = int.Parse(talentCode.Substring(33, 1));
                        BladeFlurry             = int.Parse(talentCode.Substring(34, 1));
                        SwordSpecialization     = int.Parse(talentCode.Substring(35, 1));
                        FistSpecialization      = int.Parse(talentCode.Substring(36, 1));
                        BladeTwisting           = int.Parse(talentCode.Substring(37, 1));
                        WeaponExpertise         = int.Parse(talentCode.Substring(38, 1));
                        Aggression              = int.Parse(talentCode.Substring(39, 1));
                        Vitality                = int.Parse(talentCode.Substring(40, 1));
                        AdrenalineRush          = int.Parse(talentCode.Substring(41, 1));
                        NervesOfSteel           = int.Parse(talentCode.Substring(42, 1));
                        CombatPotency           = int.Parse(talentCode.Substring(43, 1));
                        SurpriseAttacks         = int.Parse(talentCode.Substring(44, 1));

                        MasterOfDeception = int.Parse(talentCode.Substring(45, 1));
                        Opportunity       = int.Parse(talentCode.Substring(46, 1));
                        SleightOfHand     = int.Parse(talentCode.Substring(47, 1));
                        DirtyTricks       = int.Parse(talentCode.Substring(48, 1));
                        Camouflage        = int.Parse(talentCode.Substring(49, 1));
                        Initiative        = int.Parse(talentCode.Substring(50, 1));
                        GhostlyStrike     = int.Parse(talentCode.Substring(51, 1));
                        ImprovedAmbush    = int.Parse(talentCode.Substring(52, 1));
                        Setup             = int.Parse(talentCode.Substring(53, 1));
                        Elusiveness       = int.Parse(talentCode.Substring(54, 1));
                        SerratedBlades    = int.Parse(talentCode.Substring(55, 1));
                        HeightenedSenses  = int.Parse(talentCode.Substring(56, 1));
                        Preparation       = int.Parse(talentCode.Substring(57, 1));
                        DirtyDeeds        = int.Parse(talentCode.Substring(58, 1));
                        Hemorrhage        = int.Parse(talentCode.Substring(59, 1));
                        MasterOfSubtlety  = int.Parse(talentCode.Substring(60, 1));
                        Deadliness        = int.Parse(talentCode.Substring(61, 1));
                        EnvelopingShadows = int.Parse(talentCode.Substring(62, 1));
                        Premeditation     = int.Parse(talentCode.Substring(63, 1));
                        CheatDeath        = int.Parse(talentCode.Substring(64, 1));
                        SinisterCalling   = int.Parse(talentCode.Substring(65, 1));
                        Shadowstep        = int.Parse(talentCode.Substring(66, 1));
                        TalentsSaved      = true;
                    }
                }
            }
            catch (Exception) {
            }
            #endregion
        }