public IPlugInAPI.strMultiReturn GetRefreshActionPostUI([AllowNull] NameValueCollection postData, IPlugInAPI.strTrigActInfo actionInfo)
        {
            IPlugInAPI.strMultiReturn result = default;
            result.DataOut     = actionInfo.DataIn;
            result.TrigActInfo = actionInfo;
            result.sResult     = string.Empty;
            if (postData != null && postData.Count > 0)
            {
                RefreshDeviceAction action = (actionInfo.DataIn != null) ?
                                             (RefreshDeviceAction)ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) :
                                             new RefreshDeviceAction();

                foreach (var pair in postData)
                {
                    string text = Convert.ToString(pair, CultureInfo.InvariantCulture);
                    if (!string.IsNullOrWhiteSpace(text) && text.StartsWith(RefreshActionUIDropDownName, StringComparison.Ordinal))
                    {
                        action.DeviceRefId = Convert.ToInt32(postData[text], CultureInfo.InvariantCulture);
                    }
                }

                result.DataOut = ObjectSerialize.SerializeToBytes(action);
            }

            return(result);
        }
Beispiel #2
0
        public new bool Save(object param = null)
        {
            try
            {
                List <Type> knownTypes = new List <Type>()
                {
                };                                            // typeof(AnimationNodeViewModel), typeof(OutputNodeViewModel) };

                string saveShadowCopy = this.Location + ".sbak";

                ObjectSerialize.Serialize(this, saveShadowCopy as string, knownTypes);

                Folder = Path.GetDirectoryName(saveShadowCopy as string);

                Name = Path.GetFileNameWithoutExtension(saveShadowCopy as string);

                File.Copy(saveShadowCopy, saveShadowCopy.Replace(".sbak", ""), true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(true);
        }
Beispiel #3
0
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.IsWriting && PhotonNetwork.IsMasterClient)
     {
         if (streamDatas.Count != 0)
         {
             string _dataJson = JsonConvert.SerializeObject(streamDatas);
             byte[] _dataByte = ObjectSerialize.Serialize(_dataJson);
             stream.SendNext(_dataByte.Length);
             stream.SendNext(_dataByte);
             streamDatas.Clear();
             byteStreamed = _dataByte.Length;
         }
         else
         {
             stream.SendNext(0);
         }
     }
     if (stream.IsReading)
     {
         int _byteCount = (int)stream.ReceiveNext();
         if (_byteCount != 0)
         {
             byteStreamed = _byteCount;
             byte[] _dataBytes = (byte[])stream.ReceiveNext();
             string _dataJson  = (string)ObjectSerialize.DeSerialize(_dataBytes);
             Dictionary <StreamDataType, string> _datas = (Dictionary <StreamDataType, string>)JsonConvert.DeserializeObject(_dataJson, typeof(Dictionary <StreamDataType, string>));
             foreach (KeyValuePair <StreamDataType, string> _data in _datas)
             {
                 ClientManager.client.RecevingData(_data.Key, _data.Value);
             }
         }
     }
 }
