示例#1
0
        void UpdateSettings(string id, NotificationTarget target, bool state)
        {
            var    settingsById = Settings.Program.UserNotifications.ById;
            string targetString = target.ToString();

            if (state)
            {
                if (!settingsById.TryGetValue(id, out var values))
                {
                    values           = new HashSet <string>();
                    settingsById[id] = values;
                }
                values.Add(targetString);
            }
            else
            {
                if (settingsById.TryGetValue(id, out var values))
                {
                    values.Remove(targetString);
                    if (values.Count == 0)
                    {
                        settingsById.Remove(id);
                    }
                }
            }
            // TODO: сделать сохранение настроек асинхронным
            // и писать не каждый раз, а время от времени
            Settings.Program.Save();
        }
示例#2
0
        async Task ExecuteSendPushNotificationCommand(string tag)
        {
            var id = await MobileCenter.GetInstallIdAsync();

            var content = new NotificationContent();
            var target  = new NotificationTarget();

            content.Body  = "This is a test!";
            content.Title = "push sent from mobile device";

            target.Devices = new string[] { id.ToString() };

            //if (!string.IsNullOrEmpty(tag))
            //target.Audiences = new List<string>() { tag };

            var push = new MobileCenterNotification();

            push.Content = content;
            push.Target  = target;

            push.Content.CustomData = new Dictionary <string, string>()
            {
                { "hello", "mahdi" }
            };

            var httpclient = new HttpClient();

            var jsonin = JsonConvert.SerializeObject(push);

            var res = await httpclient.PostAsync <string>("http://mobilecenterpush.azurewebsites.net/api/sendpush", push);
        }
