コード例 #1
0
        /// <summary>
        /// Aplica todos los cambios que han sido aplicados a una entidad y a todos objetos relacionados con la misma.
        /// </summary>
        /// <param name="model">Instancia del objeto.</param>
        /// <param name="nm">Mensaje de notificación.</param>
        public async Task <int> Save(T model, Notifications nm = null)
        {
            int result = 0;

            try
            {
                var validationErrors = _db.ChangeTracker.Entries <IValidatableObject>()
                                       .SelectMany(e => e.Entity.Validate(null))
                                       .Where(r => r != ValidationResult.Success);

                if (validationErrors.Any())
                {
                    // Reportar los mensajes de validación
                    foreach (var ve in validationErrors)
                    {
                        var member = ve.MemberNames.First();
                        nm?.Add(new Message()
                        {
                            Level       = Level.Validation,
                            Description = $"La propiedad {member}. Tiene {ve.ErrorMessage}."
                        });
                    }
                }
                else
                {
                    result = await _db.ApplyChanges <T>(model);
                }

                return(result);
            }
            catch (DbUpdateConcurrencyException dce)
            {
                ManageConcurrency(dce, nm);
            }
            catch (Exception ex)
            {
                if (nm == null)
                {
                    throw ex;
                }
                else
                {
                    while (ex != null)
                    {
                        var msg = Messages.General.EXCEPTION;
                        msg.Description = ex.Message;
                        nm.Add(msg);

                        ex = ex.InnerException;
                    }
                }
            }

            return(result);
        }
コード例 #2
0
        // Create
        public Discipline(string name, Course course, Professor professor, int weeklyWorkload, int period, int professorWorkload)
        {
            Name           = name;
            Course         = course;
            Professor      = professor;
            WeeklyWorkload = weeklyWorkload;
            Period         = period;
            var maxWorkload = new ProfessorMaxWorkLoadDictionary().Get(Professor.Degree);

            if (professorWorkload + WeeklyWorkload > maxWorkload)
            {
                Notifications.Add("WeeklyWorkload", $"A carga horária máxima do professor {maxWorkload} não pode ser excedida");
            }
        }
コード例 #3
0
        /// <summary>
        ///     Initializes static members of the <see cref="ThemeManager" /> class.
        /// </summary>
        /// <param name="menu">
        ///     The menu.
        /// </param>
        public static void Initialize(Menu menu)
        {
            Events.OnLoad += (sender, args) =>
            {
                Menu = new Menu("thememanager", "Theme Manager");

                Menu.Add(
                    new MenuList <string>(
                        "themeID",
                        "Theme",
                        new[] { "Default", "Blue", "Blue 2", "Light", "Light 2", "Colored", "Tech" })).ValueChanged
                    += (o, eventArgs) =>
                    {
                    Notifications.Add(new Notification("Theme Manager", "Please reload Menu !"));
                    };

                menu.Add(Menu);

                switch (Menu["themeID"].GetValue <MenuList>().Index)
                {
                case 0:
                    Current = new DefaultTheme();
                    break;

                case 1:
                    Current = new BlueTheme();
                    break;

                case 2:
                    Current = new BlueTheme2();
                    break;

                case 3:
                    Current = new LightTheme();
                    break;

                case 4:
                    Current = new LightTheme2();
                    break;

                case 5:
                    Current = new ColoredTheme();
                    break;

                case 6:
                    Current = new TechTheme();
                    break;
                }
            };
        }
コード例 #4
0
        public Renekton()
        {
            Notifications.Add(new Notification("Dao Hung AIO f**k WWapper", "Renekton credits Soresu and Exory"));
            InitRenekton();
            InitMenu();

            Chat.Print("<font color=\"#05FAAC\"><b>DH.Renekton:</b></font> Feedback send to facebook yts.1996 Sayuto");
            Chat.Print("<font color=\"#FF9900\"><b>Credits: Soresu and Exory</b></font>");
            Game.OnUpdate      += Game_OnGameUpdate;
            Orbwalker.OnAction += OnActionDelegate;
            Drawing.OnDraw     += Game_OnDraw;
            //Jungle.setSmiteSlot();
            //HpBarDamageIndicator.DamageToUnit = ComboDamage;
        }
コード例 #5
0
 public void AddNotification(string id, string notification)
 {
     DoOnMainThread(() =>
     {
         var matchingIds = Notifications
                           .Where(kv => kv.Key == id)
                           .ToArray();
         foreach (var item in matchingIds)
         {
             Notifications.Remove(item);
         }
         Notifications.Add(new KeyValuePair <string, string>(id, notification));
     });
 }
