Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AlertRepository alertRepo = new AlertRepository();

            // Check if we're supposed to delete an alert
            if (!string.IsNullOrEmpty(Request.QueryString["DELETEALERT"]))
            {
                int parsedAlertID = Parsers.ParseInt(Request.QueryString["DELETEALERT"].ToString().Trim());

                if (parsedAlertID > 0)
                {
                    alertRepo.Delete(parsedAlertID);
                }

                Response.Redirect(Request.Url.GetLeftPart(UriPartial.Path));
            }


            // Populate date fields
            if (!IsPostBack)
            {
                ResetInputFields();
            }

            // Load all alerts from the database
            List <Alert> AllAlerts = alertRepo.GetAll();

            foreach (Alert alert in AllAlerts)
            {
                tblAlerts.Rows.Add(addAlertRow(alert));
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblServerTime.Text = DateTime.Now.ToLongDateString() + " - " + DateTime.Now.ToLongTimeString() + " (" + System.Environment.MachineName + ")";

            // Load any alerts from the database
            AlertRepository alertRepository = new AlertRepository();
            List <Alert>    ActiveAlerts    = alertRepository.GetActive();

            if (ActiveAlerts.Count > 0)
            {
                StringBuilder AlertBarContent = new StringBuilder();

                foreach (Alert alert in ActiveAlerts)
                {
                    if (alert.Importance == AlertImportance.High)
                    {
                        AlertBarContent.Append("<div class=\"alertbar_high\">" + alert.Content + "</div>");
                    }
                    else
                    {
                        AlertBarContent.Append("<div class=\"alertbar_normal\">" + alert.Content + "</div>");
                    }
                }

                litAlertContainer.Text = AlertBarContent.ToString();
            }
        }
Ejemplo n.º 3
0
        public AlertControllerUnitTest(ITestOutputHelper testOutputHelper)
        {
            _testOutputHelper = testOutputHelper;
            IAlertRepository service = new AlertRepository();

            _controller = new AlertController(service);
        }
Ejemplo n.º 4
0
 public InvoiceController(InvoiceRepository Irepo, IMapper mapper, InventoryRepository Invrepo, AuthRepository auth, AlertRepository alert)
 {
     _mapper  = mapper;
     _Irepo   = Irepo;
     _Invrepo = Invrepo;
     _auth    = auth;
     _alert   = alert;
 }
Ejemplo n.º 5
0
        public List <Alert> GetAlerts(int userID)
        {
            List <Alert> alerts = AlertRepository.GetItems(x => x.UserID == userID && !x.Delivered);

            foreach (var alert in alerts)
            {
                alert.Delivered = true;
            }
            AlertRepository.SaveChanges();
            return(alerts);
        }
Ejemplo n.º 6
0
 public void CreateAlert(AlertType alertType, int taskID, params int[] usersID)
 {
     foreach (var userID in usersID.Distinct())
     {
         AlertRepository.AddItem(new Alert()
         {
             AlertType = AlertType.Executed,
             TaskID    = taskID,
             UserID    = userID
         });
     }
 }
Ejemplo n.º 7
0
        static Functions()
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                CloudConfigurationManager.GetSetting("IoTStorageConnectionString"));
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            //DataPointTable = tableClient.GetTableReference("SumpPumpMonitorData");
            string tableStorageConnectionString = storageAccount.ToString(true);

            DataPointRepository = new DataPointRepository(tableStorageConnectionString);
            DutyCycleRepository = new DutyCycleRepository(tableStorageConnectionString);
            AlertRepository     = new AlertRepository(tableStorageConnectionString);
        }
Ejemplo n.º 8
0
        public IList <Alert> GetPendingAlertsByPriority(int id)
        {
            List <Alert> result = new List <Alert>();

            try
            {
                var repository = new AlertRepository();
                result = repository.GetPendingAlertsByPriority(id).ToList();
            }
            catch (Exception ex)
            {
                new Logger("Error in AlertsController - GetPendingAlertsByPriority(): " + ex.Message, ex);
                throw;
            }
            return(result);
        }
Ejemplo n.º 9
0
        public IList <Alert> GetResolvedAlerts(DateTime dttm)
        {
            List <Alert> result = new List <Alert>();

            try
            {
                var repository = new AlertRepository();
                result = repository.GetResolvedAlerts(dttm).ToList();
            }
            catch (Exception ex)
            {
                new Logger("Error in AlertsController - GetResolvedAlerts(): " + ex.Message, ex);
                throw;
            }
            return(result);
        }
