Пример #1
0
        public void createNote()
        {
            int reasonkey = 1;

            //Create the authentication header, initialize with credentials, and
            //create the service proxy. For details, see the API Developer's
            //Guide and the Reference Library CHM.
            Authentication_class var_auth = new Authentication_class();
            AuthenticationHeader ah       = var_auth.getAuthentication_header();

            AsmRepository.SetServiceLocationUrl("http://mncsvasm.mskydev1.local/asm/all/servicelocation.svc");
            var customersConfiguration = AsmRepository.GetServiceProxyCachedOrDefault <ICustomersService>(ah);
            //Instanstiate and initialize a ValidAddress object.
            //For a description of each property, see the API Reference Library CHM.
            Note new_note = new Note();

            new_note.CategoryId = 1;
            //new_note.CategoryKey = "ADMINPOS";
            new_note.CompletionStageId = 1;
            //new_note.CompletionStageKey = NoteCompletionStage.ENTITY_ID.ToString();

            new_note.Body = "tes notes dari huda";

            new_note.CustomerId = 35153;


            Note the_new_note = customersConfiguration.CreateNote(new_note, 0);

            Console.WriteLine("note created. ID = {0}", the_new_note.Id);
            Console.ReadLine();
        }
Пример #2
0
        public HttpResponseMessage GetServiceTypeById(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 TSService = AsmRepository.GetServiceProxyCachedOrDefault <IWorkforceConfigurationService>(ah);

            BaseQueryRequest request = new BaseQueryRequest();

            request.FilterCriteria = new CriteriaCollection();
            request.FilterCriteria.Add(new Criteria("Id", id));

            ServiceTypeCollection servicetype = TSService.GetServiceTypeList(request);

            if (servicetype != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, servicetype));
            }
            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);
            }
        }
Пример #4
0
        public void updateDeviceStatus(string serial_number, int reason_id)
        {
            Authentication_class var_auth   = new Authentication_class();
            AuthenticationHeader authHeader = var_auth.getAuthentication_header();

            AsmRepository.SetServiceLocationUrl(var_auth.var_url_asm);

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

            int return_status = 0;

            try
            {
                Device device = deviceService.GetDeviceBySerialNumber(serial_number);
                if (device != null)
                {
                    deviceService.UpdateDeviceStatus(device.Id.Value, reason_id);
                    //return_status = 1;
                    Console.WriteLine("device id = " + device.Id, "serial number = " + device.SerialNumber);
                }
                else
                {
                    //return_status = 0;
                    Console.WriteLine("Can't find device with serial number : " + serial_number);
                }
            }
            catch (Exception ex)
            {
                //return null;
                Console.WriteLine("Errors : " + ex.Message);
                Console.WriteLine("Stack : " + ex.StackTrace);
            }
        }
        // Identify device to shipping order
        public ShippingOrder identifyDevice(String username_ad, String password_ad, ShippingOrder soc, string serial_number, int tp_id, int model_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);

            try
            {
                var so_lineitem = soc.ShippingOrderLines.Items.Find(t => t.TechnicalProductId == tp_id);

                if (so_lineitem == null)
                {
                    //Console.WriteLine("Can't find techinical product with id : " + tp_id + " in shipping order with id : " + soc.Id.Value);
                    return(null);
                }

                var buildlist = new BuildList
                {
                    OrderLineId     = so_lineitem.Id,
                    OrderId         = soc.Id,
                    ModelId         = model_id,
                    StockHandlerId  = soc.ShipFromStockHandlerId,
                    TransactionType = BuildListTransactionType.ShippingSerializedProducts
                };

                var b_build_list = deviceService.CreateBuildList(buildlist);

                var d_a_list = deviceService.AddDeviceToBuildListManually(b_build_list.Id.Value, serial_number);

                if (d_a_list.Accepted.Value)
                {
                    var dblist = deviceService.PerformBuildListAction(b_build_list.Id.Value);
                }
                else
                {
                    //Console.WriteLine("Failed to attach decoder with SN : " + serial_number + " to Shipping Order : Error : " + d_a_list.Error);
                    return(null);
                }

                return(soc);
            }
            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(null);
            }
        }