コード例 #6
0
 public void AddNotification(string id, string notification, bool isLoading = false)
 {
     DoOnMainThread(() =>
     {
         var matchingIds = Notifications
                           .Where(kv => kv.Key == id)
                           .ToArray();
         foreach (var item in matchingIds)
         {
             Notifications.Remove(item);
         }
         Notifications.Add(new Notification(id, notification, isLoading));
     });
 }
コード例 #7
0
        public Varus()
        {
            Notifications.Add(new Notification("Dao Hung AIO f**k WWapper", "Varus credit jQuery"));
            spells[Spells.Q].SetSkillshot(.25f, 70f, 1850f, false, false, SkillshotType.Line);
            spells[Spells.E].SetSkillshot(0.35f, 120, 1500, false, false, SkillshotType.Circle);
            spells[Spells.R].SetSkillshot(.25f, 120f, 1850f, false, false, SkillshotType.Line);

            spells[Spells.Q].SetCharged("VarusQLaunch", "VarusQLaunch", 925, 1600, 2);
            Initialize();
            Game.OnUpdate           += OnGameUpdate;
            Drawing.OnDraw          += Drawing_OnDraw;
            AIBaseClient.OnBuffGain += AIBaseClientBuffGain;
            AIBaseClient.OnBuffLose += AIBaseClientBuffLose;
        }
コード例 #8
0
        private bool UsuarioValido(Usuario usuario)
        {
            if (usuario.EstaValido())
            {
                return(true);
            }

            foreach (var error in usuario.ValidationResult.Errors)
            {
                Notifications.Add(error.ErrorMessage, error.ErrorCode, sender);
            }

            return(false);
        }
コード例 #9
0
 internal void ShowToast(RenderFragment message, string type)
 {
     InvokeAsync(() =>
     {
         var toast = new NotificationModel(Remove)
         {
             Id      = Guid.NewGuid(),
             Message = message,
             Type    = type
         };
         Notifications.Add(toast);
         StateHasChanged();
     });
 }
コード例 #10
0
        public void AddNotification(string caption, string message, string details, MessageType type)
        {
            Notification not = new Notification();

            not.Header  = caption;
            not.Message = message;
            not.Type    = type;
            not.Details = details;
            if (!Notifications.Contains(not))
            {
                Notifications.Add(not);
            }
            OnNotificationsUpdated();
        }
コード例 #11
0
        public IEnumerable <string> Get()
        {
            Notifications.Add("erro da controller usuario", sender);

            var endereco = new Endereco("", "", "", "", "", "", "");

            var usuario = new Usuario("Jonh Doe", "026.103.931-80");

            //usuario.AtribuirEndereco(endereco);

            _usuarioService.Adicionar(usuario);

            return(_usuarioRepository.ObterTodos().Select(p => p.Nome));
        }
コード例 #12
0
        public MainWindow()
        {
            InitializeComponent();

            var windowMonitor = new WindowMonitor(this);
            var notifications = new Notifications();

            for (var i = 1; i < 10; i++)
            {
                notifications.Add(new Notification($"{i}", $"Message {i}"));
            }

            _notificationManager = new NotificationManager(windowMonitor, notifications);
        }
コード例 #13
0
        public async Task Executar(long id)
        {
            var linha = await context.Linhas.FindAsync(id);

            if (linha is null)
            {
                Notifications.Add("not-found", "Linha não encontrada!");
            }
            else
            {
                context.Remove(linha);
                await context.SaveChangesAsync();
            }
        }
コード例 #14
0
        private async Task AddFakeNotifications(RecognizedObjects recognizedObject)
        {
            await Task.Delay(1500);

            Application.Current.Dispatcher.Invoke(
                DispatcherPriority.Background,
                new Action(() =>
            {
                var mfi             = new System.Globalization.DateTimeFormatInfo();
                string strMonthName = mfi.GetMonthName(DateTime.Now.Month).ToString();
                switch (recognizedObject)
                {
                case RecognizedObjects.Apple:
                    Notifications.Add($"Apples are a seasonal fruit in {strMonthName}!");
                    Notifications.Add("If you buy 200gr more, you'll get a 20% discount!");
                    Thread.Sleep(500);
                    Notifications.Add("Pears are discounted too!");
                    break;

                case RecognizedObjects.Orange:
                    if (!new[] { 1, 6, 7, 8, 9, 10, 11, 12 }.Any(a => a == DateTime.Now.Month))
                    {
                        Notifications.Add($"Oranges are a seasonal fruit in {strMonthName}!");
                    }
                    else
                    {
                        Notifications.Add(new NiceNotification($"You are buying off-season fruits. Oranges are in season from February to May.", "Khaki"));
                    }
                    Notifications.Add("Good choice! In this period Vitamin C is important!");
                    break;

                case RecognizedObjects.Banana:
                    Notifications.Add($"Bananas are a seasonal fruit in {strMonthName}!");
                    Notifications.Add("Buongustaio!");
                    break;

                case RecognizedObjects.Strawberry:
                    if (!new[] { 2, 3, 4, 5 }.Any(a => a == DateTime.Now.Month))
                    {
                        Notifications.Add($"Stawberries are a seasonal fruit in {strMonthName}!");
                    }
                    else
                    {
                        Notifications.Add(new NiceNotification($"You are buying off-season fruits. Strawberries are in season from February to May.", "Khaki"));
                    }
                    break;
                }
            }));
        }
