partial void InitializeSuperGameBoy()
		{
			borderChangedHandler = OnBorderChanged;
			additionalKeys = new GameBoyKeys[3];
			sgbCharacterData = new byte[0x2000];
			sgbBorderMapData = new ushort[0x800]; // This will also include palettes 4 - 7
			sgbCommandBuffer = new byte[7 * 16];
		}
        public void HandleBuildCompletion_ShouldNotSendBuildSuccess_WhenBuildBroken()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var buildEvent = new BuildCompletionEvent { TeamProject = "TestProject" };

            notificationHandler.HandleBuildCompletion(buildEvent);

            notifier.DidNotReceiveWithAnyArgs().SendBuildSuccessNotification(null, 0);
        }
        public void HandleBuildCompletion_ShouldNotSendBuildFailed_WhenNotificationNotSubscribed()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var buildEvent = new BuildCompletionEvent { TeamProject = "ProjectWithOnlyCheckin" };

            notificationHandler.HandleBuildCompletion(buildEvent);

            notifier.DidNotReceiveWithAnyArgs().SendBuildFailedNotification(null, 0);
        }
示例#4
0
        private static void StartService(IConfigurationProvider configurationProvider)
        {
            var hipChatNotifier = new HipChatNotifier(configurationProvider);
            var notificationHandler = new NotificationHandler(hipChatNotifier, configurationProvider);

            using (var host = new ServiceHost(new TfsHipChatEventService(notificationHandler)))
            {
                host.Open();
                System.Console.WriteLine("TfsHipChat started!");
                System.Console.ReadLine();
            }
        }
        public void HandleBuildCompletion_ShouldNotSendBuildSuccess_WhenBuildSuccessfulAndMappingNotDefined()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var buildEvent = new BuildCompletionEvent
                                 {
                                     CompletionStatus = "Successfully Completed",
                                     TeamProject = "ProjectWithNoMapping"
                                 };

            notificationHandler.HandleBuildCompletion(buildEvent);

            notifier.DidNotReceiveWithAnyArgs().SendBuildSuccessNotification(null, 0);
        }
        protected override void OnStart(string[] args)
        {
            var configurationProvider = new ConfigurationProvider { Path = GetConfigPath() };
            var errors = configurationProvider.Validate();

            if (errors.Count > 0)
            {
                var message = String.Join("\n", errors);
                throw new Exception(message);
            }

            var hipChatNotifier = new HipChatNotifier(configurationProvider);
            var notificationHandler = new NotificationHandler(hipChatNotifier, configurationProvider);
            _host = new ServiceHost(new TfsHipChatEventService(notificationHandler));
            _host.Open();
        }
		partial void InitializeThreading()
		{
			synchronizationContext = SynchronizationContext.Current;
			handlePostedNotification = HandlePostedNotification;
			frameDoneHandler = OnFrameDone;
			videoFrameCallback = RenderVideoFrameCallback;
#if WITH_THREADING
			clockManager = new GameBoyClockManager();
			emulationStartedHandler = OnEmulationStarted;
			emulationStoppedHandler = OnEmulationStopped;
			threadingEnabled = true;
			processorThread = new Thread(RunProcessor) { IsBackground = true };
			audioFrameThread = new Thread(RunAudioRenderer) { IsBackground = true };

			processorThread.Start();
			audioFrameThread.Start();
#endif
		}
