void Awake()
 {
     Instance = this;
     setReferences();
     moveNotificationOffscreen();
     subscribeEvents();
 }
 private void LoadDataFromFiles()
 {
     DoctorController.getInstance().LoadFromFile();
     PatientController.getInstance().LoadFromFile();
     AppointmentController.getInstance().LoadAppointmentsFromFile();
     NotificationController.GetInstance().LoadFromFile();
 }
Beispiel #3
0
        public static void Check2()
        {
            var notificationController = new NotificationController();
            Dictionary <BotUserChannel, DateTime> userList;
            Dictionary <BotUserChannel, DateTime> userListNew;

            if (TrendingTopics.trendingList != null)
            {
                foreach (string t in TrendingTopics.trendingList)
                {
                    if (UserInfo.topicDict2.TryGetValue(t, out userList))
                    {
                        userListNew = new Dictionary <BotUserChannel, DateTime>(userList);

                        foreach (KeyValuePair <BotUserChannel, DateTime> user in userList)
                        {
                            if (DateTime.Now > user.Value.AddHours(1))
                            {
                                userListNew[user.Key]  = DateTime.Now;
                                UserInfo.topicDict2[t] = userListNew;

                                BotUserChannel u = user.Key;
                                // notificationController.SendMessage(u.url, u.from, u.recipient, t);
                                sendMessage(u.url, u.from, u.recipient, t);
                            }
                        }
                    }
                }
            }
        }
        public void TestInitialize()
        {
            _cedUser = new CedUser(new UserEntity {
                Email = "*****@*****.**",
            }, null);

            _mockAuthUserServices    = new Mock <IUserServices>();
            _mockRoleServices        = new Mock <IRoleServices>();
            _mockApplicationServices = new Mock <IApplicationServices>();
            _mockIndustryServices    = new Mock <IIndustryServices>();
            _mockRegionServices      = new Mock <IRegionServices>();

            _mockEventServices           = new Mock <IEventServices>();
            _mockEventDirectorServices   = new Mock <IEventDirectorServices>();
            _mockLogServices             = new Mock <ILogServices>();
            _mockNotificationServices    = new Mock <INotificationServices>();
            _mockUserServices            = new Mock <IUserServices>();
            _mockUserRoleServices        = new Mock <IUserRoleServices>();
            _mockInAppNotificationHelper = new Mock <IInAppNotificationHelper>();

            _mockHttpContextBase = new Mock <HttpContextBase>();

            _mockNotificationServices
            .Setup(x => x.GetNotifications(It.IsAny <string>(), It.IsAny <NotificationType[]>(), It.IsAny <int?>()))
            .Returns(new List <NotificationEntity>());

            _sut = SetUpController();

            AutoMapperConfig.Register();
        }