Ejemplo n.º 10
0
        public BaseUnitOfWork(ExtraInfo extra = null)
        {
            _context = new ClassicsContext(extra);

            ProfileRepository   = new ProfileRepository(_context);
            UserRepository      = new UserRepository(_context);
            AddressRepository   = new AddressRepository(_context);
            BlobFileRepository  = new BlobFileRepository(_context);
            BrandRepository     = new BrandRepository(_context);
            CarModelRepository  = new CarModelRepository(_context);
            MyCarRepository     = new MyCarRepository(_context);
            ProductRepository   = new ProductRepository(_context);
            SerieRepository     = new SerieRepository(_context);
            SupplierRepository  = new SupplierRepository(_context);
            AlertRepository     = new AlertRepository(_context);
            UserAlertRepository = new UserAlertRepository(_context);
        }
Ejemplo n.º 11
0
        protected void btnSaveNewAlert_Click(object sender, EventArgs e)
        {
            // Parse the dates
            int From_Year   = Parsers.ParseInt(drpYear_From.Text);
            int From_Month  = Parsers.ParseInt(drpMonth_From.Text);
            int From_Day    = Parsers.ParseInt(txtDay_From.Text);
            int From_Hour   = Parsers.ParseInt(txtHour_From.Text);;
            int From_Minute = Parsers.ParseInt(txtMinute_From.Text);

            DateTime FromDate = new DateTime(From_Year, From_Month, From_Day, From_Hour, From_Minute, 0);

            int To_Year   = Parsers.ParseInt(drpYear_To.Text);
            int To_Month  = Parsers.ParseInt(drpMonth_To.Text);
            int To_Day    = Parsers.ParseInt(txtDay_To.Text);
            int To_Hour   = Parsers.ParseInt(txtHour_To.Text);;
            int To_Minute = Parsers.ParseInt(txtMinute_To.Text);

            DateTime ToDate = new DateTime(To_Year, To_Month, To_Day, To_Hour, To_Minute, 0);

            int    importance_int = Parsers.ParseInt(drpImportance.Text);
            string alertContent   = txtAlertContent.Text;

            AlertImportance importance = AlertImportance.Normal;

            if (importance_int > 0)
            {
                importance = AlertImportance.High;
            }

            if (!string.IsNullOrEmpty(alertContent))
            {
                Alert newAlert = new Alert()
                {
                    Content     = alertContent,
                    DisplayFrom = FromDate,
                    DisplayTo   = ToDate,
                    Importance  = importance
                };

                AlertRepository alertRepo = new AlertRepository();
                alertRepo.Insert(newAlert);
                Response.Redirect(Request.RawUrl);
            }
        }
Ejemplo n.º 12
0
        public async void Should_Fill_Alerts_Table()
        {
            var msgL = await _mtaFeedService.GetCurrentRealtimeFeedMessage(SubwayLines.L);
            var msgIrt = await _mtaFeedService.GetCurrentRealtimeFeedMessage(SubwayLines.RED_GREEN_S);

            var alertFactory = new AlertFactory();
            var alertsIrt = alertFactory.CreateItemsFromFeedMessage(msgIrt);
            var alertsL = alertFactory.CreateItemsFromFeedMessage(msgL);

            // Clear Tables
            using (var alertRepos = new AlertRepository() { Connection = _connection })
            {
                alertRepos.ClearAll();

                // Load Tables
                alertRepos.AddRange(alertsIrt);
                alertRepos.AddRange(alertsL);
            }
        }
Ejemplo n.º 13
0
        //public ApplicationUserManager(SocialMediaManager socialMediaManager)
        //{
        //    alertRepository = new AlertRepository();
        //    userRepository = new UserRepository();
        //    this.socialMediaManager = socialMediaManager;
        //}

        public ApplicationUserManager(UnitOfWorkManager unitOfWorkManager) : base(new UserStoreRepository(unitOfWorkManager.UnitOfWork.Context))
        {
            alertRepository        = new AlertRepository(unitOfWorkManager.UnitOfWork);
            userRepository         = new UserRepository(unitOfWorkManager.UnitOfWork);
            this.unitOfWorkManager = unitOfWorkManager;
        }