示例#8
0
 private void OnDestroy()
 {
     s_instance = null;
 }
		partial void InitializeDebug()
		{
			breakpointHandler = null;
			breakPointList = new List<int>();
		}
        /// <summary>
        ///     Register a handler for notifications.
        /// </summary>
        /// <typeparam name="TNotification">
        ///     The notification message type.
        /// </typeparam>
        /// <param name="clientConnection">
        ///     The <see cref="LspConnection"/>.
        /// </param>
        /// <param name="method">
        ///     The name of the notification method to handle.
        /// </param>
        /// <param name="handler">
        ///     A <see cref="NotificationHandler{TNotification}"/> delegate that implements the handler.
        /// </param>
        /// <returns>
        ///     An <see cref="IDisposable"/> representing the registration.
        /// </returns>
        public static IDisposable HandleNotification <TNotification>(this LspConnection clientConnection, string method, NotificationHandler <TNotification> handler)
        {
            if (clientConnection == null)
            {
                throw new ArgumentNullException(nameof(clientConnection));
            }

            if (String.IsNullOrWhiteSpace(method))
            {
                throw new ArgumentException($"Argument cannot be null, empty, or entirely composed of whitespace: {nameof(method)}.", nameof(method));
            }

            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            return(clientConnection.RegisterHandler(
                       new DelegateNotificationHandler <TNotification>(method, handler)
                       ));
        }
        public void HandleWorkItemChanged_ShouldNotSendNotification_WhenTaskHistoryChangedIsAutomaticChangesetComment()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var changedEvent = new WorkItemChangedEvent
            {
                PortfolioProject = "TestProject",
                ChangeType = "Change",
                CoreFields =
                {
                    StringFields = new[]
                                {
                                    new Field() {Name = "Work Item Type", NewValue = "Task"},
                                    new Field() {Name = "State", NewValue = "In Progress"}
                                }
                },
                TextFields = new[] { new TextField() { Name = "History", Value = "Associated with changeset 123456" } }
            };

            notificationHandler.HandleWorkItemChanged(changedEvent);

            notifier.DidNotReceiveWithAnyArgs().SendTaskHistoryCommentNotification(null, 0);
        }
        public void HandleWorkItemChanged_ShouldSendNotification_WhenTaskStateIsChanged()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var changedEvent = new WorkItemChangedEvent
                {
                    PortfolioProject = "TestProject",
                    ChangeType = "Change",
                    CoreFields = { StringFields = new[] {new Field() {Name = "Work Item Type", NewValue = "Task"}} },
                    ChangedFields = { StringFields = new[] {new Field() {Name = "State", NewValue = "In Progress"}} }
                };

            notificationHandler.HandleWorkItemChanged(changedEvent);

            notifier.ReceivedWithAnyArgs().SendTaskStateChangedNotification(null, 0);
        }
 private void InitializeNotificationHandler()
 {
     NotificationHandler = new NotificationHandler();
     NotificationHandler.Publish(NotificationType.Info, "Starting");
 }
        public void HandleCheckin_ShouldSendNotification_WhenSubscribedImplicitly()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var checkinEvent = new CheckinEvent { TeamProject = "TestProject" };

            notificationHandler.HandleCheckin(checkinEvent);

            notifier.ReceivedWithAnyArgs().SendCheckinNotification(null, 0);
        }
示例#15
0
        public static void UnsafeRemoveObserver(System.Type notificationType, INotificationDispatcher sender, NotificationHandler handler)
        {
            if (notificationType == null)
            {
                throw new System.ArgumentNullException("notificationType");
            }
            if (!TypeUtil.IsType(notificationType, typeof(Notification)))
            {
                throw new TypeArgumentMismatchException(notificationType, typeof(Notification), "notificationType");
            }
            if (object.ReferenceEquals(sender, null))
            {
                throw new System.ArgumentNullException("sender");
            }
            if (handler == null)
            {
                throw new System.ArgumentNullException("handler");
            }

            sender.Observers.UnsafeRemoveObserver(notificationType, handler);
        }
示例#16
0
        public static void UnsafeRemoveObserver(System.Type notificationType, object sender, NotificationHandler handler)
        {
            if (notificationType == null)
            {
                throw new System.ArgumentNullException("notificationType");
            }
            if (!TypeUtil.IsType(notificationType, typeof(Notification)))
            {
                throw new TypeArgumentMismatchException(notificationType, typeof(Notification), "notificationType");
            }
            if (object.ReferenceEquals(sender, null))
            {
                throw new System.ArgumentNullException("sender");
            }
            if (handler == null)
            {
                throw new System.ArgumentNullException("handler");
            }

            if (sender is INotificationDispatcher)
            {
                (sender as INotificationDispatcher).Observers.UnsafeRemoveObserver(notificationType, handler);
            }
            else if (GameObjectUtil.IsGameObjectSource(sender))
            {
                var dispatcher = GameObjectUtil.GetGameObjectFromSource(sender).GetComponent <GameObjectNotificationDispatcher>();
                if (dispatcher != null)
                {
                    dispatcher.Observers.UnsafeRemoveObserver(notificationType, handler);
                }
            }
            else
            {
                throw new System.ArgumentException("Sender is not a NotificationDispatcher.", "sender");
            }
        }
示例#17
0
 public bool HasNotification(string notificationName, NotificationHandler callFun)
 {
     return(m_MsgMap.ContainsKey(notificationName) ? m_MsgMap[notificationName].Contains(callFun) : false);
 }
