Esempio n. 1
0
 /// <summary>
 /// 添加新闻
 /// </summary>
 public ENews AddNews(string title, string categoryId, string userId, string departId, string content, NewState state = NewState.Enabled, DateTime? openTime = null)
 {
     ENews news = Dc.News.Create();
     news.ID = SqlDataHelper.CreateID();
     news.CreateTime = DateTime.Now;
     news.Content = content;
     news.DepartmentID = departId;
     news.LazyTime = openTime;
     news.State = state;
     news.SubCategoryID = categoryId;
     news.Title = title;
     news.UserID = userId;
     news.WatchCount = 0;
     Dc.News.Add(news);
     try
     {
         Dc.SaveChanges();
     }
     catch (InvalidOperationException)
     {
         throw new DbSaveException();
     }
     return news;
 }
Esempio n. 2
0
 partial void PostAssignTwoLineListItemProperties(ISharpRenderer <global::Android.Views.View> renderer, int level, NewState newState, TProps previous, TProps nextProps);
Esempio n. 3
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.IsDefault.HasValue)
     {
         Element.IsDefault = nextProps.IsDefault.Value.Value;
     }
     if (nextProps.IsCancel.HasValue)
     {
         Element.IsCancel = nextProps.IsCancel.Value.Value;
     }
 }
Esempio n. 4
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.ExpandDirection.HasValue)
     {
         Element.ExpandDirection = nextProps.ExpandDirection.Value.Value;
     }
     if (nextProps.IsExpanded.HasValue)
     {
         Element.IsExpanded = nextProps.IsExpanded.Value.Value;
     }
     if (!ReferenceEquals(previous?.Expanded, null) && ReferenceEquals(nextProps.Expanded, null))
     {
         Element.Expanded -= nextProps.Expanded;
     }
     if (ReferenceEquals(previous?.Expanded, null) && !ReferenceEquals(nextProps.Expanded, null))
     {
         Element.Expanded += nextProps.Expanded;
     }
     if (!ReferenceEquals(previous?.Collapsed, null) && ReferenceEquals(nextProps.Collapsed, null))
     {
         Element.Collapsed -= nextProps.Collapsed;
     }
     if (ReferenceEquals(previous?.Collapsed, null) && !ReferenceEquals(nextProps.Collapsed, null))
     {
         Element.Collapsed += nextProps.Collapsed;
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="lastState"></param>
 public override void EnterState(NewState lastState)
 {
     anim.SetTrigger(animMovingHash);
     agent.enabled = true;
 }
Esempio n. 6
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.Background.HasValue)
     {
         Element.Background = nextProps.Background.Value.Value;
     }
     if (nextProps.Bullet.HasValue)
     {
         Element.Bullet = nextProps.Bullet.Value.Value;
     }
 }
Esempio n. 7
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.Source.HasValue)
     {
         Element.Source = nextProps.Source.Value.Value;
     }
     if (nextProps.Clock.HasValue)
     {
         Element.Clock = nextProps.Clock.Value.Value;
     }
     if (nextProps.Stretch.HasValue)
     {
         Element.Stretch = nextProps.Stretch.Value.Value;
     }
     if (nextProps.StretchDirection.HasValue)
     {
         Element.StretchDirection = nextProps.StretchDirection.Value.Value;
     }
     if (nextProps.Volume.HasValue)
     {
         Element.Volume = nextProps.Volume.Value.Value;
     }
     if (nextProps.Balance.HasValue)
     {
         Element.Balance = nextProps.Balance.Value.Value;
     }
     if (nextProps.IsMuted.HasValue)
     {
         Element.IsMuted = nextProps.IsMuted.Value.Value;
     }
     if (nextProps.ScrubbingEnabled.HasValue)
     {
         Element.ScrubbingEnabled = nextProps.ScrubbingEnabled.Value.Value;
     }
     if (nextProps.UnloadedBehavior.HasValue)
     {
         Element.UnloadedBehavior = nextProps.UnloadedBehavior.Value.Value;
     }
     if (nextProps.LoadedBehavior.HasValue)
     {
         Element.LoadedBehavior = nextProps.LoadedBehavior.Value.Value;
     }
     if (nextProps.Position.HasValue)
     {
         Element.Position = nextProps.Position.Value.Value;
     }
     if (nextProps.SpeedRatio.HasValue)
     {
         Element.SpeedRatio = nextProps.SpeedRatio.Value.Value;
     }
     if (!ReferenceEquals(previous?.MediaFailed, null) && ReferenceEquals(nextProps.MediaFailed, null))
     {
         Element.MediaFailed -= nextProps.MediaFailed;
     }
     if (ReferenceEquals(previous?.MediaFailed, null) && !ReferenceEquals(nextProps.MediaFailed, null))
     {
         Element.MediaFailed += nextProps.MediaFailed;
     }
     if (!ReferenceEquals(previous?.MediaOpened, null) && ReferenceEquals(nextProps.MediaOpened, null))
     {
         Element.MediaOpened -= nextProps.MediaOpened;
     }
     if (ReferenceEquals(previous?.MediaOpened, null) && !ReferenceEquals(nextProps.MediaOpened, null))
     {
         Element.MediaOpened += nextProps.MediaOpened;
     }
     if (!ReferenceEquals(previous?.BufferingStarted, null) && ReferenceEquals(nextProps.BufferingStarted, null))
     {
         Element.BufferingStarted -= nextProps.BufferingStarted;
     }
     if (ReferenceEquals(previous?.BufferingStarted, null) && !ReferenceEquals(nextProps.BufferingStarted, null))
     {
         Element.BufferingStarted += nextProps.BufferingStarted;
     }
     if (!ReferenceEquals(previous?.BufferingEnded, null) && ReferenceEquals(nextProps.BufferingEnded, null))
     {
         Element.BufferingEnded -= nextProps.BufferingEnded;
     }
     if (ReferenceEquals(previous?.BufferingEnded, null) && !ReferenceEquals(nextProps.BufferingEnded, null))
     {
         Element.BufferingEnded += nextProps.BufferingEnded;
     }
     if (!ReferenceEquals(previous?.ScriptCommand, null) && ReferenceEquals(nextProps.ScriptCommand, null))
     {
         Element.ScriptCommand -= nextProps.ScriptCommand;
     }
     if (ReferenceEquals(previous?.ScriptCommand, null) && !ReferenceEquals(nextProps.ScriptCommand, null))
     {
         Element.ScriptCommand += nextProps.ScriptCommand;
     }
     if (!ReferenceEquals(previous?.MediaEnded, null) && ReferenceEquals(nextProps.MediaEnded, null))
     {
         Element.MediaEnded -= nextProps.MediaEnded;
     }
     if (ReferenceEquals(previous?.MediaEnded, null) && !ReferenceEquals(nextProps.MediaEnded, null))
     {
         Element.MediaEnded += nextProps.MediaEnded;
     }
 }
