/// <summary>
 /// Get Header Notification List for Login User
 /// </summary>
 /// <returns></returns>
 public ActionResult GetNotificationList()
 {
     NotificationObject notifications = new NotificationObject();
     ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
     NotificationEngine notificationEngine = new NotificationEngine();
     string response = notificationEngine.GetNotificationsJSON(Request.Cookies["sessionkey"].Value);
     responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response);
     notifications = (NotificationObject)Serializer.JSONStringToObject<NotificationObject>(responseObject.ResultObjectJSON);
     return PartialView("_HeaderNotificationList", notifications.Notifications);
 }
 public ActionResult GetNotificationDetail(int pNotificationID, int pProblemID)
 {
     NotificationObject notificationobj = new NotificationObject();
     ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
     NotificationEngine notificationEngine = new NotificationEngine();
     string response = notificationEngine.GetNotificationDetailsJSON(Request.Cookies["sessionkey"].Value, pNotificationID.ToString(), pProblemID.ToString());
     responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response);
     notificationobj = (NotificationObject)Serializer.JSONStringToObject<NotificationObject>(responseObject.ResultObjectJSON);
     return PartialView("_NotificationDetail", notificationobj);
 }
Ejemplo n.º 3
0
        private void PushToClient(long Id)
        {
            if (Id != 0)
            {
                Order orderToUpdate = db.Orders.Where(i => i.Id == Id).Single();

                NotificationEngine notificationengine = new NotificationEngine();
                //notificationengine.PushFromServer(string.Format("{{'Key':'order','Value':'{0}'}}", newId.ToString()));
                KeyValuePair <string, string> dictOrder = new KeyValuePair <string, string>("order", Id.ToString());
                notificationengine.PushFromServer(dictOrder);

                ArrayList SeatArray = orderToUpdate.SeatArray(SeatType.Vacant);
                string    jsonSeats = JsonConvert.SerializeObject(SeatArray);
                KeyValuePair <string, string> dictSeats = new KeyValuePair <string, string>("seats", jsonSeats);
                notificationengine.PushFromServer(dictSeats);
            }
        }
        public ActionResult GetNotificationByPaging(int pageIndex)
        {
            List<Notification> notifications = new List<Notification>();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            NotificationEngine notificationEngine = new NotificationEngine();
            string response = notificationEngine.GetNotificationsJSON(Request.Cookies["sessionkey"].Value);
            responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response);
            notifications = (List<Notification>)Serializer.JSONStringToObject<List<Notification>>(responseObject.ResultObjectJSON);

            int totalRecords = notifications.Count > 0 ? notifications[0].TotalNotificationCount : 0;
            int totalPagesCount = 0;
            totalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)_pageSize);
            ViewBag.PageNumber = pageIndex;
            ViewBag.PageSize = _pageSize;
            ViewBag.TotalPagesCount = totalPagesCount;
            ViewBag.TotalRecords = totalRecords;
            return PartialView("_NotificationList", notifications);
        }
Ejemplo n.º 5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              StateOfNeoSeedData seeder,
                              NotificationEngine notificationEngine)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            // Shows UseCors with CorsPolicyBuilder.
            app.UseCors(builder =>
            {
                builder
                .WithOrigins("http://localhost:8111", "http://localhost:4200")
                .AllowAnyMethod()
                .AllowAnyHeader()
                .AllowCredentials();
            });

            app.UseStaticFiles();

            app.UseSignalR(routes =>
            {
                routes.MapHub <BlockHub>("/hubs/block");
                routes.MapHub <NodeHub>("/hubs/node");
                routes.MapHub <TransactionCountHub>("/hubs/trans-count");
                routes.MapHub <TransactionAverageCountHub>("/hubs/trans-average-count");
                routes.MapHub <FailedP2PHub>("/hubs/fail-p2p");
            });

            //app.UseHttpsRedirection();
            seeder.Init();

            notificationEngine.Init();

            app.UseMvc();
        }