Пример #6
0
        public HttpResponseMessage GetAgreementByTypeId(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);

            IViewFacadeService viewFacadeService = AsmRepository.GetServiceProxyCachedOrDefault <IViewFacadeService>(ah);

            BaseQueryRequest request = new BaseQueryRequest();

            request.FilterCriteria = new CriteriaCollection();

            //Agreement type is a user-configured property. The value in
            //this key-value pair is the agreement type ID. You can get this
            //value from the Configuration Module or from a call to
            //the AgreementManagementConfigurationService.
            request.FilterCriteria.Add(new Criteria("TypeId", id));
            AgreementViewCollection coll = viewFacadeService.GetAgreementView(request);

            if (coll != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, coll));
            }
            else
            {
                var       message = string.Format("error");
                HttpError err     = new HttpError(message);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
        }
Пример #7
0
        public HttpResponseMessage CreateNote([FromBody] CreateNoteParams created_data)
        {
            Authentication_class var_auth = new Authentication_class();
            AuthenticationHeader ah       = var_auth.getAuthHeader(created_data.username_ad, created_data.password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);
            var customersConfiguration = AsmRepository.GetServiceProxyCachedOrDefault <ICustomersService>(ah);
            //Instanstiate and initialize a ValidAddress object.
            //For a description of each property, see the API Reference Library CHM.
            Note new_note = new Note();

            new_note.CategoryId = created_data.the_categoryId;               //1
            //new_note.CategoryKey = "ADMINPOS";
            new_note.CompletionStageId = created_data.the_completionStageId; //1
            //new_note.CompletionStageKey = NoteCompletionStage.ENTITY_ID.ToString();

            new_note.Body = created_data.the_body_note;

            new_note.CustomerId = created_data.the_customerId;


            Note the_new_note = customersConfiguration.CreateNote(new_note, 0);

            if (the_new_note != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, the_new_note));
            }
            else
            {
                var       message = string.Format("error");
                HttpError err     = new HttpError(message);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
        }
Пример #8
0
        public void transferDevice(int reason183, int to_stockhandler_id, string sn)
        {
            Authentication_class var_auth   = new Authentication_class();
            AuthenticationHeader authHeader = var_auth.getAuthentication_header();

            AsmRepository.SetServiceLocationUrl(var_auth.var_url_asm);

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

            try
            {
                BuildList bl = new BuildList();
                bl.TransactionType = BuildListTransactionType.TransferToAnotherStockHandler;
                bl.Reason          = reason183;
                bl.StockHandlerId  = to_stockhandler_id;


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

                // Add device to build list
                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);
            }
        }
Пример #9
0
        public void getWorkOrderByCustomerId()
        {
            #region Authenticate and create proxies
            Authentication_class var_auth = new Authentication_class();
            AuthenticationHeader ah       = var_auth.getAuthentication_header();
            AsmRepository.SetServiceLocationUrl("http://mncsvasm.mskydev1.local/asm/all/servicelocation.svc");
            var workforceService = AsmRepository.GetServiceProxyCachedOrDefault <IWorkforceService>(ah);
            #endregion
            //Instantiate the request object and define filter criteria
            //GetWorkOrdersRequest implements the BaseQueryRequest, so you can filter, sort,
            //and page the returned records.
            //You can use the properties of WorkOrder to filter and sort.
            GetWorkOrdersRequest request = new GetWorkOrdersRequest();
            request.FilterCriteria.Add("CustomerId", 16190);
            request.FilterCriteria.Add("WorkOrderStatusId", 1);
            #region Get the customer's work orders and display the results.
            WorkOrderCollection coll = workforceService.GetWorkOrders(request);

            if (coll != null && coll.Items.Count > 0)
            {
                foreach (WorkOrder w in coll)
                {
                    Console.WriteLine("Found Work Order ID = {0}; Create Date = {1}", w.Id, w.RegisteredDateTime);
                }
            }
            else
            {
                Console.WriteLine("Sorry--No work orders found.");
            }
            Console.ReadLine();
            #endregion
        }
Пример #10
0
        public HttpResponseMessage GetDeviceById(int id, 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 devicesService = AsmRepository.GetServiceProxyCachedOrDefault <IDevicesService>(authHeader);
            //var provinces = devicesService.GetDeviceById(id); //parameter id
            Device devices = devicesService.GetDeviceById(id);

            //List<string> list = new List<string>();
            //list.Add("deviceId"); list.Add(devices.Id.ToString());
            //list.Add("SerialNumber"); list.Add(devices.SerialNumber);
            //list.Add("Shidate"); list.Add(devices.ShipDate.ToString());
            //list.Add("StatusId"); list.Add(devices.StatusId.ToString());
            //list.Add("ModelId"); list.Add(devices.ModelId.ToString());
            //list.Add("BigCarReferenceNumber"); list.Add(devices.BigCAReferenceNumber);

            if (devices != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, devices));
            }
            else
            {
                var       message = string.Format("error");
                HttpError err     = new HttpError(message);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }

            //return devices;
        }