Esempio n. 8
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.SelectedValuePath.HasValue)
     {
         Element.SelectedValuePath = nextProps.SelectedValuePath.Value.Value;
     }
     if (!ReferenceEquals(previous?.SelectedItemChanged, null) && ReferenceEquals(nextProps.SelectedItemChanged, null))
     {
         Element.SelectedItemChanged -= nextProps.SelectedItemChanged;
     }
     if (ReferenceEquals(previous?.SelectedItemChanged, null) && !ReferenceEquals(nextProps.SelectedItemChanged, null))
     {
         Element.SelectedItemChanged += nextProps.SelectedItemChanged;
     }
 }
Esempio n. 9
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.Item.HasValue)
     {
         Element.Item = nextProps.Item.Value.Value;
     }
     if (nextProps.ItemsPanel.HasValue)
     {
         Element.ItemsPanel = nextProps.ItemsPanel.Value.Value;
     }
     if (nextProps.Header.HasValue)
     {
         Element.Header = nextProps.Header.Value.Value;
     }
     if (nextProps.HeaderStyle.HasValue)
     {
         Element.HeaderStyle = nextProps.HeaderStyle.Value.Value;
     }
     if (nextProps.HeaderTemplate.HasValue)
     {
         Element.HeaderTemplate = nextProps.HeaderTemplate.Value.Value;
     }
     if (nextProps.HeaderTemplateSelector.HasValue)
     {
         Element.HeaderTemplateSelector = nextProps.HeaderTemplateSelector.Value.Value;
     }
     if (nextProps.ValidationErrorTemplate.HasValue)
     {
         Element.ValidationErrorTemplate = nextProps.ValidationErrorTemplate.Value.Value;
     }
     if (nextProps.DetailsTemplate.HasValue)
     {
         Element.DetailsTemplate = nextProps.DetailsTemplate.Value.Value;
     }
     if (nextProps.DetailsTemplateSelector.HasValue)
     {
         Element.DetailsTemplateSelector = nextProps.DetailsTemplateSelector.Value.Value;
     }
     if (nextProps.DetailsVisibility.HasValue)
     {
         Element.DetailsVisibility = nextProps.DetailsVisibility.Value.Value;
     }
     if (nextProps.IsSelected.HasValue)
     {
         Element.IsSelected = nextProps.IsSelected.Value.Value;
     }
     if (!ReferenceEquals(previous?.Selected, null) && ReferenceEquals(nextProps.Selected, null))
     {
         Element.Selected -= nextProps.Selected;
     }
     if (ReferenceEquals(previous?.Selected, null) && !ReferenceEquals(nextProps.Selected, null))
     {
         Element.Selected += nextProps.Selected;
     }
     if (!ReferenceEquals(previous?.Unselected, null) && ReferenceEquals(nextProps.Unselected, null))
     {
         Element.Unselected -= nextProps.Unselected;
     }
     if (ReferenceEquals(previous?.Unselected, null) && !ReferenceEquals(nextProps.Unselected, null))
     {
         Element.Unselected += nextProps.Unselected;
     }
 }
Esempio n. 10
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.Text.HasValue)
     {
         Element.Text = nextProps.Text.Value.Value;
     }
     if (nextProps.FontFamily.HasValue)
     {
         Element.FontFamily = nextProps.FontFamily.Value.Value;
     }
     if (nextProps.FontStyle.HasValue)
     {
         Element.FontStyle = nextProps.FontStyle.Value.Value;
     }
     if (nextProps.FontWeight.HasValue)
     {
         Element.FontWeight = nextProps.FontWeight.Value.Value;
     }
     if (nextProps.FontStretch.HasValue)
     {
         Element.FontStretch = nextProps.FontStretch.Value.Value;
     }
     if (nextProps.FontSize.HasValue)
     {
         Element.FontSize = nextProps.FontSize.Value.Value;
     }
     if (nextProps.Foreground.HasValue)
     {
         Element.Foreground = nextProps.Foreground.Value.Value;
     }
     if (nextProps.Background.HasValue)
     {
         Element.Background = nextProps.Background.Value.Value;
     }
     if (nextProps.TextDecorations.HasValue)
     {
         Element.TextDecorations = nextProps.TextDecorations.Value.Value;
     }
     if (nextProps.TextEffects.HasValue)
     {
         Element.TextEffects = nextProps.TextEffects.Value.Value;
     }
     if (nextProps.LineHeight.HasValue)
     {
         Element.LineHeight = nextProps.LineHeight.Value.Value;
     }
     if (nextProps.LineStackingStrategy.HasValue)
     {
         Element.LineStackingStrategy = nextProps.LineStackingStrategy.Value.Value;
     }
     if (nextProps.TextAlignment.HasValue)
     {
         Element.TextAlignment = nextProps.TextAlignment.Value.Value;
     }
     if (nextProps.TextTrimming.HasValue)
     {
         Element.TextTrimming = nextProps.TextTrimming.Value.Value;
     }
     if (nextProps.TextWrapping.HasValue)
     {
         Element.TextWrapping = nextProps.TextWrapping.Value.Value;
     }
     if (nextProps.BaselineOffset.HasValue)
     {
         Element.BaselineOffset = nextProps.BaselineOffset.Value.Value;
     }
 }
