Пример #1
0
        /// <summary>
        /// Generate Sample Authoritative Instruction Info Message
        /// </summary>
        /// <param name="filename"></param>
        private void GenerateInfoMessage(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 aiInfo = new AuthoritativeInstructionActionInfo()
            {
                Message = "This is a New Info Message For Concote: AA24288"
            };

            var aiAction = new AuthoritativeInstructionAction {
                Item = aiInfo
            };

            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 Info Message : " + xmlString + " \n\n\n");
        }
Пример #2
0
        /// <summary>
        /// Generate Sample Authoritative Instruction Create Message
        /// </summary>
        /// <param name="filename"></param>
        private void GenerateCreateMessage(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; //DateTime.ParseExact(dt.ToString("yyyy-MM-dd"),"yyyy-MM-dd",null);

            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 CreateType {
                Count = 102, Stockpile = 661, FirstWagon = firstwagon, LastWagon = lastwagon
            };

            var cm = new CoalMetadataType
            {
                CoalType          = "Curragh Mid Ash",
                CoalProperty      = CoalMetadataTypeCoalProperty.Normal,
                Ash               = 0.25f,
                AshSpecified      = true,
                Moisture          = 0.25f,
                MoistureSpecified = true
            };

            var dtNow = DateTime.Now;
            var ld    = new LoadOutDetailsType
            {
                LoadLocation         = "ALocation",
                LoadOutOperator      = "CurraghUser",
                TonnesLoaded         = 8328,
                UnloadInstruction    = "A Sample Instruction",
                LoadCompleteDateTime = dtNow.AddHours(-1)
            };

            var cc = new CommentType
            {
                ConsignmentComment = "Optional Create Comment"
            };

            var aiCreate = new AuthoritativeInstructionActionCreate
            {
                Instruction    = ct,
                CoalMetadata   = cm,
                LoadOutDetails = ld,
                CreateComment  = cc
            };

            var aiAction = new AuthoritativeInstructionAction {
                Item = aiCreate
            };

            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("Create Authoritative Instruction XML For Create Message : " + xmlString + " \n\n\n");
        }
Пример #3
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");
        }
Пример #4
0
        /// <summary>
        /// Generate Sample Authoritative Instruction Update Message
        /// </summary>
        /// <param name="filename"></param>
        private void GenerateUpdateMessage(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 newfirstwagon = new WagonType {
                Sequence = 2, Number = 56012, Type = WagonTypeType.Wagon, Class = "VCBS"
            };

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

            var ut = new UpdateType {
                NewCount = 102, NewStockpile = 661, NewFirstWagon = newfirstwagon, NewLastWagon = newlastwagon
            };

            var cm = new CoalMetadataType
            {
                CoalType     = "Curragh PCI Coal",
                CoalProperty = CoalMetadataTypeCoalProperty.Normal,
                Ash          = 0.05f,
                Moisture     = 0.05f
            };

            var uc = new CommentType
            {
                ConsignmentComment = "Mendatory Update Comment..."
            };

            var aiUpdate = new AuthoritativeInstructionActionUpdate()
            {
                Instruction   = ut,
                CoalMetadata  = cm,
                UpdateComment = uc
            };

            var aiAction = new AuthoritativeInstructionAction {
                Item = aiUpdate
            };

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

            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 Update Message : " + xmlString + " \n\n\n");
        }