Пример #1
0
        /// <summary>
        /// Cancel this ticket item
        /// </summary>
        public void Cancel(CancelType cancelType, int employeeId, bool isWasted)
        {
            CancelType = cancelType;
            IsWasted   = isWasted;
            if (isWasted && (PreparedTime == null))
            {
                SetPreparedTime(DateTime.Now);
            }
            else if (!isWasted)
            {
                SetPreparedTime(null);
            }
            else
            {
                IsChanged = true;
            }
            CancelingEmployeeId = employeeId;
            WhenCanceled        = DateTime.Now;

            if (!isWasted)
            {
                AdjustInventory(this, true);
            }

            Update();
        }
Пример #2
0
        private void CancelDelivery(CancelType type)
        {
            if ((int)type == 0)
            {
                if (spawnedVehicle.Exists())
                {
                    spawnedVehicle.IsPersistent = false;
                }
                if (driver.Exists())
                {
                    driver.IsPersistent         = false;
                    driver.BlockPermanentEvents = false;
                }
                if (vehicleBlip.Exists())
                {
                    vehicleBlip.Delete();
                }
                if (vehicleDeliveryBlip.Exists())
                {
                    vehicleDeliveryBlip.Delete();
                }

                StopVehicleDeliveryMenu.Visible = false;
                VehicleMenuThreadEnabled        = false;
                IsCarDeliveryInProcess          = false;
            }
            if ((int)type == 1)
            {
                character.Tasks.ClearImmediately();

                if (officer.Exists())
                {
                    officer.IsPersistent         = false;
                    officer.BlockPermanentEvents = false;
                    officer.Delete();
                }
                if (policeVehicle.Exists())
                {
                    policeVehicle.IsPersistent = false;
                    policeVehicle.Delete();
                }
                if (officerBlip.Exists())
                {
                    officerBlip.Delete();
                }

                character.IsPositionFrozen = false;
                WeaponMenuThreadEnabled    = false;
                IsWeaponDeliveryInProcess  = false;
            }
        }
Пример #3
0
        // CancelOrder
        public async Task <CancelOrder> CancelOrder(CancelType cancelType, string orderID, string currency, TradingPair tradingPair)
        {
            string market = String.Format("{0}_{1}", currency, tradingPair.ToString());

            using (var client = new HttpClient())
            {
                // create the URL string.
                string endpoint = "api/private/cancelorder";

                // JSON POST parameters
                JObject jObject = new JObject();
                jObject["Type"]    = cancelType.ToString();
                jObject["OrderId"] = orderID;
                jObject["Market"]  = market;
                string postParams = jObject.ToString(Formatting.None, null);

                // Http Client params
                SetHttpClientPropertiesPrivate(client, endpoint, postParams);

                // make the request
                var content  = new StringContent(postParams, Encoding.UTF8, "application/json");
                var response = await client.PostAsync(endpoint, content);

                // parse the response and return the data.
                var jsonResponseString = await response.Content.ReadAsStringAsync();

                CancelOrderEntity cancelOrderEntity = new CancelOrderEntity();

                try
                {
                    cancelOrderEntity = JsonConvert.DeserializeObject <CancelOrderEntity>(jsonResponseString);
                }
                catch (Exception e)
                {
                    throw new Exception(_ParseError, e);
                }

                // Check success message from server
                if (cancelOrderEntity.Success == false)
                {
                    throw new Exception(_SuccessError);
                }

                return(cancelOrderEntity.Result);
            }
        }