Пример #11
0
        public OfferDefinitionCollection GetPromoNow(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);

            IProductCatalogConfigurationService prodService = AsmRepository.AllServices.GetProductCatalogConfigurationService(authHeader);

            IOfferManagementConfigurationService offService = AsmRepository.AllServices.GetOfferManagementConfigurationService(authHeader);
            OfferDefinitionCollection            offers     = offService.GetOfferDefinitions(new BaseQueryRequest()
            {
                FilterCriteria = new CriteriaCollection()
                {
                    new Criteria()
                    {
                        Key      = "Active",
                        Operator = Operator.Equal,
                        Value    = "1"
                    }
                }
            });



            return(offers);
        }
Пример #12
0
        public HttpResponseMessage SendCommandToDevice(string serial_number, int id_action, 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 the_string = "";

            var deviceService = AsmRepository.AllServices.GetDevicesService(authHeader);
            var viewfService  = AsmRepository.AllServices.GetViewFacadeService(authHeader);

            //int pre_act_7 = 99177; // pre-activation for 7 days.
            var device = deviceService.GetDeviceBySerialNumber(serial_number);

            if (device != null)
            {
                deviceService.SendCommandToDevice(device.Id.Value, id_action);


                return(Request.CreateResponse(HttpStatusCode.OK, "SUCCESS"));
            }
            else
            {
                var       message = string.Format("An Error Has Occured on serial number", serial_number);
                HttpError err     = new HttpError(message);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, err));
                //Console.WriteLine("Can't find device with SN :" + serial_number);
            }
        }
Пример #13
0
        public HttpResponseMessage GetSoftwareProduct(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);
            //This value is the customer's ID number.
            int customerId = id;
            //In ICC, a Page can hold up to 20 records. Page = 0 returns ALL records.
            int page = 0;
            //Call the method and display the results.
            var agreements = agreementManagementService.GetSoftwareForAgreementDetailById(2912043);

            if (agreements != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, agreements));
            }
            else
            {
                var       message = string.Format("error");
                HttpError err     = new HttpError(message);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
        }
Пример #14
0
        public WorkOrder CompleteWorkOrder(WorkOrder wo_param, int reason_param, string work_desc_param, string action_taken, int completion_reason_id_param)
        {
            Authentication_class var_auth   = new Authentication_class();
            AuthenticationHeader authHeader = var_auth.getAuthentication_header();

            AsmRepository.SetServiceLocationUrl(var_auth.var_url_asm);

            WorkOrder ww        = null;
            var       woService = AsmRepository.AllServices.GetWorkforceService(authHeader);
            var       wo        = AsmRepository.AllServices.GetWorkforceService(authHeader).GetWorkOrder(wo_param.Id.Value);


            try
            {
                string temp_work_description = wo_param.ProblemDescription;
                string temp_action_taken     = wo_param.ActionTaken;

                wo.ProblemDescription = temp_work_description + "#" + work_desc_param;
                wo.ActionTaken        = temp_action_taken + "#" + action_taken;
                wo.CompletedDateTime  = DateTime.Now;
                wo.ReasonKey          = 99470;

                ww = woService.CompleteWorkOrder(wo, 99470);
                return(ww);
            }
            catch (Exception ex)
            {
                msg = "Exceptions : " + ex.Message + " Stack : " + ex.StackTrace;
                Console.WriteLine(msg);
            }
            //
            Console.WriteLine(msg);
            return(ww);
        }
Пример #15
0
        public ProvinceCollection GetAllProvinces(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 custService = AsmRepository.AllServices.GetCustomersConfigurationService(authHeader);
            ProvinceCollection provinces = custService.GetProvinceByCountry(1);

            //IEnumerable<string> enumerable = (IEnumerable<string>)provinces;

            List <string> list = new List <string>();

            //Provinces ok1 = new Provinces();

            // Loop through List with foreach.
            foreach (var prime in provinces)
            {
                var a = prime.Id.ToString();
                list.Add(a);
                var b = prime.Name.ToString();
                list.Add(b);
            }

            //var provinces_listString = provinces.OrderBy(x => x.Id).Select(x => new Provinces { Id_nya = (int) x.Id, Name_nya = (string) x.Name }).ToList();
            //var result = ((IEnumerable<string>)provinces).Cast<object>().ToList();
            return(provinces);
        }