Beispiel #4
0
        public IPlugInAPI.strMultiReturn GetRefreshActionPostUI([AllowNull] NameValueCollection postData, IPlugInAPI.strTrigActInfo actionInfo)
        {
            IPlugInAPI.strMultiReturn result = default;
            result.DataOut     = actionInfo.DataIn;
            result.TrigActInfo = actionInfo;
            result.sResult     = string.Empty;
            if (postData != null && postData.Count > 0)
            {
                var action = (actionInfo.DataIn != null) ?
                             (TakeSnapshotAction)ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) :
                             new TakeSnapshotAction();

                foreach (var pair in postData)
                {
                    string text = Convert.ToString(pair, CultureInfo.InvariantCulture);
                    if (!string.IsNullOrWhiteSpace(text))
                    {
                        if (text.StartsWith(nameof(TakeSnapshotAction.Id), StringComparison.Ordinal))
                        {
                            action.Id = postData[text];
                        }
                        else if (text.StartsWith(NameToIdWithPrefix(nameof(TakeSnapshotAction.TimeSpan)), StringComparison.Ordinal))
                        {
                            try
                            {
                                action.TimeSpan = TimeSpan.Parse(postData[text], CultureInfo.InvariantCulture);
                            }
                            catch (Exception)
                            {
                                result.sResult += "<BR>Time span is not valid";
                            }
                        }
                        else if (text.StartsWith(NameToIdWithPrefix(nameof(TakeSnapshotAction.Interval)), StringComparison.Ordinal))
                        {
                            try
                            {
                                action.Interval = TimeSpan.Parse(postData[text], CultureInfo.InvariantCulture);
                            }
                            catch (Exception)
                            {
                                result.sResult += "<BR>Interval is not valid";
                            }
                        }
                    }
                }

                if (string.IsNullOrWhiteSpace(action.Id))
                {
                    result.sResult += "<BR>Camera is not valid";
                }
                result.DataOut = ObjectSerialize.SerializeToBytes(action);
            }

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// Opens a file and returns the corresponding VEXProjectViewModel
        /// </summary>
        /// <param name="info">The string location of the file</param>
        /// <returns>The <see cref="VEXProjectViewModel"/> for the file.</returns>
        public ContentViewModel OpenContent(object info, object param)
        {
            var location = info as string;

            if (location != null)
            {
                try
                {
                    var mProjectTreeService = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService;
                    var vm = VEFModule.UnityContainer.Resolve(typeof(VEXProjectViewModel), "") as VEXProjectViewModel;

                    var model = ObjectSerialize.Deserialize <VEXProjectModel>(location);

                    if (model == null)
                    {
                        model = VEFModule.UnityContainer.Resolve(typeof(VEXProjectModel), "") as VEXProjectModel;
                    }

                    var view = VEFModule.UnityContainer.Resolve(typeof(VEXProjectView), "") as VEXProjectView;


                    //Model details
                    model.SetLocation(info);

                    //Set the model and view
                    vm.SetModel(model);
                    vm.SetView(view);
                    vm.Title = Path.GetFileName(location);
                    (vm.View as UserControl).DataContext = model;



                    model.Open(location);

                    //      model.Document.Text = File.ReadAllText(location);
                    model.SetDirty(false);

                    mProjectTreeService.SetAsRoot(model);


                    return(vm);
                }
                catch (Exception exception)
                {
                    _loggerService.Log(exception.Message, LogCategory.Exception, LogPriority.High);
                    _loggerService.Log(exception.StackTrace, LogCategory.Exception, LogPriority.High);
                    return(null);
                }

                //Clear the undo stack
                //   model.Document.UndoStack.ClearAll();
            }
            return(null);
        }
        public IPlugInAPI.strMultiReturn GetRefreshActionPostUI([AllowNull] NameValueCollection postData, IPlugInAPI.strTrigActInfo actionInfo)
        {
            IPlugInAPI.strMultiReturn result = default;
            result.DataOut     = actionInfo.DataIn;
            result.TrigActInfo = actionInfo;
            result.sResult     = string.Empty;
            if (postData != null && postData.Count > 0)
            {
                var action = (actionInfo.DataIn != null) ?
                             (ChromecastCastAction)ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) :
                             new ChromecastCastAction();

                foreach (var pair in postData)
                {
                    string text = Convert.ToString(pair);
                    if (!string.IsNullOrWhiteSpace(text))
                    {
                        if (text.StartsWith(nameof(ChromecastCastAction.ChromecastDeviceId)))
                        {
                            action.ChromecastDeviceId = postData[text];
                        }
                        else if (text.StartsWith(nameof(ChromecastCastAction.Url)))
                        {
                            action.Url = postData[text];
                        }
                        else if (text.StartsWith(nameof(ChromecastCastAction.ContentType)))
                        {
                            action.ContentType = postData[text];
                        }
                        else if (text.StartsWith(nameof(ChromecastCastAction.Live)))
                        {
                            action.Live = postData[text] == "checked";
                        }
                    }
                }

                if (string.IsNullOrWhiteSpace(action.Url))
                {
                    result.sResult += "<BR>Url is not valid";
                }

                if (string.IsNullOrWhiteSpace(action.ChromecastDeviceId))
                {
                    result.sResult += "<BR>Chromecast device is not valid";
                }
                result.DataOut = ObjectSerialize.SerializeToBytes(action);
            }

            return(result);
        }
        public string GetRefreshActionUI(string uniqueControlId, IPlugInAPI.strTrigActInfo actionInfo)
        {
            StringBuilder       stb                 = new StringBuilder();
            var                 currentDevices      = GetCurrentDeviceImportDevices();
            RefreshDeviceAction refreshDeviceAction = ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) as RefreshDeviceAction;

            string selection = string.Empty;

            if (refreshDeviceAction != null)
            {
                selection = refreshDeviceAction.DeviceRefId.ToString(CultureInfo.InvariantCulture);
            }

            stb.Append(FormDropDown(RefreshActionUIDropDownName + uniqueControlId, currentDevices, selection, 400, string.Empty, true, "Events"));
            return(stb.ToString());
        }
