/// <summary>
        /// 核心函数,传输流事件的入口函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnStart(object sender, ProtocolEventArgs <Start> e)
        {
            ///<summary>
            ///该语句是PDS原代码中没有的,所以导致了PDS中的数据生成速度是1s。
            ///补充该句才能以文件中的interval来生成数据。
            /// </summary>
            e.Message.MaxMessageRate = Model.Interval;
            //构造TaskRunner
            TaskRunner = new PDS.WITSMLstudio.Framework.TaskRunner(e.Message.MaxMessageRate)
            {
                OnError   = LogStreamingError,
                OnExecute = StreamChannelData
            };
            if (Client.Handler <IChannelStreamingProducer>().IsSimpleStreamer)
            {
                //channelMetadata就是json文件各个道的描述信息
                List <ChannelMetadataRecord> channelMetadata = GetChannelMetadata(e.Header);

                //将channelMetadata设置到流的处理器中
                Client.Handler <IChannelStreamingProducer>().
                ChannelMetadata(e.Header, channelMetadata);
                //channelmetadata存到channelstreaminginfo里面,channelstreaminginfo内容更少
                foreach (var channel in channelMetadata.Select(ToChannelStreamingInfo))
                {
                    ChannelStreamingInfo.Add(channel);
                }
                //start一开,StreamChannelData就来,
                TaskRunner.Start();
            }
        }
        /// <summary>
        /// Called when the <see cref="OpenSession" /> message is recieved.
        /// </summary>
        /// <param name="e">The <see cref="ProtocolEventArgs{OpenSession}" /> instance containing the event data.</param>
        public void OnSessionOpened(ProtocolEventArgs<OpenSession> e)
        {
            if (e.Message.SupportedProtocols.All(x => x.Protocol != (int) Protocols.Store))
                return;

            CanExecute = true;
        }
Beispiel #3
0
        /// <summary>
        /// Gets the object details for the specified URI.
        /// </summary>
        /// <param name="etpAdapter">The ETP adapter.</param>
        /// <param name="args">The <see cref="ProtocolEventArgs{GetObject, DataObject}" /> instance containing the event data.</param>
        public void FindObjects(IEtpAdapter etpAdapter, ProtocolEventArgs <Etp12.Protocol.StoreQuery.FindObjects, Etp12.Protocol.StoreQuery.DataObjectResponse> args)
        {
            string serverSortOrder;

            FindObjects(etpAdapter, args.Message.Uri, args.Context.DataObjects, out serverSortOrder);
            args.Context.ServerSortOrder = serverSortOrder;
        }
        protected void HandleChannelMetadata(object sender, ProtocolEventArgs <ChannelMetadata> e)
        {
            var receivedTime = DateTime.UtcNow;

            if (e.Header.Protocol == 1 && e.Header.MessageType == 2)
            {
                var timediff = receivedTime - m_Time;

                string          message  = "Channels received: [";
                ChannelMetadata metadata = new ChannelMetadata();
                metadata.Channels = new List <ChannelMetadataRecord>();
                foreach (var channel in e.Message.Channels)
                {
                    metadata.Channels.Add(channel);
                    ChannelStreamingInfo channelStreamingInfo = new ChannelStreamingInfo()
                    {
                        ChannelId  = channel.ChannelId,
                        StartIndex = new StreamingStartIndex()
                        {
                            Item = null
                        },
                        ReceiveChangeNotification = true
                    };
                }


                ChannelInfoReceived?.Invoke(metadata);

                message = $"\nResponse : [Protocol {e.Header.Protocol} MessageType {e.Header.MessageType}]";
                Message?.Invoke(message, timediff.TotalMilliseconds, TraceLevel.Info);
            }
        }
        /// <summary>
        /// Called when the <see cref="OpenSession" /> message is recieved.
        /// </summary>
        /// <param name="e">The <see cref="ProtocolEventArgs{OpenSession}" /> instance containing the event data.</param>
        public void OnSessionOpened(ProtocolEventArgs <OpenSession> e)
        {
            if (e.Message.SupportedProtocols.All(x => x.Protocol != (int)Protocols.ChannelStreaming))
            {
                return;
            }

            var protocol = e.Message.SupportedProtocols
                           .First(x => x.Protocol == (int)Protocols.ChannelStreaming);

            IsSimpleStreamer = protocol.ProtocolCapabilities
                               .Where(x => x.Key.EqualsIgnoreCase(ChannelStreamingProducerHandler.SimpleStreamer))
                               .Select(x => x.Value.Item)
                               .OfType <bool>()
                               .FirstOrDefault();

            var handler = Parent.Client.Handler <IChannelStreamingConsumer>();

            handler.OnChannelMetadata += OnChannelMetadata;
            handler.OnChannelData     += OnChannelData;

            CanStart         = true;
            CanStopStreaming = false;
            UpdateCanDescribe();

            Channels.Clear();
            ChannelStreamingInfos.Clear();
        }