示例#3
0
 private static Notification DefaultNotification(NotificationTarget target, string message, string title)
 {
     return(new Notification()
     {
         Target = target,
         Description = message,
         Title = title,
         CloseOnSelect = true
     });
 }
        public bool ReleaseNotification(int id, bool doSendToClient = true)
        {
            var notificationRepo = IoC.Container.Resolve <BaseRepositoryV2 <MedDbContext, Notification> >();

            try
            {
                var notifi = notificationRepo.GetAll().Where(e => e.ID == id && e.Status == (int)Med.Common.Enums.Notification.NotificationStatusTypeId.UnReleased).FirstOrDefault();
                if (notifi == null)
                {
                    return(false);
                }
                var targetRepo = IoC.Container.Resolve <BaseRepositoryV2 <MedDbContext, NotificationTarget> >();
                if (string.IsNullOrEmpty(notifi.DrugStoreID))
                {
                    var drugStoreRepo        = IoC.Container.Resolve <BaseRepositoryV2 <MedDbContext, NhaThuoc> >();
                    var lstNhaThuoc          = drugStoreRepo.GetAll().Where(e => e.HoatDong).Select(e => e.MaNhaThuoc).ToList();
                    NotificationTarget taget = null;
                    foreach (string manhaThuoc in lstNhaThuoc)
                    {
                        taget = new NotificationTarget()
                        {
                            NotificationID         = notifi.ID,
                            DrugStoreID            = manhaThuoc,
                            NotificationReadTypeID = (int)Med.Common.Enums.Notification.NotificationReadTypeId.UnRead,
                            NotificationDate       = DateTime.Now
                        };
                        targetRepo.Add(taget);
                    }
                }
                else
                {
                    var taget = new NotificationTarget()
                    {
                        NotificationID         = notifi.ID,
                        DrugStoreID            = notifi.DrugStoreID,
                        NotificationReadTypeID = (int)Med.Common.Enums.Notification.NotificationReadTypeId.UnRead,
                        NotificationDate       = DateTime.Now
                    };
                    targetRepo.Add(taget);
                }
                notifi.Status = (int)Med.Common.Enums.Notification.NotificationStatusTypeId.Released;
                notificationRepo.Update(notifi);
                targetRepo.Commit();
                notificationRepo.Commit();
                if (doSendToClient)
                {
                    NotifyUsersLoadNotifications();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#5
0
        public static async Task <HttpResponseMessage> PushForUsersAsync([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            var appCenterToken = GetEnvironmentVariable("AppCenterToken");
            var ownerName      = GetEnvironmentVariable("OwnerName");

            if (!IsProperlyConfigured(appCenterToken, ownerName, log))
            {
                return(req.CreateResponse(HttpStatusCode.ExpectationFailed, new
                {
                    Error = "Server Fault.The Server is missing critical configuration settings."
                }));
            }

            try
            {
                string requestBody = await req.Content.ReadAsStringAsync();

                if (string.IsNullOrWhiteSpace(requestBody))
                {
                    return(req.CreateResponse(HttpStatusCode.BadRequest, "The request has no content"));
                }

                var request = JsonConvert.DeserializeObject <UserNotificationRequest>(requestBody);
                var db      = new AppCenterUserTrackingContext();

                var registrations = db.UserRegistrations.Where(reg => request.Users.Contains(reg.UserId));

                var targets = new Dictionary <string, NotificationTarget>();
                foreach (var platform in registrations.Select(r => r.Platform).Distinct())
                {
                    var target = new NotificationTarget
                    {
                        Type    = TargetType.Devices,
                        Devices = registrations.Where(r => r.Platform == platform).Select(r => r.DeviceId)
                    };
                    targets.Add(platform, target);
                }

                var notificationRequest = new NotificationRequest
                {
                    Targets = targets,
                    Content = request.Content
                };
                var responses = await ProcessTargetsAsync(notificationRequest, ownerName, appCenterToken, log);

                return(GenerateResponse(req, responses));
            }
            catch (Exception ex)
            {
                log.Error("Unexpected Error occurred", ex);
                return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
示例#6
0
        private static async Task <bool> SendPushNotification(string title, string body, string installId)
        {
            NotificationTarget notificationTarget = new NotificationTarget()
            {
                devices = new List <string>()
                {
                    installId
                },
                type = "devices_target"
            };

            NotificationContent notificationContent = new NotificationContent()
            {
                body  = body,
                name  = "Test notification",
                title = title,
            };

            pushNotification pushNotification = new pushNotification()
            {
                notification_content = notificationContent,
                notification_target  = notificationTarget,
            };

            HttpClient httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
            httpClient.DefaultRequestHeaders.Add("X-API-Token", "f91e1f79bf5eaa0faeee9d67d1a4c56f16ee8e8a");

            StringContent stringContent = pushNotification.AsJson();

            try
            {
                HttpResponseMessage httpResponseMessage = await httpClient.PostAsync("https://api.appcenter.ms/v0.1/apps/michalis_anagnostou-hotmail.com/Notification/push/notifications", stringContent);

                if (httpResponseMessage.IsSuccessStatusCode)
                {
                    return(true);
                }
                else if (httpResponseMessage.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    var json = await httpResponseMessage.Content.ReadAsStringAsync();

                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("there was an error");
                return(false);
            }

            return(false);
        }
示例#7
0
        public async Task <string> GetContent(NotificationTarget target, string templatePath, dynamic model)
        {
            string templateTypePath = "Templates\\" + target.ToString();
            string basePath         = Path.Combine(AppDomain.CurrentDomain !.BaseDirectory !, templateTypePath);
            var    engine           = new RazorLightEngineBuilder()
                                      .UseFileSystemProject(basePath)
                                      .UseMemoryCachingProvider()
                                      .Build();

            return(await engine.CompileRenderAsync(templatePath, model));
        }
示例#8
0
        public void Post(NotificationTarget target)
        {
            var pushInformation = PushInformation.Load(AppDomain.CurrentDomain.BaseDirectory + "../info.xml");              // 保存先はてきとうに

            if (pushInformation == null)
            {
                return;
            }
            pushInformation.Targets.Remove(pushInformation.Targets.FirstOrDefault(t => t.EndPoint == target.EndPoint));
            pushInformation.Targets.Add(target);
            PushInformation.Save(pushInformation, AppDomain.CurrentDomain.BaseDirectory + "../info.xml");
        }
示例#9
0
        public static bool ShouldNotifyRowSubtree(NotificationTarget target)
        {
            NotificationTarget value =
                NotificationTarget.Rows |
                NotificationTarget.RowHeaders |
                NotificationTarget.CellsPresenter |
                NotificationTarget.Cells |
                NotificationTarget.RefreshCellContent |
                NotificationTarget.DetailsPresenter;

            return(TestTarget(target, value));
        }
示例#10
0
 private async Task <List <RecipientDto> > GetRecipients(NotificationTarget notificationTarget, EntityEvent entityEvent)
 {
     if (notificationTarget == NotificationTarget.Customer)
     {
         return(await GetRecipientsForEvent(entityEvent));
     }
     if (notificationTarget == NotificationTarget.Admin)
     {
         return(_settings.CurrentValue.Admins.Select(x => new RecipientDto()
         {
             Name = x.Name, EmailAddress = x.Email
         }).ToList());
     }
     return(new List <RecipientDto>());
 }
示例#11
0
        public void OnSubscriptionChanged(ExtendedItemViewModel item, NotificationTarget target)
        {
            bool newState = item.NotificationState[target].NotificationEnabled;

            switch (target)
            {
            case NotificationTarget.Alert:
                OnGenericSubscriptionChanged(item, alertItemKeys, newState);
                break;

            case NotificationTarget.Invasion:
                OnGenericSubscriptionChanged(item, invasionItemKeys, newState);
                break;

            default:
                throw new NotImplementedException();
            }

            UpdateSettings(item.Item.Id, target, newState);
        }
示例#12
0
        public bool PushUserNotification(string destinationuser, string message, NotificationTarget target, UserRole role,
                                         NotificationType notificationType, string clickaction)
        {
            //This method was discontinued.

            ////Check if its role or user

            ////do the role maths here
            //var usersinrole = _userservice.GetAllUsers().Where(x => x.Roles.Contains(role));

            //foreach(var user in usersinrole )
            //{
            //    //push to each of theme

            //    var notify = new UserNotification
            //    {
            //        UserId = user.Guid.ToString(),
            //        Message = message,
            //        Role = role,
            //        Target = Convert.ToInt32(target),
            //        ClickAction = clickaction,
            //        Type = Convert.ToInt32(notificationType)
            //    };

            //    _session.Transact(session => session.Save(notify));

            //    //Notify the theres a new notification
            //    var args = new NewNotificationArgs
            //    {
            //        Notification = notify
            //    };
            //    //Notify the Hub of the new Input
            // EventContext.Instance.Publish(typeof(INewNotificationEvent), args);

            //}

            return(true);
        }
 public NotificationMessage(NotificationTarget targetType, string target)
 {
     TargetType = targetType;
     Target     = target;
 }
        /// <summary>
        ///     General notification for DependencyProperty changes from the grid or from columns.
        /// </summary>
        internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, NotificationTarget target)
        {
            if (DataGridHelper.ShouldNotifyCellsPresenter(target))
            {
                if (e.Property == DataGridColumn.WidthProperty ||
                    e.Property == DataGridColumn.DisplayIndexProperty)
                {
                    if (((DataGridColumn)d).IsVisible)
                    {
                        InvalidateDataGridCellsPanelMeasureAndArrange();
                    }
                }
                else if (e.Property == DataGrid.FrozenColumnCountProperty ||
                         e.Property == DataGridColumn.VisibilityProperty ||
                         e.Property == DataGrid.CellsPanelHorizontalOffsetProperty ||
                         e.Property == DataGrid.HorizontalScrollOffsetProperty ||
                         string.Compare(propertyName, "ViewportWidth", StringComparison.Ordinal) == 0 ||
                         string.Compare(propertyName, "DelayedColumnWidthComputation", StringComparison.Ordinal) == 0)
                {
                    InvalidateDataGridCellsPanelMeasureAndArrange();
                }
                else if (string.Compare(propertyName, "RealizedColumnsBlockListForNonVirtualizedRows", StringComparison.Ordinal) == 0)
                {
                    InvalidateDataGridCellsPanelMeasureAndArrange(/* withColumnVirtualization */ false);
                }
                else if (string.Compare(propertyName, "RealizedColumnsBlockListForVirtualizedRows", StringComparison.Ordinal) == 0)
                {
                    InvalidateDataGridCellsPanelMeasureAndArrange(/* withColumnVirtualization */ true);
                }
                else if (e.Property == DataGrid.RowHeightProperty || e.Property == HeightProperty)
                {
                    DataGridHelper.TransferProperty(this, HeightProperty);
                }
                else if (e.Property == DataGrid.MinRowHeightProperty || e.Property == MinHeightProperty)
                {
                    DataGridHelper.TransferProperty(this, MinHeightProperty);
                }
                else if (e.Property == DataGrid.EnableColumnVirtualizationProperty)
                {
                    DataGridHelper.TransferProperty(this, VirtualizingStackPanel.IsVirtualizingProperty);
                }
            }

            if (DataGridHelper.ShouldNotifyCells(target) ||
                DataGridHelper.ShouldRefreshCellContent(target))
            {
                ContainerTracking <DataGridCell> tracker = _cellTrackingRoot;
                while (tracker != null)
                {
                    tracker.Container.NotifyPropertyChanged(d, propertyName, e, target);
                    tracker = tracker.Next;
                }
            }
        }
 public NotificationMessage(NotificationTarget targetType)
 {
     TargetType = targetType;
 }
示例#16
0
        /// <summary>
        ///     General notification for DependencyProperty changes from the grid or from columns.
        /// </summary>
        internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, NotificationTarget target)
        {
            DataGridColumn column = d as DataGridColumn;

            if ((column != null) && (column != Column))
            {
                // This notification does not apply to this cell
                return;
            }

            // All the notifications which are to be handled by the cell
            if (DataGridHelper.ShouldNotifyCells(target))
            {
                if (e.Property == DataGridColumn.WidthProperty)
                {
                    DataGridHelper.OnColumnWidthChanged(this, e);
                }
                else if (e.Property == DataGrid.CellStyleProperty || e.Property == DataGridColumn.CellStyleProperty || e.Property == StyleProperty)
                {
                    DataGridHelper.TransferProperty(this, StyleProperty);
                }
                else if (e.Property == DataGrid.IsReadOnlyProperty || e.Property == DataGridColumn.IsReadOnlyProperty || e.Property == IsReadOnlyProperty)
                {
                    DataGridHelper.TransferProperty(this, IsReadOnlyProperty);
                }
                else if (e.Property == DataGridColumn.DisplayIndexProperty)
                {
                    TabIndex = column.DisplayIndex;
                }
            }

            // All the notifications which needs forward to columns
            if (DataGridHelper.ShouldRefreshCellContent(target))
            {
                if (column != null && NeedsVisualTree)
                {
                    if (!string.IsNullOrEmpty(propertyName))
                    {
                        column.RefreshCellContent(this, propertyName);
                    }
                    else if (e != null && e.Property != null)
                    {
                        column.RefreshCellContent(this, e.Property.Name);
                    }
                }
            }
        }
 /// <summary>
 ///     General notification for DependencyProperty changes from the grid or from columns.
 /// </summary>
 internal void NotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e, NotificationTarget target)
 {
     NotifyPropertyChanged(d, string.Empty, e, target);
 }
 /// <summary>
 ///     General notification for DependencyProperty changes from the grid or from columns.
 /// </summary>
 /// <remarks>
 ///     This can be called from a variety of sources, such as from column objects
 ///     or from this DataGrid itself when there is a need to notify the rows and/or
 ///     the cells in the DataGrid about a property change. Down-stream handlers 
 ///     can check the source of the change using the "d" parameter.
 /// </remarks>
 /// 
 
 internal void NotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e, NotificationTarget target)
 {
     NotifyPropertyChanged(d, string.Empty, e, target);
     if(target==NotificationTarget.RowHeaders)
     {
         if(RowHeaderChanged!=null)
             RowHeaderChanged(d,new EventArgs());
     }
 }
示例#19
0
 public static bool ShouldNotifyColumns(NotificationTarget target)
 {
     return(TestTarget(target, NotificationTarget.Columns));
 }
示例#20
0
        /// <summary>
        ///     General notification for DependencyProperty changes from the grid or from columns.
        /// </summary>
        /// <remarks>
        ///     This can be called from a variety of sources, such as from column objects
        ///     or from this DataGrid itself when there is a need to notify the rows and/or
        ///     the cells in the DataGrid about a property change. Down-stream handlers 
        ///     can check the source of the change using the "d" parameter.
        /// </remarks>
        internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, NotificationTarget target)
        {
            if (DataGridHelper.ShouldNotifyDataGrid(target))
            {
                if (e.Property == AlternatingRowBackgroundProperty)
                {
                    // If the alternate row background is set, the count may be coerced to 2
                    CoerceValue(AlternationCountProperty);
                }
            }

            // Rows, Cells, CellsPresenter, DetailsPresenter or RowHeaders
            if (DataGridHelper.ShouldNotifyRowSubtree(target))  
            {
                // Notify the Rows about the property change
                ContainerTracking<DataGridRow> tracker = _rowTrackingRoot;
                while (tracker != null)
                {
                    tracker.Container.NotifyPropertyChanged(d, propertyName, e, target);
                    tracker = tracker.Next;
                }
            }

            if (DataGridHelper.ShouldNotifyColumnCollection(target) || DataGridHelper.ShouldNotifyColumns(target))
            {
                InternalColumns.NotifyPropertyChanged(d, propertyName, e, target);
            }

            if ((DataGridHelper.ShouldNotifyColumnHeadersPresenter(target) || DataGridHelper.ShouldNotifyColumnHeaders(target)) && ColumnHeadersPresenter != null)
            {
                ColumnHeadersPresenter.NotifyPropertyChanged(d, propertyName, e, target);   
            }
        }
示例#21
0
 public static bool ShouldRefreshCellContent(NotificationTarget target)
 {
     return(TestTarget(target, NotificationTarget.RefreshCellContent));
 }
示例#22
0
 public static bool ShouldNotifyRows(NotificationTarget target)
 {
     return(TestTarget(target, NotificationTarget.Rows));
 }
示例#23
0
 /// <summary>
 ///     General notification for DependencyProperty changes from the grid or from columns.
 /// </summary>
 internal void NotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e, NotificationTarget target)
 {
     NotifyPropertyChanged(d, string.Empty, e, target);
 }
        /// <summary>
        ///     Notification for column header-related DependencyProperty changes from the grid or from columns.
        /// </summary>
        internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, NotificationTarget target)
        {
            DataGridColumn column = d as DataGridColumn;
            if (DataGridHelper.ShouldNotifyColumnHeadersPresenter(target))
            {
                if (e.Property == DataGridColumn.WidthProperty ||
                    e.Property == DataGridColumn.DisplayIndexProperty)
                {
                    if (column.IsVisible)
                    {
                        InvalidateDataGridCellsPanelMeasureAndArrange();
                    }
                }
                else if (e.Property == DataGrid.FrozenColumnCountProperty ||
                    e.Property == DataGridColumn.VisibilityProperty ||
                    e.Property == DataGrid.CellsPanelHorizontalOffsetProperty ||
                    string.Compare(propertyName, "ViewportWidth", StringComparison.Ordinal) == 0 ||
                    string.Compare(propertyName, "DelayedColumnWidthComputation", StringComparison.Ordinal) == 0)
                {
                    InvalidateDataGridCellsPanelMeasureAndArrange();
                }
                else if (e.Property == DataGrid.HorizontalScrollOffsetProperty)
                {
                    InvalidateArrange();
                    InvalidateDataGridCellsPanelMeasureAndArrange();
                }
                else if (string.Compare(propertyName, "RealizedColumnsBlockListForNonVirtualizedRows", StringComparison.Ordinal) == 0)
                {
                    InvalidateDataGridCellsPanelMeasureAndArrange(/* withColumnVirtualization */ false);
                }
                else if (string.Compare(propertyName, "RealizedColumnsBlockListForVirtualizedRows", StringComparison.Ordinal) == 0)
                {
                    InvalidateDataGridCellsPanelMeasureAndArrange(/* withColumnVirtualization */ true);
                }
                else if (e.Property == DataGrid.CellsPanelActualWidthProperty)
                {
                    InvalidateArrange();
                }
                else if (e.Property == DataGrid.EnableColumnVirtualizationProperty)
                {
                    DataGridHelper.TransferProperty(this, VirtualizingStackPanel.IsVirtualizingProperty);
                }
            }
            
            if (DataGridHelper.ShouldNotifyColumnHeaders(target))
            {
                if (e.Property == DataGridColumn.HeaderProperty)
                {
                    if (HeaderCollection != null)
                    {
                        HeaderCollection.NotifyHeaderPropertyChanged(column, e);
                    }
                }
                else
                {
                    // Notify the DataGridColumnHeader objects about property changes
                    ContainerTracking<DataGridColumnHeader> tracker = _headerTrackingRoot;

                    while (tracker != null)
                    {
                        tracker.Container.NotifyPropertyChanged(d, e);
                        tracker = tracker.Next;
                    }

                    // Handle Style & Height change notification for PART_FillerColumnHeader.
                    if (d is DataGrid &&
                        (e.Property == DataGrid.ColumnHeaderStyleProperty || e.Property == DataGrid.ColumnHeaderHeightProperty))
                    {
                        DataGridColumnHeader fillerColumnHeader = GetTemplateChild(ElementFillerColumnHeader) as DataGridColumnHeader;
                        if (fillerColumnHeader != null)
                        {
                            fillerColumnHeader.NotifyPropertyChanged(d, e);
                        }
                    }
                }
            }
        }
 public NotificationTargetDescription(NotificationTarget target, string name, Brush color) =>
 (Target, Name, Color) = (target, name, color);