Beispiel #5
0
        private void Do(object o)
        {
            lock (this)
            {
                try
                {
                    List <Business.Models.WarningData> wd = new List <Business.Models.WarningData>();
                    wd.Add(new Business.Models.WarningData()
                    {
                        key   = "销售单审核",
                        value = BugsBox.Pharmacy.MonitorHandlers.Sale.GetNeedCheckOrder()
                    });
                    wd.Add(new Business.Models.WarningData()
                    {
                        key   = "拣货",
                        value = BugsBox.Pharmacy.MonitorHandlers.Sale.GetNeedTake()
                    });

                    wd.Add(new Business.Models.WarningData()
                    {
                        key   = "拣货核查",
                        value = BugsBox.Pharmacy.MonitorHandlers.Sale.GetNeedCheckChuKu()
                    });
                    wd.Add(new Business.Models.WarningData()
                    {
                        key   = "配送",
                        value = BugsBox.Pharmacy.MonitorHandlers.Sale.GetNeedPeiSong()
                    });
                    wd.Add(new Business.Models.WarningData()
                    {
                        key   = "销退销售员审核",
                        value = BugsBox.Pharmacy.MonitorHandlers.Sale.GetNeed_XT_XSY_Check()
                    });
                    wd.Add(new Business.Models.WarningData()
                    {
                        key   = "销退营业部审核",
                        value = BugsBox.Pharmacy.MonitorHandlers.Sale.GetNeed_XT_YYB_Check()
                    });
                    wd.Add(new Business.Models.WarningData()
                    {
                        key   = "销退质管部审核",
                        value = BugsBox.Pharmacy.MonitorHandlers.Sale.GetNeed_XT_ZGB_Check()
                    });

                    if (wd.Where(p => p.value > 0).Count() > 0)
                    {
                        NotificationController.NeedHandleSale(wd.Where(p => p.value > 0).ToArray());
                    }

                    IsDoOver = true;
                    CallBackDelegate cbd = o as CallBackDelegate;
                    cbd();
                }
                catch (Exception ex)
                {
                    LoggerHelper.Instance.Error(ex);
                    IsDoOver = true;
                }
            }
        }
        public void ReturnPartialView_NotificationsPartial()
        {
            // Arrange
            var mockedNotificationService = new Mock <INotificationService>();
            var mockedStatisticService    = new Mock <IStatisticService>();
            var mockedUserService         = new Mock <IUserService>();
            var mockedViewModelService    = new Mock <IViewModelService>();
            var users = new List <NotificationUserViewModel>()
            {
                new NotificationUserViewModel(),
                new NotificationUserViewModel()
            };

            mockedViewModelService.Setup(x => x.GetMappedUserNotifications(It.IsAny <IEnumerable <Notification> >())).Returns(users);

            var notificationController = new NotificationController(
                mockedNotificationService.Object,
                mockedStatisticService.Object,
                mockedUserService.Object,
                mockedViewModelService.Object);
            int    skip   = 2;
            int    count  = 2;
            string userId = "some-id";

            // Act & Assert
            notificationController
            .WithCallTo(x => x.ShowMoreResults(skip, count, userId))
            .ShouldRenderPartialView("_NotificationsPartial")
            .WithModel <IEnumerable <NotificationUserViewModel> >(m =>
            {
                Assert.AreEqual(users, m);
            });
        }
        private NotificationController SetUpController()
        {
            var routes     = new RouteCollection();
            var controller = new NotificationController(
                _mockAuthUserServices.Object,
                _mockRoleServices.Object,
                _mockApplicationServices.Object,
                _mockIndustryServices.Object,
                _mockRegionServices.Object,
                _mockEventServices.Object,
                _mockEventDirectorServices.Object,
                _mockLogServices.Object,
                _mockNotificationServices.Object,
                _mockUserServices.Object,
                _mockUserRoleServices.Object,
                _mockInAppNotificationHelper.Object)
            {
                CurrentCedUser = _cedUser
            };

            var routeData = new RouteData();

            routeData.Values.Add("controller", "NotificationController");
            controller.ControllerContext = new ControllerContext(_mockHttpContextBase.Object, routeData, controller);
            controller.Url = new UrlHelper(new RequestContext(_mockHttpContextBase.Object, routeData), routes);

            return(controller);
        }
    /// <summary>
    /// 1分後に繰り返し通知送信。
    /// </summary>
    void OnSendRepeatNotificationAfter1Minute()
    {
        var notificationDateTime = DateTime.Now + new TimeSpan(0, 1, 0);
        var repeatInterval       = new TimeSpan(0, 1, 0);

        NotificationController.SendNotification("通知テスト", "1分後に繰り返し通知", notificationDateTime, NotificationController.Notifications.NOTIFICATION_1, true, repeatInterval);
    }
Beispiel #9
0
        public async Task NotificationRule_Edit_Test_Valid_ID()
        {
            //Arrange
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim(ClaimTypes.Name, "example name"),
                new Claim(ClaimTypes.NameIdentifier, "1"),
                new Claim("custom-claim", "example claim value"),
            }, "mock"));

            var optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            optionsBuilder.UseInMemoryDatabase(databaseName: "CommerceTestDB");
            var _dbContext = new ApplicationDbContext(optionsBuilder.Options);

            var controller = new NotificationController(_dbContext);

            controller.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = user
                }
            };

            //Act
            var result = await controller.Edit(1);

            //Assert
            Assert.NotNull(result);
        }
Beispiel #10
0
        public void GetNotification_NotificationIsNotNull_ViewResult()
        {
            // Arrange
            var data = new List <Notification>
            {
                new Notification {
                    Id = 1
                }
            }.AsQueryable();

            var mockSet = MockHelper.MockDbSet(data);

            var mockContext = new Mock <Context>();

            mockContext.SetupGet(c => c.Notifications).Returns(mockSet.Object);

            var controller = new NotificationController(mockContext.Object);

            // Act

            var result = controller.GetNotification(1) as ViewResult;

            // Assert

            Assert.IsNotNull(result);
        }
        public bool AddMember(string nodeId, string nodeTypeId, string username)
        {
            ITenant tenant = HttpContext.Current.GetCurrentTenant();

            if (tenant == null)
            {
                return(false);
            }

            Guid?userId = UsersController.get_user_id(tenant.Id, username);
            Guid nId    = CNController.get_node_id(tenant.Id, nodeId, nodeTypeId);

            NodeMember nm = new NodeMember();

            nm.Node.NodeID    = nId;
            nm.Member.UserID  = userId;
            nm.MembershipDate = DateTime.Now;
            nm.AcceptionDate  = DateTime.Now;

            List <Dashboard> retDashboards = new List <Dashboard>();

            bool result = userId.HasValue && CNController.add_member(tenant.Id, nm, ref retDashboards);

            if (result)
            {
                NotificationController.transfer_dashboards(tenant.Id, retDashboards);
            }

            return(result);
        }
Beispiel #12
0
 private void StartNotificationProcess()
 {
     try
     {
         AppFileLogger.getInstance().Log("On Start Fired..!!", MessageType.LOG);
         NotificationController controller = new NotificationController();
         controller.SendNotification();
         AppFileLogger.getInstance().Log("end of on ..!!", MessageType.LOG);
     }
     catch (Exception ex)
     {
         try
         {
             AppFileLogger.getInstance().Log(ex.Message, MessageType.ERROR);
         }
         catch (Exception innerEx)
         {
             var sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\ERROR.txt");
             sw.WriteLine(DateTime.Now);
             sw.WriteLine(innerEx.Message);
             sw.Flush();
             sw.Close();
         }
     }
 }