コード例 #15
0
 public void AlbumBeenLinked()
 {
     if (CurrentPage.GetType() == typeof(WebAlbumListViewModel))
     {
         if (!SharedMethods.CheckIfZuneSoftwareIsRunning())
         {
             Notifications.Add(new ErrorMessage(ErrorMode.Warning,
                                                "Any albums you link / delink will not show their changes until the zune software is running."));
         }
         else
         {
             _webAlbumListViewModel.SelectedAlbum.RefreshAlbum();
         }
     }
 }
コード例 #16
0
ファイル: NotifyService.cs プロジェクト: planath/BoilerPlate
        private void CreateNewNotification(int identifier, string title, string message, DateTime scheduledDateTime)
        {
            var notification = new UILocalNotification();

            notification.FireDate   = (NSDate)scheduledDateTime;
            notification.AlertTitle = title;
            notification.AlertBody  = message;
            notification.SoundName  = UILocalNotification.DefaultSoundName;
            var howManyEventsAreYouLateTo = OnDue + 1;

            notification.ApplicationIconBadgeNumber = howManyEventsAreYouLateTo;

            UIApplication.SharedApplication.ScheduleLocalNotification(notification);
            Notifications.Add(identifier, notification);
        }
コード例 #17
0
        public void AddNotification(NotificationBase notification)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.Invoke(new Action(() => AddNotification(notification)));
                return;
            }
            notification.Id = count++;
            if (Notifications.Count + 1 > MAX_NOTIFICATIONS)
            {
                buffer.Add(notification);
            }
            else
            {
                Notifications.Add(notification);
            }

            //Show window if there're notifications
            if (Notifications.Count > 0 && !IsActive)
            {
                Show();
            }
            Resize();
        }
コード例 #18
0
        public Professor(Guid id, string firstName, string lastName, string email, string phone, EDegree degree) : base(email)
        {
            Id    = id;
            Email = new Email(email);
            if (!string.IsNullOrEmpty(Email.Notification))
            {
                Notifications.Add("Email", Email.Notification);
            }

            FirstName = firstName;
            LastName  = lastName;
            Phone     = phone;
            Degree    = degree;
            Validation();
        }
コード例 #19
0
        public ServerViewModel(IWCFHostService hostService, IUnitOfWork db, ISettingsService settingsService, IDialogService dialogService)
        {
            this.hostService     = hostService;
            this.db              = db;
            this.settingsService = settingsService;
            this.dialogService   = dialogService;

            Client = new ChatWCFService.Client(settingsService.Name);
            Port   = settingsService.Port;
            hostService.ClientConnected += (s, e) =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    ConnectedClients.Add(e.Client);
                    Notifications.Add(new Notification($"Client {e.Client.Name} connected", DateTime.Now, NotificationType.ClientConnected));
                });
            };
            hostService.ClientDisconneced += (s, e) =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    var client = ConnectedClients.Where(c => c.Name == e.Client.Name).FirstOrDefault();
                    ConnectedClients.Remove(client);
                    Notifications.Add(new Notification($"Client {e.Client.Name} disconnected", DateTime.Now, NotificationType.ClientDisconnected));
                });
            };
            hostService.MessageReceived += (s, e) =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() => {
                    Messages?.Add(new Model.Message(e.Message));
                });
            };

            DispatcherHelper.RunAsync(async() =>
            {
                var messages = (await db.Messages.GetAll()).Select(m => new Model.Message(m));
                foreach (var message in messages)
                {
                    Messages.Add(message);
                }
            });
            Messenger.Default.Register <NotificationMessage>(this, (m) => {
                switch (m.Notification)
                {
                case "ServerWindowClosed": StopServer(); break;
                }
            });
        }
