Example #1
0
        public HttpResponseMessage getDeviceinAgreementDetailByCustId(int id, String username_ad, String password_ad)
        {
            Authentication_class var_auth = new Authentication_class();
            AuthenticationHeader ah       = var_auth.getAuthHeader(username_ad, password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);
            var agreementManagementService = AsmRepository.GetServiceProxyCachedOrDefault <IAgreementManagementService>(ah);
            var viewService = AsmRepository.GetServiceProxy <IViewFacadeService>(ah);

            var viewD = viewService.GetCustomerDeviceView(new BaseQueryRequest()
            {
                FilterCriteria = Op.Eq("CustomerId", id),
                PageCriteria   = new PageCriteria()
                {
                    Page     = 0,
                    PageSize = 100
                },
                DeepLoad = true
            });

            if (viewD != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, viewD));
            }
            else
            {
                var       message = string.Format("error");
                HttpError err     = new HttpError(message);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
        }
        public CategoryProductPriceExCollection GetCommercialProductByCustomerId(String username_ad, String password_ad, int id)
        {
            Authentication_class var_auth = new Authentication_class();
            AuthenticationHeader ah       = var_auth.getAuthHeader(username_ad, password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);
            var agService = AsmRepository.AllServices.GetAgreementManagementService(ah);

            try
            {
                var agreements = agService.GetAgreements(new BaseQueryRequest()
                {
                    FilterCriteria = Op.Eq("CustomerId", id)
                });
                var map = agService.GetManageAgreementProductReference(agreements.Items[0].Id.Value);
                return(map.CategoryProductPriceExCollection);
                //foreach (var cp in map.CategoryProductPriceExCollection)
                //{
                //    Console.WriteLine("Allowed Product Category : " + cp.CommercialProductCategoryName + " | Product Name : " + cp.CommercialProductName + " Price : " + cp.ListPriceAmount);
                //}
                //Console.WriteLine("total product : {0}", map.CategoryProductPriceExCollection.Count());
            }
            catch (Exception ex)
            {
                return(null);
                //Console.WriteLine("Errors : " + ex.Message);
                //Console.WriteLine("Stack : " + ex.StackTrace);
            }
        }
Example #3
0
        public ReinforceMul(int N = 7)
        {
            this.N = N;
            int dim0 = N, dim1 = N * N, dim2 = N;

            var a      = Op.Scalar <int>("a");
            var b      = Op.Scalar <int>("b");
            var c_gold = Op.Scalar <int>("c_gold");
            var L      = Op.Shared(NN.Random.Uniform(-1f, 1f, N, dim0), "L");

            var xa  = Blocks.Linear("Wa", L[a], dim1);
            var xb  = Blocks.Linear("Wb", L[b], dim1);
            var xab = Blocks.Linear("Wab", L[a] * L[b], dim1);

            var x = Blocks.Linear("Wc", Op.Tanh(xa + xb + xab), dim2);
            var y = Op.Softmax(x);

            var c = Operators.Scalars.ReinforceCategorical.Create(y, "baseline");

            c.Name = nameof(c);
            var eq = Op.Eq(c_gold, c);

            c.Reward      = eq.As <float>();
            c.Reward.Name = "reward";
            this.baseline = c.Baseline;

            var loss    = -c.As <float>();
            var weights = loss.FindAll <Tensor <float> .Shared>();

            foreach (var W in weights)
            {
                loss += 0.001f * Op.Norm2(W);
            }
            loss.Name = nameof(loss);

            var grad = Op.Grad(loss); // reward isn't differentiable but Reinforce will still backpropagate gradients

            var lr      = Op.Scalar <float>("lr");
            var updates = new OrderedDictionary();

            foreach (var W in grad.Keys)
            {
                updates[W] = W - lr * grad[W];
            }

            //var dB = (Scalar<float>)loss.Backpropagation.ScalarDerivatives[c.Baseline];
            //updates[c.Baseline] = c.Baseline - lr * dB;
            updates[c.Baseline] = c.Baseline * 0.9f + 0.1f * c.Reward;

            var train_ = Op.Function(new IVar[] { a, b, c_gold, lr }, c.Reward, updates);

            Train = lr_ => {
                var sample = NextSample();
                return((int)train_(sample.Item1, sample.Item2, sample.Item3, lr_));
            };

            Mul = Op.Function(input: (a, b), output: Op.Argmax(x));
        }
        //  Get Shipping Order by Hardware Product Agreeemntdetail ID
        public int getShippingOrderByHardware(String username_ad, String password_ad, int hw_agreementdetail_id)
        {
            Authentication_class var_auth   = new Authentication_class();
            AuthenticationHeader authHeader = var_auth.getAuthHeader(username_ad, password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);

            //var docmService = AsmRepository.GetServiceProxy<IDocumentManagementService>(authHeader);
            var soService     = AsmRepository.AllServices.GetOrderManagementService(authHeader);
            var faService     = AsmRepository.AllServices.GetFinanceService(authHeader);
            var sbService     = AsmRepository.AllServices.GetSandBoxManagerService(authHeader);
            var agService     = AsmRepository.AllServices.GetAgreementManagementService(authHeader);
            var deviceService = AsmRepository.AllServices.GetDevicesService(authHeader);
            var viewfService  = AsmRepository.AllServices.GetViewFacadeService(authHeader);

            int so = 0;

            try
            {
                var sol = soService.FindShippingOrderLines(new BaseQueryRequest()
                {
                    FilterCriteria = Op.Eq("AgreementDetailId", hw_agreementdetail_id),
                    PageCriteria   = new PageCriteria()
                    {
                        Page = 0, PageSize = 100
                    }
                });

                if (sol.Items.Count > 0)
                {
                    so = sol.Items[0].ShippingOrderId.Value;
                }
                else
                {
                    return(0);
                }

                return(so);
            }
            catch (Exception ex)
            {
                //msg = "Errors : " + ex.Message + "  ------  Exception Stack : " + ex.StackTrace;
                //Console.WriteLine("Errors : " + ex.Message);
                //Console.WriteLine("Stack : " + ex.StackTrace);
                //logger.Error(msg);
                return(0);
            }
        }