Ejemplo n.º 14
0
        private static async Task AsyncMain()
        {
            // Load Feed Message
            var dbConnStr = ConfigurationManager.ConnectionStrings["DbConnStr"].ConnectionString;

            var combinedUrl = string.Format(Url, ApiKey);
            var service = new FeedMessageService(combinedUrl);
            var msgIrt = await service.GetCurrentRealtimeFeedMessage(SubwayLines.RED_GREEN_S);
            var msgL = await service.GetCurrentRealtimeFeedMessage(SubwayLines.L);

            var alertFactory = new AlertFactory();
            var stopTimeFactory = new StopTimeUpdateFactory();
            var tripFactory = new TripFactory();
            var vehicleFactory = new VehiclePositionFactory();

            var alertsIrt = alertFactory.CreateItemsFromFeedMessage(msgIrt);
            var alertsL = alertFactory.CreateItemsFromFeedMessage(msgL);

            using (SqlConnection conn = new SqlConnection(dbConnStr))
            {

                using (var alertRepos = new AlertRepository() {Connection = conn})
                {
                    // Clear Tables
                    alertRepos.ClearAll();

                    // Load Tables
                    alertRepos.AddRange(alertsIrt);
                    alertRepos.AddRange(alertsL);
                }

                var stopsIrt = stopTimeFactory.CreateItemsFromFeedMessage(msgIrt);
                var stopsL = stopTimeFactory.CreateItemsFromFeedMessage(msgL);

                using (var stopsRepos = new StopTimeUpdateRepository() { Connection = conn })
                {
                    // Clear Tables
                    stopsRepos.ClearAll();

                    // Load Tables
                    stopsRepos.AddRange(stopsIrt);
                    stopsRepos.AddRange(stopsL);
                }

                var tripsIrt = tripFactory.CreateItemsFromFeedMessage(msgIrt);
                var tripsL = tripFactory.CreateItemsFromFeedMessage(msgL);

                using (var tripsRepos = new TripRepository() { Connection = conn })
                {
                    // Clear Tables
                    tripsRepos.ClearAll();

                    // Load Tables
                    tripsRepos.AddRange(tripsIrt);
                    tripsRepos.AddRange(tripsL);
                }

                var vehiclesIrt = vehicleFactory.CreateItemsFromFeedMessage(msgIrt);
                var vehiclesL = vehicleFactory.CreateItemsFromFeedMessage(msgL);

                using (var vehiclesRepos = new VehiclePositionRepository() { Connection = conn })
                {
                    // Clear Tables
                    vehiclesRepos.ClearAll();

                    // Load Tables
                    vehiclesRepos.AddRange(vehiclesIrt);
                    vehiclesRepos.AddRange(vehiclesL);
                }
            }
        }
Ejemplo n.º 15
0
        public AlertControllerTests()
        {
            IAlertRepository repository = new AlertRepository();

            _productsController = new AlertController(repository);
        }
 public AlertManager(UnitOfWorkManager unitOfWorkManager)
 {
     this.socialMediaRepository = new SocialMediaRepository(unitOfWorkManager.UnitOfWork);
     this.alertRepository       = new AlertRepository(unitOfWorkManager.UnitOfWork);
 }
Ejemplo n.º 17
0
        //public ApplicationUserManager(SocialMediaManager socialMediaManager)
        //{
        //    alertRepository = new AlertRepository();
        //    userRepository = new UserRepository();
        //    this.socialMediaManager = socialMediaManager;
        //}

        public ApplicationUserManager(IUserStore <ApplicationUser> store) : base(store)
        {
            this.alertRepository = new AlertRepository();
            userRepository       = new UserRepository();
        }
Ejemplo n.º 18
0
        public async void Should_Fill_All_Tables()
        {
            var msgL = await _mtaFeedService.GetCurrentRealtimeFeedMessage(SubwayLines.L);
            var msgIrt = await _mtaFeedService.GetCurrentRealtimeFeedMessage(SubwayLines.RED_GREEN_S);

            var alertFactory = new AlertFactory();
            var stopTimeFactory = new StopTimeUpdateFactory();
            var tripFactory = new TripFactory();
            var vehicleFactory = new VehiclePositionFactory();

            var alertsIrt = alertFactory.CreateItemsFromFeedMessage(msgIrt);
            var alertsL = alertFactory.CreateItemsFromFeedMessage(msgL);

            using (var alertRepos = new AlertRepository() { Connection = _connection })
            {
                // Clear Tables
                alertRepos.ClearAll();

                // Load Tables
                alertRepos.AddRange(alertsIrt);
                alertRepos.AddRange(alertsL);
            }

            var stopsIrt = stopTimeFactory.CreateItemsFromFeedMessage(msgIrt);
            var stopsL = stopTimeFactory.CreateItemsFromFeedMessage(msgL);

            using (var stopsRepos = new StopTimeUpdateRepository() { Connection = _connection })
            {
                // Clear Tables
                stopsRepos.ClearAll();

                // Load Tables
                stopsRepos.AddRange(stopsIrt);
                stopsRepos.AddRange(stopsL);
            }

            var tripsIrt = tripFactory.CreateItemsFromFeedMessage(msgIrt);
            var tripsL = tripFactory.CreateItemsFromFeedMessage(msgL);

            using (var tripsRepos = new TripRepository() { Connection = _connection })
            {
                // Clear Tables
                tripsRepos.ClearAll();

                // Load Tables
                tripsRepos.AddRange(tripsIrt);
                tripsRepos.AddRange(tripsL);
            }

            var vehiclesIrt = vehicleFactory.CreateItemsFromFeedMessage(msgIrt);
            var vehiclesL = vehicleFactory.CreateItemsFromFeedMessage(msgL);

            using (var vehiclesRepos = new VehiclePositionRepository() { Connection = _connection }) {
                // Clear Tables
                vehiclesRepos.ClearAll();

                // Load Tables
                vehiclesRepos.AddRange(vehiclesIrt);
                vehiclesRepos.AddRange(vehiclesL);
            }
        }