示例#26
0
 public static bool ShouldNotifyColumnHeadersPresenter(NotificationTarget target)
 {
     return(TestTarget(target, NotificationTarget.ColumnHeadersPresenter));
 }
        /// <summary>
        ///     General notification for DependencyProperty changes from the grid or from columns.
        /// </summary>
        internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, NotificationTarget target)
        {
            DataGridColumn column = d as DataGridColumn;
            if ((column != null) && (column != Column))
            {
                // This notification does not apply to this cell
                return;
            }

            // All the notifications which are to be handled by the cell
            if (DataGridHelper.ShouldNotifyCells(target))
            {
                if (e.Property == DataGridColumn.WidthProperty)
                {
                    DataGridHelper.OnColumnWidthChanged(this, e);
                }
                else if (e.Property == DataGrid.CellStyleProperty || e.Property == DataGridColumn.CellStyleProperty || e.Property == StyleProperty)
                {
                    DataGridHelper.TransferProperty(this, StyleProperty);
                }
                else if (e.Property == DataGrid.IsReadOnlyProperty || e.Property == DataGridColumn.IsReadOnlyProperty || e.Property == IsReadOnlyProperty)
                {
                    DataGridHelper.TransferProperty(this, IsReadOnlyProperty);
                }
                else if (e.Property == DataGridColumn.DisplayIndexProperty)
                {
                    TabIndex = column.DisplayIndex;
                }
            }

            // All the notifications which needs forward to columns
            if (DataGridHelper.ShouldRefreshCellContent(target))
            {
                if (column != null && NeedsVisualTree)
                {
                    if (!string.IsNullOrEmpty(propertyName))
                    {
                        column.RefreshCellContent(this, propertyName);
                    }
                    else if (e != null && e.Property != null)
                    {
                        column.RefreshCellContent(this, e.Property.Name);
                    }
                }
            }
        }