Esempio n. 11
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (!ReferenceEquals(previous?.DragStarted, null) && ReferenceEquals(nextProps.DragStarted, null))
     {
         Element.DragStarted -= nextProps.DragStarted;
     }
     if (ReferenceEquals(previous?.DragStarted, null) && !ReferenceEquals(nextProps.DragStarted, null))
     {
         Element.DragStarted += nextProps.DragStarted;
     }
     if (!ReferenceEquals(previous?.DragDelta, null) && ReferenceEquals(nextProps.DragDelta, null))
     {
         Element.DragDelta -= nextProps.DragDelta;
     }
     if (ReferenceEquals(previous?.DragDelta, null) && !ReferenceEquals(nextProps.DragDelta, null))
     {
         Element.DragDelta += nextProps.DragDelta;
     }
     if (!ReferenceEquals(previous?.DragCompleted, null) && ReferenceEquals(nextProps.DragCompleted, null))
     {
         Element.DragCompleted -= nextProps.DragCompleted;
     }
     if (ReferenceEquals(previous?.DragCompleted, null) && !ReferenceEquals(nextProps.DragCompleted, null))
     {
         Element.DragCompleted += nextProps.DragCompleted;
     }
 }
Esempio n. 12
0
 partial void PostAssignLinearLayoutCompatProperties(ISharpRenderer <global::Android.Views.View> renderer, int level, NewState newState, TProps previous, TProps nextProps);
 partial void PostAssignContentLoadingProgressBarProperties(ISharpRenderer <global::Android.Views.View> renderer, int level, NewState newState, TProps previous, TProps nextProps);
 public InstantaneousDamageRepsonseBlock(BinaryReader binaryReader)
 {
     this.responseType = (ResponseType)binaryReader.ReadInt16();
     this.constraintDamageType = (ConstraintDamageType)binaryReader.ReadInt16();
     this.flags = (Flags)binaryReader.ReadInt32();
     this.damageThresholdRepsonseFiresAfterCrossingThisThreshold1FullHealth = binaryReader.ReadSingle();
     this.transitionEffect = binaryReader.ReadTagReference();
     this.damageEffect = new InstantaneousResponseDamageEffectStruct(binaryReader);
     this.region = binaryReader.ReadStringID();
     this.newState = (NewState)binaryReader.ReadInt16();
     this.runtimeRegionIndex = binaryReader.ReadInt16();
     this.effectMarkerName = binaryReader.ReadStringID();
     this.damageEffectMarker = new InstantaneousResponseDamageEffectMarkerStruct(binaryReader);
     this.responseDelayInSeconds = binaryReader.ReadSingle();
     this.delayEffect = binaryReader.ReadTagReference();
     this.delayEffectMarkerName = binaryReader.ReadStringID();
     this.constraintGroupName = binaryReader.ReadStringID();
     this.ejectingSeatLabel = binaryReader.ReadStringID();
     this.skipFraction = binaryReader.ReadSingle();
     this.destroyedChildObjectMarkerName = binaryReader.ReadStringID();
     this.totalDamageThreshold = binaryReader.ReadSingle();
 }