コード例 #20
0
        //[RebelAuthorize(Permissions = new[] { FixedPermissionIds.Permissions })]
        public virtual JsonResult PublicAccessForm(PublicAccessModel model)
        {
            using (var uow = BackOfficeRequestContext.Application.Hive.OpenWriter <IContentStore>())
            {
                var entity = uow.Repositories.Get <TypedEntity>(model.Id);
                if (entity == null)
                {
                    throw new NullReferenceException("Could not find entity with id " + model.Id);
                }

                // Store the redirect locations
                var currentPubclicAccessRelation = uow.Repositories.GetParentRelations(entity.Id, FixedRelationTypes.PublicAccessRelationType)
                                                   .SingleOrDefault();

                if (model.LoginPageId.IsNullValueOrEmpty() &&
                    !model.UserGroupIds.Any() && currentPubclicAccessRelation != null)
                {
                    uow.Repositories.RemoveRelation(currentPubclicAccessRelation);
                }
                else
                {
                    uow.Repositories.ChangeOrCreateRelationMetadata(FixedHiveIds.SystemRoot, entity.Id, FixedRelationTypes.PublicAccessRelationType,
                                                                    new[] {
                        new RelationMetaDatum("UserGroupIds", model.UserGroupIds.ToJsonString()),
                        new RelationMetaDatum("LoginPageId", model.LoginPageId.ToString()),
                        new RelationMetaDatum("ErrorPageId", model.ErrorPageId.ToString())
                    });
                }

                uow.Complete();

                var successMsg = "PublicAccess.Success.Message".Localize(this, new
                {
                    Name = entity.GetAttributeValue(NodeNameAttributeDefinition.AliasValue, "Name")
                });

                Notifications.Add(new NotificationMessage(
                                      successMsg,
                                      "PublicAccess.Title".Localize(this), NotificationType.Success));

                return(new CustomJsonResult(new
                {
                    success = true,
                    notifications = Notifications,
                    msg = successMsg
                }.ToJsonString));
            }
        }
コード例 #21
0
        /// <summary>
        /// Processes the submit for insert/update
        /// </summary>
        /// <param name="model"></param>
        /// <param name="entity"></param>
        protected ActionResult ProcessSubmit(DataTypeEditorModel model, AttributeType entity)
        {
            Mandate.ParameterNotNull(model, "model");

            model.BindModel(this);

            model.Id = entity != null ? entity.Id : HiveId.Empty;

            if (!ModelState.IsValid)
            {
                AddValidationErrorsNotification();
                EnsurePropEditorListViewBagData();
                return(View(model));
            }

            //persist the data
            using (var uow = BackOfficeRequestContext.Application.Hive.OpenWriter <IContentStore>())
            {
                if (entity == null)
                {
                    //map to new entity
                    entity = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map <DataTypeEditorModel, AttributeType>(model);
                }
                else
                {
                    //map back to existing entity from updated model
                    BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map(model, entity);
                }

                uow.Repositories.Schemas.AddOrUpdate(entity);
                uow.Complete();

                Notifications.Add(new NotificationMessage(
                                      "DataType.Save.Message".Localize(this),
                                      "DataType.Save.Title".Localize(this),
                                      NotificationType.Success));

                //add path for entity for SupportsPathGeneration (tree syncing) to work,
                //we need to manually contruct the path because of the static root node id.
                GeneratePathsForCurrentEntity(new EntityPathCollection(entity.Id, new[] { new EntityPath(new[]
                    {
                        new HiveId(FixedSchemaTypes.SystemRoot, null, new HiveIdValue(new Guid(CorePluginConstants.DataTypeTreeRootNodeId))),
                        entity.Id
                    }) }));

                return(RedirectToAction("Edit", new { id = entity.Id }));
            }
        }
コード例 #22
0
        private static void OnGameLoad()
        {
            if (ObjectManager.Player.CharacterName != "Swain")
            {
                return;
            }

            Swain.OnLoad();
            var not1 = new Notification("ProDragon Swain", "Swain loaded \n And don't forget to give me feedback :) ");
            var not2 = new Notification("Combo", "Q, W, E, R auto active");
            var not3 = new Notification("killsteal", "Q, W, E auto active");

            Notifications.Add(not1);
            Notifications.Add(not2);
            Notifications.Add(not3);
        }