示例#28
0
 public static bool ShouldNotifyDataGrid(NotificationTarget target)
 {
     return(TestTarget(target, NotificationTarget.DataGrid));
 }
示例#29
0
 public static bool ShouldNotifyDetailsPresenter(NotificationTarget target)
 {
     return(TestTarget(target, NotificationTarget.DetailsPresenter));
 }
示例#30
0
        /// <summary>
        ///     General notification for DependencyProperty changes from the grid or from columns.
        /// </summary>
        internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, NotificationTarget target)
        {
            if (DataGridHelper.ShouldNotifyCellsPresenter(target))
            {
                if (e.Property == DataGridColumn.WidthProperty ||
                    e.Property == DataGridColumn.DisplayIndexProperty)
                {
                    if (((DataGridColumn)d).IsVisible)
                    {
                        InvalidateDataGridCellsPanelMeasureAndArrange();
                    }
                }
                else if (e.Property == DataGrid.FrozenColumnCountProperty ||
                    e.Property == DataGridColumn.VisibilityProperty ||
                    e.Property == DataGrid.CellsPanelHorizontalOffsetProperty ||
                    e.Property == DataGrid.HorizontalScrollOffsetProperty ||
                    string.Compare(propertyName, "ViewportWidth", StringComparison.Ordinal) == 0 ||
                    string.Compare(propertyName, "DelayedColumnWidthComputation", StringComparison.Ordinal) == 0)
                {
                    InvalidateDataGridCellsPanelMeasureAndArrange();
                }
                else if (string.Compare(propertyName, "RealizedColumnsBlockListForNonVirtualizedRows", StringComparison.Ordinal) == 0)
                {
                    InvalidateDataGridCellsPanelMeasureAndArrange(/* withColumnVirtualization */ false);
                }
                else if (string.Compare(propertyName, "RealizedColumnsBlockListForVirtualizedRows", StringComparison.Ordinal) == 0)
                {
                    InvalidateDataGridCellsPanelMeasureAndArrange(/* withColumnVirtualization */ true);
                }
                else if (e.Property == DataGrid.RowHeightProperty || e.Property == HeightProperty)
                {
                    DataGridHelper.TransferProperty(this, HeightProperty);
                }
                else if (e.Property == DataGrid.MinRowHeightProperty || e.Property == MinHeightProperty)
                {
                    DataGridHelper.TransferProperty(this, MinHeightProperty);
                }
                else if (e.Property == DataGrid.EnableColumnVirtualizationProperty)
                {
                    DataGridHelper.TransferProperty(this, VirtualizingStackPanel.IsVirtualizingProperty);
                }
            }

            if (DataGridHelper.ShouldNotifyCells(target) ||
                DataGridHelper.ShouldRefreshCellContent(target))
            {
                ContainerTracking<DataGridCell> tracker = _cellTrackingRoot;
                while (tracker != null)
                {
                    tracker.Container.NotifyPropertyChanged(d, propertyName, e, target);
                    tracker = tracker.Next;
                }
            }
        }
