/// <summary>
        /// Notifies the specified notification token.
        /// </summary>
        /// <param name="notificationToken">The notification token.</param>
        /// <param name="announcement">The announcement.</param>
        public void Notify(string notificationToken, PageItemModel announcement)
        {
            try
            {
                if (!string.IsNullOrEmpty(GCMApiKey))
                {
                    Broker.RegisterGcmService(new GcmPushChannelSettings(this.GCMApiKey));

                    foreach (var device in AndroidDevices)
                    {
                        Broker.QueueNotification(new GcmNotification()
                                                 .ForDeviceRegistrationId(device.DeviceId)
                                                 .WithJson(Newtonsoft.Json.JsonConvert.SerializeObject(new
                        {
                            alert             = announcement.PageHeaderText,
                            sound             = "default",
                            badge             = GetUnreadNotification(device),
                            LaunchImage       = announcement.PageItemImageUrl,
                            PageItemId        = announcement.PageItemId.ToString(),
                            NotificationToken = notificationToken
                        })));
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ExceptionValueTracker(notificationToken, announcement);
            }
        }
 public ActionResult Add(PageItemModel pageItem)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (ControllerContext.HttpContext.Request.Files != null &&
                 ControllerContext.HttpContext.Request.Files.Count > 0)
             {
                 string imagePath = this.UploadImage(ControllerContext.HttpContext.Request.Files[0]);
                 pageItem.PageItemImage = imagePath;
             }
             else
             {
                 pageItem.PageItemImage = string.Empty;
             }
             var newPageItem = this._pageItemDataRepository.InsertCustom(pageItem);
             return(RedirectToAction("GetPageItems", "SubPageList", new RouteValueDictionary(new { pageId = pageItem.PageId })));
         }
         else
         {
             return(PartialView("SubItemInsert", pageItem));
         }
     }
     catch (Exception ex)
     {
         ex.ExceptionValueTracker(pageItem);
     }
     return(Content(""));
 }
 public ActionResult Add(PageItemModel pageItem)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (ControllerContext.HttpContext.Request.Files != null
                 && ControllerContext.HttpContext.Request.Files.Count > 0)
             {
                 string imagePath = this.UploadImage(ControllerContext.HttpContext.Request.Files[0]);
                 pageItem.PageItemImage = imagePath;
             }
             else
             {
                 pageItem.PageItemImage = string.Empty;
             }
             var newPageItem = this._pageItemDataRepository.InsertCustom(pageItem);
             return RedirectToAction("GetPageItems", "SubPageList", new RouteValueDictionary(new { pageId = pageItem.PageId }));
         }
         else
         {
             return PartialView("SubItemInsert", pageItem);
         }
     }
     catch (Exception ex)
     {
         ex.ExceptionValueTracker(pageItem);
     }
     return Content("");
 }
        /// <summary>
        /// Notifies the specified notification token.
        /// </summary>
        /// <param name="notificationToken">The notification token.</param>
        /// <param name="announcement">The announcement.</param>
        public void Notify(string notificationToken, PageItemModel announcement)
        {
            try
            {
                var appleCert = File.ReadAllBytes(Path.Combine
                                                      (AppDomain.CurrentDomain.BaseDirectory, APNSCertificatePath));

                Broker.RegisterAppleService(new ApplePushChannelSettings
                                                (!APNSUseSandBox, appleCert, APNSCertificatePassword, true));

                foreach (var device in AppleDevices)
                {
                    Broker.QueueNotification(new AppleNotification()
                                             .ForDeviceToken(device.DeviceId)
                                             .WithAlert(new AppleNotificationAlert()
                    {
                        LaunchImage = announcement.PageItemImageUrl, Body = announcement.PageHeaderText
                    })
                                             .WithCustomItem(DeviceNotification.PageItemId, announcement.PageItemId)
                                             .WithCustomItem(DeviceNotification.NotificationToken, notificationToken)
                                             .WithBadge(GetUnreadNotification(device))
                                             .WithSound("default"));
                }
            }
            catch (Exception ex)
            {
                ex.ExceptionValueTracker(notificationToken, announcement);
            }
        }
        /// <summary>
        /// Notifies the specified notification token.
        /// </summary>
        /// <param name="notificationToken">The notification token.</param>
        /// <param name="announcement">The announcement.</param>
        public void Notify(string notificationToken, PageItemModel announcement)
        {
            try
            {
                if (!string.IsNullOrEmpty(GCMApiKey))
                {
                    Broker.RegisterGcmService(new GcmPushChannelSettings(this.GCMApiKey));

                    foreach (var device in AndroidDevices)
                    {
                        Broker.QueueNotification(new GcmNotification()
                            .ForDeviceRegistrationId(device.DeviceId)
                            .WithJson(Newtonsoft.Json.JsonConvert.SerializeObject(new
                            {
                                alert = announcement.PageHeaderText,
                                sound = "default",
                                badge = GetUnreadNotification(device),
                                LaunchImage = announcement.PageItemImageUrl,
                                PageItemId = announcement.PageItemId.ToString(),
                                NotificationToken = notificationToken
                            })));
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ExceptionValueTracker(notificationToken, announcement);
            }
        }
        /// <summary>
        /// Notifies the specified notification token.
        /// </summary>
        /// <param name="notificationToken">The notification token.</param>
        /// <param name="announcement">The announcement.</param>
        public void Notify(string notificationToken, PageItemModel announcement)
        {
            try
            {
                var appleCert = File.ReadAllBytes(Path.Combine
                    (AppDomain.CurrentDomain.BaseDirectory, APNSCertificatePath));

                Broker.RegisterAppleService(new ApplePushChannelSettings
                    (!APNSUseSandBox, appleCert, APNSCertificatePassword, true));

                foreach (var device in AppleDevices)
                {
                    Broker.QueueNotification(new AppleNotification()
                        .ForDeviceToken(device.DeviceId)
                        .WithAlert(new AppleNotificationAlert() { LaunchImage = announcement.PageItemImageUrl, Body = announcement.PageHeaderText })
                        .WithCustomItem(DeviceNotification.PageItemId, announcement.PageItemId)
                        .WithCustomItem(DeviceNotification.NotificationToken, notificationToken)
                        .WithBadge(GetUnreadNotification(device))
                        .WithSound("default"));
                }
            }
            catch (Exception ex)
            {
                ex.ExceptionValueTracker(notificationToken, announcement);
            }
        }
示例#7
0
        public ActionResult Index(int PageId, int PageItemId)
        {
            ViewBag.PageId     = PageId;
            ViewBag.PageItemId = PageItemId;
            PageItemModel pageItems = this._pageItemDataRepository.GetList(x => x.PageId == PageId && x.PageItemId == PageItemId).FirstOrDefault();

            return(View("Index.mobile", pageItems));
        }
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            _selected = GetSelected();


            if (_selected?.Item?.Model != null)
            {
                _modelImageService.LoadItem(_selected.Item.Model, pictureBox1.Width, pictureBox1.Height)
                .ContinueWith(x => pictureBox1.Image = x.Result);
            }
        }
示例#9
0
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            _selected = GetSelected();


            if (_selected?.Item?.Model != null)
            {
                lblItemName.Text = _selected.Item.Id_nb;
                _modelImageService.LoadItem(_selected.Item.Model, pictureBox1.Width, pictureBox1.Height)
                .ContinueWith(x => _modelImageService.AttachImage(pictureBox1, x));
            }
        }
        public ActionResult Edit(PageItemModel pageItem)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    pageItem.UpdatedOn = DateTime.Now;
                    if (ControllerContext.HttpContext.Request.Files != null &&
                        ControllerContext.HttpContext.Request.Files.Count > 0)
                    {
                        if (string.IsNullOrEmpty(pageItem.PageItemImage))
                        {
                            pageItem.PageItemImage = HandleImage(pageItem.PageItemId);
                        }
                        else
                        {
                            string imagePath = this.UploadImage(ControllerContext.HttpContext.Request.Files[0]);
                            pageItem.PageItemImage = imagePath;
                        }
                    }
                    else
                    {
                        pageItem.PageItemImage = string.Empty;
                    }

                    this._pageItemDataRepository.Update(pageItem);
                    return(RedirectToAction("GetPageItems", "SubPageList", new RouteValueDictionary(new { pageId = pageItem.PageId })));
                }
                else
                {
                    return(PartialView("SubItemDetail", pageItem));
                }
            }
            catch (Exception ex)
            {
                ex.ExceptionValueTracker();
            }
            return(Content(string.Empty));
        }
        /// <summary>
        /// Notifies the specified devices.
        /// </summary>
        /// <param name="devices">The devices.</param>
        /// <param name="announcement">The announcement.</param>
        public void Notify(PageItemModel announcement)
        {
            try
            {
                string notificationToken = Guid.NewGuid().ToString("N");
                Func <MobileDeviceType, List <DeviceRegistryModel> > devices = (type) =>
                                                                               this.allDevices.Where(x => x.DeviceType.Equals((int)type)).ToList();

                IList <Task> notificationProcess = new List <Task>();

                notificationProcess.Add(Task.Factory.StartNew(() =>
                                                              NotifyToAndroid(devices(MobileDeviceType.Android), notificationToken, announcement)));

                notificationProcess.Add(Task.Factory.StartNew(() =>
                                                              NotifyToiOS(devices(MobileDeviceType.Apple), notificationToken, announcement)));

                Task.WaitAll(notificationProcess.ToArray());
            }
            catch (Exception ex)
            {
                ex.ExceptionValueTracker(announcement);
            }
        }
        public ActionResult Add(int pageId)
        {
            try
            {
                PageItemModel pageItem = new PageItemModel()
                {
                    StatusId          = (int)StatusEnum.Active,
                    PageId            = pageId,
                    PageItemSubDetail = string.Empty,
                    CreatedOn         = DateTime.Now,
                    ActivatedOn       = DateTime.Now
                };
                IList <PageModel> pages = new List <PageModel>();
                pages         = this._pageDataRepository.GetList(x => x.StatusId.Equals((int)StatusEnum.Active)).ToList();
                ViewBag.Pages = new SelectList(pages, "PageId", "PageDesc");

                return(PartialView("SubItemInsert", pageItem));
            }
            catch (Exception ex)
            {
                ex.ExceptionValueTracker();
            }
            return(Content(""));
        }
        public ActionResult Add(int pageId)
        {
            try
            {
                PageItemModel pageItem = new PageItemModel()
                {
                    StatusId = (int)StatusEnum.Active,
                    PageId = pageId,
                    PageItemSubDetail = string.Empty,
                    CreatedOn = DateTime.Now,
                    ActivatedOn = DateTime.Now
                };
                IList<PageModel> pages = new List<PageModel>();
                pages = this._pageDataRepository.GetList(x => x.StatusId.Equals((int)StatusEnum.Active)).ToList();
                ViewBag.Pages = new SelectList(pages, "PageId", "PageDesc");

                return PartialView("SubItemInsert", pageItem);
            }
            catch (Exception ex)
            {
                ex.ExceptionValueTracker();
            }
            return Content("");
        }
        public ActionResult Edit(PageItemModel pageItem)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    pageItem.UpdatedOn = DateTime.Now;
                    if (ControllerContext.HttpContext.Request.Files != null
                        && ControllerContext.HttpContext.Request.Files.Count > 0)
                    {
                        if (string.IsNullOrEmpty(pageItem.PageItemImage))
                        {
                            pageItem.PageItemImage = HandleImage(pageItem.PageItemId);
                        }
                        else
                        {
                            string imagePath = this.UploadImage(ControllerContext.HttpContext.Request.Files[0]);
                            pageItem.PageItemImage = imagePath;
                        }
                    }
                    else
                    {
                        pageItem.PageItemImage = string.Empty;
                    }

                    this._pageItemDataRepository.Update(pageItem);
                    return RedirectToAction("GetPageItems", "SubPageList", new RouteValueDictionary(new { pageId = pageItem.PageId }));
                }
                else
                {
                    return PartialView("SubItemDetail", pageItem);
                }
            }
            catch (Exception ex)
            {
                ex.ExceptionValueTracker();
            }
            return Content(string.Empty);
        }
        /// <summary>
        /// Notifies the specified devices.
        /// </summary>
        /// <param name="devices">The devices.</param>
        /// <param name="announcement">The announcement.</param>
        public void Notify(PageItemModel announcement)
        {
            try
            {
                string notificationToken = Guid.NewGuid().ToString("N");
                Func<MobileDeviceType, List<DeviceRegistryModel>> devices = (type) =>
                    this.allDevices.Where(x => x.DeviceType.Equals((int)type)).ToList();

                IList<Task> notificationProcess = new List<Task>();

                notificationProcess.Add(Task.Factory.StartNew(() =>
                    NotifyToAndroid(devices(MobileDeviceType.Android), notificationToken, announcement)));

                notificationProcess.Add(Task.Factory.StartNew(() =>
                    NotifyToiOS(devices(MobileDeviceType.Apple), notificationToken, announcement)));

                Task.WaitAll(notificationProcess.ToArray());
            }
            catch (Exception ex)
            {
                ex.ExceptionValueTracker(announcement);
            }
        }