Пример #16
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 HttpResponseMessage GetLedgerAccounts(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 financeConfigurationService = AsmRepository.GetServiceProxyCachedOrDefault <IFinanceConfigurationService>(ah);
            //Instantiate a request object and its FilterCriteria
            LedgerAccountQueryRequest request = new LedgerAccountQueryRequest();

            request.FilterCriteria = new CriteriaCollection();
            //Populate the FilterCriteria, using In operator to perform an "Or" query.
            //request.FilterCriteria.Add(new Criteria("LedgerAccountCode", "U2001", Operator.In));
            //request.FilterCriteria.Add(new Criteria("LedgerAccountCode", "RU2001", Operator.In));
            //request.FilterCriteria.Add(new Criteria("LedgerAccountCode", "P9500", Operator.In));
            //request.FilterCriteria.Add(new Criteria("LedgerAccountCode", "RP9500", Operator.In));
            request.FilterCriteria.Add(new Criteria("IconId", "", Operator.Like));
            //Call the method.
            LedgerAccountCollection collection = financeConfigurationService.GetLedgerAccounts(request);

            //Display the results.

            if (collection != null && collection.Items.Count > 0)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, collection));
            }
            else
            {
                var       message = string.Format("error");
                HttpError err     = new HttpError(message);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
        }
Пример #18
0
        public QuoteInvoiceCollection GetQuoteByCustomerId(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 billingService             = AsmRepository.GetServiceProxyCachedOrDefault <IBillingEngineService>(ah);
            var financeService             = AsmRepository.GetServiceProxyCachedOrDefault <IFinanceService>(ah);
            var agreementManagementService = AsmRepository.GetServiceProxyCachedOrDefault <IAgreementManagementService>(ah);

            #region Step 1
            //First, get Pending quotes to check their QuoteDates.
            //Instantiate a class for the request.
            BaseQueryRequest req = new BaseQueryRequest();
            req.FilterCriteria = new CriteriaCollection();
            //Define the selection criteria.
            //Replace 73948 with the CustomerId of the customer you want.
            req.FilterCriteria.Add("CustomerId", id);
            //Get the customer's QuoteInvoices.
            QuoteInvoiceCollection qts = billingService.FindQuoteInvoices(req);
            if (qts != null && qts.Items.Count > 0)
            {
                return(qts);
                //foreach (var q in qts)
                //{
                //    Console.WriteLine("Customer ID {0}: QuoteDate = {1} QuoteInvoice ID = {2}",
                //    q.CustomerId, q.QuoteDate, q.Id);
                //    Console.WriteLine("Quote amount = {0} Quote type = {1}",
                //    q.TotalAmount, q.QuoteType);
                //    //If the QuoteDate < Today, then regenerate the quote.
                //    if (q.QuoteDate < System.DateTime.Today)
                //    {
                //        QuoteInvoiceRequest request = new QuoteInvoiceRequest();
                //        request.QuoteId = q.Id;
                //        //If Save = True, ICC saves the QuoteInvoice.
                //        //To get the quote info but not commit it to the database,
                //        //set the flag to False. This is useful when
                //        //you only want to know what the customer would pay next
                //        //period, but you don't want to create the quote.
                //        request.Save = true;
                //        //Regenerate the quote to save Today's quote info.
                //        QuoteInvoiceResponse response = billingService.RegenerateQuoteInvoice(request);
                //        Console.WriteLine("New quote generated. ID = {0}; Amount = {1}",
                //        response.NewQuoteInvoice.Id, response.NewQuoteInvoice.TotalAmount);
                //    }
                //    else
                //    {
                //        Console.WriteLine("Customer's quotes are up-to-date.");
                //    }
                //}
            }
            else
            {
                return(null);
            }
            #endregion step 1
        }
        public HttpResponseMessage AddDeposit(String username_ad, String password_ad, int customer_id, int deposite_amount)
        {
            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 customersService            = AsmRepository.GetServiceProxyCachedOrDefault <ICustomersService>(authHeader);
            var financeService              = AsmRepository.GetServiceProxyCachedOrDefault <IFinanceService>(authHeader);
            var financeConfigurationService = AsmRepository.GetServiceProxyCachedOrDefault <IFinanceConfigurationService>(authHeader);

            var fa = financeService.GetFinancialAccountsForCustomer(customer_id, new CriteriaCollection()
            {
                new Criteria()
                {
                    Key      = "TypeId",
                    Operator = Operator.Equal,
                    Value    = "1" // 1 means quote billing financial account
                }
            }, 0);

            if (fa.TotalCount == 0)
            {
                //Console.WriteLine("There are no finanical account on customer with id : " + customer_id);
                return(null);
            }
            CreateManualAdjustmentFTsResult the_result = financeService.CreateManualAdjustmentFTs(new CreateManualAdjustmentFTsRequest()
            {
                FinancialTransactions = new FinancialTransactionCollection()
                {
                    new FinancialTransaction()
                    {
                        BaseAmount         = deposite_amount,
                        Comment            = "This is deposit for Testing!",
                        CurrencyId         = 1,
                        CreatedByEvent     = 500,
                        LedgerAccountId    = 416,
                        FinancialAccountId = fa.Items[0].Id.Value,
                        PeriodFrom         = DateTime.Now,
                        PeriodTo           = DateTime.Now.AddDays(90)
                    }
                }
            });

            if (the_result != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, the_result));
            }
            else
            {
                var       message = string.Format("error");
                HttpError err     = new HttpError(message);
                return(Request.CreateResponse(HttpStatusCode.OK, message));
            }
        }
        public int GetAgreementByTypeId(String username_ad, String password_ad, int productId, int amount, String dt)
        {
            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 priceServce            = AsmRepository.AllServices.GetPricingService(ah);
            var agService              = AsmRepository.GetServiceProxyCachedOrDefault <IAgreementManagementService>(ah);
            int listprice_condition_id = 0;
            var listprice_conditions   = agService.GetAgreementDetailWithPricing(productId);

            DateTime myDate = DateTime.ParseExact(dt, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);


            if (listprice_conditions.PricingInfoCollection.Items.Count > 0)
            {
                listprice_condition_id = listprice_conditions.PricingInfoCollection.Items[0].ListPriceConditionId.Value;
                return(listprice_condition_id);
            }
            else
            {
                //Console.WriteLine("There are no pirce found on this product, please check your configuraitons! agreement detail id : " + agreement_detail_id);
                return(0);
            }

            var priceOverride = priceServce.GetPriceOverridesByListPriceConditionId(listprice_condition_id, (int)Entities.AgreementDetail, productId, 0);

            if (priceOverride.Items.Count == 0)
            {
                priceServce.CreatePriceOverride(new PriceOverride()
                {
                    Amount               = amount,
                    CurrencyId           = 1,
                    ListPriceConditionId = listprice_condition_id,
                    EntityId             = productId,
                    EntityType           = (int)Entities.AgreementDetail,
                    OverrideType         = PayMedia.ApplicationServices.Pricing.ServiceContracts.OverrideTypes.FixedPrice,
                    Recurring            = true,
                    //OverrideInvoiceText = "New Price from 2017-5-16"
                }, 0);
            }
            else
            {
                priceOverride.Items[0].Amount = amount;

                if (myDate < DateTime.Now)
                {
                    priceServce.UpdatePriceOverride(priceOverride.Items[0], 0);
                }
                else
                {
                    priceServce.ScheduleUpdatePriceOverride(priceOverride.Items[0], myDate, 0);
                }
            }
        }
