Пример #1
0
 public ITransmissionContext Create(MessageLayer messageLayer, Message message)
 {
     return(new TransmissionContext(new TransmissionTimer())
     {
         Message = message
     });
 }
Пример #2
0
 private void AddNewMilitaryMessagelayer()
 {
     _militaryMessageLayer = new MessageLayer(SymbolDictionaryType.Mil2525c)
     {
         ID = Guid.NewGuid().ToString("D")
     };
     _mapView.Map.Layers.Add(_militaryMessageLayer);
 }
Пример #3
0
 private void ClearMilitaryMessageLayer()
 {
     if (_militaryMessageLayer != null && _mapView != null)
     {
         _mapView.Map.Layers.Remove(_militaryMessageLayer.ID);
         _militaryMessageLayer = null;
         AddNewMilitaryMessagelayer();
     }
 }
Пример #4
0
 public void SetUp()
 {
     _transactionMock        = new Mock <ITransmissionContext>();
     _transactionFactoryMock = new Mock <ITransmissionContextFactory>();
     _lowerLayerMock         = new Mock <ILayer>();
     _observer     = new Mock <IMessageObserver>();
     _messageLayer = new MessageLayer(_lowerLayerMock.Object, _transactionFactoryMock.Object);
     _messageLayer.RegisterObserver(_observer.Object);
     _transactionFactoryMock.Setup(f => f.Create(_messageLayer, It.IsAny <Message>())).Returns(_transactionMock.Object);
 }
Пример #5
0
        public ActionResult Edit(ModifyMessageModel model)
        {
            var updateRecipients = false;

            ModelState.Remove(model.UrlOnly ? "Text" : "Url");
            ProcessRecipientsCsvUpload csvData = new ProcessRecipientsCsvUpload
            {
                PostedFile = model.UploadedFile,
            };

            if (!csvData.CheckCsvOk()) // check csv upload before modelstate so can process irrespectively
            {
                ModelState.AddModelError("UploadedFile", csvData.Error);
                model.RecipientList = MessageLayer.FieldToRecipientList(model.RecipientsField);
                return(View(model));
            }
            if (csvData.Empty && !model.DeleteRecipients && !ModelState.IsValid)
            {
                model.RecipientList = MessageLayer.FieldToRecipientList(model.RecipientsField);
                return(View(model));
            }
            var msg = Db.CmsMessages.FirstOrDefault(m => m.Id == model.Id);

            if (msg == null)
            {
                return(new HttpNotFoundResult("Message item was not found"));
            }
            var store = MessageLayer.ConvertModifyMessageModelToStoreMessage(model);

            if (!csvData.Empty)
            {
                updateRecipients = true;
                store.Recipients = csvData.Recipients;
            }
            else if (model.DeleteRecipients)
            {
                updateRecipients = true;
                store.Recipients = "";
            }
            else
            {
                store.Recipients = model.RecipientsField;
            }
            try
            {
                MessageLayer.UpdateMessage(Db, store, msg);
            }
            catch (Exception)
            {
                //FIXME: add logging here
                model.RecipientList = MessageLayer.FieldToRecipientList(model.RecipientsField);
                return(View(model));
            }
            return(updateRecipients ? RedirectToAction("Edit", new { id = model.Id }) : RedirectToAction("Index"));
        }
Пример #6
0
        public void Run()
        {
            // Altseedを初期化する。
            asd.Engine.Initialize("Dispose_Object2D", 640, 480, new asd.EngineOption());

            // 画像を読み込む。
            var texture = asd.Engine.Graphics.CreateTexture2D("Data/Texture/Picture1.png");

            // シーンのインスタンスを生成する。
            var scene = new asd.Scene();

            // カスタマイズしたレイヤーのインスタンスを生成する。
            var layer = new MessageLayer();

            // カスタマイズしたオブジェクトのインスタンスを生成する。
            var obj = new MessageObject();

            // オブジェクトの位置とテクスチャを設定する。
            obj.Position = new asd.Vector2DF(50, 50);
            obj.Texture  = texture;

            // 描画するシーンを指定する。
            asd.Engine.ChangeScene(scene);

            // 描画するレイヤーをシーンに追加する。
            scene.AddLayer(layer);

            // 描画するオブジェクトをレイヤーに追加する。
            layer.AddObject(obj);

            // フレーム数を数えるための変数。
            int count = 0;

            // Altseedのウインドウが閉じられていないか確認する。
            while (asd.Engine.DoEvents())
            {
                // Altseedを更新する。
                asd.Engine.Update();

                // フレームを数える。
                ++count;

                // 10フレーム目になったら
                if (count == 10)
                {
                    Console.WriteLine("Layerを破棄します");
                    // レイヤーを破棄する。
                    layer.Vanish();
                }
            }

            // Altseedを終了する。
            asd.Engine.Terminate();
        }