Example #5
0
        public HttpResponseMessage GetTotalAmountQuoteByCustomerId(String username_ad, String password_ad, int id)
        {
            Authentication_class var_auth   = new Authentication_class();
            AuthenticationHeader authHeader = var_auth.getAuthHeader(username_ad, password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);
            var billService = AsmRepository.GetServiceProxy <IBillingEngineService>(authHeader);
            var finService  = AsmRepository.AllServices.GetFinanceService(authHeader);

            decimal totalamount = 0;

            var fa = finService.GetFinancialAccountsForCustomer(id, new CriteriaCollection()
            {
                new Criteria()
                {
                    Key      = "TypeId",
                    Operator = Operator.Equal,
                    Value    = "1"
                }
            }, 0).Items[0];

            //Console.WriteLine("Financial Account Id : " + fa.Id.Value);

            var quoteinvoice = billService.FindQuoteInvoices(new BaseQueryRequest()
            {
                FilterCriteria = Op.Eq("FinancialAccountId", fa.Id.Value) & Op.Eq("QuoteStatusId", "1")
            });

            foreach (var quote in quoteinvoice)
            {
                string quote_type = "";
                //Console.WriteLine("Find quote Id : " + quote.Id.Value);
                if (quote.QuoteGenerationMethod == QuoteGenerationMethod.EventBased)
                {
                    quote_type = "Immediate Quote";
                }
                else if (quote.QuoteGenerationMethod == QuoteGenerationMethod.ServiceRetention)
                {
                    quote_type = "Regular Quote";
                }
                //Console.WriteLine("Quote Type" + quote_type);
                totalamount = quote.TotalAmount.Value + totalamount;
            }


            return(Request.CreateResponse(HttpStatusCode.OK, "TotalAmount = " + totalamount));
        }
Example #6
0
        public ReinforceConst(int N = 5)
        {
            this.N = N;
            gold   = N / 2;

            var a      = Op.Scalar <int>("a");
            var c_gold = Op.Scalar <int>("c_gold");
            var L      = Op.Shared(NN.Random.Uniform(-1f, 1f, N, N), "L");

            var x = L[a];
            var y = Op.Softmax(x);

            var c = Operators.Scalars.ReinforceCategorical.Create(y, "baseline");

            c.Name = nameof(c);
            var eq = Op.Eq(c_gold, c);

            c.Reward      = eq.As <float>();
            c.Reward.Name = "reward";

            var loss = -c.As <float>() + 0.001f * Op.Norm2(L);
            var grad = Op.Grad(loss); // c isn't differentiable but Reinforce will still backpropagate gradients

            var lr      = Op.Scalar <float>("lr");
            var updates = new OrderedDictionary();

            foreach (var W in grad.Keys)
            {
                updates[W] = W - lr * grad[W];
            }

            var dB = (Scalar <float>)loss.Backpropagation.ScalarDerivatives[c.Baseline];

            updates[c.Baseline] = c.Baseline - lr * dB;

            var train_ = Op.Function(new IVar[] { a, c_gold, lr }, c.Reward, updates);

            Train = lr_ => {
                var sample = NextSample();
                return((int)train_(sample.Item1, sample.Item2, lr_));
            };

            Const = Op.Function(a, c);
        }
