Exemplo n.º 1
0
 /// <summary>
 /// Adds the message handler. It must initialize binding between the <see cref="IMessageHandler" /> and the local data resources.
 /// </summary>
 /// <param name="messageHandler">The message handler.</param>
 /// <param name="configuration">The configuration.</param>
 internal protected virtual void AddMessageHandler(IMessageHandler messageHandler, AssociationConfiguration configuration)
 {
     DataSetId = new DataSelector()
     {
         DataSetWriterId = configuration.DataSetWriterId, PublisherId = configuration.PublisherId
     };
 }
        private DataTable SelectData(User user, Selector selector)
        {
            DataTable    table  = new DataTable();
            DataSelector select = new DataSelector();

            if (selector.SelectorOption == SelectorOptions.GetSummary)
            {
                table = select.GetSummary(selector.Predicates["dateStart"], selector.Predicates["dateEnd"]);
            }
            else if (selector.SelectorOption == SelectorOptions.GetSign)
            {
                table = select.GetSigns();
            }
            else if (selector.SelectorOption == SelectorOptions.GetProjects)
            {
                table = select.GetProjects();
            }
            else if (selector.SelectorOption == SelectorOptions.GetAccountables)
            {
                table = select.GetAccountables();
            }
            else if (selector.SelectorOption == SelectorOptions.GetItems)
            {
                table = select.GetItems();
            }

            return(table);
        }
Exemplo n.º 3
0
        public async Task <bool> LoadPlugin(string pluginUrl)
        {
            try
            {
                string filepath = null;

                if (File.Exists(pluginUrl))
                {
                    filepath = pluginUrl;
                }
                else
                {
                    Uri uri = new Uri(pluginUrl);
                    filepath = FindLocalisedPlugin(uri);

                    if (filepath is null)
                    {
                        using (HttpClient client = new HttpClient())
                        {
                            var    streamTask = client.GetStreamAsync(uri);
                            string localDir   = LocalDirectory(uri);
                            if (!Directory.Exists(localDir))
                            {
                                Directory.CreateDirectory(localDir);
                            }

                            var    stream        = await streamTask;
                            string localisedFile = Path.Combine(localDir, Path.GetFileName(pluginUrl));
                            using (FileStream fstream = new FileStream(localisedFile, FileMode.CreateNew))
                            {
                                await stream.CopyToAsync(fstream);
                            }

                            if (Path.GetExtension(pluginUrl).Equals(".zip", StringComparison.OrdinalIgnoreCase))
                            {
                                ZipFile.ExtractToDirectory(localisedFile, localDir);
                            }
                        }
                    }

                    filepath = FindLocalisedPlugin(uri);
                }

                if (filepath != null && File.Exists(filepath))
                {
                    Assembly.LoadFrom(filepath);
                    XMeeplangDeserialiser.InvalidateCache();
                    DataSelector.InvalidateCache();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "{0} thrown trying to load plugin {1}: {2}", ex.GetType().Name, pluginUrl, ex.Message);
            }
            return(false);
        }
Exemplo n.º 4
0
        protected string RenderAttributes(DataSelector target, Rect rect, List <string> segments, string value)
        {
            var attributes = target.GetAttributes(segments);

            attributes.Insert(0, "No Selection");
            var index = value == null ? 0 : attributes.FindIndex(a => a == value);

            var newIndex = EditorGUI.Popup(rect, index, attributes.ToArray());

            return(newIndex <= 0 ? null : attributes[newIndex]);
        }
Exemplo n.º 5
0
        protected virtual DateTime GetDateFromForm(string title)
        {
            DateTime     result = ConfigTempoSinglenton.GetInstance().WorkDate;
            DataSelector ds     = new DataSelector(result, title, false);

            ds.ShowDialog();
            if (ds.DialogResult.HasValue && ds.DialogResult.Value)
            {
                result = ds.SelectedDate;
                //confi.DataContext = vm.ConfigParams;
            }
            return(result);
        }