示例#18
0
        public static void UnsafeRegisterGlobalObserver(System.Type notificationType, NotificationHandler handler)
        {
            if (notificationType == null)
            {
                throw new System.ArgumentNullException("notificationType");
            }
            if (!TypeUtil.IsType(notificationType, typeof(Notification)))
            {
                throw new TypeArgumentMismatchException(notificationType, typeof(Notification), "notificationType");
            }
            if (handler == null)
            {
                throw new System.ArgumentNullException("handler");
            }

            NotificationHandler d;

            if (_unsafeGlobalHandlers.TryGetValue(notificationType, out d))
            {
                _unsafeGlobalHandlers[notificationType] = d + handler;
            }
            else
            {
                _unsafeGlobalHandlers[notificationType] = handler;
            }
        }
 public void RemoveObserver <T>(NotificationHandler <T> handler) where T : Notification
 {
     _globalNotificationHandlers.RemoveObserver <T>(handler);
 }
 public void RegisterObserver <T>(NotificationHandler <T> handler, bool useWeakReference = false) where T : Notification
 {
     _globalNotificationHandlers.RegisterObserver <T>(handler, useWeakReference);
 }
示例#21
0
 public RegisterService(NotificationHandler notificationHandler, MockedProductRepository repository)
 {
     _notificationHandler = notificationHandler;
     _repository          = repository;
 }
 public DeParaServicoController(NotificationHandler notificationHandler,
                                IDeParaServicoService deParaServicoService)
 {
     _notificationHandler  = notificationHandler;
     _deParaServicoService = deParaServicoService;
 }
示例#23
0
 protected Application()
 {
     this.Notification = new NotificationHandler();
 }
示例#24
0
 public BaseAssertion()
 {
     Notifications = new NotificationHandler();
 }
 public CategoriaContabilController(NotificationHandler notificationHandler, ICategoriaContabilService categoriaContabilService)
 {
     _notificationHandler      = notificationHandler;
     _categoriaContabilService = categoriaContabilService;
 }
        public void HandleCheckin_ShouldSendNotificationToCorrectRoom_WhenCheckinOccurs()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var checkinEvent = new CheckinEvent { TeamProject = "AnotherTestProject" };

            notificationHandler.HandleCheckin(checkinEvent);

            notifier.Received().SendCheckinNotification(checkinEvent, 456);
        }
 public InterestTaxControllerUnitTest()
 {
     _interestTaxRepository = Substitute.For <IInterestTaxRepository>();
     _notification          = new NotificationHandler();
 }
        public void HandleWorkItemChanged_ShouldNotSendNotification_WhenChangeTypeIsNotChange()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var changedEvent = new WorkItemChangedEvent()
                {
                    PortfolioProject = "TestProject",
                    ChangeType = "foo",
                    CoreFields = { StringFields = new[] { new Field() { Name = "Work Item Type", NewValue = "Product Backlog Item" } } },
                    ChangedFields = { StringFields = new[] { new Field() { Name = "State", NewValue = "In Progress" } } }
                };

            notificationHandler.HandleWorkItemChanged(changedEvent);

            notifier.DidNotReceiveWithAnyArgs().SendTaskChangedRemainingNotification(null, 0);
            notifier.DidNotReceiveWithAnyArgs().SendTaskOwnerChangedNotification(null, 0);
            notifier.DidNotReceiveWithAnyArgs().SendTaskStateChangedNotification(null, 0);
            notifier.DidNotReceiveWithAnyArgs().SendTaskHistoryCommentNotification(null, 0);
        }