Пример #7
0
        public HttpResponseMessage Put(UpdateMessageStatusModel model)
        {
            var access = UserRights.V2Login(Db, Request);

            if (access.HasErrors)
            {
                return(Request.CreateErrorResponse(access.ErrorCode, access.ErrorMessage));
            }
            var ok = MessageLayer.LogMessageStatus(CmsDb, model, access.Session.record_id);

            return(Request.CreateResponse(ok?HttpStatusCode.OK:HttpStatusCode.InternalServerError));
        }
Пример #8
0
        public ActionResult Archive(long id)
        {
            var msg = Db.CmsMessages.FirstOrDefault(m => m.Id == id);

            if (msg == null)
            {
                return(new HttpNotFoundResult("Message item was not found"));
            }
            var model = MessageLayer.MsgToMessageViewModel(msg, true);

            return(View(model));
        }
Пример #9
0
        //send message to all room
        public ActionResult CheckAllRoom(MessageHTML m)
        {
            MessageLayer   memlayer = new MessageLayer();
            List <Message> mlist    = memlayer.GetMessage();

            DormLayer layer       = new DormLayer();
            Dorm      dorm        = layer.GetDorm(Session["UserName"].ToString());
            int       sender_dorm = dorm.Dorm_ID;

            int         mlistid  = mlist.Count;
            Message     mem      = new Message();
            RoomLayer   RoomDB   = new RoomLayer();
            List <Room> RoomList = RoomDB.GetStatusRoom(); //only room that have person live

            foreach (Room r in RoomList)
            {
                if (r.Dorm_ID == sender_dorm)
                {
                    PersonLayer   PL            = new PersonLayer();
                    List <Person> personoomList = PL.GetPerson();
                    foreach (Person person in personoomList)
                    {
                        if (person.Room_ID == r.Room_ID)
                        {
                            mem = new Message();
                            mem.Receiver_Username = person.Username;
                            mem.Sender_Username   = Session["UserName"].ToString();
                            mem.MessageID         = mlistid + 1;
                            mem.Title             = m.Subject;
                            mem.Text   = m.Message;
                            mem.Isread = 0;
                            mem.Date   = DateTime.Now.ToString("dd-MM-yyyy") + " " +
                                         DateTime.Today.ToString("HH:mm:ss tt"); //Date + Time

                            db.Message.Add(mem);
                            db.SaveChanges();
                            mlistid++;
                        }
                    }
                }
            }


            //return mem.Receiver_Username + " " + mem.Sender_Username + " " +
            //   " " + mem.Date ;
            return(RedirectToAction("index", new
            {
                action = 1
            }));
        }
        private async void Init()
        {
            // Wait until all layers are loaded
            await MyMapView.LayersLoadedAsync();

            bool isSymbolDictionaryInitialized = false;

            try
            {
                // Create a new SymbolDictionary instance
                _symbolDictionary             = new SymbolDictionary(SymbolDictionaryType.Mil2525c);
                isSymbolDictionaryInitialized = true;
            }
            catch { }

            if (!isSymbolDictionaryInitialized)
            {
                MessageBox.Show("Failed to create symbol dictionary.", "Symbol Dictionary Search Sample");
                return;
            }

            // Collection of strings to hold the selected symbol dictionary keywords
            SelectedKeywords = new ObservableCollection <string>();

            // Remove any empty strings space from keywords
            _keywords = _symbolDictionary.Keywords.OrderBy(k => k).ToList();
            _keywords = _keywords.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();

            // Remove any empty strings space from categories
            _categories = new[] { "" }.Concat(_symbolDictionary.Filters["CATEGORY"]);
            Categories  = _categories.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct();

            // Collection of view models for the displayed list of symbols
            Symbols = new ObservableCollection <SymbolViewModel>();

            // Set the image size
            _imageSize = 64;

            // Get reference to MessageLayer to use with messages
            _messageLayer = MyMapView.Map.Layers.OfType <MessageLayer>().First();

            // Fire initial search to populate the results with all symbols
            Search();

            // Enable the UI
            btnSearch.IsEnabled = true;

            // Set the DataContext for binding
            DataContext = this;
        }
        private async void Init()
        {
            // Wait until all layers are loaded
            await MyMapView.LayersLoadedAsync();

            bool isSymbolDictionaryInitialized = false;
            try
            {
                // Create a new SymbolDictionary instance 
                _symbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);
                isSymbolDictionaryInitialized = true;
            }
            catch { }

            if (!isSymbolDictionaryInitialized)
            {
                MessageBox.Show("Failed to create symbol dictionary.", "Symbol Dictionary Search Sample");
                return;
            }

            // Collection of strings to hold the selected symbol dictionary keywords
            SelectedKeywords = new ObservableCollection<string>();

            // Remove any empty strings space from keywords
            _keywords = _symbolDictionary.Keywords.OrderBy(k => k).ToList();
            _keywords = _keywords.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();

            // Remove any empty strings space from categories
            _categories = new[] { "" }.Concat(_symbolDictionary.Filters["CATEGORY"]);
            Categories = _categories.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct();

            // Collection of view models for the displayed list of symbols
            Symbols = new ObservableCollection<SymbolViewModel>();

            // Set the image size
            _imageSize = 64;

            // Get reference to MessageLayer to use with messages
            _messageLayer = MyMapView.Map.Layers.OfType<MessageLayer>().First();

            // Fire initial search to populate the results with all symbols
            Search();

            // Enable the UI
            btnSearch.IsEnabled = true;

            // Set the DataContext for binding
            DataContext = this;
        }