Пример #21
0
        public int find_geodefinition(string param_postal_code)
        {
            int var_geodefid = 0;
            Authentication_class var_auth = new Authentication_class();
            AuthenticationHeader ah       = var_auth.getAuthentication_header();

            AsmRepository.SetServiceLocationUrl("http://192.168.177.4/asm/all/servicelocation.svc");

            var customersConfigurationService = AsmRepository.GetServiceProxyCachedOrDefault <ICustomersConfigurationService>(ah);
            var customersService = AsmRepository.GetServiceProxyCachedOrDefault <ICustomersService>(ah);

            //Instantiate a request object
            GeoDefinitionCriteria criteria = new GeoDefinitionCriteria();

            //If you know the customer's address ID, you can replace "481" with the addressId
            //and use the returned address to populate the address criteria.
            //Address address = customersService.GetAddress(param_serv_addr_id);
            //If your GeoDefinitions are configured on address details, and if you do not
            //know the customer's addressId, set FindByFullAddressDetails to True and
            //enter the address details.
            //criteria.FindByFullAddressDetails = true;
            //criteria.CountryId = 1;
            //criteria.Province = 1;
            //criteria.BigCity = "LOS ANGELES";
            //criteria.SmallCity = null;
            //criteria.PostalCode = "95BH1";
            //criteria.Street = "VINE ST";
            //If your GeoDefinitions are configured on postal code, and if you do not
            //know the customer's addressId, set FindByPostalCode to True and
            //enter the postal code.
            criteria.FindByPostalCode = true;
            criteria.PostalCode       = param_postal_code;
            //Get the GeoDefinition for the address. There should be only one.
            //If there are more than one, then there is an error in the GeoDefinition
            //configuration.
            GeoDefinitionCollection collection = customersConfigurationService.FindGeoDefinitions(criteria);

            //Display the results.
            if (collection != null && collection.Items.Count > 0)
            {
                foreach (var item in collection)
                {
                    var_geodefid = item.Id.Value;
                    //Console.WriteLine("GeoDefId {0} <==> geolocation {1}", item.Id, item.GeoLocations);
                }
                return(var_geodefid);
            }
            else
            {
                return(0);
                //Console.WriteLine("I found nothing.");
            }
            //Console.ReadLine();
        }