示例#29
0
        }//end Signup

        public async Task <IActionResult> SignupConfirm(SignupViewModel model, List <IFormFile> img)
        {
            string nvm;

            try
            {
                if (!User.Identity.IsAuthenticated)
                {
                    nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Require_Login, contentRootPath);
                    return(RedirectToAction("Signin", new { notification = nvm }));
                }
                if (!ModelState.IsValid)
                {
                    nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Wrong_Values, contentRootPath);
                    return(RedirectToAction("Signup", new { notification = nvm }));
                }
                else
                {
                    if (model != null)
                    {
                        var chkUser = await _userManager.FindByNameAsync(model.Username);

                        ApplicationUser chkEmail;
                        if (model.Email != null)
                        {
                            chkEmail = await _userManager.FindByEmailAsync(model.Email);
                        }
                        else
                        {
                            chkEmail = null;
                        }
                        if (chkUser == null && chkEmail == null)
                        {
                            var currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

                            var greDate = CustomizeCalendar.PersianToGregorian(model.Dateofbirth ?? DateTime.Now);

                            //create new user
                            ApplicationUser newUser = new ApplicationUser()
                            {
                                FirstName     = model.Firstname,
                                LastName      = model.Lastname,
                                UserName      = model.Username,
                                Email         = model.Email,
                                PhoneNumber   = model.Phonenumber,
                                SpecialUser   = model.Specialuser,
                                Status        = model.Status,
                                DefinedByUser = currentUser,
                                DateOfBirth   = greDate,
                                Rank          = 1,
                                NationalCode  = model.Nationalcode
                            };
                            if (model.Gender == true)
                            {
                                newUser.Gendre = 1; //male
                            }
                            else if (model.Gender == false)
                            {
                                newUser.Gendre = 2; //female
                            }
                            else
                            {
                                newUser.Gendre = null; //not specified
                            }

                            var user_status = await _userManager.CreateAsync(newUser, model.Password);

                            if (user_status.Succeeded)
                            {
                                await _userManager.AddToRoleAsync(newUser, "SuperVisor");

                                //Add image of user in 'UserImage' table, seperately
                                if (img.Count > 0)
                                {
                                    var newAddedUser = await _userManager.FindByNameAsync(newUser.UserName);

                                    if (newAddedUser != null)
                                    {
                                        try
                                        {
                                            UserImage userImage = new UserImage()
                                            {
                                                UserId  = newAddedUser.Id,
                                                Caption = newAddedUser.LastName + "_" + DateTime.Now
                                            };
                                            img.ForEach(x =>
                                            {
                                                if (x != null)
                                                {
                                                    byte[] b = new byte[x.Length];
                                                    x.OpenReadStream().Read(b, 0, b.Length);
                                                    userImage.Image = b;

                                                    //Make Thumbnail
                                                    MemoryStream mem1 = new MemoryStream(b);
                                                    Image img2        = Image.FromStream(mem1);
                                                    Bitmap bmp        = new Bitmap(img2, 120, 120);
                                                    MemoryStream mem2 = new MemoryStream();
                                                    bmp.Save(mem2, System.Drawing.Imaging.ImageFormat.Jpeg);
                                                    userImage.ImageThumbnail = mem2.ToArray();
                                                }
                                            });
                                            _db.UserImage.Add(userImage);
                                            _db.SaveChanges();
                                        }
                                        catch (Exception)
                                        {
                                            nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Insert_Image, contentRootPath);
                                            return(RedirectToAction("Signup", new { notification = nvm }));
                                        }
                                    }
                                }

                                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Success_Insert, contentRootPath);
                                return(RedirectToAction("Signup", new { notification = nvm }));
                            }
                            nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Insert, contentRootPath);
                            return(RedirectToAction("Signup", new { notification = nvm }));
                        }
                        else
                        {
                            nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Insert, contentRootPath);
                            return(RedirectToAction("Signup", new { notification = nvm }));
                        }
                    }
                    else
                    {
                        nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Operation, contentRootPath);
                        return(RedirectToAction("Signup", new { notification = nvm }));
                    }
                }
            }
            catch (Exception)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Operation, contentRootPath);
                return(RedirectToAction("Signup", new { notification = nvm }));
            }
        }//end SignupConfirm
        public void HandleWorkItemChanged_ShouldNotSendNotification_WhenWorkItemTypeIsNotTask()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var changedEvent = new WorkItemChangedEvent() { PortfolioProject = "TestProject", ChangeType = "foo"};

            notificationHandler.HandleWorkItemChanged(changedEvent);

            notifier.DidNotReceiveWithAnyArgs().SendTaskChangedRemainingNotification(null, 0);
            notifier.DidNotReceiveWithAnyArgs().SendTaskOwnerChangedNotification(null, 0);
            notifier.DidNotReceiveWithAnyArgs().SendTaskStateChangedNotification(null, 0);
            notifier.DidNotReceiveWithAnyArgs().SendTaskHistoryCommentNotification(null, 0);
        }