Esempio n. 15
0
        private async void StartActuator()
        {
            try
            {
                Log.Informational("Starting application.");

                XmppCredentials Credentials = SimpleXmppConfiguration.GetConfigUsingSimpleConsoleDialog("xmpp.config",
                                                                                                        Guid.NewGuid().ToString().Replace("-", string.Empty), // Default user name.
                                                                                                        Guid.NewGuid().ToString().Replace("-", string.Empty), // Default password.
                                                                                                        typeof(App).GetTypeInfo().Assembly);

                Log.Informational("Connecting to XMPP server.");

                xmppClient = new XmppClient(Credentials, "en", typeof(App).GetTypeInfo().Assembly);

                if (Credentials.Sniffer && MainPage.Sniffer != null)
                {
                    xmppClient.Add(MainPage.Sniffer);
                }

                if (!string.IsNullOrEmpty(Credentials.Events))
                {
                    Log.Register(new XmppEventSink("XMPP Event Sink", xmppClient, Credentials.Events, false));
                }

                if (!string.IsNullOrEmpty(Credentials.ThingRegistry))
                {
                    thingRegistryClient = new ThingRegistryClient(xmppClient, Credentials.ThingRegistry);

                    thingRegistryClient.Claimed += (sender, e) =>
                    {
                        ownerJid = e.JID;
                        Log.Informational("Thing has been claimed.", ownerJid, new KeyValuePair <string, object>("Public", e.IsPublic));
                        this.RaiseOwnershipChanged();
                    };

                    thingRegistryClient.Disowned += (sender, e) =>
                    {
                        Log.Informational("Thing has been disowned.", ownerJid);
                        ownerJid = string.Empty;
                        this.Register();                            // Will call this.OwnershipChanged() after successful registration.
                    };

                    thingRegistryClient.Removed += (sender, e) =>
                    {
                        Log.Informational("Thing has been removed from the public registry.", ownerJid);
                    };
                }

                if (!string.IsNullOrEmpty(Credentials.Provisioning))
                {
                    provisioningClient = new ProvisioningClient(xmppClient, Credentials.Provisioning);
                }

                Timer ConnectionTimer = new Timer((P) =>
                {
                    if (xmppClient.State == XmppState.Offline || xmppClient.State == XmppState.Error || xmppClient.State == XmppState.Authenticating)
                    {
                        try
                        {
                            Log.Informational("Reconnecting.");
                            xmppClient.Reconnect();
                        }
                        catch (Exception ex)
                        {
                            Log.Critical(ex);
                        }
                    }
                }, null, 60000, 60000);

                xmppClient.OnStateChanged += (sender, NewState) =>
                {
                    Log.Informational(NewState.ToString());

                    switch (NewState)
                    {
                    case XmppState.Connected:
                        connected = true;

                        if (!registered && thingRegistryClient != null)
                        {
                            Register();
                        }
                        break;

                    case XmppState.Offline:
                        immediateReconnect = connected;
                        connected          = false;

                        if (immediateReconnect)
                        {
                            xmppClient.Reconnect();
                        }
                        break;
                    }
                };

                xmppClient.OnPresenceSubscribe += (sender, e) =>
                {
                    Log.Informational("Subscription request received from " + e.From + ".");

                    e.Accept();                         // TODO: Provisioning

                    RosterItem Item = xmppClient.GetRosterItem(e.FromBareJID);
                    if (Item == null || Item.State == SubscriptionState.None || Item.State == SubscriptionState.From)
                    {
                        xmppClient.RequestPresenceSubscription(e.FromBareJID);
                    }

                    xmppClient.SetPresence(Availability.Chat);
                };

                xmppClient.OnPresenceUnsubscribe += (sender, e) =>
                {
                    Log.Informational("Unsubscription request received from " + e.From + ".");
                    e.Accept();
                };

                xmppClient.OnRosterItemUpdated += (sender, e) =>
                {
                    if (e.State == SubscriptionState.None && e.PendingSubscription != PendingSubscription.Subscribe)
                    {
                        xmppClient.RemoveRosterItem(e.BareJid);
                    }
                };

                bool SwitchOn = false;

                sensorServer = new SensorServer(xmppClient, provisioningClient, false);
                sensorServer.OnExecuteReadoutRequest += (Sender, Request) =>
                {
                    DateTime Now = DateTime.Now;

                    Log.Informational("Readout requested", string.Empty, Request.Actor);

                    Request.ReportFields(true, new BooleanField(ThingReference.Empty, Now, "Lamp", SwitchOn, FieldType.Momentary, FieldQoS.AutomaticReadout));
                };

                controlServer = new ControlServer(xmppClient,
                                                  new BooleanControlParameter("Lamp", "Control", "Lamp switch on.", "If checked, lamp is turned on.",
                                                                              (Node) => SwitchOn,
                                                                              (Node, Value) =>
                {
                    SwitchOn = Value;
                    Log.Informational("Lamp turned " + (SwitchOn ? "ON" : "OFF"));
                    UpdateMainWindow(SwitchOn);
                }));

                this.bobClient  = new BobClient(this.xmppClient, Path.Combine(Path.GetTempPath(), "BitsOfBinary"));
                this.chatServer = new ChatServer(xmppClient, this.bobClient, this.sensorServer, this.controlServer, this.provisioningClient);

                interoperabilityServer = new InteroperabilityServer(xmppClient);
                interoperabilityServer.OnGetInterfaces += (sender, e) =>
                {
                    e.Add("XMPP.IoT.Actuator.Lamp");
                };

                xmppClient.Connect();
            }
            catch (Exception ex)
            {
                Log.Emergency(ex);

                MessageDialog Dialog = new MessageDialog(ex.Message, "Error");
                await Dialog.ShowAsync();
            }
        }
        public void SensorData_Test_03_Subscribe_ChangeBy()
        {
            this.ConnectClients();
            try
            {
                ManualResetEvent    Done   = new ManualResetEvent(false);
                ManualResetEvent    Error  = new ManualResetEvent(false);
                IEnumerable <Field> Fields = null;

                SensorDataSubscriptionRequest Request = this.sensorClient.Subscribe(this.client2.FullJID, FieldType.All,
                                                                                    new FieldSubscriptionRule[]
                {
                    new FieldSubscriptionRule("Temperature", this.temp, 1)
                },
                                                                                    Duration.Parse("PT1S"), Duration.Parse("PT5S"), false);
                Request.OnStateChanged += (sender, NewState) =>
                {
                    Console.Out.WriteLine(NewState.ToString());
                    return(Task.CompletedTask);
                };
                Request.OnErrorsReceived += (sender, Errors) =>
                {
                    Error.Set();
                    return(Task.CompletedTask);
                };
                Request.OnFieldsReceived += (sender, NewFields) =>
                {
                    Fields = NewFields;
                    Done.Set();
                    return(Task.CompletedTask);
                };

                this.temp += 0.5;
                this.sensorServer.NewMomentaryValues(new QuantityField(ThingReference.Empty, DateTime.Now, "Temperature", this.temp, 1, "C",
                                                                       FieldType.Momentary, FieldQoS.AutomaticReadout));

                Thread.Sleep(2000);

                this.temp += 0.5;
                this.sensorServer.NewMomentaryValues(new QuantityField(ThingReference.Empty, DateTime.Now, "Temperature", this.temp, 1, "C",
                                                                       FieldType.Momentary, FieldQoS.AutomaticReadout));

                Assert.AreEqual(0, WaitHandle.WaitAny(new WaitHandle[] { Done, Error }, 10000), "Subscription not performed correctly");

                foreach (Field Field in Fields)
                {
                    Console.Out.WriteLine(Field.ToString());
                }

                Done.Reset();

                this.temp -= 1;
                this.sensorServer.NewMomentaryValues(new QuantityField(ThingReference.Empty, DateTime.Now, "Temperature", this.temp, 1, "C",
                                                                       FieldType.Momentary, FieldQoS.AutomaticReadout));

                Assert.AreEqual(0, WaitHandle.WaitAny(new WaitHandle[] { Done, Error }, 10000), "Subscription not performed correctly");

                foreach (Field Field in Fields)
                {
                    Console.Out.WriteLine(Field.ToString());
                }
            }
            finally
            {
                this.DisposeClients();
            }
        }
        public void SensorData_Test_06_Subscribe_MinInterval()
        {
            this.ConnectClients();
            try
            {
                ManualResetEvent    Done   = new ManualResetEvent(false);
                ManualResetEvent    Error  = new ManualResetEvent(false);
                IEnumerable <Field> Fields = null;

                SensorDataSubscriptionRequest Request = this.sensorClient.Subscribe(this.client2.FullJID, FieldType.All,
                                                                                    new FieldSubscriptionRule[]
                {
                    new FieldSubscriptionRule("Temperature", this.temp, 1, null)
                },
                                                                                    Duration.Parse("PT1S"), Duration.Parse("PT5S"), false);
                Request.OnStateChanged += (sender, NewState) =>
                {
                    Console.Out.WriteLine(NewState.ToString());
                    return(Task.CompletedTask);
                };
                Request.OnErrorsReceived += (sender, Errors) =>
                {
                    Error.Set();
                    return(Task.CompletedTask);
                };
                Request.OnFieldsReceived += (sender, NewFields) =>
                {
                    Fields = NewFields;
                    Done.Set();
                    return(Task.CompletedTask);
                };

                int      Count = 6;
                DateTime Start = DateTime.Now;

                while (Count > 0)
                {
                    this.temp += 1;
                    this.sensorServer.NewMomentaryValues(new QuantityField(ThingReference.Empty, DateTime.Now, "Temperature", this.temp, 1, "C",
                                                                           FieldType.Momentary, FieldQoS.AutomaticReadout));

                    this.temp -= 1;
                    this.sensorServer.NewMomentaryValues(new QuantityField(ThingReference.Empty, DateTime.Now, "Temperature", this.temp, 1, "C",
                                                                           FieldType.Momentary, FieldQoS.AutomaticReadout));

                    switch (WaitHandle.WaitAny(new WaitHandle[] { Done, Error }, 100))
                    {
                    case 0:
                        Done.Reset();
                        Count--;
                        break;

                    case 1:
                        Assert.Fail("Subscription not performed correctly");
                        break;
                    }
                }

                TimeSpan Elapsed = DateTime.Now - Start;
                Assert.IsTrue(Elapsed > new TimeSpan(0, 0, 5));
            }
            finally
            {
                this.DisposeClients();
            }
        }