Пример #12
0
        protected override void OnStart()
        {
            scene = new MessageScene();
            layer = new MessageLayer();
            obj   = new MessageObject();

            Assert.AreEqual(0, scene.Phase);
            Assert.AreEqual(false, scene.HaveBeenDisposed);
            Assert.AreEqual(false, layer.IsAdded);
            Assert.AreEqual(false, layer.HaveBeenDisposed);
            Assert.AreEqual(false, obj.IsAdded);
            Assert.AreEqual(false, obj.HaveBeenDisposed);

            Engine.ChangeSceneWithTransition(scene, new TransitionFade(0.1f, 0.1f));
        }
Пример #13
0
        private ulong ProcessAllMessages(INvgElement nvgElement, MessageLayer messageLayer)
        {
            ulong messageCount    = 0;
            var   nvgPointElement = nvgElement as NvgPointElement;

            if (TryProcessMessage(nvgPointElement, messageLayer))
            {
                messageCount++;
            }
            foreach (var nvgChildElement in nvgElement.Children)
            {
                messageCount += ProcessAllMessages(nvgChildElement, messageLayer);
            }
            return(messageCount);
        }
Пример #14
0
        public ActionResult FeedbackSubmit(string detail_feedback)
        {
            JongHorDBEntities1  db          = new JongHorDBEntities1();
            DormLayer           layer       = new DormLayer();
            PersonBusinessLayer personLayer = new PersonBusinessLayer();
            MessageLayer        memlayer    = new MessageLayer();
            List <Message>      mlist       = memlayer.GetMessage();
            int    mlistid = mlist.Count;
            Person user    = personLayer.GetUser(Session["UserName"].ToString());

            Message message = new Message();

            message.Receiver_Username = layer.GetDorm(user.Dorm_ID.Value).Person.Username;
            message.Sender_Username   = user.Username;
            message.MessageID         = mlistid + 1;
            message.Title             = "Feedback";
            Room room = user.Room;

            message.Text   = (room.Floor + "" + room.Room_ID) + ": " + detail_feedback;
            message.Isread = 0;
            message.Date   = DateTime.Now.ToString("dd-MM-yyyy") + " " +
                             DateTime.Today.ToString("HH:mm:ss tt"); //Date + Time

            db.Message.Add(message);
            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                // Combine the original exception message with the new one.
                var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                // Throw a new DbEntityValidationException with the improved exception message.
                throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
            }

            Response.Write("<script>alert('Message has been sent')</script>");
            return(Index());
        }