Beispiel #6
0
        private void OnChannelMetadata(object sender, ProtocolEventArgs <ChannelMetadata> e)
        {
            if (!e.Message.Channels.Any())
            {
                Parent.Details.Append(Environment.NewLine + "// No channels were described");
                return;
            }

            // add to channel metadata collection
            e.Message.Channels.ForEach(x =>
            {
                if (Channels.Any(c => c.ChannelUri.EqualsIgnoreCase(x.ChannelUri)))
                {
                    return;
                }

                Channels.Add(x);
                ChannelStreamingInfos.Add(ToChannelStreamingInfo(x));
            });

            if (e.Header.MessageFlags != (int)MessageFlags.MultiPart)
            {
                LogChannelMetadata(Channels);
            }
        }
Beispiel #7
0
 private void OnChannelData(object sender, ProtocolEventArgs <ChannelData> e)
 {
     if (e.Message.Data.Any())
     {
         LogChannelData(e.Message.Data);
     }
 }
Beispiel #8
0
 /// <summary>
 /// Handles the GetObject message of the Store protocol.
 /// </summary>
 /// <param name="args">The <see cref="ProtocolEventArgs{GetObject, DataObject}" /> instance containing the event data.</param>
 /// <param name="dataObjects">The data objects.</param>
 /// <param name="errors">The errors.</param>
 protected override void HandleGetDataObjects(ProtocolEventArgs <GetDataObjects> args, IList <DataObject> dataObjects, IList <ErrorInfo> errors)
 {
     foreach (var uri in args.Message.Uris)
     {
         GetObject(args, uri, dataObjects, errors);
     }
 }
        /// <summary>
        /// Handles the GetResources message of the Discovery protocol.
        /// </summary>
        /// <param name="args">The ProtocolEventArgs{GetResources, IList{Resource}} instance containing the event data.</param>
        protected override void HandleGetResources(ProtocolEventArgs <GetResources, IList <Resource> > args)
        {
            if (!EtpUri.IsRoot(args.Message.Uri))
            {
                var uri = this.CreateAndValidateUri(args.Message.Uri, args.Header.MessageId);

                if (!uri.IsValid)
                {
                    args.Cancel = true;
                    return;
                }
            }

            var max = WitsmlSettings.MaxGetResourcesResponse;

            foreach (var provider in Providers.OrderBy(x => x.DataSchemaVersion))
            {
                // TODO: Optimize inside each version specific provider
                if (args.Context.Count >= max)
                {
                    break;
                }

                provider.GetResources(args);
            }

            // Limit max number of GetResourcesResponse returned to customer
            while (args.Context.Count > max)
            {
                args.Context.RemoveAt(args.Context.Count - 1);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Called when the GetObject response is received.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="ProtocolEventArgs{Object}"/> instance containing the event data.</param>
        private void OnObject(object sender, ProtocolEventArgs <Energistics.Protocol.Store.Object> e)
        {
            Details.SetText(string.Format(
                                "// Header:{2}{0}{2}{2}// Body:{2}{1}",
                                Client.Serialize(e.Header, true),
                                Client.Serialize(e.Message, true),
                                Environment.NewLine));

            var data   = e.Message.DataObject.GetString();
            var uri    = new EtpUri(e.Message.DataObject.Resource.Uri);
            var isJson = EtpContentType.Json.EqualsIgnoreCase(uri.Format);

            if (isJson)
            {
                var objectType = OptionsIn.DataVersion.Version200.Equals(uri.Version)
                    ? ObjectTypes.GetObjectType(uri.ObjectType, uri.Version)
                    : ObjectTypes.GetObjectGroupType(uri.ObjectType, uri.Version);

                var dataObject = EtpExtensions.Deserialize(objectType, data);
                data = EtpExtensions.Serialize(dataObject, true);
            }

            DataObject.SetText(data);
            Runtime.Invoke(() => DataObject.Language = isJson ? "JavaScript" : "XML");
        }
Beispiel #11
0
        /// <summary>
        /// Logs the data object.
        /// </summary>
        /// <typeparam name="T">The message type.</typeparam>
        /// <param name="e">The <see cref="ProtocolEventArgs{T}"/> instance containing the event data.</param>
        /// <param name="dataObject">The data object.</param>
        /// <param name="append">if set to <c>true</c> append the data object; otherwise, replace.</param>
        private void LogDataObject <T>(ProtocolEventArgs <T> e, DataObject dataObject, bool append = false) where T : ISpecificRecord
        {
            LogObjectDetails(e);

            var data   = dataObject.GetString();
            var uri    = new EtpUri(dataObject.Resource.Uri);
            var isJson = EtpContentType.Json.EqualsIgnoreCase(uri.Format);

            if (isJson)
            {
                var objectType = OptionsIn.DataVersion.Version200.Equals(uri.Version)
                    ? ObjectTypes.GetObjectType(uri.ObjectType, uri.Version)
                    : ObjectTypes.GetObjectGroupType(uri.ObjectType, uri.Version);

                var instance = EtpExtensions.Deserialize(objectType, data);
                data = EtpExtensions.Serialize(instance, true);
            }

            if (append)
            {
                DataObject.Append(data);
                DataObject.Append(Environment.NewLine + Environment.NewLine);
            }
            else
            {
                DataObject.SetText(data);
            }

            Runtime.Invoke(() => DataObject.Language = isJson ? "JavaScript" : "XML");
        }
        /// <summary>
        /// Handles the FindObjects message of the Store protocol.
        /// </summary>
        /// <param name="args">The <see cref="ProtocolEventArgs{FindObjects, DataObject}"/> instance containing the event data.</param>
        protected override void HandleFindObjects(ProtocolEventArgs <FindObjects, IList <DataObject> > args)
        {
            try
            {
                var uri = this.CreateAndValidateUri(args.Message.Uri, args.Header.MessageId);
                if (!uri.IsValid)
                {
                    args.Cancel = true;
                    return;
                }

                if (!this.ValidateUriObjectType(uri, args.Header.MessageId))
                {
                    args.Cancel = true;
                    return;
                }

                WitsmlOperationContext.Current.Request = new RequestContext(Functions.GetObject, uri.ObjectType, null, null, null);

                var provider = Container.Resolve <IStoreStoreProvider>(new ObjectName(uri.GetDataSchemaVersion()));
                provider.FindObjects(Session.Adapter, args);

                // Check for empty query results
                if (!(args.Context?.Any()).GetValueOrDefault())
                {
                    Acknowledge(args.Header.MessageId, MessageFlags.NoData);
                    args.Cancel = true;
                }
            }
            catch (ContainerException ex)
            {
                this.UnsupportedObject(ex, args.Message.Uri, args.Header.MessageId);
                args.Cancel = true;
            }
        }
Beispiel #13
0
        protected virtual void OnStart(object sender, ProtocolEventArgs <Start> e)
        {
            TaskRunner = new TaskRunner(e.Message.MaxMessageRate)
            {
                OnExecute = StreamChannelData,
                OnError   = LogStreamingError
            };

            if (Client.Handler <IChannelStreamingProducer>().IsSimpleStreamer)
            {
                var channelMetadata = Simulator.GetChannelMetadata(e.Header)
                                      .Cast <ChannelMetadataRecord>()
                                      .ToList();

                Channels.Clear();
                Channels.AddRange(channelMetadata);

                Client.Handler <IChannelStreamingProducer>()
                .ChannelMetadata(e.Header, channelMetadata);

                foreach (var channel in channelMetadata.Select(ToChannelStreamingInfo))
                {
                    ChannelStreamingInfo.Add(channel);
                }

                TaskRunner.Start();
            }
        }
Beispiel #14
0
        protected void VerifySessionWithProtcols(ProtocolEventArgs <OpenSession> args, params Protocols[] requestedProtocols)
        {
            // Verify OpenSession response
            Assert.IsNotNull(args?.Message?.SessionId);
            var message = args.Message;

            // Verify Session ID
            Guid sessionId;

            Assert.IsNotNull(message.SessionId);
            Assert.IsTrue(Guid.TryParse(message.SessionId, out sessionId));
            Assert.IsNotNull(sessionId);

            // Verify count of Supported Protocols
            var supportedProtocols = message.SupportedProtocols;

            Assert.IsTrue(supportedProtocols.Count <= requestedProtocols.Length);

            // Verify Supported Protocols
            foreach (var protocol in supportedProtocols)
            {
                var version = protocol.ProtocolVersion;

                // Verify against requested protocols
                Assert.IsTrue(requestedProtocols.Any(x => protocol.Protocol == (int)x));

                // Verify protocol versions
                Assert.AreEqual(TestSettings.EtpVersion, $"{version.Major}.{version.Minor}");
            }
        }
Beispiel #15
0
        /// <summary>
        /// Handles the GetObject message of the Store protocol.
        /// </summary>
        /// <param name="args">The <see cref="ProtocolEventArgs{GetObject, DataObject}"/> instance containing the event data.</param>
        protected override void HandleGetObject(ProtocolEventArgs<GetObject, DataObject> args)
        {
            try
            {
                var uri = this.CreateAndValidateUri(args.Message.Uri, args.Header.MessageId);
                if (!uri.IsValid)
                {
                    args.Cancel = true;
                    return;
                }

                if (!this.ValidateUriObjectType(uri, args.Header.MessageId))
                {
                    args.Cancel = true;
                    return;
                }

                WitsmlOperationContext.Current.Request = new RequestContext(Functions.GetObject, uri.ObjectType, null, null, null);

                var provider = Container.Resolve<IStoreStoreProvider>(new ObjectName(uri.GetDataSchemaVersion()));
                provider.GetObject(args);

                if (args.Context.Data == null || args.Context.Data.Length < 1)
                {
                    this.NotFound(args.Message.Uri, args.Header.MessageId);
                    args.Cancel = true;
                }
            }
            catch (ContainerException ex)
            {
                this.UnsupportedObject(ex, args.Message.Uri, args.Header.MessageId);
                args.Cancel = true;
            }
        }
        private void ProducerHandler_OnChannelStreamingStart(object sender, ProtocolEventArgs <ChannelStreamingStart> e)
        {
            string a = "";

            Message?.Invoke("response from Simulate just Test", 0, TraceLevel.Info);
            //  throw new NotImplementedException();
        }
Beispiel #17
0
 private void OnProtocolClosed(object sender, ProtocolEventArgs e)
 {
     Console.WriteLine("Connection has " + e.Protocol.State);
     if (msgServer != null)
     {
         msgServer.SendMessageToMessageServer(97002, LogCategory.Alarm, LogLevel.Alarm, "Connection to Configuration Server has been lost!");
     }
 }
        private void ProducerHandler_OnStart(object sender, ProtocolEventArgs <Start> e)
        {
            String a       = "";
            string message = $"\nRequest: [Protocol {e.Header .Protocol } MessageType {e.Header.MessageType}]";

            message = e.Message.ToString();
            Message?.Invoke(message, 123456, TraceLevel.Info);
        }
Beispiel #19
0
 /// <summary>
 /// Logs the object details.
 /// </summary>
 /// <typeparam name="T">The message type</typeparam>
 /// <param name="e">The <see cref="ProtocolEventArgs{T}"/> instance containing the event data.</param>
 private void LogObjectDetails <T>(ProtocolEventArgs <T> e) where T : ISpecificRecord
 {
     Details.SetText(string.Format(
                         "// Header:{2}{0}{2}{2}// Body:{2}{1}{2}",
                         EtpExtensions.Serialize(e.Header, true),
                         EtpExtensions.Serialize(e.Message, true),
                         Environment.NewLine));
 }
Beispiel #20
0
        protected void VerifyProtocolException(ProtocolEventArgs <ProtocolException> args, long messageId, EtpErrorCodes errorCode)
        {
            VerifyCorrelationId(args, messageId);

            // Verify Error Code
            Assert.IsNotNull(args?.Message);
            Assert.AreEqual((int)errorCode, args.Message.ErrorCode);
        }
        /// <summary>
        /// Gets a collection of resources associated to the specified URI.
        /// </summary>
        /// <param name="args">The <see cref="ProtocolEventArgs{GetResources, IList}"/> instance containing the event data.</param>
        public void GetResources(ProtocolEventArgs <GetResources, IList <Resource> > args)
        {
            if (EtpUri.IsRoot(args.Message.Uri))
            {
                args.Context.Add(DiscoveryStoreProvider.NewProtocol(EtpUris.Witsml131, "WITSML Store (1.3.1.1)"));
                return;
            }

            var uri       = new EtpUri(args.Message.Uri);
            var parentUri = uri.Parent;

            // Append query string, if any
            if (!string.IsNullOrWhiteSpace(uri.Query))
            {
                parentUri = new EtpUri(parentUri + uri.Query);
            }

            if (!uri.IsRelatedTo(EtpUris.Witsml131))
            {
                return;
            }
            if (uri.IsBaseUri || (string.IsNullOrWhiteSpace(uri.ObjectId) && ObjectTypes.Well.EqualsIgnoreCase(uri.ObjectType)))
            {
                _wellDataProvider.GetAll(uri)
                .ForEach(x => args.Context.Add(ToResource(x)));
            }
            else if (string.IsNullOrWhiteSpace(uri.ObjectId) && ObjectTypes.Wellbore.EqualsIgnoreCase(parentUri.ObjectType))
            {
                var objectType   = ObjectTypes.PluralToSingle(uri.ObjectType);
                var dataProvider = _container.Resolve <IEtpDataProvider>(new ObjectName(objectType, uri.Version));

                dataProvider
                .GetAll(parentUri)
                .Cast <IWellboreObject>()
                .ForEach(x => args.Context.Add(ToResource(x)));
            }
            else if (ObjectTypes.Well.EqualsIgnoreCase(uri.ObjectType))
            {
                _wellboreDataProvider.GetAll(uri)
                .ForEach(x => args.Context.Add(ToResource(x)));
            }
            else if (ObjectTypes.Wellbore.EqualsIgnoreCase(uri.ObjectType))
            {
                var wellboreObjectType = typeof(IWellboreObject);

                Providers
                .OfType <IWitsmlDataAdapter>()
                .Where(x => wellboreObjectType.IsAssignableFrom(x.DataObjectType))
                .Select(x => ObjectTypes.GetObjectType(x.DataObjectType))
                .OrderBy(x => x)
                .ForEach(x => args.Context.Add(DiscoveryStoreProvider.NewFolder(uri, x, ObjectTypes.SingleToPlural(x, false))));
            }
            else if (ObjectTypes.Log.EqualsIgnoreCase(uri.ObjectType))
            {
                var log = _logDataProvider.Get(uri);
                log?.LogCurveInfo?.ForEach(x => args.Context.Add(ToResource(log, x)));
            }
        }
Beispiel #22
0
        /// <summary>
        /// Gets the object details for the specified URI.
        /// </summary>
        /// <param name="args">The <see cref="ProtocolEventArgs{GetObject, DataObject}" /> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void GetObject(ProtocolEventArgs <GetObject, DataObject> args)
        {
            var uri         = new EtpUri(args.Message.Uri);
            var dataAdapter = Container.Resolve <IEtpDataProvider>(new ObjectName(uri.ObjectType, uri.Version));
            var entity      = dataAdapter.Get(uri) as IDataObject;
            var list        = GetList(entity, uri);

            StoreStoreProvider.SetDataObject(args.Context, list, uri, GetName(entity), lastChanged: GetLastChanged(entity));
        }
Beispiel #23
0
        /// <summary>
        /// Called when the <see cref="OpenSession" /> message is recieved.
        /// </summary>
        /// <param name="e">The <see cref="ProtocolEventArgs{OpenSession}" /> instance containing the event data.</param>
        public void OnSessionOpened(ProtocolEventArgs <OpenSession> e)
        {
            if (e.Message.SupportedProtocols.All(x => x.Protocol != (int)Protocols.GrowingObject))
            {
                return;
            }

            CanExecute = true;
        }
Beispiel #24
0
        /// <summary>
        /// Gets the object details for the specified URI.
        /// </summary>
        /// <param name="args">The <see cref="ProtocolEventArgs{GetObject, DataObject}" /> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void GetObject(ProtocolEventArgs <GetObject, DataObject> args)
        {
            var uri         = new EtpUri(args.Message.Uri);
            var dataAdapter = Container.Resolve <IEtpDataProvider>(new ObjectName(uri.ObjectType, uri.GetDataSchemaVersion()));
            var entity      = dataAdapter.Get(uri) as Witsml200.AbstractObject;
            var lastChanged = (entity?.Citation.LastUpdate).ToUnixTimeMicroseconds().GetValueOrDefault();

            StoreStoreProvider.SetDataObject(args.Context, entity, uri, GetName(entity), lastChanged: lastChanged);
        }
Beispiel #25
0
 private void Protocol_CommandEnd(object sender, ProtocolEventArgs e)
 {
     if (!e.Status || e.DataObject == null)
     {
         return;
     }
     //Получим данные и отправим их в наше View
     context.Post(GetProtocolData, e.DataObject);
 }
Beispiel #26
0
 /// <summary>
 /// Logs the object details.
 /// </summary>
 /// <typeparam name="T">The message type.</typeparam>
 /// <typeparam name="TContext">The context type.</typeparam>
 /// <param name="e">The <see cref="ProtocolEventArgs{T, TContext}"/> instance containing the event data.</param>
 private void LogObjectDetails <T, TContext>(ProtocolEventArgs <T, TContext> e) where T : ISpecificRecord
 {
     Details.SetText(string.Format(
                         "// Header:{3}{0}{3}{3}// Body:{3}{1}{3}{3}// Context:{3}{2}{3}",
                         Client.Serialize(e.Header, true),
                         Client.Serialize(e.Message, true),
                         Client.Serialize(e.Context, true),
                         Environment.NewLine));
 }
Beispiel #27
0
        /// <summary>
        /// Called when the ETP session is initialized.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="ProtocolEventArgs{OpenSession}"/> instance containing the event data.</param>
        private void OnOpenSession(object sender, ProtocolEventArgs <OpenSession> e)
        {
            Runtime.Invoke(() => Runtime.Shell.StatusBarText = "Connected");
            LogObjectDetails(e);

            // notify child view models
            Items.OfType <ISessionAware>()
            .ForEach(x => x.OnSessionOpened(e));
        }
Beispiel #28
0
 private void LogObjectDetails <T>(ProtocolEventArgs <T> e) where T : ISpecificRecord
 {
     //Details.SetText();
     this.Details.Dispatcher.Invoke(new Action(() => { this.Details.AppendText(string.Format(
                                                                                   "// Header:{2}{0}{2}{2}// Body:{2}{1}{2}",
                                                                                   Client.Serialize(e.Header, true),
                                                                                   Client.Serialize(e.Message, true),
                                                                                   Environment.NewLine)); }));
 }
        protected void HandleOpenSession(object sender, ProtocolEventArgs <OpenSession> e)
        {
            var    receivedTime = DateTime.UtcNow;
            string message      = e.Message.ToMessage();

            message = $"\nResponse : [Protocol {e.Header.Protocol} MessageType {e.Header.MessageType}]\n{message}";
            var timediff = receivedTime - m_Time;

            Message?.Invoke(message, timediff.TotalMilliseconds, TraceLevel.Info);
        }
Beispiel #30
0
        /// <summary>
        /// Called when the <see cref="OpenSession" /> message is recieved.
        /// </summary>
        /// <param name="e">The <see cref="ProtocolEventArgs{OpenSession}" /> instance containing the event data.</param>
        public void OnSessionOpened(ProtocolEventArgs <OpenSession> e)
        {
            if (e.Message.SupportedProtocols.All(x => x.Protocol != (int)Protocols.Discovery))
            {
                return;
            }

            CanExecute = true;
            RefreshContextMenu();
        }
Beispiel #31
0
        public void TestDefaultSerialization()
        {
            var original = new ProtocolEventArgs();
            var serialized = JsonSerialization.Minimal.Serialize(original);
            var deseralized = JsonSerialization.Minimal.Deserialize<ProtocolEventArgs>(serialized);

            Assert.IsNotNull(deseralized.Now);
            Assert.IsNotNull(deseralized.Then);
            Assert.IsNotNull(deseralized.Stamp);
            Assert.IsNotNull(deseralized.StateDifference);
            Assert.IsNotNull(deseralized.ProtocolType);
            Assert.AreEqual(ProtocolEventType.None, deseralized.ProtocolEventType);
        }
Beispiel #32
0
 private void onProtocolClosedTServer(object sender, ProtocolEventArgs e)
 {
     EnviaMensagemSignalR("ServidorCTI", "Passou pelo método: onProtocolClosedTServer");
 }
Beispiel #33
0
        private void onProtocolOpenedTServer(object sender, ProtocolEventArgs e)
        {
            string v = "TServer";
            if (string.Equals(e.Protocol.ProtocolDescription.ProtocolName, v))
                pTServer = true;

            EnviaMensagemSignalR("ServidorCTI", "Passou pelo método: onProtocolOpenedTServer");
        }
Beispiel #34
0
        public void TestSingleDepthPopulationSerialization()
        {
            var original = new ProtocolEventArgs() {
                Now = {
                    Bans = new List<BanModel>() {
                        new BanModel()
                    },
                    Chats = new List<ChatModel>() {
                        new ChatModel()
                    },
                    Items = new List<ItemModel>() {
                        new ItemModel()
                    },
                    Kicks = new List<KickModel>() {
                        new KickModel()
                    },
                    Kills = new List<KillModel>() {
                        new KillModel()
                    },
                    Moves = new List<MoveModel>() {
                        new MoveModel()
                    },
                    Players = new List<PlayerModel>() {
                        new PlayerModel()
                    },
                    Points = new List<Point3DModel>() {
                        new Point3DModel()
                    },
                    Settings = new List<Settings>() {
                        new Settings()
                    },
                    Spawns = new List<SpawnModel>() {
                        new SpawnModel()
                    }
                },
                Then = {
                    Bans = new List<BanModel>() {
                        new BanModel()
                    },
                    Chats = new List<ChatModel>() {
                        new ChatModel()
                    },
                    Items = new List<ItemModel>() {
                        new ItemModel()
                    },
                    Kicks = new List<KickModel>() {
                        new KickModel()
                    },
                    Kills = new List<KillModel>() {
                        new KillModel()
                    },
                    Moves = new List<MoveModel>() {
                        new MoveModel()
                    },
                    Players = new List<PlayerModel>() {
                        new PlayerModel()
                    },
                    Points = new List<Point3DModel>() {
                        new Point3DModel()
                    },
                    Settings = new List<Settings>() {
                        new Settings()
                    },
                    Spawns = new List<SpawnModel>() {
                        new SpawnModel()
                    }
                },
                StateDifference = new ProtocolStateDifference(),
                ProtocolEventType = ProtocolEventType.ProtocolBanlistUpdated,
                ProtocolType = new ProtocolType(),
                Stamp = new DateTime(2000, 10, 10, 10, 10, 10)
            };
            var serialized = JsonSerialization.Minimal.Serialize(original);
            var deseralized = JsonSerialization.Minimal.Deserialize<ProtocolEventArgs>(serialized);

            Assert.IsNotEmpty(deseralized.Now.Bans);
            Assert.IsNotEmpty(deseralized.Now.Chats);
            Assert.IsNotEmpty(deseralized.Now.Items);
            Assert.IsNotEmpty(deseralized.Now.Kicks);
            Assert.IsNotEmpty(deseralized.Now.Kills);
            Assert.IsNotEmpty(deseralized.Now.Moves);
            Assert.IsNotEmpty(deseralized.Now.Players);
            Assert.IsNotEmpty(deseralized.Now.Points);
            Assert.IsNotEmpty(deseralized.Now.Settings);
            Assert.IsNotEmpty(deseralized.Now.Spawns);

            Assert.IsNotEmpty(deseralized.Then.Bans);
            Assert.IsNotEmpty(deseralized.Then.Chats);
            Assert.IsNotEmpty(deseralized.Then.Items);
            Assert.IsNotEmpty(deseralized.Then.Kicks);
            Assert.IsNotEmpty(deseralized.Then.Kills);
            Assert.IsNotEmpty(deseralized.Then.Moves);
            Assert.IsNotEmpty(deseralized.Then.Players);
            Assert.IsNotEmpty(deseralized.Then.Points);
            Assert.IsNotEmpty(deseralized.Then.Settings);
            Assert.IsNotEmpty(deseralized.Then.Spawns);

            Assert.IsNotNull(deseralized.ProtocolType);
            Assert.IsNotNull(deseralized.StateDifference);
            Assert.AreEqual(new DateTime(2000, 10, 10, 10, 10, 10), deseralized.Stamp);
            Assert.AreEqual(ProtocolEventType.ProtocolBanlistUpdated, deseralized.ProtocolEventType);
        }