Esempio n. 18
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.Header.HasValue)
     {
         Element.Header = nextProps.Header.Value.Value;
     }
     if (nextProps.HeaderTemplate.HasValue)
     {
         Element.HeaderTemplate = nextProps.HeaderTemplate.Value.Value;
     }
     if (nextProps.HeaderTemplateSelector.HasValue)
     {
         Element.HeaderTemplateSelector = nextProps.HeaderTemplateSelector.Value.Value;
     }
     if (nextProps.HeaderStringFormat.HasValue)
     {
         Element.HeaderStringFormat = nextProps.HeaderStringFormat.Value.Value;
     }
 }
Esempio n. 19
0
 partial void PostAssignSwipeRefreshLayoutProperties(ISharpRenderer <global::Android.Views.View> renderer, int level, NewState newState, TProps previous, TProps nextProps);
Esempio n. 20
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.X1.HasValue)
     {
         Element.X1 = nextProps.X1.Value.Value;
     }
     if (nextProps.Y1.HasValue)
     {
         Element.Y1 = nextProps.Y1.Value.Value;
     }
     if (nextProps.X2.HasValue)
     {
         Element.X2 = nextProps.X2.Value.Value;
     }
     if (nextProps.Y2.HasValue)
     {
         Element.Y2 = nextProps.Y2.Value.Value;
     }
 }
Esempio n. 21
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.ResizeDirection.HasValue)
     {
         Element.ResizeDirection = nextProps.ResizeDirection.Value.Value;
     }
     if (nextProps.ResizeBehavior.HasValue)
     {
         Element.ResizeBehavior = nextProps.ResizeBehavior.Value.Value;
     }
     if (nextProps.ShowsPreview.HasValue)
     {
         Element.ShowsPreview = nextProps.ShowsPreview.Value.Value;
     }
     if (nextProps.PreviewStyle.HasValue)
     {
         Element.PreviewStyle = nextProps.PreviewStyle.Value.Value;
     }
     if (nextProps.KeyboardIncrement.HasValue)
     {
         Element.KeyboardIncrement = nextProps.KeyboardIncrement.Value.Value;
     }
     if (nextProps.DragIncrement.HasValue)
     {
         Element.DragIncrement = nextProps.DragIncrement.Value.Value;
     }
 }
Esempio n. 22
0
 partial void PostAssignAppWidgetHostViewProperties(ISharpRenderer <global::Android.Views.View> renderer, int level, NewState newState, TProps previous, TProps nextProps);