Пример #15
0
        private static bool TryProcessMessage(NvgPointElement nvgPointElement, MessageLayer messageLayer)
        {
            if (null != nvgPointElement)
            {
                if (!nvgPointElement.IsEmpty)
                {
                    var message = CreateMessage(nvgPointElement);
                    if (messageLayer.ProcessMessage(message))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #16
0
        public ActionResult ExportLog(ExportByDateParametersModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.From.HasValue && model.To.HasValue && model.From.Value > model.To.Value)
            {
                ModelState.AddModelError("To", "The 'From' cannot be greater than the 'To' Date");
                return(View(model));
            }

            var result = MessageLayer.ExportLogByDateToByteArray(Db, IbaDb, model.From, model.To);

            return(File(result, System.Net.Mime.MediaTypeNames.Text.Plain, "export.csv"));
        }
Пример #17
0
        private void PrepareResponse(Request request)
        {
            // consecutive response require new MID that must be stored for RST matching
            if (request.Response.ID == Message.InvalidID)
            {
                request.Response.ID = MessageLayer.NextMessageID();
            }

            // 16-bit second counter
            Int32 secs = (Int32)((DateTime.Now - request.StartTime).TotalMilliseconds / 1000) & 0xFFFF;

            request.Response.SetOption(Option.Create(OptionType.Observe, secs));

            // store ID for RST matching
            UpdateLastMessageID(request.PeerAddress.ToString(), request.UriPath, request.Response.ID);
        }
Пример #18
0
        protected override void OnStart()
        {
            var scene = new Scene();

            Engine.ChangeScene(scene);

            var layer1 = new MessageLayer("Layer1");

            layer1.UpdatePriority = 1;
            scene.AddLayer(layer1);

            var layer2 = new MessageLayer("Layer2");

            layer2.UpdatePriority = 0;
            scene.AddLayer(layer2);
        }
Пример #19
0
        public HttpResponseMessage Get([FromUri] MessageRequestModel model)
        {
            if (model == null)
            {
                model = new MessageRequestModel();
            }
            var access = UserRights.V2Login(Db, Request);

            if (access.HasErrors)
            {
                return(Request.CreateErrorResponse(access.ErrorCode, access.ErrorMessage));
            }
            var result = MessageLayer.GetMessagesFromData(CmsDb, access.Session.record_id, model);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
		// Load data - enable functionality after layers are loaded.
		private async void mapView_ExtentChanged(object sender, EventArgs e)
		{
			try
			{
				mapView.ExtentChanged -= mapView_ExtentChanged;

				// Wait until all layers are loaded
				await mapView.LayersLoadedAsync();
				
				_messageLayer = mapView.Map.Layers.OfType<MessageLayer>().First();
				processMessagesBtn.IsEnabled = true;
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "Message Processing Sample");
			}
		}
Пример #21
0
        public ActionResult Send(long id)
        {
            var msg = Db.CmsMessages.FirstOrDefault(m => m.Id == id);

            if (msg == null)
            {
                return(new HttpNotFoundResult("Message item was not found"));
            }
            if (msg.Title.IsNullOrWhiteSpace() || (msg.UrlOnly && msg.Url.IsNullOrWhiteSpace()) ||
                (!msg.UrlOnly && msg.Text.IsNullOrWhiteSpace()))
            {
                return(RedirectToAction("Edit", new { id = msg.Id }));
            }
            var model = MessageLayer.MsgToMessageViewModel(msg, true);

            return(View(model));
        }
Пример #22
0
        // Load data - enable functionality after layers are loaded.
        private async void mapView_ExtentChanged(object sender, EventArgs e)
        {
            try
            {
                mapView.ExtentChanged -= mapView_ExtentChanged;

                // Wait until all layers are loaded
                await mapView.LayersLoadedAsync();

                _messageLayer = mapView.Map.Layers.OfType <MessageLayer>().First();
                processMessagesBtn.IsEnabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message Processing Sample");
            }
        }
		// Load data - enable functionality after layers are loaded.
		private async void MyMapView_ExtentChanged(object sender, EventArgs e)
		{
			try
			{
				MyMapView.ExtentChanged -= MyMapView_ExtentChanged;

				// Wait until all layers are loaded
				var layers = await MyMapView.LayersLoadedAsync();

				_messageLayer = MyMapView.Map.Layers.OfType<MessageLayer>().First();
				processMessagesBtn.IsEnabled = true;
			}
			catch (Exception ex)
			{
				var _x = new MessageDialog(ex.Message, "Message Processing Sample").ShowAsync();
			}
		}
        // Load data - enable functionality after layers are loaded.
        private async void MyMapView_ExtentChanged(object sender, EventArgs e)
        {
            try
            {
                MyMapView.ExtentChanged -= MyMapView_ExtentChanged;

                // Wait until all layers are loaded
                var layers = await MyMapView.LayersLoadedAsync();

                _messageLayer = MyMapView.Map.Layers.OfType <MessageLayer>().First();
                processMessagesBtn.IsEnabled = true;
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Message Processing Sample").ShowAsync();
            }
        }
Пример #25
0
        /// <summary>
        /// Processes all added NVG elements using the registered map view.
        /// Make sure this method is called from the UI thread!
        /// </summary>
        public async void ProcessAllMessages()
        {
            var mapView = _viewModel.FocusMapView;

            if (null == mapView)
            {
                return;
            }

            // Create a new message layer and wait till the layer was loaded
            var messageLayer = new MessageLayer();

            mapView.Map.Layers.Add(messageLayer);
            await mapView.LayersLoadedAsync(new[] { messageLayer });

            // Process all messages
            ulong messageCount = 0;
            var   layerName    = @"Message Layer";

            foreach (var nvgElement in _nvgElements)
            {
                messageCount += ProcessAllMessages(nvgElement, messageLayer);
            }

            // If only one NVG element was processed use the filename as the layer name
            if (1 == _nvgElements.Count)
            {
                var nvgFileMetadata = _nvgElements.First() as INvgFileMetadata;
                if (null != nvgFileMetadata?.FileInfo)
                {
                    layerName = nvgFileMetadata.FileInfo.Name;
                }
            }

            var nvgLayerItem = new NvgLayerItem(messageLayer)
            {
                Name         = layerName,
                MessageCount = messageCount
            };

            LayerItems.Add(nvgLayerItem);

            // Clear the elements
            _nvgElements.Clear();
        }
		public SymbolDictionarySearchSample()
		{
			InitializeComponent();
			// Create a new SymbolDictionary instance 
			_symbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);
			_keywords = _symbolDictionary.Keywords.ToList();

			// Collection of view models for the displayed list of symbols
			Symbols = new ObservableCollection<SymbolViewModel>();

			// Set the DataContext for binding
			DataContext = this;
			// Set the image size
			_imageSize = 40;

			// Get reference to MessageLayer to use with messages
			_messageLayer = mapView.Map.Layers.OfType<MessageLayer>().First();
		}
Пример #27
0
        private ModifyMessageModel MessageToModifyMessageModel(CmsMessage msg)
        {
            var result = new ModifyMessageModel
            {
                UrlOnly         = msg.UrlOnly,
                Text            = msg.Text,
                Url             = msg.Url,
                Id              = msg.Id,
                MessageType     = msg.MessageType,
                Title           = msg.Title,
                RecipientsField = msg.Recipients,
                SendDateTime    = msg.SendDate,
                TimeZone        = msg.TimeZone,
                RecipientList   = MessageLayer.FieldToRecipientList(msg.Recipients)
            };

            return(result);
        }
Пример #28
0
        public SymbolDictionarySearchSample()
        {
            InitializeComponent();
            // Create a new SymbolDictionary instance
            _symbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);
            _keywords         = _symbolDictionary.Keywords.ToList();

            // Collection of view models for the displayed list of symbols
            Symbols = new ObservableCollection <SymbolViewModel>();

            // Set the DataContext for binding
            DataContext = this;
            // Set the image size
            _imageSize = 40;

            // Get reference to MessageLayer to use with messages
            _messageLayer = mapView.Map.Layers.OfType <MessageLayer>().First();
        }