Beispiel #8
0
        public string GetRefreshActionUI(string uniqueControlId, IPlugInAPI.strTrigActInfo actionInfo)
        {
            StringBuilder stb    = new StringBuilder();
            var           action = ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) as TakeSnapshotAction;

            var cameras = new NameValueCollection();

            foreach (var camera in pluginConfig.AllCameras)
            {
                cameras.Add(camera.Key, camera.Value.Name);
            }

            stb.Append(FormDropDown(nameof(TakeSnapshotAction.Id) + uniqueControlId, cameras, action?.Id ?? string.Empty, 250, string.Empty, true));
            stb.Append("for &nbsp;");
            stb.Append(FormTimeSpan(nameof(TakeSnapshotAction.TimeSpan) + uniqueControlId, string.Empty, action?.TimeSpan ?? TimeSpan.Zero, true));
            stb.Append("at interval");
            stb.Append(FormTimeSpan(nameof(TakeSnapshotAction.Interval) + uniqueControlId, string.Empty, action?.Interval ?? TimeSpan.FromSeconds(1), true));
            return(stb.ToString());
        }
Beispiel #9
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // ObservableCollection<ConnectionViewModel> test = new ObservableCollection<ConnectionViewModel>();

                AnimationNodeViewModel evm  = new AnimationNodeViewModel();
                OutputNodeViewModel    onvm = new OutputNodeViewModel();

                OutputConnectorViewModel opcvm = new OutputConnectorViewModel()
                {
                    Element = evm
                };
                InputConnectorViewModel ipcvm = new InputConnectorViewModel()
                {
                    Element = onvm
                };

                var cvm = new ConnectionViewModel()
                {
                    From = opcvm, To = ipcvm
                };
                //test.Add();

                List <Type> knownTypes = new List <Type>()
                {
                    typeof(AnimationNodeViewModel), typeof(OutputNodeViewModel)
                };

                AnimationComponent ac = new AnimationComponent();
                ac.FB_AnimationComponent.AnimationBlendTree.AnimNodes.Add(evm);
                ac.FB_AnimationComponent.AnimationBlendTree.AnimNodes.Add(onvm);
                ac.FB_AnimationComponent.AnimationBlendTree.NodeConnections.Add(cvm);

                ObjectSerialize.Serialize(ac, "./test", knownTypes);

                //   var testRes = ObjectSerialize.Deserialize<AnimationComponent>("./test");
                var testRes = ObjectSerialize.Deserialize <VEXProjectModel>(@"F:\Projekte\coop\XGame\data\Editor\New VEX Project xyy.oideProj");
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #10
0
        public bool Send(string queueName, string routingKey, MessageDto message)
        {
            try
            {
                lock (_factory)
                {
                    using (_connection = _factory.CreateConnection())
                    {
                        using (_model = _connection.CreateModel())
                        {
                            _model.ExchangeDeclare(_rabbitMQSettings.ExchangeName, _rabbitMQSettings.Type, durable: true);

                            _model.QueueDeclare(queueName, true, false, false, null);
                            _model.QueueBind(queueName, _rabbitMQSettings.ExchangeName, routingKey);

                            message.InstanceId = Me.GetInstance().Id;
                            message.RequestId  = Guid.NewGuid();
                            message.CreateAt   = DomainUtils.GetLocalDate();

                            byte[] objsend = ObjectSerialize.Serialize(message);

                            _model.BasicPublish(_rabbitMQSettings.ExchangeName, routingKey, null, objsend);
                        }
                    }
                }

                using (var scope = Services.CreateScope())
                {
                    var scopedProcessingService = scope.ServiceProvider.GetRequiredService <IMessageService>();
                    scopedProcessingService.InsertAsync(message).Wait();
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.ToString());
                _model.Dispose();
                _connection.Dispose();
                return(false);
            }
        }