Esempio n. 23
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.Style.HasValue)
     {
         Element.Style = nextProps.Style.Value.Value;
     }
     if (nextProps.OverridesDefaultStyle.HasValue)
     {
         Element.OverridesDefaultStyle = nextProps.OverridesDefaultStyle.Value.Value;
     }
     if (nextProps.UseLayoutRounding.HasValue)
     {
         Element.UseLayoutRounding = nextProps.UseLayoutRounding.Value.Value;
     }
     if (nextProps.Resources.HasValue)
     {
         Element.Resources = nextProps.Resources.Value.Value;
     }
     if (nextProps.DataContext.HasValue)
     {
         Element.DataContext = nextProps.DataContext.Value.Value;
     }
     if (nextProps.BindingGroup.HasValue)
     {
         Element.BindingGroup = nextProps.BindingGroup.Value.Value;
     }
     if (nextProps.Language.HasValue)
     {
         Element.Language = nextProps.Language.Value.Value;
     }
     if (nextProps.Name.HasValue)
     {
         Element.Name = nextProps.Name.Value.Value;
     }
     if (nextProps.Tag.HasValue)
     {
         Element.Tag = nextProps.Tag.Value.Value;
     }
     if (nextProps.InputScope.HasValue)
     {
         Element.InputScope = nextProps.InputScope.Value.Value;
     }
     if (nextProps.LayoutTransform.HasValue)
     {
         Element.LayoutTransform = nextProps.LayoutTransform.Value.Value;
     }
     if (nextProps.Width.HasValue)
     {
         Element.Width = nextProps.Width.Value.Value;
     }
     if (nextProps.MinWidth.HasValue)
     {
         Element.MinWidth = nextProps.MinWidth.Value.Value;
     }
     if (nextProps.MaxWidth.HasValue)
     {
         Element.MaxWidth = nextProps.MaxWidth.Value.Value;
     }
     if (nextProps.Height.HasValue)
     {
         Element.Height = nextProps.Height.Value.Value;
     }
     if (nextProps.MinHeight.HasValue)
     {
         Element.MinHeight = nextProps.MinHeight.Value.Value;
     }
     if (nextProps.MaxHeight.HasValue)
     {
         Element.MaxHeight = nextProps.MaxHeight.Value.Value;
     }
     if (nextProps.FlowDirection.HasValue)
     {
         Element.FlowDirection = nextProps.FlowDirection.Value.Value;
     }
     if (nextProps.Margin.HasValue)
     {
         Element.Margin = nextProps.Margin.Value.Value;
     }
     if (nextProps.HorizontalAlignment.HasValue)
     {
         Element.HorizontalAlignment = nextProps.HorizontalAlignment.Value.Value;
     }
     if (nextProps.VerticalAlignment.HasValue)
     {
         Element.VerticalAlignment = nextProps.VerticalAlignment.Value.Value;
     }
     if (nextProps.FocusVisualStyle.HasValue)
     {
         Element.FocusVisualStyle = nextProps.FocusVisualStyle.Value.Value;
     }
     if (nextProps.Cursor.HasValue)
     {
         Element.Cursor = nextProps.Cursor.Value.Value;
     }
     if (nextProps.ForceCursor.HasValue)
     {
         Element.ForceCursor = nextProps.ForceCursor.Value.Value;
     }
     if (nextProps.ToolTip.HasValue)
     {
         Element.ToolTip = nextProps.ToolTip.Value.Value;
     }
     if (nextProps.ContextMenu.HasValue)
     {
         Element.ContextMenu = nextProps.ContextMenu.Value.Value;
     }
     if (!ReferenceEquals(previous?.TargetUpdated, null) && ReferenceEquals(nextProps.TargetUpdated, null))
     {
         Element.TargetUpdated -= nextProps.TargetUpdated;
     }
     if (ReferenceEquals(previous?.TargetUpdated, null) && !ReferenceEquals(nextProps.TargetUpdated, null))
     {
         Element.TargetUpdated += nextProps.TargetUpdated;
     }
     if (!ReferenceEquals(previous?.SourceUpdated, null) && ReferenceEquals(nextProps.SourceUpdated, null))
     {
         Element.SourceUpdated -= nextProps.SourceUpdated;
     }
     if (ReferenceEquals(previous?.SourceUpdated, null) && !ReferenceEquals(nextProps.SourceUpdated, null))
     {
         Element.SourceUpdated += nextProps.SourceUpdated;
     }
     if (!ReferenceEquals(previous?.DataContextChanged, null) && ReferenceEquals(nextProps.DataContextChanged, null))
     {
         Element.DataContextChanged -= nextProps.DataContextChanged;
     }
     if (ReferenceEquals(previous?.DataContextChanged, null) && !ReferenceEquals(nextProps.DataContextChanged, null))
     {
         Element.DataContextChanged += nextProps.DataContextChanged;
     }
     if (!ReferenceEquals(previous?.RequestBringIntoView, null) && ReferenceEquals(nextProps.RequestBringIntoView, null))
     {
         Element.RequestBringIntoView -= nextProps.RequestBringIntoView;
     }
     if (ReferenceEquals(previous?.RequestBringIntoView, null) && !ReferenceEquals(nextProps.RequestBringIntoView, null))
     {
         Element.RequestBringIntoView += nextProps.RequestBringIntoView;
     }
     if (!ReferenceEquals(previous?.SizeChanged, null) && ReferenceEquals(nextProps.SizeChanged, null))
     {
         Element.SizeChanged -= nextProps.SizeChanged;
     }
     if (ReferenceEquals(previous?.SizeChanged, null) && !ReferenceEquals(nextProps.SizeChanged, null))
     {
         Element.SizeChanged += nextProps.SizeChanged;
     }
     if (!ReferenceEquals(previous?.Initialized, null) && ReferenceEquals(nextProps.Initialized, null))
     {
         Element.Initialized -= nextProps.Initialized;
     }
     if (ReferenceEquals(previous?.Initialized, null) && !ReferenceEquals(nextProps.Initialized, null))
     {
         Element.Initialized += nextProps.Initialized;
     }
     if (!ReferenceEquals(previous?.Loaded, null) && ReferenceEquals(nextProps.Loaded, null))
     {
         Element.Loaded -= nextProps.Loaded;
     }
     if (ReferenceEquals(previous?.Loaded, null) && !ReferenceEquals(nextProps.Loaded, null))
     {
         Element.Loaded += nextProps.Loaded;
     }
     if (!ReferenceEquals(previous?.Unloaded, null) && ReferenceEquals(nextProps.Unloaded, null))
     {
         Element.Unloaded -= nextProps.Unloaded;
     }
     if (ReferenceEquals(previous?.Unloaded, null) && !ReferenceEquals(nextProps.Unloaded, null))
     {
         Element.Unloaded += nextProps.Unloaded;
     }
     if (!ReferenceEquals(previous?.ToolTipOpening, null) && ReferenceEquals(nextProps.ToolTipOpening, null))
     {
         Element.ToolTipOpening -= nextProps.ToolTipOpening;
     }
     if (ReferenceEquals(previous?.ToolTipOpening, null) && !ReferenceEquals(nextProps.ToolTipOpening, null))
     {
         Element.ToolTipOpening += nextProps.ToolTipOpening;
     }
     if (!ReferenceEquals(previous?.ToolTipClosing, null) && ReferenceEquals(nextProps.ToolTipClosing, null))
     {
         Element.ToolTipClosing -= nextProps.ToolTipClosing;
     }
     if (ReferenceEquals(previous?.ToolTipClosing, null) && !ReferenceEquals(nextProps.ToolTipClosing, null))
     {
         Element.ToolTipClosing += nextProps.ToolTipClosing;
     }
     if (!ReferenceEquals(previous?.ContextMenuOpening, null) && ReferenceEquals(nextProps.ContextMenuOpening, null))
     {
         Element.ContextMenuOpening -= nextProps.ContextMenuOpening;
     }
     if (ReferenceEquals(previous?.ContextMenuOpening, null) && !ReferenceEquals(nextProps.ContextMenuOpening, null))
     {
         Element.ContextMenuOpening += nextProps.ContextMenuOpening;
     }
     if (!ReferenceEquals(previous?.ContextMenuClosing, null) && ReferenceEquals(nextProps.ContextMenuClosing, null))
     {
         Element.ContextMenuClosing -= nextProps.ContextMenuClosing;
     }
     if (ReferenceEquals(previous?.ContextMenuClosing, null) && !ReferenceEquals(nextProps.ContextMenuClosing, null))
     {
         Element.ContextMenuClosing += nextProps.ContextMenuClosing;
     }
 }