Пример #29
0
        public async Task <ActionResult> Send(MessageViewModel model)
        {
            try
            {
                var msg = Db.CmsMessages.FirstOrDefault(m => m.Id == model.Id);
                if (msg == null)
                {
                    return(new HttpNotFoundResult("Message item was not found"));
                }
                msg.Status = CmsMessageStatus.Outbox;
                MessageLayer.ProcessOneMessage(Db, msg);
                await MessageLayer.SendMessage(Db, msg.Id, msg.SendDate);

                Db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View(model));
            }
        }
Пример #30
0
        protected override void OnStart()
        {
            var scene = new Scene();

            layer1 = new MessageLayer()
            {
                Name = "Layer1"
            };
            var layer2 = new MessageLayer()
            {
                Name = "Layer2"
            };

            obj1 = new MessageObject("Object1");
            var obj2 = new MessageObject("Object2");

            Engine.ChangeScene(scene);
            scene.AddLayer(layer1);
            scene.AddLayer(layer2);
            layer1.AddObject(obj1);
            layer1.AddObject(obj2);
        }
Пример #31
0
        private bool ProcessMessage(MessageLayer messageLayer, Message msg)
        {
            if (messageLayer != null && msg != null)
            {
                var result = messageLayer.ProcessMessage(msg);

                if (!_phaseMessageDictionary.ContainsKey(messageLayer.ID))
                {
                    _phaseMessageDictionary.Add(messageLayer.ID, new List <string>());
                }

                if (!_phaseMessageDictionary[messageLayer.ID].Contains(msg.Id))
                {
                    // add
                    _phaseMessageDictionary[messageLayer.ID].Add(msg.Id);
                }

                return(result);
            }

            return(false);
        }