示例#31
0
        public async Task <IActionResult> RemoveUserConfirm(string id)
        {
            NotificationViewModel nvm;

            try
            {
                if (ModelState.IsValid)
                {
                    if (id.Length > 0)
                    {
                        var currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

                        var currentUserRole = await _userManager.GetRolesAsync(currentUser);

                        var isUserExist = await _userManager.FindByIdAsync(id);

                        //only MainAdmin can Remove other users
                        if (User.Identity.Name != MainAdmin)
                        {
                            nvm = NotificationHandler.SerializeMessage <NotificationViewModel>(NotificationHandler.Access_denied_delete, contentRootPath);
                            return(Json(nvm));
                        }

                        //cannot remove yourself
                        if (isUserExist.UserName == User.Identity.Name)
                        {
                            nvm = NotificationHandler.SerializeMessage <NotificationViewModel>(NotificationHandler.Access_denied_self_delete, contentRootPath);
                            return(Json(nvm));
                        }

                        var selectUserToRemove_role = await _userManager.GetRolesAsync(isUserExist);

                        if (isUserExist != null)
                        {
                            using (var transaction = _db.Database.BeginTransaction())
                            {
                                bool           delUserImage = true, delUserModified = true;
                                IdentityResult result = null;

                                //remove user roles
                                if (selectUserToRemove_role.Count() > 0)
                                {
                                    foreach (var item in selectUserToRemove_role.ToList())
                                    {
                                        // item should be the name of the role
                                        result = await _userManager.RemoveFromRoleAsync(isUserExist, item);
                                    }
                                }

                                //remove user images
                                var doesUserHaveImage = _db.UserImage.Where(x => x.UserId == isUserExist.Id).ToList();
                                if (doesUserHaveImage.Count > 0)
                                {
                                    foreach (var item in doesUserHaveImage)
                                    {
                                        delUserImage = _dbUserImage.DeleteById(item.Id);
                                    }
                                }

                                //remove user backups
                                var doesUserHaveBackup = _db.UserModified.Where(x => x.UserId == isUserExist.Id).ToList();
                                if (doesUserHaveBackup.Count > 0)
                                {
                                    foreach (var item in doesUserHaveBackup)
                                    {
                                        delUserModified = _dbUserModified.DeleteById(item.Id);
                                    }
                                }
                                var status = await _userManager.DeleteAsync(isUserExist);

                                if (status.Succeeded && result.Succeeded && delUserImage == true && delUserModified == true)
                                {
                                    transaction.Commit(); //saves the database

                                    //removed successfully
                                    nvm = NotificationHandler.SerializeMessage <NotificationViewModel>(NotificationHandler.Success_Remove, contentRootPath);
                                    return(Json(nvm));
                                }
                            }
                        }
                    }
                }
                nvm = NotificationHandler.SerializeMessage <NotificationViewModel>(NotificationHandler.Failed_Remove, contentRootPath);
                return(Json(nvm));
            }
            catch (Exception)
            {
                //failed operation
                nvm = NotificationHandler.SerializeMessage <NotificationViewModel>(NotificationHandler.Failed_Operation, contentRootPath);
                return(Json(nvm));
            }
        }//end RemoveUserConfirm
示例#32
0
 /// <summary>
 /// Register a description of all the notification methods supported by the RPC server
 /// </summary>
 public void RegisterNotificationMethod(NotificationType notificationType, NotificationHandler notificationHandler)
 {
     notificationMethods.Add(notificationType.Method, new NotificationMethod() { Type = notificationType, HandleNotification = notificationHandler });
 }
 public NotificationPool()
 {
     _genericHandler = new NotificationHandler(this.HandleGenericNotification);
 }
示例#34
0
 public GUILibrary(LiteDatabase library, NotificationHandler notificationHandler) : base(library)
 {
     this.notificationHandler = notificationHandler;
 }
        /// <summary>
        ///     Register a handler for empty notifications.
        /// </summary>
        /// <param name="clientDispatcher">
        ///     The <see cref="LspDispatcher"/>.
        /// </param>
        /// <param name="method">
        ///     The name of the notification method to handle.
        /// </param>
        /// <param name="handler">
        ///     A <see cref="NotificationHandler"/> delegate that implements the handler.
        /// </param>
        /// <returns>
        ///     An <see cref="IDisposable"/> representing the registration.
        /// </returns>
        public static IDisposable HandleEmptyNotification(this LspDispatcher clientDispatcher, string method, NotificationHandler handler)
        {
            if (clientDispatcher == null)
            {
                throw new ArgumentNullException(nameof(clientDispatcher));
            }

            if (string.IsNullOrWhiteSpace(method))
            {
                throw new ArgumentException($"Argument cannot be null, empty, or entirely composed of whitespace: {nameof(method)}.", nameof(method));
            }

            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            return(clientDispatcher.RegisterHandler(
                       new DelegateEmptyNotificationHandler(method, handler)
                       ));
        }