Beispiel #13
0
        public void TestNotificationIdPersistence()
        {
            // arrange
            iServer.SetDesiredResponse(iServerResponseV1);
            var waitHandle = new AutoResetEvent(false);

            iView.ShowCallback = (notification, shownow) =>
            {
                notification.Closed(false);
                waitHandle.Set();
            };

            // act
            using (var controller = new NotificationController(iInvoker, iPersistence, iServer, iView, NotificationController.DefaultTimespan))
            {
                Assert.That(waitHandle.WaitOne(kTimeoutMilliseconds));
            }

            // flush pending invocations
            AwaitInvoker();

            // assert
            Assert.IsNotNull(iView.Current);
            Assert.IsNotNull(iView.LastShown);
            Assert.AreEqual(iView.Current, iView.LastShown);
            Assert.AreEqual(iPersistence.LastNotificationVersion, 1);
            Assert.AreEqual(iNotificationVersion1.Uri, iView.Current.Uri(false));
            Assert.AreEqual(iNotificationVersion1.Version, iView.Current.Version);
        }
Beispiel #14
0
        public void TestServerTaskCancelledResultsInNoViewBeingShown()
        {
            // arrange
            iServer.ForceCancelTask = true; // simulate a cancellation
            var waitHandle = new AutoResetEvent(false);

            iServer.CheckCallback = (response) =>
            {
                iInvoker.BeginInvoke(new Action(() =>
                {
                    waitHandle.Set();
                }));
            };
            iView.ShowCallback = (notification, shownow) =>
            {
                Assert.Fail("View show should not be called");
            };

            // act
            using (var controller = new NotificationController(iInvoker, iPersistence, iServer, iView, NotificationController.DefaultTimespan))
            {
                Assert.That(waitHandle.WaitOne(kTimeoutMilliseconds));
            }

            // flush pending invocations
            AwaitInvoker();

            // assert
            Assert.IsNull(iView.Current);
            Assert.IsNull(iView.LastShown);
            Assert.AreEqual(iPersistence.LastNotificationVersion, 0);
        }
Beispiel #15
0
        public async Task PostNotificationTest()
        {
            var service  = new Mock <INotificationService>();
            var response = new SendNotificationResponse
            {
                NotificationRecordId = Guid.NewGuid(),
                Results = new List <NotificationSendingResult>()
            };

            var request = new SendNotificationRequest
            {
                EventType       = NotificationEvent.ArticleCreated,
                RecipientUserId = "userId",
                Parameters      = new Dictionary <string, object>()
            };

            SendNotificationRequest req = null;

            service.Setup(x => x.PostAsync(It.Is <SendNotificationRequest>(notificationRequest => notificationRequest == request)))
            .Callback <SendNotificationRequest>(r => req = r)
            .ReturnsAsync(response)
            .Verifiable();

            var controller = new NotificationController(_logger, service.Object).WithUser();
            var result     = await controller.SendNotificationAsync(request);

            service.Verify();
            Assert.NotNull(req);

            var res = Assert.IsType <OkObjectResult>(result);

            Assert.IsType <SendNotificationResponse>(res.Value);
            Assert.Equal(response, res.Value);
        }
        public async void Add_AddIsTrue()
        {
            //Mock Claims object
            var mockIdentity = new GenericIdentity("User");

            mockIdentity.AddClaim(new Claim("UserId", "2"));
            var principal = new GenericPrincipal(mockIdentity, null);

            //Mock HttpContext
            var mockHttpContext = new Mock <HttpContext>();

            mockHttpContext.Setup(m => m.User).Returns(principal);

            var user = new User
            {
                ID            = 1,
                Activated     = 0,
                Email         = "user@email",
                Notifications = new List <Notification>()
            };


            mockUserService.Setup(m => m.Find(It.IsAny <long>(), It.IsAny <Expression <Func <User, object> >[]>()))
            .Returns(user);

            var controller = new NotificationController(mapper, mockUserService.Object, mockNotificationService.Object);

            controller.ControllerContext.HttpContext = mockHttpContext.Object;

            var result = await controller.Add(true, 2, 1, 3) as JsonResult;

            Assert.Equal("Done!", result.Value);
        }