Пример #32
0
        private ActionResult DoCreate(ModifyMessageModel model)
        {
            ModelState.Remove(model.UrlOnly ? "Text" : "Url");
            ProcessRecipientsCsvUpload csvData = new ProcessRecipientsCsvUpload
            {
                PostedFile = model.UploadedFile,
            };

            if (!csvData.CheckCsvOk()) // check csv upload before modelstate so can process irrespectively
            {
                ModelState.AddModelError("UploadedFile", csvData.Error);
                model.RecipientList = MessageLayer.FieldToRecipientList(model.RecipientsField);
                return(View("Create", model));
            }
            if (csvData.Empty && !ModelState.IsValid)
            {
                model.RecipientList = MessageLayer.FieldToRecipientList(model.RecipientsField);
                return(View("Create", model));
            }
            var store = MessageLayer.ConvertModifyMessageModelToStoreMessage(model);

            store.UserId = User.Identity.GetUserId();
            if (!csvData.Empty)
            {
                store.Recipients = csvData.Recipients;
            }
            //model.Recipients;
            if (!MessageLayer.AddMessage(Db, store))
            {
                model.RecipientList = MessageLayer.FieldToRecipientList(model.RecipientsField);
                return(View("Create", model));
            }
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Edit", new { id = store.NewId }));
            }
            return(RedirectToAction("Index"));
        }
        private async void Init()
        {
            // Wait until all layers are loaded
            await MyMapView.LayersLoadedAsync();

            bool isSymbolDictionaryInitialized = false;

            try
            {
                // Create a new SymbolDictionary instance
                _symbolDictionary             = new SymbolDictionary(SymbolDictionaryType.Mil2525c);
                isSymbolDictionaryInitialized = true;
            }
            catch { }

            if (!isSymbolDictionaryInitialized)
            {
                await new MessageDialog("Failed to create symbol dictionary.", "Symbol Dictionary Search Sample").ShowAsync();
                return;
            }

            // Remove any empty strings space from keywords
            _keywords = _symbolDictionary.Keywords.OrderBy(k => k).ToList();
            _keywords = _keywords.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();

            // Collection of view models for the displayed list of symbols
            Symbols = new ObservableCollection <SymbolViewModel>();

            // Set the DataContext for binding
            DataContext = this;

            // Set the image size
            _imageSize = 64;

            // Get reference to MessageLayer to use with messages
            _messageLayer = MyMapView.Map.Layers.OfType <MessageLayer>().First();
        }
        private async void Init()
        {
            // Wait until all layers are loaded
            await MyMapView.LayersLoadedAsync();

			bool isSymbolDictionaryInitialized = false;
			try
			{
				// Create a new SymbolDictionary instance 
				_symbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);
				isSymbolDictionaryInitialized = true;
			}
			catch { }

			if (!isSymbolDictionaryInitialized)
			{
				await new MessageDialog("Failed to create symbol dictionary.", "Symbol Dictionary Search Sample").ShowAsync();
				return;
			}

            // Remove any empty strings space from keywords
            _keywords = _symbolDictionary.Keywords.OrderBy(k => k).ToList();
            _keywords = _keywords.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();

            // Collection of view models for the displayed list of symbols
            Symbols = new ObservableCollection<SymbolViewModel>();

            // Set the DataContext for binding
            DataContext = this;

            // Set the image size
            _imageSize = 64;

            // Get reference to MessageLayer to use with messages
            _messageLayer = MyMapView.Map.Layers.OfType<MessageLayer>().First();
        }
 private void AddNewMilitaryMessagelayer()
 {
     if (_militaryMessageLayer == null)
     {
         _militaryMessageLayer = new MessageLayer(SymbolDictionaryType.Mil2525c) { ID = Guid.NewGuid().ToString("D") };
         _mapView.Map.Layers.Add(_militaryMessageLayer);
     }
 }
 public ITransmissionContext Create(MessageLayer messageLayer, Message message)
 {
     return new TransmissionContext(new TransmissionTimer()) { Message = message };
 }
		private async void ProcessMessages()
		{
			try
			{
				await MyMapView.LayersLoadedAsync();

				_messageLayer = MyMapView.Map.Layers.OfType<MessageLayer>().First();

				// This function simulates real time message processing by processing a static set of messages from an XML document.
				/* 
				* |== Example Message ==|
				* 
				* <message>
				*      <_type>position_report</_type>
				*      <_action>update</_action>
				*      <_id>16986029-8295-48d1-aa6a-478f400a53c0</_id>
				*      <_wkid>3857</_wkid>
				*      <sic>GFGPOLKGS-----X</sic>
				*      <_control_points>-226906.99878,6679149.88998;-228500.51759,6677576.8009;-232194.67644,6675625.78198</_control_points>
				*      <uniquedesignation>DIRECTION OF ATTACK</uniquedesignation>
				* </message>
				*/

				var file = new FileInfo(DATA_PATH);

				// Load the XML document
				XDocument xmlDocument = XDocument.Load(file.FullName, LoadOptions.None);

				// Create a collection of messages
				IEnumerable<XElement> messagesXml = from n in xmlDocument.Root.Elements()
													where n.Name == "message"
													select n;

				// Iterate through the messages passing each to the ProcessMessage method on the MessageProcessor.
				// The MessageGroupLayer associated with this MessageProcessor will handle the creation of any 
				// GraphicsLayers and Graphic objects necessary to display the message.
				foreach (XElement messageXml in messagesXml)
				{
					Message message = new Message(from n in messageXml.Elements() select new KeyValuePair<string, string>(n.Name.ToString(), n.Value));
					_messageLayer.ProcessMessage(message);
				}

				/*
				* Alternatively you can programmatically construct the message and set the attributes.
				* e.g.
				* 
				* // Create a new message
				* Message msg = new Message();           
				* 
				* // Set the ID and other parts of the message
				* msg.Id = messageID;
				* msg.Add("_type", "position_report");
				* msg.Add("_action", "update");
				* msg.Add("_control_points", X.ToString(CultureInfo.InvariantCulture) + "," + Y.ToString(CultureInfo.InvariantCulture));
				* msg.Add("_wkid", "3857");
				* msg.Add("sic", symbolID);
				* msg.Add("uniquedesignation", "1");
				* 
				* // Process the message using the MessageProcessor within the MessageGroupLayer
				* _messageLayer.ProcessMessage(msg);
				*/
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "Message Processing Sample");
			}
		}
        private bool ProcessMessage(MessageLayer messageLayer, Message msg)
        {
            if (messageLayer != null && msg != null)
            {
                var result = messageLayer.ProcessMessage(msg);

                if (!_phaseMessageDictionary.ContainsKey(messageLayer.ID))
                {
                    _phaseMessageDictionary.Add(messageLayer.ID, new List<string>());
                }

                if (!_phaseMessageDictionary[messageLayer.ID].Contains(msg.Id))
                {
                    // add
                    _phaseMessageDictionary[messageLayer.ID].Add(msg.Id);
                }

                DoCloneMission(null);

                return result;
            }

            return false;
        }