Ejemplo n.º 6
0
        public Offender Save(Offender offender)
        {
            var offenderRepository = new OffenderRepository();
            var errorLogger        = new ErrorLogger();
            var notificationEngine = new NotificationEngine();

            try
            {
                offender = offenderRepository.Save(offender);

                if (offender.OffenderId > 0)
                {
                    notificationEngine.Notify(string.Format("Offender {0} saved", offender.OffenderId));
                }
            }
            catch (Exception exc)
            {
                errorLogger.Log(exc.ToString(), LoggerType.Database);
            }

            return(offender);
        }
Ejemplo n.º 7
0
        public void CheckAndUpdateAll()
        {
            var plexSettings = Plex.GetSettings();

            if (!ValidateSettings(plexSettings))
            {
                Log.Debug("Validation of the plex settings failed.");
                return;
            }
            //var libraries = CachedLibraries(plexSettings, true); //force setting the cache (10 min intervals via scheduler)

            //if (libraries == null || !libraries.Any())
            //{
            //    Log.Debug("Did not find any libraries in Plex.");
            //    return;
            //}
            var content = PlexContent.GetAll().ToList();
            var movies  = GetPlexMovies(content).ToArray();
            var shows   = GetPlexTvShows(content).ToArray();
            var albums  = GetPlexAlbums(content).ToArray();

            var requests        = RequestService.GetAll();
            var requestedModels = requests as RequestedModel[] ?? requests.Where(x => !x.Available).ToArray();

            if (!requestedModels.Any())
            {
                Log.Debug("There are no requests to check.");
                return;
            }

            var modifiedModel = new List <RequestedModel>();

            foreach (var r in requestedModels)
            {
                var  releaseDate = r.ReleaseDate == DateTime.MinValue ? string.Empty : r.ReleaseDate.ToString("yyyy");
                bool matchResult;

                switch (r.Type)
                {
                case RequestType.Movie:
                    matchResult = IsMovieAvailable(movies, r.Title, releaseDate, r.ImdbId);
                    break;

                case RequestType.TvShow:
                    if (!plexSettings.EnableTvEpisodeSearching)
                    {
                        matchResult = IsTvShowAvailable(shows, r.Title, releaseDate, r.TvDbId, r.SeasonList);
                    }
                    else
                    {
                        matchResult = r.Episodes.Any() ?
                                      r.Episodes.All(x => IsEpisodeAvailable(r.TvDbId, x.SeasonNumber, x.EpisodeNumber)) :
                                      IsTvShowAvailable(shows, r.Title, releaseDate, r.TvDbId, r.SeasonList);
                    }
                    break;

                case RequestType.Album:
                    matchResult = IsAlbumAvailable(albums, r.Title, r.ReleaseDate.Year.ToString(), r.ArtistName);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }


                if (matchResult)
                {
                    r.Available = true;
                    modifiedModel.Add(r);
                    continue;
                }
            }

            Log.Debug("Requests that will be updated count {0}", modifiedModel.Count);

            if (modifiedModel.Any())
            {
                NotificationEngine.NotifyUsers(modifiedModel, plexSettings.PlexAuthToken, NotificationType.RequestAvailable);
                RequestService.BatchUpdate(modifiedModel);
            }
        }
 public NotificationService()
 {
     InitializeComponent();
     this.engine = new NotificationEngine();
 }
        /// <summary>
        /// Get Notification Listing Page
        /// </summary>
        /// <param name="id">Optional parameter Id as a Id of notification which supposed to be mark as a read</param>
        /// <returns></returns>
        public ActionResult Index(int id = 0)
        {
            //List<SystemNotificationsViewModel> modelList = new List<SystemNotificationsViewModel>();
            List<Notification> notifications = new List<Notification>();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            NotificationEngine notificationEngine = new NotificationEngine();
            string response = notificationEngine.GetNotificationsJSON(Request.Cookies["sessionkey"].Value);
            responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response);
            notifications = (List<Notification>)Serializer.JSONStringToObject<List<Notification>>(responseObject.ResultObjectJSON);
            int totalRecords = notifications.Count > 0 ? notifications[0].TotalNotificationCount : 0;
            int totalPagesCount = 0;
            totalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)_pageSize);
            ViewBag.PageNumber = 1;
            ViewBag.PageSize = _pageSize;
            ViewBag.TotalPagesCount = totalPagesCount;
            ViewBag.TotalRecords = totalRecords;

            return View(notifications);
        }
 public ActionResult UpdateNotificationStatus(int id)
 {
     ViewBag.PageNumber = 1;
     ViewBag.PageSize = _pageSize;
     ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
     NotificationEngine notificationEngine = new NotificationEngine();
     string response = notificationEngine.UpdateNotificationStatus(Request.Cookies["sessionkey"].Value, id.ToString());
     responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response);
     return Content("Sucess");
 }