Ejemplo n.º 19
0
 public InventoryController(InventoryRepository repo, AuthRepository auth, AlertRepository alert)
 {
     _repo  = repo;
     _auth  = auth;
     _alert = alert;
 }
Ejemplo n.º 20
0
 public void SetRepositories(UnitOfWorkManager unitOfWorkManager)
 {
     alertRepository = new AlertRepository(unitOfWorkManager.UnitOfWork);
     userRepository  = new UserRepository(unitOfWorkManager.UnitOfWork);
 }
Ejemplo n.º 21
0
 public AlertController(AlertRepository repo, AuthRepository auth, InventoryRepository inv)
 {
     _repo = repo;
     _auth = auth;
     _inv  = inv;
 }
Ejemplo n.º 22
0
        /// <summary>
        /// When implemented in a derived class, executes the scheduled job asynchronously. Implementations that want to know whether
        ///             the scheduled job is being cancelled can get a <see cref="P:Microsoft.WindowsAzure.Mobile.Service.ScheduledJob.CancellationToken"/> from the <see cref="M:CancellationToken"/> property.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Threading.Tasks.Task"/> representing the asynchronous operation.
        /// </returns>
        public override async Task ExecuteAsync()
        {
            // Load Feed Message
            var dbConnStr = ConfigurationManager.ConnectionStrings["MTA_DB"].ConnectionString;

            var combinedUrl = string.Format(Url, ApiKey);
            var service = new FeedMessageService(combinedUrl);
            var msgIrt = await service.GetCurrentRealtimeFeedMessage(SubwayLines.RED_GREEN_S);
            var msgL = await service.GetCurrentRealtimeFeedMessage(SubwayLines.L);

            var alertFactory = new AlertFactory();
            var stopTimeFactory = new StopTimeUpdateFactory();
            var tripFactory = new TripFactory();
            var vehicleFactory = new VehiclePositionFactory();

            var alertsIrt = alertFactory.CreateItemsFromFeedMessage(msgIrt);
            var alertsL = alertFactory.CreateItemsFromFeedMessage(msgL);

            using (SqlConnection conn = new SqlConnection(dbConnStr))
            {

                    conn.Open();

                using (var alertRepos = new AlertRepository() {Connection = conn})
                {
                    // Clear Tables
                    alertRepos.ClearAll(); 

                    // Load Tables
                    alertRepos.AddRange(alertsIrt);
                    alertRepos.AddRange(alertsL);
                }

                var stopsIrt = stopTimeFactory.CreateItemsFromFeedMessage(msgIrt);
                var stopsL = stopTimeFactory.CreateItemsFromFeedMessage(msgL);

                using (var stopsRepos = new StopTimeUpdateRepository() { Connection = conn })
                {
                    // Clear Tables
                    stopsRepos.ClearAll();

                    // Load Tables
                    stopsRepos.AddRange(stopsIrt);
                    stopsRepos.AddRange(stopsL);
                }

                var tripsIrt = tripFactory.CreateItemsFromFeedMessage(msgIrt);
                var tripsL = tripFactory.CreateItemsFromFeedMessage(msgL);

                using (var tripsRepos = new TripRepository() { Connection = conn })
                {
                    // Clear Tables
                    tripsRepos.ClearAll();

                    // Load Tables
                    tripsRepos.AddRange(tripsIrt);
                    tripsRepos.AddRange(tripsL);
                }

                var vehiclesIrt = vehicleFactory.CreateItemsFromFeedMessage(msgIrt);
                var vehiclesL = vehicleFactory.CreateItemsFromFeedMessage(msgL);

                using (var vehiclesRepos = new VehiclePositionRepository() { Connection = conn })
                {
                    // Clear Tables
                    vehiclesRepos.ClearAll();

                    // Load Tables
                    vehiclesRepos.AddRange(vehiclesIrt);
                    vehiclesRepos.AddRange(vehiclesL);
                }

                using (var cmd = new SqlCommand("sp_CreateRealtimeSchedule", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.ExecuteNonQuery();
                }
            }

            //return Task.FromResult(true);
        }