コード例 #1
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, GetPolicyResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("Policy", targetDepth))
                    {
                        var unmarshaller = ManagedPolicyUnmarshaller.Instance;
                        response.Policy = unmarshaller.Unmarshall(context);
                        continue;
                    }
                }
            }

            return;
        }
コード例 #2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetPolicyResponse response = new GetPolicyResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Policy", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Policy = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("RevisionId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.RevisionId = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
コード例 #3
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            GetPolicyResponse response = new GetPolicyResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("GetPolicyResult", 2))
                    {
                        UnmarshallResult(context, response);
                        continue;
                    }

                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return(response);
        }
コード例 #4
0
        public static GetPolicyResponse Unmarshall(UnmarshallerContext context)
        {
            GetPolicyResponse getPolicyResponse = new GetPolicyResponse();

            getPolicyResponse.HttpResponse = context.HttpResponse;
            getPolicyResponse.RequestId    = context.StringValue("GetPolicy.RequestId");

            GetPolicyResponse.GetPolicy_Policy policy = new GetPolicyResponse.GetPolicy_Policy();
            policy.PolicyName        = context.StringValue("GetPolicy.Policy.PolicyName");
            policy.PolicyType        = context.StringValue("GetPolicy.Policy.PolicyType");
            policy.Description       = context.StringValue("GetPolicy.Policy.Description");
            policy.DefaultVersion    = context.StringValue("GetPolicy.Policy.DefaultVersion");
            policy.PolicyDocument    = context.StringValue("GetPolicy.Policy.PolicyDocument");
            policy.CreateDate        = context.StringValue("GetPolicy.Policy.CreateDate");
            policy.UpdateDate        = context.StringValue("GetPolicy.Policy.UpdateDate");
            policy.AttachmentCount   = context.IntegerValue("GetPolicy.Policy.AttachmentCount");
            getPolicyResponse.Policy = policy;

            GetPolicyResponse.GetPolicy_DefaultPolicyVersion defaultPolicyVersion = new GetPolicyResponse.GetPolicy_DefaultPolicyVersion();
            defaultPolicyVersion.VersionId         = context.StringValue("GetPolicy.DefaultPolicyVersion.VersionId");
            defaultPolicyVersion.IsDefaultVersion  = context.BooleanValue("GetPolicy.DefaultPolicyVersion.IsDefaultVersion");
            defaultPolicyVersion.PolicyDocument    = context.StringValue("GetPolicy.DefaultPolicyVersion.PolicyDocument");
            defaultPolicyVersion.CreateDate        = context.StringValue("GetPolicy.DefaultPolicyVersion.CreateDate");
            getPolicyResponse.DefaultPolicyVersion = defaultPolicyVersion;

            return(getPolicyResponse);
        }
コード例 #5
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetPolicyResponse response = new GetPolicyResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("creationDate", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.CreationDate = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("defaultVersionId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.DefaultVersionId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("generationId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.GenerationId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("lastModifiedDate", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.LastModifiedDate = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("policyArn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.PolicyArn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("policyDocument", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.PolicyDocument = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("policyName", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.PolicyName = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
コード例 #6
0
        public GetPolicyResponse GetPolicy(GetPolicyRequest parameter)
        {
            var product          = this.virtuClient.GetProducts().Single(A => A.Name, "Верное решение");
            var risks            = this.virtuClient.GetRisks(product.ID);
            var currencies       = this.virtuClient.GetCurrencies(product.ID);
            var getBuyoutTariffs = this.virtuClient.GetBuyouts(product.ID);
            var strategyDetails  = this.virtuClient.StrategiesSearch(new StrategiesSearchInput()
            {
                IsActive      = true,
                ReadRedefined = true,
            });
            var policy   = this.virtuClient.Read(parameter.policyId);
            var currency = currencies.Single(A => A.ID, policy.Currency);

            var strategyDetail       = strategyDetails.Single(A => A.ID, policy.InvestmentStrategyData.ID);
            var investingCurrency    = currencies.Single(A => A.ID, strategyDetail.OptionCurrency);
            GetPolicyResponse result = new GetPolicyResponse()
            {
                amount          = policy.Premium.Value,
                coefficient     = policy.ParticipationCoefficient.Value,
                status          = getStatus(policy.StatusName),
                strategy        = policy.InvestmentStrategyRaw,
                fullDescription = product.Description,
                currency        = getCurrency(currency).Value,
                coverCapital    = 100,
                effectiveDate   = getDate(policy.EffectiveDate).Value,
                expirationDate  = getDate(policy.ExpirationDate).Value,
                insuranceRisks  = risks.Select(A => new risk()
                {
                    id   = A.ID,
                    sum  = policy.Premium.Value.ToString(),
                    text = A.Name,
                }).ToArray(),
                paymentsPlan      = null,
                policyNumber      = policy.SERIAL + " " + policy.NUMBER,
                productId         = policy.ProductID,
                productName       = product.Name,
                redemptionAmounts = getBuyoutTariffs.Select(A => new redemptionAmountInfo()
                {
                    sum  = decimal.Parse(A.InsSum.value),
                    date = DateTime.Today.AddYears(int.Parse(A.Year.value))
                }).ToArray(),
            };

            result.profitability = calcDividends(
                premium: result.amount,
                participationCoefficient: result.coefficient,
                currency: result.currency,
                investingCurrency: getCurrency(investingCurrency).Value,
                startDate: getDate(strategyDetail.InvestmentStartDate).Value,
                endDate: DateTime.Today,
                strategyId: strategyDetail.ID,
                quoteOnStartDate: strategyDetail.BaseIndexOnStartDate.Value);
            return(result);
        }
コード例 #7
0
        public static GetPolicyResponse Unmarshall(UnmarshallerContext context)
        {
            GetPolicyResponse getPolicyResponse = new GetPolicyResponse();

            getPolicyResponse.HttpResponse = context.HttpResponse;
            getPolicyResponse.RequestId    = context.StringValue("GetPolicy.RequestId");
            getPolicyResponse.Success      = context.BooleanValue("GetPolicy.Success");
            getPolicyResponse.ErrMessage   = context.StringValue("GetPolicy.ErrMessage");
            getPolicyResponse.Data         = context.StringValue("GetPolicy.Data");
            getPolicyResponse.ObjectString = context.StringValue("GetPolicy.ObjectString");

            return(getPolicyResponse);
        }
コード例 #8
0
        public void getAndApplyPolicy(String session)
        {
            GetPolicyRequest request = new GetPolicyRequest();

            request.session = MainWindow.Session;
            try
            {
                GetPolicyResponse response = client.GetPolicy(request);
                closeApps();
                getServices();
                applicationService.BannedApplications = response.policy.bannedApps;
                applicationService.BannedSites        = response.policy.bannedSites;
                applicationService.BannedServices     = response.policy.bannedServices;
                applicationService.banApplications();
                applicationService.banSites();
                applicationService.banServices();
            }
            catch (Exception ex)
            {
                return;
            }
        }