Beispiel #17
0
        public void Create_Test()
        {
            var mockRepo = new Mock <DevCmsDb>();

            mockRepo.SetupDbSetMock(db => db.Notifications, new List <Notification>());
            var emailServiceMock = new Mock <EmailService>(mockRepo.Object);

            var controller = new NotificationController(mockRepo.Object, emailServiceMock.Object);

            var model = new Notification
            {
                Email   = "test",
                Name    = "name",
                Phone   = "",
                Message = "message"
            };

            Assert.Equal(0, mockRepo.Object.Notifications.Count());

            var result = controller.Create(model);

            Assert.Equal("success", result);

            mockRepo.Verify(db => db.SaveChanges(), Times.Once());
            emailServiceMock.Verify(s => s.SendEmail(It.IsAny <Notification>()), Times.Once());

            Assert.Equal(1, mockRepo.Object.Notifications.Count());
            Assert.Equal("test", mockRepo.Object.Notifications.First().Email);
            Assert.Equal("name", mockRepo.Object.Notifications.First().Name);
            Assert.Equal("message", mockRepo.Object.Notifications.First().Message);
        }
Beispiel #18
0
 public NotificationControllerTests()
 {
     _mockNotificationRepo = new Mock <INotificationServices>();
     _mockUserRepo         = new Mock <IUserServices>();
     _mockEmailRepo        = new Mock <IEmailService>();
     _controller           = new NotificationController(_mockNotificationRepo.Object, _mockUserRepo.Object, _mockEmailRepo.Object);
 }
Beispiel #19
0
    void Start()
    {
        // Save a reference to the main GameController object
        gameController         = GameObject.FindWithTag("GameController").GetComponent <GameController>();
        notificationController = GameObject.FindWithTag("GameController").GetComponent <NotificationController>();
        scoreManager           = GetComponent <ScoreManager>();

        if (MaterialSender.selectedMaterial != null)
        {
            playerOriginalMaterial = MaterialSender.selectedMaterial;
        }

        GetComponent <MeshRenderer>().material = playerOriginalMaterial;

        health = maxHealth;
        healthSlider.maxValue = maxHealth;

        // Save a reference to the rigidbody object
        rb = GetComponent <Rigidbody>();

        // Retrieve the number of lanes in this game from GameController
        numLanes = gameController.numLanes;

        // Ball always starts at the center lane
        currentLane = (numLanes / 2) + 1;

        // targetLane is used to mark which lane the ball is moving towards while moving horizontally
        targetLane            = currentLane;
        healthFillImage       = healthSlider.transform.Find("Fill Area/Fill").GetComponent <Image>();
        healthFillImage.color = Color.green;

        // Enable lane lock by default (always keep the ball at the center of the lane)
        EnableLaneLock();
    }
    private void Awake()
    {
        projectController         = ProjectController.Instance;
        characterStatusController = CharacterStatusController.Instance;
        ideasController           = IdeasController.Instance;
        gameManager = GameManager.Instance;
        gameManager.OnGameStateChanged.AddListener(OnGameStateChangedHandler);

        notificationController = GameObject.FindGameObjectWithTag("NotificationController").GetComponentInChildren <NotificationController>();
        platformNameIdeas      = new List <string>();
        playerNameIdeas        = new List <string>();


        #region Select temp
        goalSlot      = new BaseWorkingProjectIdeaSlot();
        mechanicSlots = new BaseWorkingProjectIdeaSlot[2];
        for (int i = 0; i < mechanicSlots.Length; i++)
        {
            mechanicSlots[i] = new BaseWorkingProjectIdeaSlot();
        }
        themeSlots         = new BaseWorkingProjectIdeaSlot();
        countMechanicSlots = 0;
        #endregion

        Initializing();
    }
Beispiel #21
0
        /// <summary>
        /// Instantiates the Moq instance (Mock) and seed data, specifically the controllers in the API.
        /// </summary>
        private void SetUpMocks()
        {
            Repository         = new Mock <Lib.Interface.IGenericRepository>();
            Auth0HelperFactory = new Mock <IAuth0HelperFactory>();

            CoordinatorAccountController = new CoordinatorAccountController(Repository.Object, LoggerCoord, Auth0HelperFactory.Object)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = new DefaultHttpContext()
                }
            };
            CoordinatorAccountController.ControllerContext.HttpContext.Request.Headers["Authorize"] = "Not a token.";

            ProviderAccountController = new ProviderAccountController(Repository.Object, LoggerProv, Auth0HelperFactory.Object)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = new DefaultHttpContext()
                }
            };
            ProviderAccountController.ControllerContext.HttpContext.Request.Headers["Authorize"] = "Not a token.";

            NotificationController = new NotificationController(Repository.Object, LoggerNoti)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = new DefaultHttpContext()
                }
            };
            NotificationController.ControllerContext.HttpContext.Request.Headers["Authorize"] = "Not a token.";
        }