示例#31
0
    public async Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
    {
        iprot.IncrementRecursionDepth();
        try
        {
            TField field;
            await iprot.ReadStructBeginAsync(cancellationToken);

            while (true)
            {
                field = await iprot.ReadFieldBeginAsync(cancellationToken);

                if (field.Type == TType.Stop)
                {
                    break;
                }

                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.String)
                    {
                        Key = await iprot.ReadStringAsync(cancellationToken);
                    }
                    else
                    {
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                    }
                    break;

                case 2:
                    if (field.Type == TType.List)
                    {
                        {
                            TList _list137 = await iprot.ReadListBeginAsync(cancellationToken);

                            Targets = new List <NotificationTarget>(_list137.Count);
                            for (int _i138 = 0; _i138 < _list137.Count; ++_i138)
                            {
                                NotificationTarget _elem139;
                                _elem139 = new NotificationTarget();
                                await _elem139.ReadAsync(iprot, cancellationToken);

                                Targets.Add(_elem139);
                            }
                            await iprot.ReadListEndAsync(cancellationToken);
                        }
                    }
                    else
                    {
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                    }
                    break;

                case 3:
                    if (field.Type == TType.I64)
                    {
                        CreatedTime = await iprot.ReadI64Async(cancellationToken);
                    }
                    else
                    {
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                    }
                    break;

                case 4:
                    if (field.Type == TType.I64)
                    {
                        Data = await iprot.ReadI64Async(cancellationToken);
                    }
                    else
                    {
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                    }
                    break;

                case 5:
                    if (field.Type == TType.I32)
                    {
                        MaxDelay = await iprot.ReadI32Async(cancellationToken);
                    }
                    else
                    {
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                    }
                    break;

                default:
                    await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);

                    break;
                }

                await iprot.ReadFieldEndAsync(cancellationToken);
            }

            await iprot.ReadStructEndAsync(cancellationToken);
        }
        finally
        {
            iprot.DecrementRecursionDepth();
        }
    }