Esempio n. 24
0
 public override void AssignProperties(ISharpRenderer <Elements.UIElement> renderer, int level,
                                       NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     UpdateUIElementWithInstanceProperties(Element, previous, nextProps);
 }
Esempio n. 25
0
 partial void PostAssignActionBarContainerProperties(ISharpRenderer <global::Android.Views.View> renderer, int level, NewState newState, TProps previous, TProps nextProps);
Esempio n. 26
0
 partial void PostAssignExtractEditTextProperties(ISharpRenderer <global::Android.Views.View> renderer, int level, NewState newState, TProps previous, TProps nextProps);
Esempio n. 27
0
 private void OnNewState(State newState)
 {
     NewState?.Invoke(this, new EventArgs <State>(newState));
 }
Esempio n. 28
0
 public override void AssignProperties(ISharpRenderer <global::Android.Views.View> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     UpdateGridLayoutWithInstanceProperties(Element, previous, nextProps);
     PostAssignGridLayoutProperties(renderer, level, newState, previous, nextProps);
 }
Esempio n. 29
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
     if (nextProps.ViewingMode.HasValue)
     {
         Element.ViewingMode = nextProps.ViewingMode.Value.Value;
     }
     if (nextProps.IsPageViewEnabled.HasValue)
     {
         Element.IsPageViewEnabled = nextProps.IsPageViewEnabled.Value.Value;
     }
     if (nextProps.IsTwoPageViewEnabled.HasValue)
     {
         Element.IsTwoPageViewEnabled = nextProps.IsTwoPageViewEnabled.Value.Value;
     }
     if (nextProps.IsScrollViewEnabled.HasValue)
     {
         Element.IsScrollViewEnabled = nextProps.IsScrollViewEnabled.Value.Value;
     }
     if (nextProps.IsFindEnabled.HasValue)
     {
         Element.IsFindEnabled = nextProps.IsFindEnabled.Value.Value;
     }
     if (nextProps.IsPrintEnabled.HasValue)
     {
         Element.IsPrintEnabled = nextProps.IsPrintEnabled.Value.Value;
     }
     if (nextProps.Document.HasValue)
     {
         Element.Document = nextProps.Document.Value.Value;
     }
     if (nextProps.Zoom.HasValue)
     {
         Element.Zoom = nextProps.Zoom.Value.Value;
     }
     if (nextProps.MaxZoom.HasValue)
     {
         Element.MaxZoom = nextProps.MaxZoom.Value.Value;
     }
     if (nextProps.MinZoom.HasValue)
     {
         Element.MinZoom = nextProps.MinZoom.Value.Value;
     }
     if (nextProps.ZoomIncrement.HasValue)
     {
         Element.ZoomIncrement = nextProps.ZoomIncrement.Value.Value;
     }
     if (nextProps.SelectionBrush.HasValue)
     {
         Element.SelectionBrush = nextProps.SelectionBrush.Value.Value;
     }
     if (nextProps.SelectionOpacity.HasValue)
     {
         Element.SelectionOpacity = nextProps.SelectionOpacity.Value.Value;
     }
     if (nextProps.IsInactiveSelectionHighlightEnabled.HasValue)
     {
         Element.IsInactiveSelectionHighlightEnabled = nextProps.IsInactiveSelectionHighlightEnabled.Value.Value;
     }
 }