Example #7
0
        public void getAgreementDetail()
        {
            Authentication_class var_auth   = new Authentication_class();
            AuthenticationHeader authHeader = var_auth.getAuthentication_header();

            AsmRepository.SetServiceLocationUrl("http://mncsvasm.mskydev1.local/asm/all/servicelocation.svc");

            var m_IAgreementManagementService = AsmRepository.GetServiceProxyCachedOrDefault <IAgreementManagementService>(authHeader);
            var viewService = AsmRepository.GetServiceProxy <IViewFacadeService>(authHeader);


            AgreementDetailCollection adc = m_IAgreementManagementService.GetAgreementDetailsForCustomer(500016733, 1);

            if (adc != null && adc.Items.Count > 0)
            {
                foreach (AgreementDetail a in adc.Items)
                {
                    Console.WriteLine("Found product ID {0}: Status ID = {1}", a.CommercialProductId, a.Status);
                }
            }
            else
            {
                Console.WriteLine("I found nothing.");
            }



            var viewD = viewService.GetCustomerDeviceView(new BaseQueryRequest()
            {
                FilterCriteria = Op.Eq("CustomerId", 500016733),
                PageCriteria   = new PageCriteria()
                {
                    Page     = 0,
                    PageSize = 100
                },
                DeepLoad = true
            });



            foreach (var device in viewD.Items)
            {
                // here you can call GetDeviceView to get more info, parameters are the same like above GetCustomerDeviceView , just change Op.Eq("CustomerId", customer_id) to Op,Eq("Id",device.Id.Value)
                Console.WriteLine("Device ID : " + device.DeviceId.Value + " Serial Number : " + device.SerialNumber
                                  + " Status : " + device.DeviceStatusName + " Model:" + device.ModelDescription);
            }


            var viewAg = viewService.GetAgreementDetailView(new BaseQueryRequest()
            {
                FilterCriteria = Op.Eq("CustomerId", 500016733),
                PageCriteria   = new PageCriteria()
                {
                    Page     = 0,
                    PageSize = 100
                }
            });

            foreach (var product in viewAg.Items)
            {
                Console.WriteLine("Agreement Detail ID : " + product.Id.Value + " Product Name :" + product.CommercialProductName + " Charge Until Date : " + product.ChargeUntilDate + " Charge Period : "
                                  + product.ChargePeriodName + " Finance Option : " + product.FinanceOptionName + " Recurring Price : " + product.RecurringListPrice
                                  + " Status :" + product.StatusName);
            }

            Console.ReadLine();
        }
        public YangProductPriceResponse YangProductPriceByProductId(String username_ad, String password_ad, int id)
        {
            YangProductPriceResponse db = new YangProductPriceResponse();
            var cc = new List <YangProductPriceItems>();

            List <int>                CustomerClassIds_local        = null;
            List <int>                CountryIds_local              = null;
            List <int>                CustomerTypeIds_local         = null;
            List <int>                FinanceOptionIds_local        = null;
            List <int>                FinancialAccountTypeIds_local = null;
            List <string>             PostalCodes_local             = null;
            List <int>                ProvinceIds_local             = null;
            List <ListPriceCondition> ListPriceCondition_local      = null;

            IAgreementManagementService agService = null;
            IAgreementManagementConfigurationService agcService = null;
            IProductCatalogService productService = null;
            IProductCatalogConfigurationService productcService = null;
            ICustomersConfigurationService      custcService    = null;
            IFinanceConfigurationService        fincService     = null;


            Authentication_class var_auth = new Authentication_class();
            AuthenticationHeader ah       = var_auth.getAuthHeader(username_ad, password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);

            agService       = AsmRepository.AllServices.GetAgreementManagementService(ah);
            agcService      = AsmRepository.AllServices.GetAgreementManagementConfigurationService(ah);
            productService  = AsmRepository.AllServices.GetProductCatalogService(ah);
            productcService = AsmRepository.AllServices.GetProductCatalogConfigurationService(ah);
            custcService    = AsmRepository.AllServices.GetCustomersConfigurationService(ah);
            fincService     = AsmRepository.AllServices.GetFinanceConfigurationService(ah);

            BaseQueryRequest   request  = new BaseQueryRequest();
            CriteriaCollection criteria = new CriteriaCollection();

            //request.FilterCriteria.Add(new Criteria("ExternalId", 92591));
            request.FilterCriteria.Add(new Criteria("Id", id));
            //Call the method and display the results.
            CommercialProductCollection pl = productcService.GetCommercialProducts(request);

            //CommercialProductCollection pl = productcService.GetCommercialProducts(new BaseQueryRequest()
            //{
            //    //FilterCriteria = Op.Le("SellFrom", DateTime.Now) && Op.Ge("SellTo", DateTime.Now),
            //    FilterCriteria = Op.Equals("Id", id),
            //    DeepLoad = true,
            //    PageCriteria = new PageCriteria()
            //    {
            //        Page = 0
            //    }

            //});



            //Console.WriteLine("Total Commercial Product Count : " + pl.TotalCount);
            db.the_TotalCount = pl.TotalCount;

            foreach (var pr in pl.Items)
            {
                int commercial_product_id = pr.Id.Value;
                var prices = productcService.GetListPrices(new BaseQueryRequest()
                {
                    FilterCriteria = Op.Eq("UsedBy", 0) && Op.Eq("Active", true) && Op.Eq("ApplyToId", commercial_product_id),
                    DeepLoad       = true,
                    PageCriteria   = new PageCriteria()
                    {
                        Page = 0
                    }
                });

                //Console.WriteLine("Product Name : " + pr.Name + "\n");

                foreach (var ccc in pr.CommercialProductIds)
                {
                    //Console.WriteLine("value = {0}" + ccc.ToString());
                }



                //Console.WriteLine("Start to search all prices for commecial products : " + pr.Name + "\n");

                if (prices == null)
                {
                    continue;
                }

                foreach (var listprice in prices.Items)
                {
                    string msg = "";

                    if (listprice.PriceConditions == null)
                    {
                        continue;
                    }

                    foreach (var pricecondition in listprice.PriceConditions.Items)
                    {
                        msg = "";
                        if (pricecondition.Active == false)
                        {
                            continue;
                        }

                        // Type - OnceOff, Recurrence
                        msg = " Price Type : " + pricecondition.Type + "\n";

                        // Charge Period

                        if (pricecondition.ChargePeriodId != 0)
                        {
                            msg = msg + " Charge Period " + pricecondition.ChargePeriodId + " Month" + "\n";
                        }

                        // The price amount
                        if (pricecondition.PriceAmounts != null)
                        {
                            string priceamount = "";
                            foreach (var pa in pricecondition.PriceAmounts)
                            {
                                priceamount += " Amount : " + pa.Amount + " From " + pa.FromDate + ",";
                            }

                            if (priceamount != "")
                            {
                                msg = msg + " " + priceamount + "\n";
                            }

                            priceamount = "";
                        }


                        // Allowed Agreement Type conditions

                        if (pricecondition.AgreementTypeIds != null)
                        {
                            string agreement_type_list = "";
                            foreach (var agtid in pricecondition.AgreementTypeIds)
                            {
                                agreement_type_list += agcService.GetAgreementType(agtid).Description + ",";
                            }
                            if (agreement_type_list != "")
                            {
                                msg = msg + "Allowed Agreement Types :  " + agreement_type_list + "\n";
                            }
                            agreement_type_list = "";
                        }

                        // Allowed Business Unit Attributes

                        if (pricecondition.BusinessUnitAttributeValues != null)
                        {
                            string business_unit_attribute = "";
                            foreach (var bu in pricecondition.BusinessUnitAttributeValues)
                            {
                                business_unit_attribute += bu + ",";
                            }
                            if (business_unit_attribute != "")
                            {
                                msg = msg + "   Allowed Business Unit Attribute : " + business_unit_attribute + "\n";
                            }
                            business_unit_attribute = "";
                        }

                        // Allowed Charge Period

                        if (pricecondition.ChargePeriodId != null)
                        {
                            string charge_period = "";
                            if (pricecondition.ChargePeriodId == 1)
                            {
                                charge_period = "Monthly";
                            }

                            if (pricecondition.ChargePeriodId == 3)
                            {
                                charge_period = "Quauterly";
                            }

                            if (pricecondition.ChargePeriodId == 6)
                            {
                                charge_period = "HalfYearly";
                            }
                            if (pricecondition.ChargePeriodId == 12)
                            {
                                charge_period = "Yearly";
                            }
                            if (charge_period != "")
                            {
                                msg = msg + "   Allowed Charge Period : " + charge_period + "\n";
                            }
                            charge_period = "";
                        }


                        // Allowed Country

                        if (pricecondition.CountryIds != null)
                        {
                            string country_list = "";
                            foreach (var c in pricecondition.CountryIds)
                            {
                                country_list += custcService.GetCountry(c).Description + ",";
                            }
                            if (country_list != "")
                            {
                                msg = msg + " Allowed Country : " + country_list + "\n";
                            }
                            country_list     = "";
                            CountryIds_local = pricecondition.CountryIds;
                        }



                        // Allowed Currency

                        if (pricecondition.CurrencyId != null)
                        {
                            string currency = "";

                            currency = fincService.GetCurrency(pricecondition.CurrencyId.Value).Description;

                            if (currency != "")
                            {
                                msg = msg + "  Allowed Currency : " + currency + "\n";
                            }
                            currency = "";
                        }

                        // Allowed Customer Class

                        if (pricecondition.CustomerClassIds != null)
                        {
                            string customer_class = "";

                            foreach (var ci in pricecondition.CustomerClassIds)
                            {
                                customer_class += custcService.GetCustomerClass(ci).Description + ",";
                            }
                            if (customer_class != "")
                            {
                                msg = msg + "  Allowed Customer Class : " + customer_class + "\n";
                            }
                            customer_class = "";

                            CustomerClassIds_local = pricecondition.CustomerClassIds;
                        }

                        // Allowed Customer Type

                        if (pricecondition.CustomerTypeIds != null)
                        {
                            string customer_type = "";

                            foreach (var ct in pricecondition.CustomerTypeIds)
                            {
                                customer_type += custcService.GetCustomerType(ct).Name + ",";
                            }
                            if (customer_type != null)
                            {
                                msg = msg + "  Allowed Customer Type : " + customer_type + "\n";
                            }
                            customer_type         = "";
                            CustomerTypeIds_local = pricecondition.CustomerTypeIds;
                        }


                        // Allowed Finance Options

                        if (pricecondition.FinanceOptionIds != null)
                        {
                            string financeoption = "";

                            foreach (var fo in pricecondition.FinanceOptionIds)
                            {
                                financeoption += productcService.GetFinanceOption(fo).Description + ",";
                            }

                            if (financeoption != "")
                            {
                                msg = msg + " Allowed Finance Options : " + financeoption + "\n";
                            }
                            FinanceOptionIds_local = pricecondition.FinanceOptionIds;
                        }

                        // Allowed Finance Account Type

                        if (pricecondition.FinancialAccountTypeIds != null)
                        {
                            string fatype = "";

                            foreach (var fatypeid in pricecondition.FinancialAccountTypeIds)
                            {
                                fatype += fincService.GetFinancialAccountType((fatypeid)).Description + ",";
                            }

                            if (fatype != "")
                            {
                                msg = msg + "  Allowed Financial Account Type : " + fatype + "\n";
                            }
                        }

                        // Allowed Postal Codes

                        if (pricecondition.PostalCodes != null)
                        {
                            string postcode = "";

                            foreach (var pcode in pricecondition.PostalCodes)
                            {
                                postcode += pcode + ",";
                            }

                            if (postcode != "")
                            {
                                msg = msg + "  Allowed Postal Code : " + postcode + "\n";
                            }
                            PostalCodes_local = pricecondition.PostalCodes;
                        }


                        // Allowed Province

                        if (pricecondition.ProvinceIds != null)
                        {
                            string province = "";

                            foreach (var pro in pricecondition.ProvinceIds)
                            {
                                province += custcService.GetProvince(pro).Description + ",";
                            }

                            if (province != "")
                            {
                                msg = msg + "  Allowed Province : " + province + "\n";
                            }
                            ProvinceIds_local = pricecondition.ProvinceIds;
                        }
                        ListPriceCondition_local = listprice.PriceConditions.Items;
                    }
                }

                cc.Add(new YangProductPriceItems
                {
                    the_Name = pr.Name,
                    the_CommercialProductIds = pr.CommercialProductIds,
                    the_ListPriceCollection  = prices.Items,
                    the_CustomerClassIds     = CustomerClassIds_local,
                    the_CountryIds           = CountryIds_local,
                    the_CustomerTypeIds      = CustomerTypeIds_local,
                    the_ListPriceConditions  = ListPriceCondition_local
                });
            }
            db.the_items = cc;
            return(db);
        }