示例#32
0
 private static bool TestTarget(NotificationTarget target, NotificationTarget value)
 {
     return((target & value) != 0);
 }
        /// <summary>
        ///   General notification for DependencyProperty changes from the grid and/or column.  
        /// </summary>
        internal void NotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e, NotificationTarget target)
        {
            if (DataGridHelper.ShouldNotifyColumns(target))
            {
                // Remove columns target since we're handling it.  If we're targeting multiple targets it may also need to get
                // sent to the DataGrid.
                target &= ~NotificationTarget.Columns;

                if (e.Property == DataGrid.MaxColumnWidthProperty || e.Property == MaxWidthProperty)
                {
                    DataGridHelper.TransferProperty(this, MaxWidthProperty);
                }
                else if (e.Property == DataGrid.MinColumnWidthProperty || e.Property == MinWidthProperty)
                {
                    DataGridHelper.TransferProperty(this, MinWidthProperty);
                }
                else if (e.Property == DataGrid.ColumnWidthProperty || e.Property == WidthProperty)
                {
                    DataGridHelper.TransferProperty(this, WidthProperty);
                }
                else if (e.Property == DataGrid.ColumnHeaderStyleProperty || e.Property == HeaderStyleProperty)
                {
                    DataGridHelper.TransferProperty(this, HeaderStyleProperty);
                }
                else if (e.Property == DataGrid.CellStyleProperty || e.Property == CellStyleProperty)
                {
                    DataGridHelper.TransferProperty(this, CellStyleProperty);
                }
                else if (e.Property == DataGrid.IsReadOnlyProperty || e.Property == IsReadOnlyProperty)
                {
                    DataGridHelper.TransferProperty(this, IsReadOnlyProperty);
                }
                else if (e.Property == DataGrid.DragIndicatorStyleProperty || e.Property == DragIndicatorStyleProperty)
                {
                    DataGridHelper.TransferProperty(this, DragIndicatorStyleProperty);
                }
                else if (e.Property == DisplayIndexProperty)
                {
                    CoerceValue(IsFrozenProperty);
                }
                else if (e.Property == DataGrid.CanUserSortColumnsProperty)
                {
                    DataGridHelper.TransferProperty(this, CanUserSortProperty);
                }
                else if (e.Property == DataGrid.CanUserResizeColumnsProperty || e.Property == CanUserResizeProperty)
                {
                    DataGridHelper.TransferProperty(this, CanUserResizeProperty);
                }
                else if (e.Property == DataGrid.CanUserReorderColumnsProperty || e.Property == CanUserReorderProperty)
                {
                    DataGridHelper.TransferProperty(this, CanUserReorderProperty);
                }
                
                if (e.Property == WidthProperty || e.Property == MinWidthProperty || e.Property == MaxWidthProperty)
                {
                    CoerceValue(ActualWidthProperty);
                }
            }
            
            if (target != NotificationTarget.None)
            {
                // Everything else gets sent to the DataGrid so it can propogate back down 
                // to the targets that need notification.
                DataGridColumn column = (DataGridColumn)d;
                DataGrid dataGridOwner = column.DataGridOwner;
                if (dataGridOwner != null)
                {
                    dataGridOwner.NotifyPropertyChanged(d, e, target);
                }
            }
        }
