示例#1
0
        /// <summary>
        /// Calls the FulfillSalesOrderRequest and closes it as completed
        /// </summary>
        private static void CloseSalesOrder(CrmServiceClient service)
        {
            if (!_salesOrderId.HasValue)
            {
                return;
            }

            // Close the sales order with a status of Complete
            int newStatus = (int)salesorder_statuscode.Complete;
            var request   = new FulfillSalesOrderRequest
            {
                OrderClose = new OrderClose
                {
                    SalesOrderId = new EntityReference
                    {
                        LogicalName = SalesOrder.EntityLogicalName, Id = _salesOrderId.Value
                    }
                },
                Status = new OptionSetValue(newStatus)
            };

            Console.WriteLine(String.Concat("Executing FullfillSalesOrderRequest on sales order: ",
                                            _salesOrderId.Value, ",\n\t new status: ",
                                            GetLabelForStatus(SalesOrder.EntityLogicalName, "statuscode", newStatus, service)));

            service.Execute(request);

            // Validate that the sales order is complete
            var salesOrder = service.Retrieve(SalesOrder.EntityLogicalName, _salesOrderId.Value,
                                              new ColumnSet("statuscode")).ToEntity <SalesOrder>();

            Console.WriteLine(String.Concat("Validation of closed sales order: ", _salesOrderId.Value,
                                            ",\n\t status: ", salesOrder.FormattedValues["statuscode"]));
        }
示例#2
0
        /// <summary>
        /// <c>Fullfill</c> the <c>SalesOrder</c>.
        /// <para>
        /// For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.fulfillsalesorderrequest(v=crm.8).aspx
        /// </para>
        /// </summary>
        /// <param name="id"><c>SalesOrder</c> Id</param>
        /// <param name="status"><see cref="SalesOrderFulfilledStatusCode"/> status code</param>
        /// <param name="customStatusCode">If you're using your custom statuscodes set this, otherwise you can set "0 (zero)" or null</param>
        /// <param name="ordercloseSubject"><c>OrderClose</c> subject</param>
        /// <param name="ordercloseDescription"><c>OrderClose</c> description</param>
        /// <param name="ordercloseActualEnd"><c>OrderClose</c> actual end date</param>
        /// <returns>
        /// <see cref="FulfillSalesOrderResponse"/>
        /// </returns>
        public FulfillSalesOrderResponse Fulfill(Guid id, SalesOrderFulfilledStatusCode status, int customStatusCode = 0, string ordercloseSubject = "", string ordercloseDescription = "", DateTime?ordercloseActualEnd = null)
        {
            ExceptionThrow.IfGuidEmpty(id, "id");

            int statusCode = (int)status;

            if (status == SalesOrderFulfilledStatusCode.CustomStatusCode)
            {
                ExceptionThrow.IfNegative(customStatusCode, "customStatusCode");
                statusCode = customStatusCode;
            }

            if (string.IsNullOrEmpty(ordercloseSubject))
            {
                var salesorderEntity = this.Get(id, "ordernumber");
                ordercloseSubject = string.Format("Salesorder Close (Fulfill) - {0}", salesorderEntity.GetAttributeValue <string>("ordernumber"));
            }

            FulfillSalesOrderRequest request = new FulfillSalesOrderRequest
            {
                OrderClose = PrepareOrderCloseEntity(id, ordercloseSubject, ordercloseDescription, ordercloseActualEnd),
                Status     = new OptionSetValue(statusCode)
            };

            return((FulfillSalesOrderResponse)this.OrganizationService.Execute(request));
        }
        //private void CloseSalesOrder(OrganizationServiceProxy service,Guid salesorderId)
        //{
        //    SetStateRequest setStateReq = new SetStateRequest();
        //    setStateReq.EntityMoniker = new EntityReference("salesorder", salesorderId);
        //    setStateReq.State = new OptionSetValue(1);
        //    setStateReq.Status = new OptionSetValue(100001);

        //    SetStateResponse response = (SetStateResponse)service.Execute(setStateReq);
        //}

        private void FulfillSalesOrder(OrganizationServiceProxy service, Guid salesorderId)
        {
            FulfillSalesOrderRequest req = new FulfillSalesOrderRequest();
            OrderClose orderClose        = new OrderClose();

            orderClose.SalesOrderId = new EntityReference("salesorder", salesorderId);
            orderClose.Subject      = "Sales Order Closed";
            req.OrderClose          = orderClose;
            OptionSetValue o = new OptionSetValue();

            o.Value    = 100001;
            req.Status = o;
            FulfillSalesOrderResponse resp = (FulfillSalesOrderResponse)service.Execute(req);
        }
        protected override void ExecuteWorkflowLogic()
        {
            var fulfillSalesOrderRequest = new FulfillSalesOrderRequest()
            {
                Status     = SalesOrderStatus.Get(Context.ExecutionContext),
                OrderClose = new Entity("orderclose")
                {
                    ["subject"]      = Subject.Get(Context.ExecutionContext),
                    ["salesorderid"] = SalesOrder.Get(Context.ExecutionContext),
                    ["actualend"]    = CloseDate.Get(Context.ExecutionContext),
                    ["description"]  = Description.Get(Context.ExecutionContext)
                }
            };

            Context.UserService.Execute(fulfillSalesOrderRequest);
        }