Beispiel #11
0
 public void OnPhotonSerializeView(PhotonStream _stream, PhotonMessageInfo info)
 {
     if (_stream.IsWriting)
     {
         List <string> _jsonData = new List <string>
         {
             JsonConvert.SerializeObject(plyCl.mysteryPower),
             JsonConvert.SerializeObject(plyCl.BombeCount),
             JsonConvert.SerializeObject(plyCl.powerUps)
         };
         string _json = JsonConvert.SerializeObject(_jsonData);
         _stream.SendNext(ObjectSerialize.Serialize(_json));
     }
     else
     {
         List <string> _jsonData = JsonConvert.DeserializeObject <List <string> >((string)ObjectSerialize.DeSerialize((byte[])_stream.ReceiveNext()));
         plyCl.mysteryPower = JsonConvert.DeserializeObject <MysteryPower.MysteryPowers>(_jsonData[0]);
         plyCl.BombeCount   = JsonConvert.DeserializeObject <int>(_jsonData[1]);
         plyCl.powerUps     = JsonConvert.DeserializeObject <Dictionary <PowerUps, int> >(_jsonData[2]);
     }
 }
Beispiel #12
0
        private void ReceivedMessage(BasicDeliverEventArgs ea, CancellationToken stoppingToken)
        {
            Guid?receivedInstance = null;

            try
            {
                using (var scope = Services.CreateScope())
                {
                    var scopedProcessingService = scope.ServiceProvider.GetRequiredService <IMessageService>();

                    var content = Encoding.UTF8.GetString(ea.Body);

                    var obj = ObjectSerialize.TryParseJson(content, out MessageDto result);

                    if (obj)
                    {
                        receivedInstance = result.InstanceId;

                        if (result.InstanceId != Me.GetInstance().Id)
                        {
                            _logger.LogInformation("processing consumer");
                            scopedProcessingService.InsertAsync(result);
                            _logger.LogInformation($"consumer received {content}");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _channel.BasicPublish(_exchangeName, _routingKey, null, ea.Body);
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                if (receivedInstance.HasValue && receivedInstance.Value != Me.GetInstance().Id)
                {
                    _channel.BasicAck(ea.DeliveryTag, false);
                }
            }
        }
Beispiel #13
0
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.IsWriting && PhotonNetwork.IsMasterClient)
     {
         if (Maps == null)
         {
             return;
         }
         stream.SendNext(map.GetLength(0));
         stream.SendNext(map.GetLength(1));
         UpdateMap(boxSync);
         List <string> boxSyncJson = new List <string>();
         foreach (Box _box in boxSync)
         {
             boxSyncJson.Add(JsonConvert.SerializeObject(_box));
         }
         stream.SendNext(ObjectSerialize.Serialize(JsonConvert.SerializeObject(boxSyncJson)));
         boxSync = new List <Box>();
     }
     if (stream.IsReading)
     {
         int x = (int)stream.ReceiveNext();
         int y = (int)stream.ReceiveNext();
         if (map == null)
         {
             map = new Box[x, y];
         }
         byte[]        receving    = (byte[])stream.ReceiveNext();
         List <string> boxSyncJson = JsonConvert.DeserializeObject <List <string> >((string)ObjectSerialize.DeSerialize(receving));
         List <Box>    _boxSync    = new List <Box>();
         foreach (string boxJson in boxSyncJson)
         {
             Box _box = JsonConvert.DeserializeObject <Box>(boxJson);
             _boxSync.Add(_box);
             map[_box.pos.x, _box.pos.y] = _box;
         }
         UpdateMap(_boxSync);
     }
 }
        public string GetRefreshActionUI(string uniqueControlId, IPlugInAPI.strTrigActInfo actionInfo)
        {
            StringBuilder stb    = new StringBuilder();
            var           action = ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) as ChromecastCastAction;

            var chromecastDevices = new NameValueCollection();

            foreach (var device in pluginConfig.Devices)
            {
                chromecastDevices.Add(device.Key, device.Value.Name);
            }

            stb.Append(FormDropDown(nameof(ChromecastCastAction.ChromecastDeviceId) + uniqueControlId, chromecastDevices, action?.ChromecastDeviceId, 250, string.Empty, false));
            stb.Append("<p> Url:");
            stb.Append(HtmlTextBox(nameof(ChromecastCastAction.Url) + uniqueControlId, action?.Url, 100));
            stb.Append("</p><p> Content mime type:");
            stb.Append(HtmlTextBox(nameof(ChromecastCastAction.ContentType) + uniqueControlId, action?.ContentType, 50));
            stb.Append("</p><p> Live:");
            stb.Append(FormCheckBox(nameof(ChromecastCastAction.Live) + uniqueControlId, string.Empty, action?.Live ?? false));
            stb.Append("</p>");
            stb.Append(FormPageButton(SaveButtonName + uniqueControlId, "Save"));
            return(stb.ToString());
        }