Beispiel #22
0
 private void CheckLock(object o)
 {
     lock (this)
     {
         try
         {
             int num = BugsBox.Pharmacy.MonitorHandlers.Drug.LockCount();
             if (num > 0)
             {
                 NotificationController.DrugLock(num);
             }
             num = BugsBox.Pharmacy.MonitorHandlers.Drug.GetDrugInfoForOutofStockNumber();
             if (num > 0)
             {
                 NotificationController.DrugOutofStock(num);
             }
             IsCheckLockOver = true;
             CallBackDelegate cbd = o as CallBackDelegate;
             cbd();
         }
         catch (Exception ex)
         {
             IsCheckLockOver = true;
             LoggerHelper.Instance.Error(ex);
         }
     }
 }
        public UserAccountLogged()
        {
            _userController         = (Application.Current as App).UserController;
            _doctorController       = (Application.Current as App).DoctorController;
            _drugController         = (Application.Current as App).DrugController;
            _notificationController = (Application.Current as App).NotificationController;
            InitializeComponent();

            User user = _userController.GetLoggedUser();

            nameTextBox.Text    = user.Name;
            surnameTextBox.Text = user.Surname;
            emailTextBox.Text   = user.Email;
            idLabel.Content     = user.Id.ToString();

            userTypeLabel.Content = user.GetType().Name;

            Doctor doctor = _doctorController.Get(user.Id);

            if (doctor != null)
            {
                notificationDataGrid.Visibility = Visibility.Visible;

                List <Notification> notifications = new List <Notification>();

                foreach (var notificationId in doctor.Notification)
                {
                    notifications.Add(_notificationController.Get(notificationId));
                }

                notificationDataGrid.ItemsSource = notifications;
            }
        }
Beispiel #24
0
        public void ReturnPartialView_NotificationsPartial()
        {
            // Arrange
            var mockedNotificationService = new Mock <INotificationService>();
            var mockedStatisticService    = new Mock <IStatisticService>();
            var mockedUserService         = new Mock <IUserService>();
            var mockedViewModelService    = new Mock <IViewModelService>();
            var users = new List <NotificationUserViewModel>()
            {
                new NotificationUserViewModel(),
                new NotificationUserViewModel()
            };

            mockedViewModelService.Setup(x => x.GetMappedUserNotifications(It.IsAny <IEnumerable <Notification> >())).Returns(users);

            var notificationController = new NotificationController(
                mockedNotificationService.Object,
                mockedStatisticService.Object,
                mockedUserService.Object,
                mockedViewModelService.Object);
            string id             = "some-id";
            int    authorId       = 21;
            int    notificationId = 11;

            // Act & Assert
            notificationController
            .WithCallTo(x => x.AcceptFriendship(id, authorId, notificationId))
            .ShouldRenderPartialView("_NotificationsPartial")
            .WithModel <IEnumerable <NotificationUserViewModel> >(m =>
            {
                Assert.AreEqual(users, m);
            });
        }
Beispiel #25
0
        private void ChangeButton_Click(object sender, RoutedEventArgs e)
        {
            Notification newNotification = new Notification(notificationTextBox.Text, GetTimeFromComboBoxes(), (DateTime)startDatePicker.SelectedDate, (DateTime)endDatePicker.SelectedDate, (bool)notificationCheckBox.IsChecked);

            NotificationController.GetInstance().ChangeNotification((Notification)notificationComboBox.SelectedItem, newNotification);
            PatientMainWindow.GetInstance(_loggedInPatient).Notify();
        }
        public void ReadNotification_Read_Redirect()
        {
            // Arrange
            var controller = new NotificationController()
            {
                Context = context
            };
            var notificationId = IdService.GetNewNotificationId(context);

            notificationService.Save(new Notification()
            {
                NotificationId   = notificationId,
                NotificationType = new NotificationTypeRepository(context).FindById(1),
                Contents         = "DSB-201801-001",
                Status           = new StatusService(context).FindStatusByStatusId(15),
                CreatedDateTime  = DateTime.Now
            });

            // Act
            var result = controller.Read(notificationId);

            // Assert
            Assert.AreEqual(15, notificationService.FindNotificationById(notificationId).Status.StatusId);
            result.AssertActionRedirect().ToAction("DisbursementDetails");
        }
Beispiel #27
0
        public void TestNotificationIsNotShownIfAlreadySeen()
        {
            // arrange
            iPersistence.LastNotificationVersion = 1;
            iPersistence.LastShownNotification   = DateTime.Now;
            iServer.SetDesiredResponse(iServerResponseV1);
            var waitHandle = new AutoResetEvent(false);

            iView.ShowCallback = (notification, shownow) =>
            {
                if (shownow)
                {
                    Assert.Fail("View should not be shown.");
                }
                waitHandle.Set();
            };

            // act
            using (var controller = new NotificationController(iInvoker, iPersistence, iServer, iView, NotificationController.DefaultTimespan))
            {
                Assert.That(waitHandle.WaitOne(kTimeoutMilliseconds));
            }

            // flush pending invocations
            AwaitInvoker();

            // assert
            Assert.IsNotNull(iView.Current);
            Assert.IsNull(iView.LastShown);
            Assert.AreEqual(iPersistence.LastNotificationVersion, iNotificationVersion1.Version);
        }
Beispiel #28
0
 private static void AddCreatedNotification(Notification prescriptionNotification)
 {
     if (!NotificationExists(prescriptionNotification))
     {
         NotificationController.GetInstance().AddNotification(prescriptionNotification);
     }
 }
 private void Awake()
 {
     if (Instance == null)
     {
         i = this;
     }
 }
        public NotificationPage()
        {
            InitializeComponent();
            List <NotificationModel> data2 = NotificationController.InstanceCreation().GetNotificationsData();

            NotificationsList.ItemsSource = data2;
        }