Пример #22
0
        public void getServiceProvider(WorkOrder wo)
        {
            #region Authenticate and create proxies
            Authentication_class var_auth = new Authentication_class();
            AuthenticationHeader ah       = var_auth.getAuthentication_header();
            AsmRepository.SetServiceLocationUrl("http://mncsvasm.mskydev1.local/asm/all/servicelocation.svc");
            var custService  = AsmRepository.AllServices.GetCustomersService(ah);
            var custcService = AsmRepository.AllServices.GetCustomersConfigurationService(ah);
            var woService    = AsmRepository.AllServices.GetWorkforceService(ah);


            #endregion

            try
            {
                var va = custService.GetAddress(wo.AddressId.Value);

                var geo = custcService.FindGeoDefinitions(new GeoDefinitionCriteria()
                {
                    PostalCode = va.PostalCode
                });

                int   spid          = wo.ServiceProviderId.Value;
                int   serviceTypeId = wo.ServiceTypeId.Value;
                int[] geos          = new int[1];
                geos[0] = geo.Items[0].Id.Value;

                Console.WriteLine("ServiceProvider Id : " + spid + " Service Type Id :  " + serviceTypeId + " GeoDef ID :  " + geos[0]);

                // Get Service Provider Service Info
                var sps = woService.GetServiceProviderServicesByServiceProviderIdServiceTypeIdAndGeoDefIds(
                    spid, serviceTypeId, geos, 0
                    );

                foreach (var sps1 in sps.Items)
                {
                    Console.WriteLine("Servoce Provider Service : " + sps1.Description + " Service Provider Id :  " + sps1.ServiceProviderId + " Service Type Id " + sps1.ServiceTypeId + " Geo Group ID :  " + sps1.GeoDefinitionGroupId);

                    var timeslot = woService.GetTimeSlotsByServiceProviderServiceId(sps1.Id.Value, DateTime.Now);

                    // print the timeslot for this service
                    for (int i = 0; i < timeslot.Length; i++)
                    {
                        Console.WriteLine("Date : " + timeslot[i].Date + "  Time Slot ID : " + timeslot[i].TimeSlotId + " Service Provider Service Id : " + timeslot[i].ServiceProviderServiceId + "Remain Slot : " + timeslot[i].RemainingCapacity + " Is Avaiable : " + timeslot[i].IsAvailable);
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = "Exceptions : " + ex.Message + " Stack : " + ex.StackTrace;
                Console.WriteLine(msg);
            }
        }
Пример #23
0
        public ProvinceCollection GetProvinceByCountryId(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 custService = AsmRepository.AllServices.GetCustomersConfigurationService(authHeader);
            ProvinceCollection provinces = custService.GetProvinceByCountry(id); //parameter id

            return(provinces);
        }
Пример #24
0
        public void getWorkOrderUpdateWorkOrder()
        {
            #region Authenticate and create proxies
            Authentication_class var_auth = new Authentication_class();
            AuthenticationHeader ah       = var_auth.getAuthentication_header();
            AsmRepository.SetServiceLocationUrl("http://mncsvasm.mskydev1.local/asm/all/servicelocation.svc");
            var workforceService = AsmRepository.GetServiceProxyCachedOrDefault <IWorkforceService>(ah);
            #endregion
            //Instantiate the request object and define filter criteria
            //GetWorkOrdersRequest implements the BaseQueryRequest, so you can filter, sort,
            //and page the returned records.
            //You can use the properties of WorkOrder to filter and sort.
            GetWorkOrdersRequest request = new GetWorkOrdersRequest();
            request.FilterCriteria.Add("CustomerId", 16190);
            request.FilterCriteria.Add("WorkOrderStatusId", 1);
            #region Get the customer's work orders and display the results.
            WorkOrderCollection coll = workforceService.GetWorkOrders(request);

            if (coll != null && coll.Items.Count > 0)
            {
                foreach (WorkOrder w in coll)
                {
                    Console.WriteLine("Found Work Order ID = {0}; Create Date = {1}", w.Id, w.RegisteredDateTime);
                }
            }
            else
            {
                Console.WriteLine("Sorry--No work orders found.");
            }
            Console.ReadLine();
            #endregion
            //Now, instantiate a new WorkOrder and call GetWorkOrder to populate it with the
            // values of the work order you want to change.

            //"1333" is the ID of the work order you want to change.
            WorkOrder workOrder = workforceService.GetWorkOrder(1333);
            //Pass in the values you want to change.
            //workOrder.ServiceProviderId = 32086;
            //workOrder.AddressId = 1215;
            workOrder.ProblemDescription = "bbbbbbbbbbbbbbbbbbbbbbb";


            //"0" is the default reason. ICC throws an error if a default reason is not configured.
            //int reasonKey = 0;
            int reasonKey = 12; // for update problem description field
            //Call UpdateWorkOrder to update the work order and display the results.
            WorkOrder updatedWorkOrder = workforceService.UpdateWorkOrder(workOrder, reasonKey);
            Console.WriteLine("Updated WorkOrder ID {0}; Service Provider ID = {1}", updatedWorkOrder.Id, updatedWorkOrder.ServiceProviderId);
            Console.ReadLine();
        }
Пример #25
0
        public Device retrieveDevice(String username_ad, String password_ad, string serial_number)
        {
            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 devicesService = AsmRepository.GetServiceProxyCachedOrDefault <IDevicesService>(ah);

            string device_serial_number          = serial_number; //device serial number
            int    reason156_RetriveDevice       = 99146;
            int    reason183_Returned            = 99149;
            int    reason156_InStock             = 99152;
            int    reason156_ReturnToManufactory = 99151;
            int    reason156_RepairedStock       = 99153;
            int    reason156_RefurbishedStock    = 99154;
            int    reason156_Damaged             = 99155;

            int to_stockhandler_id = 1015;   // the destination stocck handler of the device

            //var deviceh = new deviceHandler(authHeader);

            // First step - change to to be return
            updateDeviceStatus(username_ad, password_ad, device_serial_number, reason156_RetriveDevice);

            // Second step - change stock handler
            transferDevice(username_ad, password_ad, reason183_Returned, to_stockhandler_id, device_serial_number);


            // Third Step - option 1 : change to in stock
            updateDeviceStatus(username_ad, password_ad, device_serial_number, reason156_InStock);

            // Third Step - option 2 : change to repaired stock
            //var the_device = updateDeviceStatus(username_ad, password_ad, device_serial_number, reason156_RepairedStock);

            // Third Step - option 3 : change to refurbished stock
            //var the_device = updateDeviceStatus(username_ad, password_ad, device_serial_number, reason156_RefurbishedStock);

            // Third Step - option 4 : change to return to manufactory
            //var the_device = updateDeviceStatus(username_ad, password_ad, device_serial_number, reason156_ReturnToManufactory);

            // Third Step - option 5 : change to damaged
            //var the_device = updateDeviceStatus(username_ad, password_ad, device_serial_number, reason156_Damaged);


            //-----------       ---------------
            Device devices = devicesService.GetDeviceBySerialNumber(serial_number);

            return(devices);
        }
        //  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);
            }
        }