示例#36
0
 protected MainController(INotificationHandler <Notification> notifications, IMediatorHandler mediatorHandler)
 {
     _mediatorHandler = mediatorHandler;
     _notifications   = (NotificationHandler)notifications;
 }
示例#37
0
 public CommandHandler(ISession session, IEventPublisher bus, INotificationHandler <Notification> notifications)
     : this(session)
 {
     _notifications = (NotificationHandler)notifications;
     _bus           = bus;
 }
示例#38
0
 public void addNotificationHandler(NotificationHandler notificationHandler)
 {
     notificationHandlers.Add(notificationHandler);
 }
		private void PostUINotification(NotificationHandler handler)
		{
			if (synchronizationContext != null) synchronizationContext.Post(handlePostedNotification, handler);
			else handler(EventArgs.Empty);
		}
示例#40
0
        }//end EditUser

        public async Task <IActionResult> EditUserConfirm(SignupViewModel model, List <IFormFile> img, string Id)
        {
            string nvm;
            var    user = await _userManager.FindByIdAsync(Id);

            var userModifier = await _userManager.FindByNameAsync(User.Identity.Name);

            try
            {
                if (user == null)
                {
                    nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Record_Not_Exist, contentRootPath);
                    return(RedirectToAction("UserList", new { notification = nvm }));
                }


                //check if other users want to change 'Admin' deny their access to do that
                var userModifierRoleId   = _db.UserRoles.Where(x => x.UserId == userModifier.Id).FirstOrDefault().RoleId;
                var userModifierRoleName = _db.Roles.Where(x => x.Id == userModifierRoleId).FirstOrDefault().Name;

                var userRoleId   = _db.UserRoles.Where(x => x.UserId == Id).FirstOrDefault().RoleId;
                var userRoleName = _db.Roles.Where(x => x.Id == userRoleId).FirstOrDefault().Name;
                if (userModifierRoleName != "Admin" && userRoleName == "Admin")
                {
                    nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Access_denied, contentRootPath);
                    return(RedirectToAction("UserList", new { notification = nvm }));
                }

                if (model.CurrentPassword != null && model.NewPassword != null && model.ConfirmNewPassword != null)
                {
                    if (userModifier == user || userModifierRoleName == "Admin")
                    {
                        var statusPasswordChange = await _userManager.ChangePasswordAsync(user, model.CurrentPassword, model.NewPassword);
                    }
                }

                //Get Backup From The User Into 'UserModified' Table
                var userJSONForBackup = JsonConvert.SerializeObject(user);

                using (var transaction = _db.Database.BeginTransaction())
                {
                    UserModified UM = new UserModified()
                    {
                        LastUserBackupJson = userJSONForBackup,
                        ModifedByUserId    = userModifier.Id,
                        UserId             = user.Id,
                        Comment            = "Edited by " + userModifier.UserName
                    };
                    _dbUserModified.Insert(UM);

                    var greDate = CustomizeCalendar.PersianToGregorian(model.Dateofbirth ?? DateTime.Now);
                    user.FirstName   = model.Firstname;
                    user.LastName    = model.Lastname;
                    user.Email       = model.Email;
                    user.PhoneNumber = model.Phonenumber;
                    user.SpecialUser = model.Specialuser;
                    //user.Status = model.Status;
                    user.DateOfBirth = greDate;
                    if (model.Gender == true)
                    {
                        user.Gendre = 1; //male
                    }
                    else if (model.Gender == false)
                    {
                        user.Gendre = 2; //female
                    }
                    else
                    {
                        user.Gendre = null; //not specified
                    }

                    if (userRoleName != model.RoleName)
                    {
                        if (userModifierRoleName != "Admin")
                        {
                            nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Access_denied, contentRootPath);
                            return(RedirectToAction("UserList", new { notification = nvm }));
                        }
                    }
                    //only admin can disable other users
                    if (userModifierRoleName == "Admin")
                    {
                        //"*****@*****.**" will never be disable
                        if (user.UserName == MainAdmin)
                        {
                            user.Status = model.Status;
                            //change user role
                            IdentityResult rol_status_1 = new IdentityResult(), rol_status_2 = new IdentityResult();
                            if (userRoleName != model.RoleName)
                            {
                                rol_status_1 = await _userManager.RemoveFromRoleAsync(user, userRoleName);

                                rol_status_2 = await _userManager.AddToRoleAsync(user, model.RoleName);
                            }
                        }
                        else
                        {
                            nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Access_denied, contentRootPath);
                            return(RedirectToAction("UserList", new { notification = nvm }));
                        }
                    }


                    //--------------------------------
                    if (img.Count > 0)
                    {
                        //disable the last images of the user
                        var doesUserHaveImage = _db.UserImage.Where(x => x.UserId == Id).ToList();
                        if (doesUserHaveImage.Count > 0)
                        {
                            foreach (var item in doesUserHaveImage)
                            {
                                var lastImagesOfUser = _dbUserImage.FindById(item.Id);
                                lastImagesOfUser.Status  = false;
                                lastImagesOfUser.Comment = $"Edited by {userModifier.UserName}";
                                _db.UserImage.Update(lastImagesOfUser);
                            }
                        }
                        //--------------------------------
                        //add new image of the user
                        UserImage userImage = new UserImage()
                        {
                            UserId  = Id,
                            Caption = model.Lastname + "_" + DateTime.Now
                        };
                        img.ForEach(x =>
                        {
                            if (x != null)
                            {
                                byte[] b = new byte[x.Length];
                                x.OpenReadStream().Read(b, 0, b.Length);
                                userImage.Image = b;

                                //Make Thumbnail
                                MemoryStream mem1 = new MemoryStream(b);
                                Image img2        = Image.FromStream(mem1);
                                Bitmap bmp        = new Bitmap(img2, 120, 120);
                                MemoryStream mem2 = new MemoryStream();
                                bmp.Save(mem2, System.Drawing.Imaging.ImageFormat.Jpeg);
                                userImage.ImageThumbnail = mem2.ToArray();
                            }
                        });
                        _dbUserImage.Insert(userImage);
                    }



                    //--------------------------------
                    var status = await _userManager.UpdateAsync(user);

                    if (status.Succeeded)
                    {
                        transaction.Commit(); //Save the new records in 'User' table and 'UserImage' table

                        nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Success_Update, contentRootPath);
                        return(RedirectToAction("UserList", new { notification = nvm }));
                    }
                }
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Update, contentRootPath);
                return(RedirectToAction("UserList", new { notification = nvm }));
            }
            catch (Exception)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Update, contentRootPath);
                return(RedirectToAction("UserList", new { notification = nvm }));
            }
        }//end EditUserConfirm
 public UsuarioService(
     NotificationHandler notificationHandler)
 {
     _notificationHandler = notificationHandler;
 }