Esempio n. 30
0
 public override void AssignProperties(ISharpRenderer <global::System.Windows.UIElement> renderer, int level, NewState newState, TProps previous, TProps nextProps)
 {
     base.AssignProperties(renderer, level, newState, previous, nextProps);
 }
        public override void Update(GameTime gameTime)
        {
            if (ifInterpolate)
            {
                CalculateInterpolationAmount(gameTime, this.currentInterpolationTimeMS, this.interDirection, ref this.currentInterpolation);
                if (currentInterpolation >= 1.0f)
                {
                    this.CurrentState               = NewState;
                    this.NewState                   = null;
                    this.currentInterpolation       = 0.0f;
                    this.currentInterpolationTimeMS = 0;
                    this.ifInterpolate              = false;
                }
                else if (currentInterpolation <= 0.0f)
                {
                    this.interDirection             = 1.0f;
                    this.NewState                   = null;
                    this.currentInterpolation       = 0.0f;
                    this.currentInterpolationTimeMS = 0;
                    this.ifInterpolate              = false;
                }
            }

            if (ifHelperInterpolate)
            {
                //Debug.Log(this.hCurrentInterpolation.ToString() + " " + gameTime.TotalGameTime.Seconds.ToString());
                CalculateInterpolationAmount(gameTime, this.hCurrentInterpolationTimeMS, this.hInterDirection, ref this.hCurrentInterpolation);
                if (hCurrentInterpolation >= 1.0f && this.hInterDirection == 1.0f) // we've interpolated TO and playing this animation atm
                {
                    this.ifHelperInterpolate = false;
                }
                else if (hCurrentInterpolation <= 0.0f && this.hInterDirection == -1.0f)  // we've ended this animation permanently
                {
                    this.ThirdState.Animation.StopClip();
                    this.ThirdState                  = null;
                    this.hCurrentInterpolation       = 0.0f;
                    this.hCurrentInterpolationTimeMS = 0;
                    this.hInterDirection             = 1.0f;
                    this.ifHelperInterpolate         = false;
                }
            }

            if (CurrentState != null)
            {
                CurrentState.Update(gameTime);
            }
            if (NewState != null)
            {
                NewState.Update(gameTime);
            }
            if (ThirdState != null)
            {
                ThirdState.Update(gameTime);
            }

            if (ThirdState != null && !ifHelperInterpolate)
            {
                // if animation is about to finish, let's interpolate back to original two states
                // first let's check time we are in now and compare it with "Back" animation transition time
                TimeSpan backTime = ThirdState.GetTimeByTransition(CurrentState);
                if (backTime == TimeSpan.Zero)
                {
                    Debug.Log("ANIMATOR ERROR: ThirdState cannot make a transition to CurrentState, because the latter is not on its transition list.");
                    return;
                }

                TimeSpan currentTime  = ThirdState.Animation.CurrentTime;
                TimeSpan durationTime = ThirdState.Animation.CurrentClip.Duration;

                if (currentTime >= (durationTime - backTime))
                {
                    // now launch interpolation back
                    this.hInterDirection             = -1.0f;
                    this.hCurrentInterpolationTimeMS = (int)backTime.TotalMilliseconds;
                    this.ifHelperInterpolate         = true;
                    this.hCurrentInterpolation       = 0.9999f;
                }
            }

            //Debug.Log((CurrentState != null ? CurrentState.Name : "null") + " " +
            // (NewState != null ? NewState.Name : "null") + " " + gameTime.TotalGameTime.Seconds.ToString());
        }
Esempio n. 32
0
 partial void PostAssignFragmentTabHostProperties(ISharpRenderer <global::Android.Views.View> renderer, int level, NewState newState, TProps previous, TProps nextProps);
Esempio n. 33
0
 /// <summary>
 /// 修改新闻
 /// </summary>
 public void EditNews(string id, string title, string categoryId, string userId, string departId, string content,NewState state = NewState.Enabled, DateTime? openTime = null)
 {
     ENews news = GetNews(id);
     if (news == null)
     {
         throw new DbNotFoundException();
     }
     if (title != null)
     {
         news.Title = title;
     }
     if (categoryId != null)
     {
         SubCategory subC = Dc.SubCategory.Find(categoryId);
         if (subC == null)
         {
             throw new DbNotFoundException();
         }
         news.SubCategoryID = categoryId;
     }
     if (userId != null)
     {
         EUser user = Dc.User.Find(userId);
         if (user == null)
         {
             throw new DbNotFoundException();
         }
         news.UserID = userId;
     }
     if (departId != null)
     {
         EDepartment dp = Dc.Department.Find(departId);
         if (dp == null)
         {
             throw new DbNotFoundException();
         }
         news.DepartmentID = departId;
     }
     if (content != null)
     {
         news.Content = content;
     }
     if (openTime != null)
     {
         news.LazyTime = openTime;
     }
     news.State = state;
     try
     {
         Dc.SaveChanges();
     }
     catch (InvalidOperationException)
     {
         throw new DbSaveException();
     }
 }