示例#5
0
        public Boolean FecharPedido(Guid pedidoId)
        {
            FulfillSalesOrderResponse resp = null;
            Entity fechapedido             = new Entity("orderclose");

            fechapedido["salesorderid"] = new EntityReference(SDKore.Crm.Util.Utility.GetEntityName <Intelbras.CRM2013.Domain.Model.Pedido>(), pedidoId);

            FulfillSalesOrderRequest fulfillSales = new FulfillSalesOrderRequest();

            fulfillSales.OrderClose = fechapedido;
            fulfillSales.Status     = new OptionSetValue(100001);
            resp = (FulfillSalesOrderResponse)this.Execute(fulfillSales);

            if (resp != null)
            {
                return(true);
            }

            return(false);
        }
示例#6
0
        public void FulfillSalesOrder(Guid orderId, int status)
        {
            var orderClose = new Entity("orderclose");
            orderClose["salesorderid"] = new EntityReference {LogicalName = "salesorder", Id = orderId};

            var request = new FulfillSalesOrderRequest
            {
                OrderClose = orderClose,
                Status = new OptionSetValue(status)
            };
            Execute(request);
        }
示例#7
0
        /// <summary>
        /// Calls the FulfillSalesOrderRequest and closes it as completed
        /// </summary>
        private void CloseSalesOrder()
        {
            if (!_salesOrderId.HasValue)
                return;
            //<snippetFulfill1>
          
            // Close the sales order with a status of Complete
            int newStatus = (int)salesorder_statuscode.Complete;
            var request = new FulfillSalesOrderRequest
            {
                OrderClose = new OrderClose
                {
                    SalesOrderId = new EntityReference 
                        { LogicalName = SalesOrder.EntityLogicalName, Id = _salesOrderId.Value }
                    
                },
                Status = new OptionSetValue(newStatus)
            };

            Console.WriteLine(String.Concat("Executing FullfillSalesOrderRequest on sales order: ",
                _salesOrderId.Value, ",\n\t new status: ", 
                GetLabelForStatus(SalesOrder.EntityLogicalName, "statuscode", newStatus))); 
            
            _serviceProxy.Execute(request);
            //</snippetFulfill1>

            // Validate that the sales order is complete
            var salesOrder = _serviceProxy.Retrieve(SalesOrder.EntityLogicalName, _salesOrderId.Value,
                new ColumnSet("statuscode")).ToEntity<SalesOrder>();

            Console.WriteLine(String.Concat("Validation of closed sales order: ", _salesOrderId.Value,
                ",\n\t status: ", salesOrder.FormattedValues["statuscode"]));
        }