Пример #27
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));
        }
        public List <ServiceProviderCollection> GetServiceProviders(String username_ad, String password_ad)
        {
            //HttpContext.Current.Server.ScriptTimeout = 300;
            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 sp_Service = AsmRepository.GetServiceProxyCachedOrDefault <IWorkforceService>(authHeader);
            int i          = 0;
            int ada        = 0;
            int total_data = 0;
            List <ServiceProviderCollection> initialList = new List <ServiceProviderCollection>();

            #region get service provider

            do
            {
                var serv_providers = sp_Service.GetServiceProviders(i);
                if (serv_providers.Items.Capacity > 0)
                {
                    ada = 1;
                    initialList.Add(serv_providers);

                    total_data = total_data + serv_providers.Count();
                    i++;
                    //Console.WriteLine("total sp = {0} ----", serv_providers.Count());
                }
                else if (serv_providers.Items.Capacity == 0)
                {
                    ada = 0;
                    //Console.WriteLine("end of program");
                    break;
                }
                else
                {
                    return(null);
                    //Console.WriteLine("Cannot find a sp.");
                }
            } while (ada != 0);

            return(initialList);

            //Console.WriteLine("total data = {0} ----", total_data);
            #endregion
        }
        public List <ServProvTimeSlot_response> GetServiceProvAndTimeSlot(String username_ad, String password_ad, int address_id, int service_type_id)
        {
            #region Authenticate and create proxies
            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 custService  = AsmRepository.AllServices.GetCustomersService(ah);
            var custcService = AsmRepository.AllServices.GetCustomersConfigurationService(ah);
            var woService    = AsmRepository.AllServices.GetWorkforceService(ah);


            #endregion

            var sp = woService.FindSPServiceWithGeoInfo(new FindSPServiceCriteria()
            {
                AddressId     = address_id,
                ServiceTypeId = service_type_id,
                Active        = true,
                PageSize      = 100
            },
                                                        1);

            //return sp.Items;

            List <ServProvTimeSlot_response> var_sp_and_timeslot = new List <ServProvTimeSlot_response>();

            foreach (var serviceprovider in sp.Items)
            {
                Console.WriteLine("Service Provider Id : " + serviceprovider.ServiceProviderId + "  Name : " + serviceprovider.ServiceProviderName + "  Service Type Id : " + serviceprovider.ServiceTypeId + " Service ID : " + serviceprovider.ServiceId + " Geo Group Id :" + serviceprovider.GeoDefinitionGroupId);

                ServiceProviderService sps      = woService.GetServiceProviderServiceByServiceTypeGeoDefGroupIdandProviderId(serviceprovider.ServiceTypeId.Value, serviceprovider.GeoDefinitionGroupId.Value, serviceprovider.ServiceProviderId.Value);
                TimeSlotDescription[]  timeslot = woService.GetTimeSlotsByServiceProviderServiceId(sps.Id.Value, DateTime.Now);
                // print the timeslot for this service
                for (int i = 0; i < timeslot.Length; i++)
                {
                    Console.WriteLine("Date :" + timeslot[i].Date + "  Time Slot ID : " + timeslot[i].TimeSlotId + " Service Provider Service Id : " + timeslot[i].ServiceProviderServiceId + "Remain Slot : " + timeslot[i].RemainingCapacity + " Is Avaiable : " + timeslot[i].IsAvailable);
                }

                var_sp_and_timeslot.Add(new ServProvTimeSlot_response
                {
                    the_timeslot         = timeslot,
                    the_service_provider = sps
                });
            }
            return(var_sp_and_timeslot);
        }
        public TimeSlotAvailability GetTimeSlotInfoWithServProvIdParams([FromBody] TimeSlotParams time_slot_param)
        {
            Authentication_class var_auth = new Authentication_class();
            AuthenticationHeader ah       = var_auth.getAuthHeader(time_slot_param.username_ad, time_slot_param.password_ad);

            AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url);

            IWorkforceService woService       = AsmRepository.AllServices.GetWorkforceService(ah);
            ICustomersService customerService = AsmRepository.GetServiceProxyCachedOrDefault <ICustomersService>(ah);

            DateTime dt = DateTime.ParseExact(time_slot_param.Date, "yyyy-MM-dd", CultureInfo.InvariantCulture);

            Customer cust = new Customer();

            cust = customerService.GetCustomer(time_slot_param.customer_id);

            var sp = woService.FindSPServiceWithGeoInfo(new FindSPServiceCriteria()
            {
                AddressId         = time_slot_param.serv_addr_id,
                ServiceTypeId     = time_slot_param.serv_type_id,
                ServiceProviderId = time_slot_param.serv_prov_id,
                Active            = true,
                PageSize          = 100
            },
                                                        1);

            TimeSlotAvailability var_timeslotAvailability = new TimeSlotAvailability();
            var var_timeslotAvailabilityItem = new List <TimeSlotAvailabilityItem>();

            foreach (SPServiceWithGeoInfo serviceprovider in sp.Items)
            {
                var sps = woService.GetServiceProviderServiceByServiceTypeGeoDefGroupIdandProviderId(serviceprovider.ServiceTypeId.Value, serviceprovider.GeoDefinitionGroupId.Value, serviceprovider.ServiceProviderId.Value);
                TimeSlotDescription[] timeslot = woService.GetTimeSlotsByServiceProviderServiceId(sps.Id.Value, dt);
                // print the timeslot for this service

                var_timeslotAvailabilityItem.Add(new TimeSlotAvailabilityItem()
                {
                    the_SPServiceWithGeoInfo = serviceprovider,
                    the_timeslot             = timeslot
                });
            }
            var_timeslotAvailability.TimeItemsData = var_timeslotAvailabilityItem;

            return(var_timeslotAvailability);
        }