示例#34
0
        public bool PushUserNotification(string destinationuser, string message, NotificationTarget target, string roles,
                                         NotificationType notificationType, string clickaction)
        {
            //Check if its role or user

            //do the role maths here
            if (target == NotificationTarget.Role)
            {
                foreach (string role in roles.Split(','))
                {
                    IList <User> usersinrole = _userService.GetAllUsersByRole(_roleSvc.GetRole(Convert.ToInt32(role)));

                    foreach (User user in usersinrole)
                    {
                        //push to each of theme

                        UserNotification notify = new UserNotification
                        {
                            UserId      = user.Guid.ToString(),
                            Message     = message,
                            Role        = _roleSvc.GetRole(Convert.ToInt32(role)),
                            Target      = Convert.ToInt32(target),
                            ClickAction = clickaction,
                            Type        = Convert.ToInt32(notificationType)
                        };

                        _session.Transact(session => session.Save(notify));

                        //send email notification
                        //Add to email queue.
                        QueuedMessage emailmsg = new QueuedMessage();
                        emailmsg.FromAddress = _mailSettings.SystemEmailAddress;
                        emailmsg.ToAddress   = user.Email;
                        emailmsg.Subject     = "NovoHub Notification - " + notify.Message.Truncate(20);
                        emailmsg.FromName    = "NOVOHUB";
                        emailmsg.Body        = notify.Message;


                        //Commented this out for now for the data input guys
                        // _emailSender.SendMailMessage(emailmsg);
                        _emailSender.AddToQueue(emailmsg);

                        //Notify the theres a new notification
                        NewNotificationArgs args = new NewNotificationArgs
                        {
                            Notification = notify
                        };
                        //Notify the Hub of the new Input
                        EventContext.Instance.Publish(typeof(INewNotificationEvent), args);
                    }
                }
            }
            else
            {
                //push to each of theme
                User             user   = _userService.GetUserByGUID(destinationuser);
                UserNotification notify = new UserNotification
                {
                    UserId      = destinationuser,
                    Message     = message,
                    Role        = user.Roles.FirstOrDefault(),
                    Target      = Convert.ToInt32(target),
                    ClickAction = clickaction,
                    Type        = Convert.ToInt32(notificationType)
                };

                _session.Transact(session => session.Save(notify));

                //send email notification
                //Add to email queue.
                QueuedMessage emailmsg = new QueuedMessage();
                emailmsg.FromAddress = _mailSettings.SystemEmailAddress;
                emailmsg.ToAddress   = user.Email;
                emailmsg.Subject     = "NovoHub Notification - " + notify.Message.Truncate(20);
                emailmsg.FromName    = "NOVOHUB";
                emailmsg.Body        = notify.Message;


                //Commented this out for now for the data input guys
                // _emailSender.SendMailMessage(emailmsg);
                _emailSender.AddToQueue(emailmsg);

                //Notify the theres a new notification
                NewNotificationArgs args = new NewNotificationArgs
                {
                    Notification = notify
                };
                //Notify the Hub of the new Input
                EventContext.Instance.Publish(typeof(INewNotificationEvent), args);
            }



            return(true);
        }
 public async Task <List <T> > GetConfigurationList <T>(NotificationTarget target)
 {
     return(await _mapper.ProjectTo <T>(_context.NotificationConfigurations.Where(x => x.Target == target)).ToListAsync());
 }
示例#36
0
 public async Task <List <NotificationConfigurationItemModel> > GetNotificationConfigurations(NotificationTarget target)
 {
     return(await _service.GetConfigurationList <NotificationConfigurationItemModel>(target));
 }
示例#37
0
        /// <summary>
        ///     General notification for DependencyProperty changes from the grid or from columns.
        /// </summary>
        internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, NotificationTarget target)
        {
            if (DataGridHelper.ShouldNotifyRows(target))
            {
                if (e.Property == DataGrid.RowBackgroundProperty || e.Property == DataGrid.AlternatingRowBackgroundProperty ||
                    e.Property == BackgroundProperty || e.Property == AlternationIndexProperty)
                {
                    DataGridHelper.TransferProperty(this, BackgroundProperty);
                }
                else if (e.Property == DataGrid.RowHeaderStyleProperty || e.Property == HeaderStyleProperty)
                {
                    DataGridHelper.TransferProperty(this, HeaderStyleProperty);
                }
                else if (e.Property == DataGrid.RowHeaderTemplateProperty || e.Property == HeaderTemplateProperty)
                {
                    DataGridHelper.TransferProperty(this, HeaderTemplateProperty);
                }
                else if (e.Property == DataGrid.RowHeaderTemplateSelectorProperty || e.Property == HeaderTemplateSelectorProperty)
                {
                    DataGridHelper.TransferProperty(this, HeaderTemplateSelectorProperty);
                }
                else if (e.Property == DataGrid.RowValidationErrorTemplateProperty || e.Property == ValidationErrorTemplateProperty)
                {
                    DataGridHelper.TransferProperty(this, ValidationErrorTemplateProperty);
                }
                else if (e.Property == DataGrid.RowDetailsTemplateProperty || e.Property == DetailsTemplateProperty)
                {
                    DataGridHelper.TransferProperty(this, DetailsTemplateProperty);
                    DataGridHelper.TransferProperty(this, DetailsVisibilityProperty);
                }
                else if (e.Property == DataGrid.RowDetailsTemplateSelectorProperty || e.Property == DetailsTemplateSelectorProperty)
                {
                    DataGridHelper.TransferProperty(this, DetailsTemplateSelectorProperty);
                    DataGridHelper.TransferProperty(this, DetailsVisibilityProperty);
                }
                else if (e.Property == DataGrid.RowDetailsVisibilityModeProperty || e.Property == DetailsVisibilityProperty || e.Property == IsSelectedProperty)
                {
                    DataGridHelper.TransferProperty(this, DetailsVisibilityProperty);
                }
                else if (e.Property == ItemProperty)
                {
                    OnItemChanged(e.OldValue, e.NewValue);
                }
                else if (e.Property == HeaderProperty)
                {
                    OnHeaderChanged(e.OldValue, e.NewValue);
                }
                else if (e.Property == BindingGroupProperty)
                {
                    // Re-run validation, but wait until Binding has occured.
                    Dispatcher.BeginInvoke(new DispatcherOperationCallback(DelayedValidateWithoutUpdate), DispatcherPriority.DataBind, e.NewValue);
                }
            }

            if (DataGridHelper.ShouldNotifyDetailsPresenter(target))
            {
                if (DetailsPresenter != null)
                {
                    DetailsPresenter.NotifyPropertyChanged(d, e);
                }
            }

            if (DataGridHelper.ShouldNotifyCellsPresenter(target) ||
                DataGridHelper.ShouldNotifyCells(target) ||
                DataGridHelper.ShouldRefreshCellContent(target))
            {
                DataGridCellsPresenter cellsPresenter = CellsPresenter;
                if (cellsPresenter != null)
                {
                    cellsPresenter.NotifyPropertyChanged(d, propertyName, e, target);
                }
            }

            if (DataGridHelper.ShouldNotifyRowHeaders(target) && RowHeader != null)
            {
                RowHeader.NotifyPropertyChanged(d, e);
            }
        }