Beispiel #31
0
        private void LoadController()
        {
            // HospitalManagementController
            doctorStatisticsController    = new DoctorStatisticsController(doctorStatisticsService);
            inventoryStatisticsController = new InventoryStatisticsController(inventoryStatisticsService);
            roomStatisticsController      = new RoomStatisticsController(roomStatisticsService);
            hospitalController            = new HospitalController(hospitalService);
            medicineController            = new MedicineController(medicineService);
            roomController      = new RoomController(roomService);
            inventoryController = new InventoryController(inventoryService);

            // MedicalController
            appointmentController = new AppointmentController(appointmentService, appointmentRecommendationService);
            diseaseController     = new DiseaseController(diseaseService);

            // MiscController
            articleController        = new ArticleController(articleService);
            doctorFeedbackController = new DoctorFeedBackController(doctorFeedbackService);
            feedbackController       = new FeedbackController(feedbackService);
            locationController       = new LocationController(locationService);
            messageController        = new MessageController(messageService);
            notificationController   = new NotificationController(notificationService);

            // UsersController
            doctorController    = new DoctorController(doctorService, diagnosisService, therapyService, medicalRecordService);
            managerController   = new ManagerController(managerService);
            patientController   = new PatientController(patientService, medicalRecordService, therapyService, diagnosisService);
            secretaryController = new SecretaryController(secretaryService);
            userController      = new UserController(userService);
        }
Beispiel #32
0
        public MainWindow()
        {
            if (App.IsShutDown)
                return;

            InitializeComponent();
            InitializeBinding();

            notificationController = new NotificationController(this);
            plink = new Plink();
            privoxy = new Privoxy();
        }
        void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            string infoMsg = String.Format("Date : {0} Time : {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongTimeString());
            log.Info(infoMsg + " REQUESTED BY WINDOWS SERVICE");

            try
            {
                NotificationController controller = new NotificationController();
                controller.Check();
            }
            catch (Exception ex)
            {
                log.Error("" + ex.Message.ToString());
            }

            log.Info(infoMsg + " RESPONDED BY WINDOWS SERVICE");
        }
 void OnDestroy()
 {
     Instance = null;
     unsubscribeEvents();
 }
 // Use this for initialization
 void Start()
 {
     notificationController = GameObject.Find("NotificationController").GetComponent<NotificationController>();
 }
    void Start()
    {
        _tileMap = GetComponent<TileMap> ();
        _generateZone = GetComponent < generateZone >();
        //myHoverObject = (GameObject) Instantiate (Resources.Load("Tile"), new Vector3 (0, 0, 0), Quaternion.identity);
        generate = false;
        zoning = true;
        currentColor = "blue";

        BuildingDatabase = new List<GameObject>();

        _GUIController = GameObject.Find ("Canvas").GetComponent<GUIController> ();
        notificationController = GameObject.Find("NotificationController").GetComponent<NotificationController>();
    }