Example #9
0
        public List <QuoteInvoiceCollection> GetPendingQuote(String username_ad, String password_ad)
        {
            Authentication_class var_auth = new Authentication_class();
            AuthenticationHeader ah       = var_auth.getAuthHeader(username_ad, password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);
            var billService = AsmRepository.GetServiceProxy <IBillingEngineService>(ah);
            var finService  = AsmRepository.AllServices.GetFinanceService(ah);

            QuoteInvoiceCollection quotes = null;
            decimal   total_amount        = 0;
            ArrayList falist           = new ArrayList();
            long      new_max_quote_id = 1;
            int       total_record     = 0;
            List <QuoteInvoiceCollection> the_items = new List <QuoteInvoiceCollection>();

            for (int i = 1; i < 10000; i++)
            {
                quotes = billService.FindQuoteInvoices(new BaseQueryRequest()
                {
                    FilterCriteria = Op.Eq("QuoteStatusId", "1") & Op.Gt("Id", 1),
                    PageCriteria   = new PageCriteria()
                    {
                        Page     = i,
                        PageSize = 300
                    },
                    SortCriteria = new SortCriteriaCollection()
                    {
                        new SortCriteria()
                        {
                            SortDirection = SortDirections.Ascending,
                            Key           = "Id"
                        }
                    },
                    DeepLoad = true
                });
                //Console.WriteLine("Loop " + i + " Times!");
                if (quotes.TotalCount == 0)
                {
                    //Console.WriteLine("End Loop ...... ");
                    break;
                }
                // set the new max quote id for next run

                int count = quotes.TotalCount - 1;
                new_max_quote_id = quotes.Items[count].Id.Value;

                foreach (var quote in quotes.Items)
                {
                    // Avoid duplicate records
                    if (falist.Contains(quote.FinancialAccountId))
                    {
                        continue;
                    }
                    else
                    {
                        falist.Add(quote.FinancialAccountId);
                    }

                    total_amount = 0;
                    total_amount = quote.TotalAmount.Value;

                    var fa = finService.GetFinancialAccount(quote.FinancialAccountId.Value);

                    // search all pending quote for same financial account and count total
                    // Why :  Customer may have multiple pending quote if he request more products or upgrade in different time, so you need count all of them.
                    foreach (var quotet in quotes.Items)
                    {
                        if (quotet.FinancialAccountId == quote.FinancialAccountId && quote.Id != quotet.Id)
                        {
                            total_amount = total_amount + quotet.TotalAmount.Value;
                            total_record++;
                            //Console.WriteLine("quotet.TotalAmount.Value " + quotet.TotalAmount.Value);
                        }
                    }

                    // Add the account debit like payment fee, downgrade fee...etc. so you need to add account balance
                    total_amount = total_amount + fa.Balance.Value;

                    //Console.WriteLine("Customer Id : " + quote.CustomerId.Value + " FA ID : " + fa.Id.Value + " , unpaid quote amount : " + total_amount);

                    //if (quote.LineItems.TotalCount > 0)
                    //{
                    //    Console.WriteLine("From " + quote.LineItems.Items[0].StartDate + " To " + quote.LineItems.Items[0].EndDate);
                    //}
                    total_record++;
                }
                the_items.Add(new QuoteInvoiceCollection(quotes));
                quotes = null;
            }

            //Console.WriteLine("Total " + total_record + " pending quotes");
            //Console.Read();

            //return new_max_quote_id;

            return(the_items);
        }
        public ShippingOrder ShipShippingOrder_ver1(string username_ad, string password_ad, int custid, string decoder_serial_number, string smartcard_serial_number, bool isInternet = false)
        {
            Authentication_class var_auth   = new Authentication_class();
            AuthenticationHeader authHeader = var_auth.getAuthHeader(username_ad, password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);

            var soService     = AsmRepository.AllServices.GetOrderManagementService(authHeader);
            var faService     = AsmRepository.AllServices.GetFinanceService(authHeader);
            var sbService     = AsmRepository.AllServices.GetSandBoxManagerService(authHeader);
            var agService     = AsmRepository.AllServices.GetAgreementManagementService(authHeader);
            var deviceService = AsmRepository.AllServices.GetDevicesService(authHeader);
            var viewfService  = AsmRepository.AllServices.GetViewFacadeService(authHeader);

            //msg = "Ship the shipping order...";
            //Console.WriteLine(msg);
            //Console.WriteLine("decoder sn : " + decoder_serial_number);
            //Console.WriteLine("smartcard sn : " + smartcard_serial_number);
            //logger.Info(msg);

            int d_tp    = 0;
            int s_tp    = 0;
            int d_model = 0;
            int s_model = 0;

            if (isInternet)
            {
                d_tp    = internet_router_tp_id;
                s_tp    = xl_sim_tp_id;
                d_model = router_model_id;
                s_model = xl_sim_model_id;
            }
            else
            {
                d_tp    = DECODER_TP_ID;
                s_tp    = SCTPID;
                d_model = DECODER_MODEL_ID;
                s_model = SC_MODEL_ID;
            }

            try
            {
                // get the pending shipping order and shipping order line
                ShippingOrder soc = soService.GetShippedOrders(custid, 0).Items.Find(t => t.StatusId == SOMAYSHIP);


                if (soc == null)
                {
                    Console.WriteLine("No Shipping Order with status May Ship, please check customer id : " + custid);
                    return(null);
                }

                // Get the hardware agreement detail of customer
                AgreementDetailView hardwaread = null;
                var hardwareads = viewfService.GetAgreementDetailView(new BaseQueryRequest()
                {
                    FilterCriteria = Op.Eq("DeviceIncluded", true) & Op.Eq("CustomerId", custid) & Op.Gt("Id", 0) & Op.IsNull("ProvisionedDevices"),
                    PageCriteria   = new PageCriteria(1),
                    SortCriteria   = new SortCriteriaCollection()
                    {
                        new SortCriteria()
                        {
                            Key           = "Id",
                            SortDirection = SortDirections.Descending
                        }
                    }
                });

                if (hardwareads.TotalCount == 0)
                {
                    //Console.WriteLine("Hardware product is not captured, can't ship the shipping order for customer id : " + custid);
                    return(null);
                }
                else
                {
                    hardwaread = hardwareads.Items[0];
                }

                // Find the shipping order lines for decoder and smartcard
                var decodersoline = soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == d_tp);
                var scsoline      = soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == s_tp);


                // Get random decoder and smartcard which are in stock, you should not use this since you have real device information.
                if (decoder_serial_number == "")
                {
                    decoder_serial_number = deviceService.GetDevices(
                        new BaseQueryRequest()
                    {
                        FilterCriteria = new CriteriaCollection()
                        {
                            new Criteria()
                            {
                                Key      = "ModelId",
                                Operator = Operator.Equal,
                                Value    = d_model.ToString()
                            },
                            new Criteria()
                            {
                                Key      = "StatusId",
                                Operator = Operator.Equal,
                                Value    = DEVICE_STATUS_STOCK
                            }
                        }
                    }).Items[0].SerialNumber;
                }
                else
                {
                    d_model = deviceService.GetDeviceBySerialNumber(decoder_serial_number).ModelId.Value;
                }


                if (smartcard_serial_number == "")
                {
                    smartcard_serial_number = deviceService.GetDevices(new BaseQueryRequest()
                    {
                        FilterCriteria = new CriteriaCollection()
                        {
                            new Criteria()
                            {
                                Key      = "ModelId",
                                Operator = Operator.Equal,
                                Value    = s_model.ToString()
                            },
                            new Criteria()
                            {
                                Key      = "StatusId",
                                Operator = Operator.Equal,
                                Value    = DEVICE_STATUS_STOCK
                            }
                        }
                    }).Items[0].SerialNumber;
                }
                else
                {
                    s_model = deviceService.GetDeviceBySerialNumber(smartcard_serial_number).ModelId.Value;
                }

                // Identify device info to the shipping order lines
                BuildList buildListdecoder = new BuildList
                {
                    OrderLineId     = decodersoline.Id,
                    OrderId         = soc.Id,
                    ModelId         = decodersoline.HardwareModelId.GetValueOrDefault(),
                    StockHandlerId  = soc.ShipFromStockHandlerId,
                    TransactionType = BuildListTransactionType.ShippingSerializedProducts
                };

                BuildList bldecoder = deviceService.CreateBuildList(buildListdecoder);

                BuildList buildListsc = new BuildList
                {
                    OrderLineId     = scsoline.Id,
                    OrderId         = soc.Id,
                    ModelId         = scsoline.HardwareModelId.GetValueOrDefault(),
                    StockHandlerId  = soc.ShipFromStockHandlerId,
                    TransactionType = BuildListTransactionType.ShippingSerializedProducts
                };

                BuildList blsc = deviceService.CreateBuildList(buildListsc);

                deviceService.AddDeviceToBuildListManually(bldecoder.Id.Value, decoder_serial_number);
                deviceService.AddDeviceToBuildListManually(blsc.Id.Value, smartcard_serial_number);

                //msg = "Starting perform build list";
                //Console.WriteLine(msg);
                //logger.Debug(msg);

                deviceService.PerformBuildListAction(bldecoder.Id.Value);
                deviceService.PerformBuildListAction(blsc.Id.Value);


                // Ship the Shipping Order
                //msg = "Starting link the device to customer";
                //Console.WriteLine(msg);
                //logger.Debug(msg);

                // Fill the agreement detail id on the shipping order line to link the device to customer
                soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == d_tp).AgreementDetailId = hardwaread.Id.Value;
                soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == s_tp).AgreementDetailId = hardwaread.Id.Value;

                soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == d_tp).ReceivedQuantity = 1;
                soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == s_tp).ReceivedQuantity = 1;

                soService.ShipOrder(soc, shipso_reason, null);
                //msg = "Shipping Order :" + soc.Id.Value + " has been shipped!";
                //logger.Info(msg);


                return(soc);
            }
            catch (Exception ex)
            {
                //Console.WriteLine("Inner Exception : " + ex.InnerException.Message);
                //msg = "Errors : " + ex.Message + "  ------  Exception Stack : " + ex.StackTrace;
                //Console.WriteLine("Errors : " + ex.Message);
                //Console.WriteLine("Stack : " + ex.StackTrace);
                //logger.Error(msg);

                return(null);
            }
        }
        public ShippingOrder ShipShippingOrder_ver2(String username_ad, String password_ad, int custid, string decoder_serial_number, string smartcard_serial_number, bool isInternet, string lnb_sn, string antenna_sn, int shippingorder_id, bool isHD)
        {
            Authentication_class var_auth   = new Authentication_class();
            AuthenticationHeader authHeader = var_auth.getAuthHeader(username_ad, password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);

            //var docmService = AsmRepository.GetServiceProxy<IDocumentManagementService>(authHeader);
            var soService     = AsmRepository.AllServices.GetOrderManagementService(authHeader);
            var faService     = AsmRepository.AllServices.GetFinanceService(authHeader);
            var sbService     = AsmRepository.AllServices.GetSandBoxManagerService(authHeader);
            var agService     = AsmRepository.AllServices.GetAgreementManagementService(authHeader);
            var deviceService = AsmRepository.AllServices.GetDevicesService(authHeader);
            var viewfService  = AsmRepository.AllServices.GetViewFacadeService(authHeader);

            //msg = "Ship the shipping order...";
            //Console.WriteLine(msg);
            //logger.Info(msg);

            int d_tp    = 0;
            int s_tp    = 0;
            int d_model = 0;
            int s_model = 0;

            int lnb_model     = 0;
            int antenna_model = 0;

            if (isInternet)
            {
                d_tp    = internet_router_tp_id;
                s_tp    = xl_sim_tp_id;
                d_model = router_model_id;
                s_model = xl_sim_model_id;
            }
            else
            {
                d_tp    = DECODER_TP_ID;
                s_tp    = SCTPID;
                d_model = DECODER_MODEL_ID;
                s_model = SC_MODEL_ID;
            }

            if (isHD)
            {
                //d_model = DECODER_HD_TP_ID;
                d_tp    = DECODER_HD_TP_ID;
                d_model = DECODER_HD_MODEL_ID;
            }

            try
            {
                // Get the hardware agreement detail of customer
                AgreementDetailView hardwaread = null;
                var hardwareads = viewfService.GetAgreementDetailView(new BaseQueryRequest()
                {
                    FilterCriteria = Op.Eq("DeviceIncluded", true) & Op.Eq("CustomerId", custid) & Op.Gt("Id", 0) & Op.IsNull("ProvisionedDevices"),
                    PageCriteria   = new PageCriteria(1),
                    SortCriteria   = new SortCriteriaCollection()
                    {
                        new SortCriteria()
                        {
                            Key           = "Id",
                            SortDirection = SortDirections.Descending
                        }
                    }
                });

                if (hardwareads.TotalCount == 0)
                {
                    //Console.WriteLine("Hardware product is not captured, can't ship the shipping order for customer id : " + custid);
                    return(null);
                }
                else
                {
                    hardwaread = hardwareads.Items[0];
                }

                // If not input the shipping order id then find the shipping order id by the random hardware product which don't assign device info yet.
                if (shippingorder_id == 0)
                {
                    shippingorder_id = getShippingOrderByHardware(username_ad, password_ad, hardwaread.Id.Value);
                    //Console.WriteLine("Ship the Shipping Order Id is : " + shippingorder_id);
                }
                // get the May shipping order and shipping order line( with smartcard or Sim card in it).
                var soc = soService.GetShippedOrders(custid, 0).Items.Find(t => (t.StatusId == SOMAYSHIP && t.Id.Value == shippingorder_id));


                if (soc == null)
                {
                    //Console.WriteLine("No Shipping Order with status May Ship, please check customer id : " + custid);
                    return(null);
                }



                // Find the shipping order lines for decoder and smartcard

                var scsoline = soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == s_tp);


                // Get random decoder and smartcard which are in stock, you should not use this since you have real device information.
                Device decoder   = null;
                Device smartcard = null;
                if (decoder_serial_number == "")
                {
                    var decoders = deviceService.GetDevices(
                        new BaseQueryRequest()
                    {
                        FilterCriteria = new CriteriaCollection()
                        {
                            new Criteria()
                            {
                                Key      = "ModelId",
                                Operator = Operator.Equal,
                                Value    = d_model.ToString()
                            },
                            new Criteria()
                            {
                                Key      = "StatusId",
                                Operator = Operator.Equal,
                                Value    = DEVICE_STATUS_STOCK
                            }
                        }
                    });
                    if (decoders.Items.Count == 0)
                    {
                        //Console.WriteLine("There are no decoder avaiable to use!");
                        return(null);
                    }
                    else
                    {
                        decoder_serial_number = decoders.Items[0].SerialNumber;
                    }
                }
                else
                {
                    decoder = deviceService.GetDeviceBySerialNumber(decoder_serial_number);
                    if (decoder.StatusId.Value == Int32.Parse(DEVICE_STATUS_STOCK) || decoder.StatusId.Value == Int32.Parse(DEVICE_STATUS_REFURSTOCK) ||
                        decoder.StatusId.Value == Int32.Parse(DEVICE_STATUS_REPAIREDSTOCK)
                        )
                    {
                    }
                    else
                    {
                        //Console.WriteLine(" Decoder with serial number " + decoder_serial_number + " is not in allowed capture status!");
                        return(null);
                    }
                }


                if (smartcard_serial_number == "")
                {
                    var smartcards = deviceService.GetDevices(new BaseQueryRequest()
                    {
                        FilterCriteria = new CriteriaCollection()
                        {
                            new Criteria()
                            {
                                Key      = "ModelId",
                                Operator = Operator.Equal,
                                Value    = s_model.ToString()
                            },
                            new Criteria()
                            {
                                Key      = "StatusId",
                                Operator = Operator.Equal,
                                Value    = DEVICE_STATUS_STOCK
                            }
                        }
                    });
                    if (smartcards.Items.Count == 0)
                    {
                        //Console.WriteLine("There are no smartcard avaiable to use!");
                        return(null);
                    }
                    else
                    {
                        smartcard_serial_number = smartcards.Items[0].SerialNumber;
                    }
                }
                else
                {
                    smartcard = deviceService.GetDeviceBySerialNumber(smartcard_serial_number);
                    if (smartcard.StatusId.Value == Int32.Parse(DEVICE_STATUS_STOCK) || smartcard.StatusId.Value == Int32.Parse(DEVICE_STATUS_REFURSTOCK) ||
                        smartcard.StatusId.Value == Int32.Parse(DEVICE_STATUS_REPAIREDSTOCK)
                        )
                    {
                    }
                    else
                    {
                        //Console.WriteLine(" Smartcard with serial number " + smartcard_serial_number + " is not in allowed capture status!");
                        return(null);
                    }
                }

                // Identify device info to the shipping order lines
                var dd = identifyDevice(username_ad, password_ad, soc, decoder_serial_number, d_tp, d_model);
                var sc = identifyDevice(username_ad, password_ad, soc, smartcard_serial_number, s_tp, s_model);
                if (lnb_sn.Length > 0)
                {
                    var lnb = deviceService.GetDeviceBySerialNumber(lnb_sn);
                    if (lnb.StatusId.Value == Int32.Parse(DEVICE_STATUS_STOCK) || lnb.StatusId.Value == Int32.Parse(DEVICE_STATUS_REFURSTOCK) ||
                        lnb.StatusId.Value == Int32.Parse(DEVICE_STATUS_REPAIREDSTOCK)
                        )
                    {
                        lnb_model = lnb.ModelId.Value;
                    }
                    else
                    {
                        //Console.WriteLine(" LNB with serial number " + lnb_sn + " is not in allowed capture status!");
                        //return null;
                    }
                    identifyDevice(username_ad, password_ad, soc, lnb_sn, lnb_tp_id, lnb.ModelId.Value);
                }
                if (antenna_sn.Length > 0)
                {
                    var antenna = deviceService.GetDeviceBySerialNumber(lnb_sn);
                    if (antenna.StatusId.Value == Int32.Parse(DEVICE_STATUS_STOCK) || antenna.StatusId.Value == Int32.Parse(DEVICE_STATUS_REFURSTOCK) ||
                        antenna.StatusId.Value == Int32.Parse(DEVICE_STATUS_REPAIREDSTOCK)
                        )
                    {
                        antenna_model = antenna.ModelId.Value;
                    }
                    else
                    {
                        //Console.WriteLine(" Antenna with serial number " + antenna_sn + " is not in allowed capture status!");
                        //return null;
                    }
                    identifyDevice(username_ad, password_ad, soc, antenna_sn, antenna_tp_id, antenna.ModelId.Value);
                }

                if (dd == null || sc == null)
                {
                    return(null);
                }

                //msg = "Starting perform build list";
                //Console.WriteLine(msg);
                //logger.Debug(msg);


                // Ship the Shipping Order
                //msg = "Starting link the device to customer";
                //Console.WriteLine(msg);
                //logger.Debug(msg);

                // Fill the agreement detail id on the shipping order line to link the device to customer
                //soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == d_tp).AgreementDetailId = hardwaread.Id.Value;
                //soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == s_tp).AgreementDetailId = hardwaread.Id.Value;

                // Fill the correct model id
                soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == d_tp).HardwareModelId          = d_model;
                soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == s_tp).HardwareModelId          = s_model;
                soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == lnb_tp_id).HardwareModelId     = lnb_model;
                soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == antenna_tp_id).HardwareModelId = antenna_model;

                soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == d_tp).ReceivedQuantity = 1;
                soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == s_tp).ReceivedQuantity = 1;

                soService.ShipOrder(soc, shipso_reason, null);
                //msg = "Shipping Order :" + soc.Id.Value + " has been shipped!";
                //logger.Info(msg);


                return(soc);
            }
            catch (Exception ex)
            {
                //Console.WriteLine("Inner Exception : " + ex.InnerException.Message);
                //msg = "Errors : " + ex.Message + "  ------  Exception Stack : " + ex.StackTrace;
                //Console.WriteLine("Errors : " + ex.Message);
                //Console.WriteLine("Stack : " + ex.StackTrace);
                //logger.Error(msg);

                return(null);
            }
        }
        public List <Hardware_list> GetSerialNumberDevices_shippingordersByCustomerId(String username_ad, String password_ad, int cust_id)
        {
            List <Hardware_list> list1 = new List <Hardware_list>();


            Authentication_class var_auth   = new Authentication_class();
            AuthenticationHeader authHeader = var_auth.getAuthHeader(username_ad, password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);

            var soService     = AsmRepository.AllServices.GetOrderManagementService(authHeader);
            var faService     = AsmRepository.AllServices.GetFinanceService(authHeader);
            var sbService     = AsmRepository.AllServices.GetSandBoxManagerService(authHeader);
            var agService     = AsmRepository.AllServices.GetAgreementManagementService(authHeader);
            var deviceService = AsmRepository.AllServices.GetDevicesService(authHeader);
            var viewfService  = AsmRepository.AllServices.GetViewFacadeService(authHeader);
            var prodcService  = AsmRepository.AllServices.GetProductCatalogConfigurationService(authHeader);

            try
            {
                int    so_shipped  = 3;
                int    so_pending  = 1;
                int    so_mayship  = 21;
                int    so_reject   = 5;
                int    so_approved = 2;
                string sn          = "";

                var sos = soService.GetShippedOrders(cust_id, 0);

                List <ShippingOrder> shipped_so = sos.Items.FindAll(T => T.StatusId == so_shipped);

                List <ShippingOrder> pending_so = sos.Items.FindAll(T => T.StatusId == so_pending);

                List <ShippingOrder> mayship_so = sos.Items.FindAll(T => T.StatusId == so_mayship);

                List <ShippingOrder> mayship_pending = null;

                // get shipped ship order info.
                foreach (var so in shipped_so)
                {
                    //Console.WriteLine("Shipped Shipping Order ID : " + so.Id.Value);
                    foreach (var item in so.ShippingOrderLines.Items)
                    {
                        var tp     = prodcService.GetTechnicalProduct(item.TechnicalProductId.Value);
                        var device = viewfService.GetDeviceView(new BaseQueryRequest()
                        {
                            FilterCriteria = Op.Eq("ShipOrderId", so.Id.Value) && Op.Eq("TechnicalProductName", tp.Name),
                            PageCriteria   = new PageCriteria()
                            {
                                Page     = 0,
                                PageSize = 5
                            }
                        });

                        if (device.TotalCount > 0)
                        {
                            sn = device.Items[0].SerialNumber;
                        }
                        list1.Add(new Hardware_list()
                        {
                            description = tp.Description, serial_number = sn, hardware_model_id = item.HardwareModelId.Value
                        });
                        //Console.WriteLine("Item Hardware Model ID : " + item.HardwareModelId.Value + " Serial Number : " + sn);
                        sn = "";
                    }
                }



                return(list1);
            }
            catch (Exception ex)
            {
                return(null);
                //msg = "Errors : " + ex.Message + "  ------  Exception Stack : " + ex.StackTrace;
                //Console.WriteLine("Errors : " + ex.Message);
                //Console.WriteLine("Stack : " + ex.StackTrace);
                //logger.Error(msg);
            }
        }