Ejemplo n.º 11
0
 // Start is called before the first frame update
 void Start()
 {
     instance = this;
 }
Ejemplo n.º 12
0
        public void CheckAndUpdateAll()
        {
            var embySettings = Emby.GetSettings();

            if (!embySettings.Enable)
            {
                return;
            }
            if (!ValidateSettings(embySettings))
            {
                Log.Debug("Validation of the Emby settings failed.");
                return;
            }

            var content = EmbyContent.GetAll().ToList();

            var movies = GetEmbyMovies(content).ToArray();
            var shows  = GetEmbyTvShows(content).ToArray();
            var albums = GetEmbyMusic(content).ToArray();

            var requests        = RequestService.GetAll();
            var requestedModels = requests as RequestedModel[] ?? requests.Where(x => !x.Available).ToArray();

            if (!requestedModels.Any())
            {
                Log.Debug("There are no requests to check.");
                return;
            }

            var modifiedModel = new List <RequestedModel>();

            foreach (var r in requestedModels)
            {
                var  releaseDate = r.ReleaseDate == DateTime.MinValue ? string.Empty : r.ReleaseDate.ToString("yyyy");
                bool matchResult;

                switch (r.Type)
                {
                case RequestType.Movie:
                    matchResult = IsMovieAvailable(movies, r.Title, releaseDate, r.ImdbId);
                    break;

                case RequestType.TvShow:
                    if (!embySettings.EnableEpisodeSearching)
                    {
                        matchResult = IsTvShowAvailable(shows, r.Title, releaseDate, r.TvDbId, r.SeasonList);
                    }
                    else
                    {
                        matchResult = r.Episodes.Any() ?
                                      r.Episodes.All(x => IsEpisodeAvailable(r.TvDbId, x.SeasonNumber, x.EpisodeNumber)) :
                                      IsTvShowAvailable(shows, r.Title, releaseDate, r.TvDbId, r.SeasonList);
                    }
                    break;

                case RequestType.Album:
                    //matchResult = IsAlbumAvailable(albums, r.Title, r.ReleaseDate.Year.ToString(), r.ArtistName); // TODO Emby
                    matchResult = false;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }


                if (matchResult)
                {
                    r.Available = true;
                    modifiedModel.Add(r);
                    continue;
                }
            }

            Log.Debug("Requests that will be updated count {0}", modifiedModel.Count);

            if (modifiedModel.Any())
            {
                NotificationEngine.NotifyUsers(modifiedModel, NotificationType.RequestAvailable);
                RequestService.BatchUpdate(modifiedModel);
            }
        }
Ejemplo n.º 13
0
        public IEnumerable <Notification> Add(Goal goal, IEnumerable <Notification> items, IEnumerable <TimeInterval> timeIntervals)
        {
            NotificationEngine.Create(goal, ref items, timeIntervals);

            return(_notificationRepository.Add(items));
        }