示例#38
0
        /// <summary>
        ///     General notification for DependencyProperty changes from the grid or from columns.
        /// </summary>
        internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, NotificationTarget target)
        {
            if (DataGridHelper.ShouldNotifyRows(target))
            {
                if (e.Property == DataGrid.RowBackgroundProperty || e.Property == DataGrid.AlternatingRowBackgroundProperty ||
                    e.Property == BackgroundProperty || e.Property == AlternationIndexProperty)
                {
                    DataGridHelper.TransferProperty(this, BackgroundProperty);
                }
                else if (e.Property == DataGrid.RowHeaderStyleProperty || e.Property == HeaderStyleProperty)
                {
                    DataGridHelper.TransferProperty(this, HeaderStyleProperty);
                }
                else if (e.Property == DataGrid.RowHeaderTemplateProperty || e.Property == HeaderTemplateProperty)
                {
                    DataGridHelper.TransferProperty(this, HeaderTemplateProperty);
                }
                else if (e.Property == DataGrid.RowHeaderTemplateSelectorProperty || e.Property == HeaderTemplateSelectorProperty)
                {
                    DataGridHelper.TransferProperty(this, HeaderTemplateSelectorProperty);
                }
                else if (e.Property == DataGrid.RowValidationErrorTemplateProperty || e.Property == ValidationErrorTemplateProperty)
                {
                    DataGridHelper.TransferProperty(this, ValidationErrorTemplateProperty);
                }
                else if (e.Property == DataGrid.RowDetailsTemplateProperty || e.Property == DetailsTemplateProperty)
                {
                    DataGridHelper.TransferProperty(this, DetailsTemplateProperty);
                    DataGridHelper.TransferProperty(this, DetailsVisibilityProperty);
                }
                else if (e.Property == DataGrid.RowDetailsTemplateSelectorProperty || e.Property == DetailsTemplateSelectorProperty)
                {
                    DataGridHelper.TransferProperty(this, DetailsTemplateSelectorProperty);
                    DataGridHelper.TransferProperty(this, DetailsVisibilityProperty);
                }
                else if (e.Property == DataGrid.RowDetailsVisibilityModeProperty || e.Property == DetailsVisibilityProperty || e.Property == IsSelectedProperty)
                {
                    DataGridHelper.TransferProperty(this, DetailsVisibilityProperty);
                }
                else if (e.Property == ItemProperty)
                {
                    OnItemChanged(e.OldValue, e.NewValue);
                }
                else if (e.Property == HeaderProperty)
                {
                    OnHeaderChanged(e.OldValue, e.NewValue);
                }
                else if (e.Property == BindingGroupProperty)
                {
                    // Re-run validation, but wait until Binding has occured.
                    Dispatcher.BeginInvoke(new DispatcherOperationCallback(DelayedValidateWithoutUpdate), DispatcherPriority.DataBind, e.NewValue);
                }
            }

            if (DataGridHelper.ShouldNotifyDetailsPresenter(target))
            {
                if (DetailsPresenter != null)
                {
                    DetailsPresenter.NotifyPropertyChanged(d, e);
                }
            }

            if (DataGridHelper.ShouldNotifyCellsPresenter(target) ||
                DataGridHelper.ShouldNotifyCells(target) ||
                DataGridHelper.ShouldRefreshCellContent(target))
            {
                DataGridCellsPresenter cellsPresenter = CellsPresenter;
                if (cellsPresenter != null)
                {
                    cellsPresenter.NotifyPropertyChanged(d, propertyName, e, target);
                }
            }

            if (DataGridHelper.ShouldNotifyRowHeaders(target) && RowHeader != null)
            {
                RowHeader.NotifyPropertyChanged(d, e);
            }
        }