Example #13
0
        public List <OfferDefinition> YangOfferDefinition(String username_ad, String password_ad)
        {
            Authentication_class var_auth   = new Authentication_class();
            AuthenticationHeader authHeader = var_auth.getAuthHeader(username_ad, password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);

            IOfferManagementConfigurationService offercService = null;
            IOfferManagementService offerService   = null;
            IPriceAdjustmentService priceadService = null;
            IPriceAdjustmentConfigurationService priceadcService = null;
            ICustomersConfigurationService       custcService    = null;
            IProductCatalogConfigurationService  productcService = null;
            IAgreementManagementService          agService       = null;



            offercService   = AsmRepository.AllServices.GetOfferManagementConfigurationService(authHeader);
            offerService    = AsmRepository.AllServices.GetOfferManagementService(authHeader);
            priceadService  = AsmRepository.AllServices.GetPriceAdjustmentService(authHeader);
            priceadcService = AsmRepository.AllServices.GetPriceAdjustmentConfigurationService(authHeader);
            custcService    = AsmRepository.AllServices.GetCustomersConfigurationService(authHeader);
            productcService = AsmRepository.AllServices.GetProductCatalogConfigurationService(authHeader);
            agService       = AsmRepository.AllServices.GetAgreementManagementService(authHeader);

            try
            {
                var offers = offercService.GetOfferDefinitions(new BaseQueryRequest()
                {
                    FilterCriteria = Op.Eq("Active", true),
                    DeepLoad       = true,
                    PageCriteria   = new PageCriteria()
                    {
                        Page = 0,
                    }
                });

                //Console.WriteLine("Find " + offers.TotalCount + " Promo defenitions...");

                return(offers.Items);

                //foreach (var offer in offers.Items)
                //{
                //    Console.WriteLine("-----------------------------------------------------------------------");
                //    Console.WriteLine("Promo Name : " + offer.Description);

                //    var offer_adjustments = priceadcService.GetPriceAdjustmentDefinitionsForOffer(offer.Id.Value, 0);

                //    Console.WriteLine(" Find total price adjustment : " + offer_adjustments.TotalCount);

                //    foreach (var offer_adjust in offer_adjustments.Items)
                //    {

                //        string condition = "";
                //        //string apply_level = "";
                //        string price = "";
                //        string charge_type = "";

                //        string apply_to_customer_class = "";
                //        string apply_to_customer_type = "";
                //        string apply_to_product = "";



                //        foreach (var cust_class in offer_adjust.ApplicableCustomerClasses)
                //        {
                //            apply_to_customer_class += custcService.GetCustomerClass(cust_class).Description + ",";
                //        }

                //        foreach (var cust_type in offer_adjust.ApplicableCustomerTypes)
                //        {
                //            apply_to_customer_type += custcService.GetCustomerType(cust_type).LongDescription + ",";
                //        }

                //        if (offer_adjust.ApplicableProducts != 0)
                //        {
                //            apply_to_product = productcService.GetCommercialProduct(offer_adjust.ApplicableProducts.Value).Name;
                //        }

                //        if (apply_to_customer_class != "")
                //        {
                //            condition += "  apply to customer class : " + apply_to_customer_class;
                //        }

                //        if (apply_to_customer_type != "")
                //        {
                //            condition += "  apply to customer type : " + apply_to_customer_type;
                //        }

                //        if (apply_to_product != "")
                //        {
                //            condition += "  apply to product : " + apply_to_product;
                //        }

                //        if (offer_adjust.Type == PriceAdjustmentTypes.PercentOff)
                //        {
                //            price = " discount is percent :" + offer_adjust.Value;
                //        }

                //        if (offer_adjust.Type == PriceAdjustmentTypes.FixedPrice)
                //        {
                //            price = " discount is fixed price : " + offer_adjust.Value;
                //        }

                //        if (offer_adjust.Type == PriceAdjustmentTypes.AmountOff)
                //        {
                //            price = " discount is off amount " + offer_adjust.Value;
                //        }

                //        if (offer_adjust.ChargeType == ChargeTypes.OnceOff)
                //        {
                //            charge_type = " charge type is  Once-Off";
                //        }
                //        else if (offer_adjust.ChargeType == ChargeTypes.Recurring)
                //        {
                //            charge_type = " charge type is Recurring";
                //        }

                //        Console.WriteLine("Apply level :  0 - ListPrice, 1 - Settlement 2 - OrderableEventDiscount 3 - PrepaidFAPayment 4 - QuoteProduct");
                //        Console.WriteLine("Adjustment " + offer_adjust.Description + " apply level : " + offer_adjust.ApplyToType.ToString() + "   |   " + condition + " Price : " + price + " " + charge_type);



                //    }
                //    Console.WriteLine("########################################################################");
                //}

                //Console.WriteLine("End");
            }
            catch (Exception ex)
            {
                return(null);
                //Console.WriteLine("Errors : " + ex.Message);
                //Console.WriteLine("Exception Stack : " + ex.StackTrace);
            }
        }