示例#42
0
        private bool SetEverythingUp()
        {
            HistoryItem firstItem = new HistoryItem();
            firstItem.Action = Yedda.Twitter.ActionType.Friends_Timeline;
            History.Push(firstItem);
            if (System.IO.File.Exists(ClientSettings.AppPath + "\\crash.txt"))
            {
                using (CrashReport errorForm = new CrashReport())
                {
                    //errorForm.Owner = this;
                    errorForm.ShowDialog();
                    errorForm.Dispose();
                }
            }
            if (!StartBackground)
            {
                this.Show();
            }
            bool ret = true;

            if (ClientSettings.CheckVersion)
            {
                Checker = new UpgradeChecker();
                Checker.UpgradeFound += new UpgradeChecker.delUpgradeFound(UpdateChecker_UpdateFound);
            }
            SetUpListControl();

            try
            {
                ResetDictionaries();
            }
            catch (OutOfMemoryException)
            {
                PockeTwit.Localization.LocalizedMessageBox.Show("There's not enough memory to run PockeTwit. You may want to close some applications and try again.");
                if (Manager != null)
                {
                    Manager.ShutDown();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                PockeTwit.Localization.LocalizedMessageBox.Show("Corrupt settings - {0}\r\nPlease reconfigure.", ex.Message);
                ClearSettings();
                ResetDictionaries();
            }

            CurrentlySelectedAccount = ClientSettings.DefaultAccount;

            Notifyer = new NotificationHandler();
            Notifyer.MessagesNotificationClicked += new NotificationHandler.DelNotificationClicked(Notifyer_MessagesNotificationClicked);

            return ret;
        }
示例#43
0
        public async Task <IActionResult> EditGeneralPageConfirm(GeneralPageViewModel model)
        {
            string nvm;

            if (ModelState.IsValid == false)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Wrong_Values, contentRootPath);
                return(RedirectToAction("ShowGeneralPage", new { notification = nvm }));
            }
            var entity = dbGeneralPage.FindById(model.Id);

            if (entity != null)
            {
                entity.Title        = model.Title;
                entity.Description  = model.Description;
                entity.RegdDateTime = DateTime.Now;
                entity.ContentHtml  = model.ContentHtml;
                entity.ShowOrder    = model.ShowOrder;
                entity.Status       = model.Status;
            }
            //Delete Old Image then Insert New Image
            string folderPath;
            string savePath;

            if (model.MainImage != null)
            {
                if (entity.MainImagePath != null)
                {
                    bool imgDel = FileManager.DeleteFile(contentRootPath, entity.MainImagePath);
                }
                folderPath = configuration.GetSection("DefaultPaths").GetSection("PagesFiles").Value;
                savePath   = await FileManager.ReadAndSaveFile(contentRootPath, folderPath, model.MainImage);

                entity.MainImagePath = savePath;
            }
            if (model.MovieFile != null)
            {
                if (entity.MoviePath != null)
                {
                    bool FileDel = FileManager.DeleteFile(contentRootPath, entity.MoviePath);
                }
                folderPath = configuration.GetSection("DefaultPaths").GetSection("PagesFiles").Value;
                savePath   = await FileManager.ReadAndSaveFile(contentRootPath, folderPath, model.MovieFile);

                entity.MoviePath = savePath;
            }
            if (model.DocumentFile != null)
            {
                if (entity.DocumentPath != null)
                {
                    bool FileDel = FileManager.DeleteFile(contentRootPath, entity.DocumentPath);
                }
                folderPath = configuration.GetSection("DefaultPaths").GetSection("PagesFiles").Value;
                savePath   = await FileManager.ReadAndSaveFile(contentRootPath, folderPath, model.DocumentFile);

                entity.DocumentPath = savePath;
            }
            try
            {
                dbGeneralPage.Update(entity);
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Success_Update, contentRootPath);
                return(RedirectToAction("ShowGeneralPage", new { notification = nvm }));
            }
            catch (Exception)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Update, contentRootPath);
                return(RedirectToAction("ShowGeneralPage", new { notification = nvm }));
            }
        }