Beispiel #37
0
        private void onWindowLoaded(object sender, RoutedEventArgs e) {
            InitializeBinding();

            var gaAppIdsToolTip = new ToolTip();
            gaAppIdsToolTip.Content = resources["GaAppIdsTooltip"] as string;
            gaAppIdsToolTip.StaysOpen = true;
            gaAppIdsToolTip.PlacementTarget = gaAppIdsTextBox;
            gaAppIdsToolTip.Placement = System.Windows.Controls.Primitives.PlacementMode.Top;
            gaAppIdsTextBox.ToolTip = gaAppIdsToolTip;

            notificationController = new NotificationController(this);
            plink = new Plink();
            privoxy = new Privoxy();
            goagent = new GoAgent();


            versionTextBlock.Text += resources["Version"] as string + " " + Assembly.GetExecutingAssembly().GetName().Version.ToString();
            websiteUrlText.Text = settings.WebsiteUrl;
            feedbackEmailText.Text = settings.FeedbackEmail;

            if (!(
                (settings.ProxyType == "SSH" && !Plink.CheckSettings()) ||
                (settings.ProxyType == "GA" && settings.GaAppIds == "")
            )) WindowState = WindowState.Minimized;

            goagent.Started += () => {
                notificationController.SetStatus("GA", NotificationController.Status.OK);
            };

            goagent.Stopped += () => {
                notificationController.SetStatus("GA", NotificationController.Status.Stopped);
            };

            //goagent.RequireRunas += () => {
            //    MessageBox.Show(resources["GoAgentRequiresRunasMessage"] as string);

            //    //var si = new ProcessStartInfo();
            //    //si.FileName = System.Windows.Forms.Application.ExecutablePath;
            //    //si.Verb = "runas";
            //    //si.Arguments = "restart";
            //    //Process.Start(si);
            //    Process.Start(System.Windows.Forms.Application.ExecutablePath, "restart");
                

            //    //App.Current.Shutdown();
            //};


            plink.Started += () => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshInformationGrid.IsEnabled = false;
                    sshConnectButton.IsEnabled = true;
                    sshConnectButton.Content = resources["Stop"] as string;
                    notificationController.SetStatus("SSH", NotificationController.Status.Processing, resources["Connecting"] as string);
                }));
            };

            plink.Connected += () => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshConnectButton.IsEnabled = true;
                    sshConnectButton.Content = resources["Disconnect"] as string;
                    notificationController.SetStatus("SSH", NotificationController.Status.OK, resources["Connected"] as string, settings.SshNotification ? String.Format(resources["SuccessConnectDescription"] as string, settings.SshServer) : null);
                }));
            };

            plink.ReconnectCountingDown += (seconds) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshConnectButton.IsEnabled = true;
                    sshConnectButton.Content = resources["Stop"] as string;
                    notificationController.SetStatus("SSH", NotificationController.Status.Stopped, String.Format(resources["ReconnectDescription"] as string, seconds));
                }));
            };

            plink.Disconnected += (isLastSuccess, isReconnect) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    sshInformationGrid.IsEnabled = true;
                    sshConnectButton.IsEnabled = true;
                    sshConnectButton.Content = resources["Connect"] as string;

                    if (plink.Error != null)
                        notificationController.SetStatus("SSH", NotificationController.Status.Error, resources["ErrorConnect"] as string, plink.Error != lastPlinkError ? plink.Error : null, System.Windows.Forms.ToolTipIcon.Error);
                    else if (isLastSuccess)
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["Disconnected"] as string, settings.SshNotification ? resources["DisconnectedDescription"] as string : null, System.Windows.Forms.ToolTipIcon.Warning);
                    else if (plink.IsNormallyStopped)
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["ConnectStopped"] as string);
                    else if (isReconnect)
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["ConnectFailed"] as string);
                    else
                        notificationController.SetStatus("SSH", NotificationController.Status.Stopped, resources["ConnectFailed"] as string, String.Format(resources["ConnectFailedDescription"] as string, settings.SshServer), System.Windows.Forms.ToolTipIcon.Warning);
                    
                    lastPlinkError = plink.Error;
                }));
            };

            //RULES
            //online rules
            if (settings.OnlineRulesLastUpdateTime.Ticks > 0) {
                lastUpdateTimeTextBlock.Text = settings.OnlineRulesLastUpdateTime.ToString(@"M\/d\/yyyy");
            }

            Rules.OnlineRules.UpdateStarted += () => {
                Dispatcher.BeginInvoke(new Action(() => {
                    onlineRulesUpdateButton.Content = resources["Updating"] as string;
                    onlineRulesUpdateButton.IsEnabled = false;
                }));
            };

            Rules.OnlineRules.Updated += (success) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    onlineRulesUpdateButton.Content = resources["Update"] as string;
                    onlineRulesUpdateButton.IsEnabled = true;
                    if (success)
                        lastUpdateTimeTextBlock.Text = settings.OnlineRulesLastUpdateTime.ToString(@"M\/d\/yyyy");
                    //else
                    //    notificationController.Tray.ShowBalloonTip(0, resources["UpdateOnlineRulesFailed"] as string, resources["UpdateOnlineRulesFailedDescription"] as string, System.Windows.Forms.ToolTipIcon.Warning);
                }));
            };

            //custom rules
            updateCustomRulesStatus();

            Rules.CustomRules.Rules.ListChanged += (o, a) => {
                Dispatcher.BeginInvoke(new Action(updateCustomRulesStatus));
            };

            Rules.Initialize();

            //* DEBUG CODE
            privoxy.Start();

            var server = new Microsoft.VisualStudio.WebHost.Server(settings.LocalServerPort, "/", App.AppDataDirectory + settings.LocalServerFolderName);
            try {
                server.Start();
            }
            catch {
                MessageBox.Show(string.Format(resources["FailedStartLocalServer"] as string, settings.LocalServerPort));
            }

            App.Current.Exit += (o, a) => {
                try {
                    server.Stop();
                }
                catch { }
            };

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "ProxyPort": break;
                    case "ListenToLocalOnly": break;
                    case "UseIntranetProxy": break;
                    case "IntranetProxyServer": break;
                    case "IntranetProxyPort": break;
                    default: return;
                }

                privoxy.Start();
            };
            //*/

            //ga

            if (settings.ProxyType == "GA") {
                goagent.Start();
            }

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "ProxyType": break;
                    default: return;
                }

                if (settings.ProxyType == "GA") {
                    goagent.Start();
                }
                else {
                    goagent.Stop();
                }
            };

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "GaPort": break;
                    case "GaProfile": break;
                    case "GaAppIds": break;
                    default: return;
                }

                if (settings.ProxyType == "GA") {
                    goagent.Start();
                }
            };


            //ssh

            if (settings.ProxyType == "SSH" && settings.AutoStart) {
                plink.Start();
            }

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "ProxyType": break;
                    default: return;
                }

                if (settings.ProxyType == "SSH") {
                    if (settings.AutoStart)
                        plink.Start();
                }
                else
                    plink.Stop();
            };

            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "SshSocksPort": break;
                    case "SshCompression": break;
                    case "SshPlonkKeyword": break;
                    default: return;
                }

                if (settings.ProxyType == "SSH") {
                    if (plink.IsConnected || plink.IsConnecting)
                        plink.Start();
                }
            };

            var usePlonkChangeBack = false;
            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "SshUsePlonk":
                        if (usePlonkChangeBack) {
                            usePlonkChangeBack = false;
                            return;
                        }
                        else break;
                    default: return;
                }

                if (settings.SshUsePlonk && !File.Exists(settings.PlonkFileName)) {
                    usePlonkChangeBack = true;
                    sshUsePlonkCheckBox.IsChecked = false;
                    MessageBox.Show(resources["PlonkMissingMessage"] as string);
                }
                else if (settings.ProxyType == "SSH") {
                    if (plink.IsConnected || plink.IsConnecting)
                        plink.Start();
                }
            };

            //http&socks
            settings.PropertyChanged += (o, a) => {
                switch (a.PropertyName) {
                    case "ProxyType": break;
                    default: return;
                }

                initIconStatus();
            };

            initIconStatus();

            var ruleCommandWatcher = new FileSystemWatcher(App.AppDataDirectory + settings.ConfigsFolderName, "*-cmd");
            ruleCommandWatcher.Created += ruleCommandHandler;
            ruleCommandWatcher.Changed += ruleCommandHandler;
            ruleCommandWatcher.EnableRaisingEvents = true;

            Timer updateCheckTimer = null;
            updateCheckTimer = new Timer((st) => {
                Dispatcher.BeginInvoke(new Action(() => {
                    if (onlineVersionStr == null) {
                        checkVersion();
                    }
                    else {
                        updateCheckTimer.Dispose();
                    }
                }));
            }, null, 0, settings.UpdateCheckDelay * 1000);

            if (App.Updated) {
                new Action(() => {
                    Thread.Sleep(1000);
                    try {
                        File.Delete(App.AppDataDirectory + settings.ResourcesFolderName + settings.UpdateInstallerName);
                    }
                    catch { }
                    notificationController.SendMessage(resources["UpdateSuccessTitle"] as string, resources["UpdateSuccessDetails"] as string);

                    if (Directory.Exists(App.AppDataDirectory + settings.GaFolderName) && settings.GaServerVersion > settings.GaLastServerVersion) {
                        settings.GaLastServerVersion = settings.GaServerVersion;
                        MessageBox.Show(resources["NewGaServerMessage"] as string);
                    }
                }).BeginInvoke(null, null);
            }

            if (App.Updated || App.FirstRun) {
                new WebClient().DownloadStringAsync(new Uri(settings.UpdateReportUrl + "?v=" + Assembly.GetExecutingAssembly().GetName().Version.ToString()));
            }

            if (WindowState != WindowState.Minimized)
                Activate();

            //if (!settings.SubmitNewRuleAsked) {
            //    settings.SubmitNewRuleAsked = true;
            //    var message = (resources["ShareRuleMessage"] as string).Replace("%n ", Environment.NewLine + Environment.NewLine);

            //    var result = MessageBox.Show(message, resources["ShareRuleTitle"] as string, MessageBoxButton.YesNo);
            //    settings.SubmitNewRule = result == MessageBoxResult.Yes;
            //}
        }
	// Use this for initialization
	void Start () {
	
		enabledWindow = false;
		notificationPanel.alpha = 0;
		ctrl = GetComponent<NotificationController>();
	}
	// Use this for initialization
	void Start () {
		ctrl = GetComponent<NotificationController>();
		testEmissions = new float[rmNames.Length];
	}
 public void Init()
 {
     mController = new NotificationController();
     mController.Interval = interval;
     mController.Model = mModel;
 }
    // Use this for initialization
    void Awake()
    {
        myAgentSpawner = FindObjectOfType<AgentSpawner> ();
        notificationController = GameObject.Find ("NotificationController").GetComponent <NotificationController> ();

        population = new List<GameObject> ();

        unAssignedPopulation = new List<GameObject>();

        buildingDatabase = new List<GameObject> ();
        farmerList = new List<GameObject>();
        farmBuildingList = new List<GameObject>();

        powerWorkerList = new List<GameObject>();
        powerBuildingList = new List<GameObject>();

        waterWorkerList = new List<GameObject> ();
        waterBuildingList = new List<GameObject> ();

        traineeList = new List<GameObject> ();
        trainingBuildingList = new List<GameObject> ();

        loadLastSave ();

        if (firstLoad) {
            //
            scrap += 75;
            //Start the game with 100 power
            power += 0;

            //Start population with a 10 person cap
            popLimit = 10;

            waterAlerted = true;
            powerAlerted = true;
            foodAlerted = true;
        }

        for ( int x = 0; x < mapSize; x++){
            for( int y = 0; y < mapSize; y++){

            }
        }

        InvokeRepeating("updateGridGraph",3,10);
    }