コード例 #23
0
ファイル: Artist.cs プロジェクト: yngvebn/ArtistBasePage
 public void AddNotification(Notification connectToLastFmNotification)
 {
     if (Notifications == null)
     {
         Notifications = new Collection <Notification>();
     }
     if (Notifications.All(c => c.Type == connectToLastFmNotification.Type && !c.Read))
     {
         Notifications.Add(connectToLastFmNotification);
         DomainEvents.Raise(new NotificationAdded()
         {
             Artist           = this,
             LastNotification = connectToLastFmNotification
         });
     }
 }
コード例 #24
0
        internal void RemoveNotification(INotificationInfo notification)
        {
            //if (Notifications.Contains(notification))
            Notifications.Remove(notification);

            if (_buffer.Count > 0)
            {
                Notifications.Add(_buffer[0]);
                _buffer.RemoveAt(0);
            }

            //Close window if there's nothing to show
            if (Notifications.Count < 1)
            {
                Hide();
            }
        }
コード例 #25
0
        private void LoadNotifications()
        {
            string proc = PluginInitialization._work.OpenForm.ProcOpen("LoadNotifications");

            try
            {
                CountAll = _repo.GetCountNotifications(
                    SelectedFilterNotificationStatus,
                    SelectedFilterPriority,
                    SelectedFilterType,
                    FilterText,
                    COUNT_IN_PAGE,
                    PageNum);

                if (Notifications == null)
                {
                    Notifications = new ObservableCollection <NotificationVM>();
                }
                else
                {
                    Notifications.Clear();
                }

                var data = _repo.GetNotifications(
                    SelectedFilterNotificationStatus,
                    SelectedFilterPriority,
                    SelectedFilterType,
                    FilterText,
                    COUNT_IN_PAGE,
                    PageNum);
                foreach (var item in data)
                {
                    Notifications.Add(new NotificationVM(item, _repo));
                }
            }
            catch (Exception ex)
            {
                PluginInitialization._work.OpenForm.ProcClose(proc);
                MessageBox.Show("Ошибка при получении уведомлений! Описание: " + ex.Message, "", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            finally
            {
                PluginInitialization._work.OpenForm.ProcClose(proc);
            }
        }
コード例 #26
0
        public JsonResult Delete(HiveId id)
        {
            Mandate.ParameterNotEmpty(id, "id");

            using (var uow = BackOfficeRequestContext.Application.Hive.OpenWriter <IContentStore>())
            {
                uow.Repositories.Schemas.Delete <AttributeType>(id);
                uow.Complete();
            }

            //return a successful JSON response

            Notifications.Add(new NotificationMessage("Delete.Successful".Localize(this), NotificationType.Success));
            var obj = new { message = "Success", notifications = Notifications };

            return(new CustomJsonResult(() => obj.ToJsonString()));
        }
コード例 #27
0
 /// <summary>
 /// Adds a notification to the queue, and display it if applicable.
 /// </summary>
 /// <param name="notification">Notification to add</param>
 public void AddNotification(Notification notification)
 {
     notification.Id = count++;
     if (Notifications.Count + 1 > MAX_NOTIFICATIONS)
     {
         buffer.Add(notification);
     }
     else
     {
         Notifications.Add(notification);
     }
     //Show window if there're notifications
     if (Notifications.Count > 0)
     {
         this.Visibility = System.Windows.Visibility.Visible;
     }
 }
コード例 #28
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="notification"></param>
        public void AddNotify(Notification notification)
        {
            if (notifications.Count + 1 > maxNotifications)
            {
                bufferNotifications.Add(notification);
            }
            else
            {
                notifications.Add(notification);
            }

            //如果有通知显示窗口
            if (notifications.Count > 0 && IsActive == false)
            {
                Show();
            }
        }
コード例 #29
0
        public void OnMessageHandler(NetNotification notification)
        {
            lock (this)
            {
                Notifications.Add(notification);

                if (Notifications.Count == expectedMessages)
                {
                    ManualResetEvent.Set();
                }
            }
            if (!this.actionType.Equals(NetAction.DestinationType.TOPIC))
            {
                client.Acknowledge(notification.Subscription, notification.Message.MessageId);
                Console.WriteLine("Acknowledge");
            }
        }
コード例 #30
0
        public void AddNotification(Notification notification)
        {
            notification.Id = count++;
            if (Notifications.Count + 1 > MAX_NOTIFICATIONS)
            {
                buffer.Add(notification);
            }
            else
            {
                Notifications.Add(notification);
            }

            //Show window if there're notifications
            if (Notifications.Count > 0 && !IsActive)
            {
                Show();
            }
        }