Example #14
0
        // import devices to stock handler
        public void importDevices(string username_ad, string password_ad)
        {
            Authentication_class var_auth   = new Authentication_class();
            AuthenticationHeader authHeader = var_auth.getAuthHeader(username_ad, password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);

            var whService     = AsmRepository.AllServices.GetLogisticsService(authHeader);
            var prodcService  = AsmRepository.AllServices.GetProductCatalogConfigurationService(authHeader);
            var deviceService = AsmRepository.AllServices.GetDevicesService(authHeader);

            try
            {
                var stockhandlers = whService.GetStockHandlers(new BaseQueryRequest()
                {
                    FilterCriteria = Op.Eq("Active", true),
                    PageCriteria   = new PageCriteria()
                    {
                        Page     = 1,
                        PageSize = 100
                    }
                });

                var models = prodcService.GetHardwareModels(new BaseQueryRequest()
                {
                    FilterCriteria = Op.Like("Description", "%Decoder%"),
                    PageCriteria   = new PageCriteria()
                    {
                        Page     = 1,
                        PageSize = 100
                    }
                });

                //models.Items.Sort();

                foreach (var model in models.Items)
                {
                    string start_sn = "ID" + model.Id.Value + "YY";
                    int    count    = 100;

                    StockReceiveDetails stockReceiveDetails = new StockReceiveDetails();
                    stockReceiveDetails.FromStockHanderId = 1;
                    stockReceiveDetails.ToStockHanderId   = 1;
                    stockReceiveDetails.Reason            = 71197;
                    stockReceiveDetails = deviceService.CreateStockReceiveDetails(stockReceiveDetails);


                    BuildList bl = new BuildList();
                    bl.TransactionType       = BuildListTransactionType.ReceiveNewStock;
                    bl.Reason                = 71197;
                    bl.ModelId               = model.Id.Value;
                    bl.StockReceiveDetailsId = stockReceiveDetails.Id.Value;

                    // Create build list
                    var nbl = deviceService.CreateBuildList(bl);

                    // Add device to build list
                    for (int i = 0; i < 300; i++)
                    {
                        string sn = start_sn + count.ToString().PadLeft(model.HardwareNumberLength.Value - start_sn.Length, '0');
                        Console.WriteLine(sn);
                        count++;
                        deviceService.AddDeviceToBuildListManually(nbl.Id.Value, sn);
                    }

                    // Perform build list
                    var bl1 = deviceService.PerformBuildListAction(nbl.Id.Value);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Errors : " + ex.Message);
                Console.WriteLine("Stack : " + ex.StackTrace);
            }
        }