Пример #4
0
        /// <summary>
        /// Cancels a submitted order
        /// </summary>
        /// <param name="cancelType">The cancel type, options: 'Single','Market','MarketBuys','MarketSells','AllBuys','AllSells','All'(required)</param>
        /// <param name="orderId">The order to cancel(required if cancel type 'Single')</param>
        /// <param name="market">The order to cancel(required if cancel type 'Market','MarketBuys','MarketSells')</param>
        /// <returns></returns>
        public async Task <CancelOrderInfo> CancelOrderAsync(CancelType cancelType, int?orderId, string market = null)
        {
            Requires.NotNull(Settings, nameof(Settings));
            var endpoint = ApiEndpoints.SubmitOrder_Endpoint();
            var strategy = new TradeSatoshiRequestCreationStrategy();
            var jsonObj  = new JObject();

            jsonObj.Add("Type", Enum.GetName(typeof(CancelType), cancelType));
            if (orderId.HasValue)
            {
                jsonObj.Add("OrderId", orderId);
            }
            if (!string.IsNullOrWhiteSpace(market))
            {
                jsonObj.Add("Market", market);
            }
            var result = await _client.PostAsync <TradeSatoshiResponse <CancelOrderInfo> >(endpoint.Uri, strategy, JsonConvert.SerializeObject(jsonObj));

            ValidateResponse(result);
            return(result.Data);
        }
Пример #5
0
        // CancelOrder
        public async Task <CancelOrder> CancelOrder(CancelType cancelType, string orderID, string currency, TradingPair tradingPair)
        {
            CancelOrder cancelOrder = await tradeSatoshiApiWrapper.CancelOrder(cancelType, orderID, currency, tradingPair);

            return(cancelOrder);
        }
Пример #6
0
        /// <summary>
        /// Generate Sample Authoritative Instruction Cancellation Message
        /// </summary>
        /// <param name="filename"></param>
        private void GenerateCancelMessage(string filename)
        {
            var ns = new XmlSerializerNamespaces();

            ns.Add("ns", "http://gpcopsschema.azurewebsites.net/schema/2015/1.0/ConsignmentService");

            // Creates an instance of the XmlSerializer class;
            // specifies the type of object to serialize.
            var        serializer = new XmlSerializer(typeof(AuthoritativeInstruction));
            TextWriter writer     = new StreamWriter(filename);

            //Customer Authority Type
            var ca = new CustomerAuthorityType
            {
                DispatchingMine     = "Curragh",
                DispatchingCustomer = "Curragh",
                UnloadLocation      = "GLD"
            };

            var aid = new AuthorisationIdType {
                Consignment = "AA24288", RailServiceID = "B53M"
            };
            var dt = new DateTime(2015, 05, 16);

            aid.RailServiceDateTime = dt;

            var aih = new AuthoritativeInstructionHeader {
                CustomerAuthority = ca, Identifier = aid
            };
            var msgDt = DateTime.Now;

            aih.MessageTimeStamp = msgDt;

            var firstwagon = new WagonType {
                Sequence = 2, Number = 56012, Type = WagonTypeType.Wagon, Class = "VCBS"
            };

            var lastwagon = new WagonType {
                Sequence = 104, Number = 49717, Type = WagonTypeType.Wagon, Class = "VSAL"
            };

            var ct = new CancelType {
                Count = 102, Stockpile = 661, FirstWagon = firstwagon, LastWagon = lastwagon
            };

            var cc = new CommentType
            {
                ConsignmentComment = "Mendatory Cancellation Comment..."
            };

            var aiCancel = new AuthoritativeInstructionActionCancel()
            {
                Instruction         = ct,
                CancellationComment = cc
            };

            var aiAction = new AuthoritativeInstructionAction {
                Item = aiCancel
            };

            var ai = new AuthoritativeInstruction {
                Action = aiAction, Header = aih
            };

            /***** To see generated XML Uncomment the code below: ******/

            var sw        = new StringWriter();
            var xmlWriter = XmlWriter.Create(sw, new XmlWriterSettings()
            {
                OmitXmlDeclaration = true, Indent = true
            });

            serializer.Serialize(xmlWriter, ai, ns);
            string xmlString = sw.ToString();

            Console.WriteLine("Authoritative Instruction XML For Cancellation Message : " + xmlString + " \n\n\n");
        }