Exemplo n.º 6
0
        public override async Task <Message> HandleMessage(Message msg)
        {
            if (From == null)
            {
                From = "{msg.AsJSON}";
            }

            MessageContext context = new MessageContext(msg, this);

            string dsAs   = null;
            string dsFrom = null;

            try
            {
                dsAs = await As.SelectStringAsync(context);

                dsFrom = await From.SelectStringAsync(context);

                if (String.IsNullOrWhiteSpace(dsAs))
                {
                    return(null);
                }

                if (!Directory.Exists(Path.GetDirectoryName(dsAs)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(dsAs));
                }

                if (!File.Exists(dsAs))
                {
                    File.Create(dsAs);
                }

                await File.WriteAllTextAsync(dsAs, dsFrom);

                return(new LocalisedResource
                {
                    DerivedFrom = msg,
                    Local = dsAs
                });
            }
            catch (Exception ex)
            {
                logger.Warn(ex, "{0} thrown when saving to {1}: {2}", ex.GetType().Name, dsAs, ex.Message);
                return(null);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                DataSelector provider = new DataSelector();
                StudentModel data     = provider.obtainData();

                if (null != data)
                {
                    this.filler.Fill(data);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 8
0
        public void ReadXML(XmlReader reader)
        {
            this.Name = reader.GetAttribute("Name");

            while (reader.NodeType != XmlNodeType.Text && reader.NodeType != XmlNodeType.EndElement)
            {
                if (!reader.Read())
                {
                    return;
                }

                if (reader.NodeType == XmlNodeType.Text)
                {
                    Content = reader.ReadContentAsString();
                }
            }
        }
Exemplo n.º 9
0
        public void BinaryUDPPackageWriterTestMethod()
        {
            int _port = 35678;

            using (BinaryUDPPackageWriter _writer = new BinaryUDPPackageWriter("localhost", _port, new Helpers.UABinaryEncoderImplementation()))
            {
                Assert.AreEqual <int>(0, _writer.m_NumberOfSentBytes);
                Assert.AreEqual <int>(0, _writer.m_NumberOfAttachToNetwork);
                Assert.AreEqual <int>(0, _writer.m_NumberOfSentMessages);
                Assert.AreEqual <HandlerState>(HandlerState.Disabled, _writer.State.State);
                _writer.AttachToNetwork();
                Assert.AreEqual <HandlerState>(HandlerState.Operational, _writer.State.State);
                Assert.AreEqual <int>(1, _writer.m_NumberOfAttachToNetwork);
                Assert.AreEqual <int>(0, _writer.m_NumberOfSentBytes);
                Assert.AreEqual <int>(0, _writer.m_NumberOfSentMessages);
                ProducerBinding _binding = new ProducerBinding()
                {
                    Value = String.Empty
                };
                int          _sentItems        = 0;
                Guid         m_Guid            = CommonDefinitions.TestGuid;
                DataSelector _testDataSelector = new DataSelector()
                {
                    DataSetWriterId = CommonDefinitions.DataSetId, PublisherId = CommonDefinitions.TestGuid
                };
                ((IMessageWriter)_writer).Send((x) => { _binding.Value = CommonDefinitions.TestValues[x]; _sentItems++; return(_binding); },
                                               Convert.ToUInt16(CommonDefinitions.TestValues.Length),
                                               UInt64.MaxValue,
                                               FieldEncodingEnum.VariantFieldEncoding,
                                               _testDataSelector,
                                               0,
                                               CommonDefinitions.TestMinimalDateTime, new ConfigurationVersionDataType()
                {
                    MajorVersion = 0, MinorVersion = 0
                }
                                               );
                Assert.AreEqual(CommonDefinitions.TestValues.Length, _sentItems);
                Assert.AreEqual <int>(1, _writer.m_NumberOfAttachToNetwork);
                Assert.AreEqual <int>(115, _writer.m_NumberOfSentBytes);
                Assert.AreEqual <int>(1, _writer.m_NumberOfSentMessages);
                byte[] _shouldBeInBuffer = CommonDefinitions.GetTestBinaryArrayVariant4Consumer();
                byte[] _outputBuffer     = _writer.DoUDPRead();
                CollectionAssert.AreEqual(_outputBuffer, _shouldBeInBuffer);
            }
        }
        public void BinaryUDPPackageWriterTestMethod()
        {
            BinaryDataTransferGraphSenderFixture _binaryStreamObservable = new BinaryDataTransferGraphSenderTest();

            using (BinaryEncoder _writer = new BinaryEncoder(_binaryStreamObservable, new Helpers.UABinaryEncoderImplementation(), MessageLengthFieldTypeEnum.TwoBytes))
            {
                Assert.AreEqual <int>(0, _binaryStreamObservable.m_NumberOfSentBytes);
                Assert.AreEqual <int>(0, _binaryStreamObservable.NumberOfAttachToNetwork);
                Assert.AreEqual <int>(0, _binaryStreamObservable.m_NumberOfSentMessages);
                Assert.AreEqual <HandlerState>(HandlerState.Disabled, _binaryStreamObservable.State.State);
                _writer.AttachToNetwork();
                _writer.State.Enable();
                Assert.AreEqual <HandlerState>(HandlerState.Operational, _binaryStreamObservable.State.State);
                Assert.AreEqual <int>(1, _binaryStreamObservable.NumberOfAttachToNetwork);
                Assert.AreEqual <int>(0, _binaryStreamObservable.m_NumberOfSentBytes);
                Assert.AreEqual <int>(0, _binaryStreamObservable.m_NumberOfSentMessages);
                ProducerBindingFixture _binding = new ProducerBindingFixture()
                {
                    Value = string.Empty
                };
                int          _sentItems        = 0;
                Guid         m_Guid            = CommonDefinitions.TestGuid;
                DataSelector _testDataSelector = new DataSelector()
                {
                    DataSetWriterId = CommonDefinitions.DataSetId, PublisherId = CommonDefinitions.TestGuid
                };
                ((IMessageWriter)_writer).Send((x) => { _binding.Value = CommonDefinitions.TestValues[x]; _sentItems++; return(_binding); },
                                               Convert.ToUInt16(CommonDefinitions.TestValues.Length),
                                               ulong.MaxValue,
                                               FieldEncodingEnum.VariantFieldEncoding,
                                               _testDataSelector,
                                               0,
                                               CommonDefinitions.TestMinimalDateTime, new ConfigurationVersionDataType()
                {
                    MajorVersion = 0, MinorVersion = 0
                }
                                               );
                Assert.AreEqual(CommonDefinitions.TestValues.Length, _sentItems);
                Assert.AreEqual <int>(1, _binaryStreamObservable.NumberOfAttachToNetwork);
                Assert.AreEqual <int>(115, _binaryStreamObservable.m_NumberOfSentBytes);
                Assert.AreEqual <int>(1, _binaryStreamObservable.m_NumberOfSentMessages);
                byte[] _shouldBeInBuffer = CommonDefinitions.GetTestBinaryArrayVariant4Consumer();
                CollectionAssert.AreEqual(_binaryStreamObservable.Buffer, _shouldBeInBuffer);
            }
        }
Exemplo n.º 11
0
        private void RenderBackgroundColor(DataSelector target, Rect position, SerializedProperty property, GUIContent label)
        {
            if (target.GenericType == null || target.SelectedType == null)
            {
                return;
            }

            Color backgroundColor;

            backgroundColor = target.GenericType == target.SelectedType ? Color.green : Color.red;

            var texture = MakeTex(500, (int)GetPropertyHeight(property, label), backgroundColor);
            var rect    = new Rect(position.x, position.y, texture.width, texture.height);

            var style = new GUIStyle();

            style.normal.background = texture;
            EditorGUI.LabelField(rect, GUIContent.none, style);
        }
Exemplo n.º 12
0
        public void Test()
        {
            // 1
            Assert.AreEqual <int>(data.Where(x => x % 2 == 0).Max(), 8);
            Assert.AreEqual <int>(data.Where(x => x % 2 == 0).Min(), 2);

            // 2
            var oddNumbers = data.Where(x => x % 2 == 1);
            var c          = 1;

            oddNumbers.ToList().ForEach(x =>
            {
                Assert.AreEqual <int>(c, x);
                c += 2;
            });

            var selector = new DataSelector()
            {
                FindStrategy = x => x.Max()
            };

            Assert.AreEqual <int>(9, selector.Find(data));
        }
Exemplo n.º 13
0
        private void Button_ClickChange(object sender, RoutedEventArgs e)
        {
            ConfigTempoSinglenton currentconfig = ConfigTempoSinglenton.GetInstance();

            switch ((sender as Button).Tag.ToString())
            {
            case "firm":
                SelectFirm sf = new SelectFirm();
                sf.ShowDialog();
                if (sf.DialogResult.HasValue && sf.DialogResult.Value)
                {
                    vm.ChangeConfigValue(0, sf.CurrentFirma.Name, sf.CurrentFirma.Bulstad);
                    currentconfig.CurrentFirma = sf.CurrentFirma.Clone();
                    currentconfig.SaveConfiguration();
                    //confi.DataContext = vm.ConfigParams;
                    //AccountsViewModel avm = new AccountsViewModel();
                    //AccountView.DataContext = avm;
                }
                break;

            case "data":
                DataSelector ds = new DataSelector(currentconfig.WorkDate);
                ds.ShowDialog();
                if (ds.DialogResult.HasValue && ds.DialogResult.Value)
                {
                    currentconfig.WorkDate = ds.SelectedDate;
                    vm.ChangeConfigValue(1, ds.SelectedDate.ToShortDateString(), "Днес " + DateTime.Now.ToShortDateString());
                    currentconfig.SaveConfiguration();
                    //confi.DataContext = vm.ConfigParams;
                }
                break;

            case "user":
                //select user
                break;
            }
        }
Exemplo n.º 14
0
        public void FullDraw()
        {
            GUIStyles.OnGUI();

            if (!Selector)
            {
                Selector = ScriptableObject.CreateInstance <DataSelector>();
            }

            if (EditorUtility.scriptCompilationFailed)
            {
                EditorGUILayout.HelpBox("Has compilation errors", MessageType.Error);
            }

            if (FileSystemTracker.Instance.HasChanges)
            {
                EditorGUILayout.HelpBox("Has changes on disk", MessageType.Warning);
            }

            UnityEngine.GUI.enabled = !Application.isPlaying && !EditorUtility.scriptCompilationFailed;
            Layout.BeginHorizontal();
            Layout.Button("Save", GameState.Instance.SaveDatabase, GUILayout.Width(100));
            Layout.Button("Load", GameState.Instance.ReloadDatabase, GUILayout.Width(100));
            Layout.EndHorizontal();
            UnityEngine.GUI.enabled = true;

            ScrollPosition = GUIClipStack.BeginScroll(ScrollPosition, GUIStyles.DarkGrayBackground);

            var gameData = GameState.Instance.GameData;

            if (gameData != null)
            {
                DrawFolderContent(gameData.RootFolder);
            }
            GUIClipStack.End();
        }
Exemplo n.º 15
0
        public MainViewModel()
        {
            ConfigTempoSinglenton currentconfig = ConfigTempoSinglenton.GetInstance();

            ConfigParams = new ObservableCollection <ConfigParamModel>();
            _firmaname   = currentconfig.CurrentFirma.Name;
            _dn          = currentconfig.CurrentFirma.DDSnum;
            _bulstad     = currentconfig.CurrentFirma.Bulstad;
            _regdds      = currentconfig.CurrentFirma.RegisterDds ? "Регистрирана по ДДС" : "Нерегистрирана по ДДС";
            ConfigParams.Add(new ConfigParamModel {
                Changer = "firm", Description = currentconfig.CurrentFirma.Bulstad, Name = "Фирма", Value = currentconfig.CurrentFirma.Name
            });
            _workdate = currentconfig.WorkDate.ToLongDateString();
            if (currentconfig.Holdings != null)
            {
                if (currentconfig.Holdings.Count > currentconfig.ActiveHolding - 1)
                {
                    _holding = currentconfig.Holdings[currentconfig.ActiveHolding - 1].Name;
                }
            }
            ConfigParams.Add(new ConfigParamModel {
                Changer = "data", Description = "Днес " + DateTime.Now.ToShortDateString(), Name = "Работна дата", Value = currentconfig.WorkDate.ToShortDateString()
            });
            if (currentconfig.Periods.FirstOrDefault(e1 => e1.Fr <= currentconfig.WorkDate && e1.To >= currentconfig.WorkDate && e1.Firma == currentconfig.ActiveFirma && e1.Holding == currentconfig.ActiveHolding) != null)
            {
                DataSelector ds = new DataSelector(currentconfig.WorkDate, "Избери работна дата");
                ds.ShowDialog();
                if (ds.DialogResult.HasValue && ds.DialogResult.Value)
                {
                    currentconfig.WorkDate = ds.SelectedDate;
                    WorkDate = ds.SelectedDate.ToLongDateString();
                    currentconfig.SaveConfiguration();
                    //confi.DataContext = vm.ConfigParams;
                }
            }
        }
Exemplo n.º 16
0
 private DataExplorer()
 {
     Selector = ScriptableObject.CreateInstance <DataSelector>();
 }
Exemplo n.º 17
0
        protected void RenderSelector(Rect position, SerializedProperty property, DataSelector target)
        {
            var sourceRect     = new Rect(position.x, position.y + 18, 500, 16);
            var componentsRect = new Rect(position.x, position.y + 36, 500, 16);
            var attributesRect = new Rect(position.x, position.y + 54, 500, 16);

            EditorGUI.PropertyField(sourceRect, property.FindPropertyRelative("source"));

            if (target.source == null)
            {
                return;
            }

            // Component dropdown.
            var componentNames = target.GetComponentNames();

            if (componentNames != null)
            {
                var componentIndex = target.ComponentIndex;
                componentNames.Insert(0, "No Selection");
                target.ComponentIndex = EditorGUI.Popup(componentsRect, "Component", target.ComponentIndex, componentNames.ToArray());

                // If the selected component changes, then reset the path segment list.
                if (componentIndex != target.ComponentIndex)
                {
                    target.PathSegments = new List <string>();
                }
            }

            // If we have a component dropdown, but haven't made a selection, then skip rendering the attribute dropdowns.
            if (componentNames != null && target.ComponentIndex == 0)
            {
                return;
            }

            var segments = new List <string>();

            using (var enumerator = target.PathSegments.GetEnumerator())
            {
                do
                {
                    string current;
                    if (!enumerator.MoveNext())
                    {
                        current = null;
                    }
                    else
                    {
                        current = enumerator.Current;
                    }

                    var selectedSegment = RenderAttributes(target, attributesRect, segments, current);
                    if (selectedSegment == null)
                    {
                        break;
                    }

                    segments.Add(selectedSegment);
                    attributesRect.y += 18;
                } while (true);
            }
            target.PathSegments = segments;
        }
 /// <summary>
 /// Sends the data described by a data set collection to remote destination.
 /// </summary>
 /// <param name="producerBinding">Encapsulates functionality used by the <see cref="T:UAOOI.Networking.SemanticData.MessageHandling.IMessageWriter" /> to collect all the data (data set items) required to prepare new message and send it over the network.</param>
 /// <param name="length">Number of items to be send used to calculate the length of the message.</param>
 /// <param name="contentMask">The content mask represented as unsigned number <see cref="T:System.UInt64" />. The order of the bits starting from the least significant
 /// bit matches the order of the data items within the data set.</param>
 /// <param name="encoding">The encoding.</param>
 /// <param name="dataSelector">The data selector.</param>
 /// <param name="messageSequenceNumber">The message sequence number. A monotonically increasing sequence number assigned by the publisher to each message sent.</param>
 /// <param name="timeStamp">The time stamp - the time the Data was collected.</param>
 /// <param name="configurationVersion">The configuration version.</param>
 /// <exception cref="ArgumentOutOfRangeException">length</exception>
 public void Send
     (Func <int, IProducerBinding> producerBinding, ushort length, ulong contentMask, FieldEncodingEnum encoding, DataSelector
     dataSelector, ushort messageSequenceNumber, DateTime timeStamp, ConfigurationVersionDataType configurationVersion)
 {
     if (length > 2)
     {
         throw new ArgumentOutOfRangeException("length");
     }
     m_Buffer = new Object[length];
     for (int i = 0; i < 2; i++)
     {
         m_Buffer[i] = producerBinding(i);
     }
     m_HaveSendData = true;
 }
Exemplo n.º 19
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DataSelector ds = new DataSelector();

            ds.Show();
        }
Exemplo n.º 20
0
 public void Send
     (Func <int, IProducerBinding> producerBinding, ushort length, ulong contentMask, FieldEncodingEnum encoding, DataSelector dataSelector,
     ushort messageSequenceNumber, DateTime timeStamp, ConfigurationVersionDataType configurationVersion)
 {
     IsOk++;
     Assert.AreEqual <int>(3, length);
 }