示例#44
0
 public SongEntry(string filePath, string artist, string album, string title, Player player, NotificationHandler notificationHandler, GUILibrary library)
 {
     this.player = player;
     this.notificationHandler = notificationHandler;
     this.library             = library;
     InitializeComponent();
     FilePath = filePath;
     ArtistAlbumLabel.Text = $"{artist} ・ {album}";
     TitleLabel.Text       = title;
     Title = title;
 }
 public SprintSlackObserver(NotificationHandler notificationHandler)
 {
     this.NotificationHandler = notificationHandler;
 }
 public GenericAppService(IUnitOfWork iuow, IMediatorHandler bus, INotificationHandler <Notification> notifications)
 {
     Notifications = (NotificationHandler)notifications;
     UnitOfWork    = iuow;
     Bus           = bus;
 }
        public void HandleBuildCompletion_ShouldSendBuildSuccessToCorrectRoom_WhenBuildSuccessful()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var buildEvent = new BuildCompletionEvent
                                 {
                                     CompletionStatus = "Successfully Completed",
                                     TeamProject = "AnotherTestProject"
                                 };

            notificationHandler.HandleBuildCompletion(buildEvent);

            notifier.Received().SendBuildSuccessNotification(buildEvent, 456);
        }
示例#48
0
 static IOBluetoothRFCOMMChannel()
 {
     notificationHandler = new NotificationHandler(HandleChannelOpened);
     registerForChannelOpenNotifications(notificationHandler, new Selector(channelOpenNotificationsSelector));
 }
        public void HandleCheckin_ShouldNotSendNotification_WhenNotSubscribed()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var checkinEvent = new CheckinEvent { TeamProject = "ProjectWithOnlyBuild" };

            notificationHandler.HandleCheckin(checkinEvent);

            notifier.DidNotReceiveWithAnyArgs().SendCheckinNotification(null, 0);
        }
示例#50
0
 internal void SimpleNotification(string v)
 {
     NotificationHandler.Invoke(v);
 }
示例#51
0
		static IOBluetoothRFCOMMChannel ()
		{
			notificationHandler = new NotificationHandler (HandleChannelOpened);
			registerForChannelOpenNotifications (notificationHandler, new Selector (channelOpenNotificationsSelector));
		}