Пример #39
0
 /// <summary>
 /// Creates a new layer item instance using the specified layer.
 /// </summary>
 /// <param name="messageLayer">The layer showing the messages.</param>
 public NvgLayerItem(MessageLayer messageLayer)
 {
     _messageLayer = messageLayer;
 }
 private void ClearMilitaryMessageLayer()
 {
     if (_militaryMessageLayer != null && _mapView != null)
     {
         _mapView.Map.Layers.Remove(_militaryMessageLayer.ID);
         _militaryMessageLayer = null;
         AddNewMilitaryMessagelayer();
     }
 }
		private async void ProcessMessages()
		{
			try
			{
				await MyMapView.LayersLoadedAsync();

				_messageLayer = MyMapView.Map.Layers.OfType<MessageLayer>().First();

				// This function simulates real time message processing by processing a static set of messages from an XML document.
				/* 
				* |== Example Message ==|
				* 
				* <message>
				*      <_type>position_report</_type>
				*      <_action>update</_action>
				*      <_id>16986029-8295-48d1-aa6a-478f400a53c0</_id>
				*      <_wkid>3857</_wkid>
				*      <sic>GFGPOLKGS-----X</sic>
				*      <_control_points>-226906.99878,6679149.88998;-228500.51759,6677576.8009;-232194.67644,6675625.78198</_control_points>
				*      <uniquedesignation>DIRECTION OF ATTACK</uniquedesignation>
				* </message>
				*/

				var file = await ApplicationData.Current.LocalFolder.TryGetItemAsync(DATA_PATH);
				if (file == null)
					throw new Exception("Local message data not found. Please download sample data from 'Sample Data Settings'");

				// Load the XML document
				XDocument xmlDocument = XDocument.Load(file.Path, LoadOptions.None);

				// Create a collection of messages
				IEnumerable<XElement> messagesXml = from n in xmlDocument.Root.Elements()
													where n.Name == "message"
													select n;

				// Iterate through the messages passing each to the ProcessMessage method on the MessageProcessor.
				foreach (XElement messageXml in messagesXml)
				{
					Message message = new Message(from n in messageXml.Elements() select new KeyValuePair<string, string>(n.Name.ToString(), n.Value));
					var messageProcessingSuccessful = _messageLayer.ProcessMessage(message);

					if (messageProcessingSuccessful == false)
					{
						var _x = new MessageDialog("Could not process the message.", "Message Processing Sample").ShowAsync();
					}
				}

				EnableSelection.IsEnabled = true;

				/*
				* Alternatively you can programmatically construct the message and set the attributes.
				* e.g.
				* 
				* // Create a new message
				* Message msg = new Message();           
				* 
				* // Set the ID and other parts of the message
				* msg.Id = messageID;
				* msg.Add("_type", "position_report");
				* msg.Add("_action", "update");
				* msg.Add("_control_points", X.ToString(CultureInfo.InvariantCulture) + "," + Y.ToString(CultureInfo.InvariantCulture));
				* msg.Add("_wkid", "3857");
				* msg.Add("sic", symbolID);
				* msg.Add("uniquedesignation", "1");
				* 
				* // Process the message using the MessageProcessor within the MessageGroupLayer
				* _messageLayer.ProcessMessage(msg);
				*/
			}
			catch (Exception ex)
			{
				var _x = new MessageDialog(ex.Message, "Message Processing Sample").ShowAsync();
			}
		}