Exemplo n.º 1
0
        /// <summary>
        /// 生成命令对象
        /// </summary>
        /// <param name="commands"></param>
        protected override void CreateCommands(NotificationList <CommandItemBase> commands)
        {
            commands.Add(new CommandItem
            {
                IsButton = true,
                Action   = arg => DoMomentCode(),
                Caption  = "生成代码片断",
                Image    = Application.Current.Resources["img_file"] as ImageSource
            });

            commands.Add(new CommandItem
            {
                IsButton = true,
                Action   = arg => CopyCode(),
                Caption  = "复制代码",
                Image    = Application.Current.Resources["img_file"] as ImageSource
            });
            foreach (var builder in ProjectBuilder.Builders.Values)
            {
                var b = builder();
                commands.Add(new ProjectCodeCommand(builder)
                {
                    Caption       = b.Caption,
                    IconName      = b.Icon,
                    OnCodeSuccess = OnCodeSuccess
                }.ToCommand(null));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 生成命令对象
        /// </summary>
        /// <returns></returns>
        protected NotificationList <CommandItemBase> CreateCommands(bool edit, bool create, bool ext)
        {
            NotificationList <CommandItemBase> commands = new NotificationList <CommandItemBase>();

            if (edit)
            {
                commands.Add(new CommandItem
                {
                    IsButton  = true,
                    NoConfirm = true,
                    Action    = CopyColumns,
                    Caption   = "复制列",
                    Image     = Application.Current.Resources["tree_item"] as ImageSource
                });
                commands.Add(new CommandItem
                {
                    IsButton  = true,
                    Action    = PasteColumns,
                    NoConfirm = true,
                    Caption   = "粘贴列",
                    Image     = Application.Current.Resources["tree_item"] as ImageSource
                });
                commands.Add(new CommandItem
                {
                    IsButton = true,
                    Action   = ClearColumns,
                    Caption  = "清除列",
                    Image    = Application.Current.Resources["img_del"] as ImageSource
                });
                commands.Add(new CommandItem
                {
                    IsButton = true,
                    Action   = DeleteColumns,
                    Caption  = "删除所选列",
                    Image    = Application.Current.Resources["img_del"] as ImageSource
                });
                commands.Add(new CommandItem
                {
                    IsButton  = true,
                    Action    = AddProperty,
                    NoConfirm = true,
                    Caption   = "新增字段",
                    Image     = Application.Current.Resources["tree_Open"] as ImageSource
                });
            }
            if (create)
            {
                CreateCommands(commands);
            }
            if (ext)
            {
                var extends = CommandCoefficient.CoefficientEditor(typeof(EntityConfig), EditorName);
                if (extends.Count > 0)
                {
                    commands.AddRange(extends);
                }
            }
            return(commands);
        }
Exemplo n.º 3
0
        void OnPollAdded(Poll poll)
        {
            Dispatcher.BeginInvoke((Action)(() => {
                if (polls.Any(c => c.Name == poll.Name))
                {
                    return;
                }

                polls.Add(new PollEditor(poll));
            }));
        }
Exemplo n.º 4
0
        void OnItemAdded(Collection collection, CollectionItem item)
        {
            Dispatcher.BeginInvoke((Action)(() => {
                if (collection.Name != selectedcollection || items.Any(i => i.User == item.User && i.Item == item.Item))
                {
                    return;
                }

                items.Add(item);
            }));
        }
Exemplo n.º 5
0
        void OnVoteAdded(PollVote vote)
        {
            Dispatcher.BeginInvoke((Action)(() => {
                if (vote.Poll != selectedpoll || votes.Any(i => i.User == vote.User && i.Vote == vote.Vote))
                {
                    return;
                }

                votes.Add(vote);
            }));
        }
Exemplo n.º 6
0
        void OnOptionAdded(PollOption option)
        {
            Dispatcher.BeginInvoke((Action)(() => {
                if (option.Poll != selectedpoll || options.Any(i => i.Key == option.Key))
                {
                    return;
                }

                options.RemoveWhere(i => i.Key == option.Key);
                options.Add(new PollOptionEditor(option));
            }));
        }
Exemplo n.º 7
0
        void OnItemBlocked(Collection collection, BlockedCollectionItem item)
        {
            Dispatcher.BeginInvoke((Action)(() => {
                if (item.Collection != selectedcollection || blockeditems.Any(i => i.Item == item.Item))
                {
                    return;
                }

                blockeditems.RemoveWhere(i => i.Item == item.Item);
                blockeditems.Add(new BlockedItemEditor(item));
            }));
        }
Exemplo n.º 8
0
        public void TestAddNotification()
        {
            NotificationList notificationList = new NotificationList();

            int expectedIllegalCount = 0;

            Assert.AreEqual(expectedIllegalCount, notificationList.GetIllegalList().Count);

            expectedIllegalCount = 1;
            notificationList.Add(NotificationLevel.Illegal, IllegalType.NotDeclaredTableName, "hello", "hello");
            Assert.AreEqual(expectedIllegalCount, notificationList.GetIllegalList().Count);

            notificationList.Add(NotificationLevel.Warning, IllegalType.NotDeclaredTableName, "hello", "hello");
            Assert.AreEqual(expectedIllegalCount, notificationList.GetIllegalList().Count);
        }
        private void GetBearers()
        {
            try
            {
                List <NotificationModel> bearersList = null;
                Task.Factory.StartNew(() =>
                {
                    ISyncServices syncService = new SyncServices();
                    bearersList = syncService.GetAllNotification();
                }).ContinueWith((obj) =>
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        if (bearersList != null)
                        {
                            bearersList = bearersList.OrderByDescending(d => DateTime.Parse(d.addedOn).Date)
                                          .Select(x => x).ToList();

                            foreach (var item in bearersList)
                            {
                                if (!string.IsNullOrEmpty(item.addedOn))
                                {
                                    item.addedOn = CommonHelpers.TimeAgo(DateTime.Parse(item.addedOn));
                                }
                                NotificationList.Add(item);
                            }
                        }
                    });
                });
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// adds a game to the list
 /// </summary>
 /// <param name="game">game to be added</param>
 public void AddGame(string game)
 {
     lock (gameslock) {
         games.Add(new Game {
             Name = game
         });
     }
 }
Exemplo n.º 11
0
 public void LoadCommandSet(string commandSetText)
 {
     foreach (var item in CommandFactory.MakeMany(commandSetText))
     {
         commands.Add(item);
     }
     currentIndex = -1;
     First();
 }
Exemplo n.º 12
0
        private void AddNotification(Notification notification)
        {
            foreach (var not in NotificationList)
            {
                if (not.Equals(notification))
                {
                    return;
                }
            }

            NotificationList.Add(notification);
        }
Exemplo n.º 13
0
        private async void LoadListData()
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                HttpClientHelper apicall = null;
                if (_type == "User")
                {
                    apicall = new HttpClientHelper(string.Format(ApiUrls.Url_GetUserNotificationData), Settings.AccessTokenSettings);
                }
                else
                {
                    isAdmin = true;
                    apicall = new HttpClientHelper(string.Format(ApiUrls.Url_GetAdminNotificationData), Settings.AccessTokenSettings);
                }

                var response = await apicall.GetResponse <List <AdminNotificationResponseModel> >();

                if (response != null)
                {
                    if (response.Count > 0)
                    {
                        IsStatusVisible = false;
                        foreach (var item in response.ToList())
                        {
                            AdminNotificationModel notificationModel = new AdminNotificationModel();
                            if (isAdmin == false)
                            {
                                notificationModel.NotificationInfo = "Admin approved your complaint for service " + item.productName + " in " + item.catagory + " catagory";
                            }
                            else
                            {
                                notificationModel.NotificationInfo = item.userName + " registered complaint for service " + item.productName + " in " + item.catagory + " catagory";
                            }
                            NotificationList.Add(notificationModel);
                        }
                    }
                    else
                    {
                        IsStatusVisible = true;
                    }
                    NotificationData = new ReadOnlyObservableCollection <AdminNotificationModel>(NotificationList);
                }
                UserDialogs.Instance.HideLoading();
            }
            else
            {
                UserDialogs.Instance.HideLoading();
                await Application.Current.MainPage.DisplayAlert("Network", AppConstant.NETWORK_FAILURE, "OK");

                return;
            }
        }
    public static void Main()
    {
        NotificationList <int> list = new NotificationList <int>();

        list.ItemAdded += delegate(object o, ItemInsertedArgs <int> args) {
            Console.WriteLine("A new item was added to the list: {0} at index {1}", args.Item, args.Index);
        };

        for (int i = 0; i < 10; i++)
        {
            list.Add(i);
        }
    }
Exemplo n.º 15
0
        /// <summary>
        /// creates a new <see cref="InfoManagementWindow"/>
        /// </summary>
        /// <param name="module">module used to access infos</param>
        public InfoManagementWindow(InfoModule module)
        {
            InitializeComponent();
            this.module = module;

            foreach (Info info in module.GetInfos())
            {
                infos.Add(new InfoItem(info));
            }

            grdInfos.ItemsSource = infos;
            infos.ItemChanged   += OnListItemChanged;
            infos.ItemRemoved   += OnItemRemoved;
        }
Exemplo n.º 16
0
        void OnReviewChanged()
        {
            items.Clear();

            double sum   = module.Entries.Sum(e => e.Weight);
            double value = 0.0f;

            foreach (ReviewEntry entry in module.Entries)
            {
                items.Add(new ReviewItem {
                    Topic = entry.Name,
                    Value = entry.Value
                });
                value += entry.Value * entry.Weight / sum;
            }

            items.Add(new ReviewItem {
                Topic = "Result",
                Value = (int)Math.Round(value)
            });

            grdItems.Visibility = Visibility.Visible;
            dispatcherTimer.Start();
        }
Exemplo n.º 17
0
        /// <summary>
        /// creates a new <see cref="Statistics.PollManagementWindow"/>
        /// </summary>
        /// <param name="module">collection module</param>
        public CollectionManagementWindow(CollectionModule module)
        {
            this.module = module;
            InitializeComponent();

            module.CollectionAdded       += OnCollectionAdded;
            module.CollectionRemoved     += OnCollectionRemoved;
            module.ItemAdded             += OnItemAdded;
            module.ItemRemoved           += OnItemRemoved;
            module.CollectionClearedUser += OnCollectionCleared;
            module.ItemBlocked           += OnItemBlocked;
            module.ItemUnblocked         += OnItemUnblocked;

            collections.ItemChanged += OnEditCollectionItemChanged;

            foreach (Collection collection in module.GetCollections())
            {
                collections.Add(new CollectionEditor(collection));
            }

            grdCollections.ItemsSource  = collections;
            grdBlockedItems.ItemsSource = blockeditems;
            grdItems.ItemsSource        = items;
        }
Exemplo n.º 18
0
        private void FillNotification()
        {
            Notification n;

            foreach (var contract in ContractList)
            {
                n = new Notification(contract);

                if (!n.HasNotification)
                {
                    continue;
                }

                NotificationList.Add(n);
            }
        }
Exemplo n.º 19
0
        public async Task Init()
        {
            var DentalClinic = await _clinicService.GetById <DentalClinic>(1);

            Name    = DentalClinic.Name;
            Address = DentalClinic.Address;
            Phone   = DentalClinic.Phone;
            Email   = DentalClinic.Email;

            if (NotificationList.Count > 0)
            {
                NotificationList.Clear();
            }
            var list = await _notificationService.GetAll <List <Notification> >(null);

            foreach (var notification in list)
            {
                NotificationList.Add(notification);
            }
        }
Exemplo n.º 20
0
        private async Task HandleNRAddButton()
        {
            // Subscribe to topic
            DependencyService.Get <IFCMNotificationSubscriber>().Subscribe("NS" + _courseId);

            // Register StudentId with the notification in the db, and update the list in App Properties
            var insertedUserNotification = await FCMPushNotificationSender.AddNotification(
                new UserNotification
            {
                StudentId = Settings.StudentId,
                Topic     = "NS" + _courseId,
                Title     = "New Notebook",
                Body      = "New notebook that you may interest in has been added"
            });

            // update the SG list in this page
            if (insertedUserNotification != null)
            {
                NotificationList.Add(insertedUserNotification);
            }
        }
Exemplo n.º 21
0
        private async Task HandleHRFacultyAddButton()
        {
            // Subscribe to topic
            DependencyService.Get <IFCMNotificationSubscriber>().Subscribe("HR" + _courseId);

            // Register StudentId with the notification in the db, and update the list in App Properties
            var insertedUserNotification = await FCMPushNotificationSender.AddNotification(
                new UserNotification
            {
                StudentId = Settings.StudentId,
                Topic     = "HRF" + _courseId,
                Title     = "Help",
                Body      = "Someone asked for help in your faculty"
            });

            // update the SG list in this page
            if (insertedUserNotification != null)
            {
                NotificationList.Add(insertedUserNotification);
            }
        }
Exemplo n.º 22
0
        private async Task HandleHRCourseAddButton()
        {
            // Subscribe to topic
            DependencyService.Get <IFCMNotificationSubscriber>().Subscribe("HR" + _courseId);

            // Register StudentId with the notification in the db, and update the list in App Properties
            var insertedUserNotification = await FCMPushNotificationSender.AddNotification(
                new UserNotification
            {
                StudentId = Settings.StudentId,
                Topic     = "HRC" + _courseId,
                Title     = "Help!",
                Body      = "Some need help in a course you attend in, you may give him a help hand"
            });

            // update the SG list in this page
            if (insertedUserNotification != null)
            {
                NotificationList.Add(insertedUserNotification);
            }
        }
Exemplo n.º 23
0
        private async Task HandleSGAddButton()
        {
            // Subscribe to topic
            DependencyService.Get <IFCMNotificationSubscriber>().Subscribe("SG" + _courseId);

            // Register StudentId with the notification in the db, and update the list in App Properties
            var insertedUserNotification = await FCMPushNotificationSender.AddNotification(
                new UserNotification
            {
                StudentId = Settings.StudentId,
                Topic     = "SG" + _courseId,
                Title     = "New Study Group",
                Body      = "New study group added in a course you interested in, join now!"
            });

            // update the SG list in this page
            if (insertedUserNotification != null)
            {
                NotificationList.Add(insertedUserNotification);
            }
        }
        private async void LoadCachedNotifications(Action<NotificationList, Exception> callback)
        {
            var retVal = new NotificationList();
            try
            {
                foreach (var item in await StorageUtility.ListItems(STATIC_NOTIFICATION_FOLDER, ""))
                {

                    var staticType = await StorageUtility.RestoreItem<BMA.BusinessLogic.Notification>(STATIC_NOTIFICATION_FOLDER, item, "");
                    retVal.Add(staticType);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            callback(retVal, null);
        }
        public async Task UpdateGraph()
        {
            var apiSource = YobotApiSource.Default;

            _loadTimer?.Dispose();
            _loadTimer = new Timer((obj) => Dispatcher.Invoke(() => StatsViewModel.IsLoading = true), null, 1000,
                                   Timeout.Infinite);

            try
            {
                var functionInfo = StatsViewModel.SourceStatsFunction;
                var func         = functionInfo.Function;

                if (func != null)
                {
                    IChartConfigModel result;
                    try
                    {
                        result = await func.Invoke(StatsViewModel.GranularityModel);
                    }
                    catch (Exception ex)
                    {
                        //Notification.Error(ex?.InnerException?.Message ?? ex.Message);
                        Execute.ToUiThread(() =>
                        {
                            NotificationList.Add(new NotificationOption
                            {
                                Type            = NotificationType.Alert,
                                Level           = NotificationLevel.Error,
                                FadeoutTime     = TimeSpan.FromSeconds(8),
                                Content         = ex?.InnerException?.Message ?? ex.Message,
                                Title           = "调用组件方法出现错误",
                                CloseExplicitly = false
                            });
                        });
                        Logger.Error(ex, "调用组件方法时异常");
                        return;
                    }

                    if (Chart == null)
                    {
                        RecreateGraph();
                    }
                    result.ChartConfig?.Invoke(Chart);

                    switch (result.ChartType)
                    {
                    case ChartType.Cartesian:
                        var cartesianResult = (CartesianChartConfigModel)result;
                        StatsViewModel.ConfigModel = cartesianResult;
                        break;

                    case ChartType.Pie:
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
            finally
            {
                StatsViewModel.IsLoading = false;
                _loadTimer?.Dispose();
            }
        }
        private void LoadLiveNotifications(Action<NotificationList, Exception> callback)
        {
            var client = new StaticClient();

            client.GetAllNotificationsAsync(-1);
            client.GetAllNotificationsCompleted += (o, e) =>
            {
                //if (e.Error == null)
                //    SetupNotificationData(e.Result, true);
                if (e.Error == null)
                {
                    var notificationList = new NotificationList();
                    foreach (var item in e.Result)
                        notificationList.Add(item);

                    callback(notificationList, null);
                }
                else
                    callback(null, e.Error);
            };
        }
Exemplo n.º 27
0
        public static void AddToNotificationList(string applicationName, string applicationPath, CustomNotification.ActionType actionType, DateTime time, bool notActivated)
        {
            string title = actionType == ActionType.BlockAllow ? "First connection: " :
                           actionType == ActionType.UnblockAllow ? "Blocked connection: " :
                           actionType == ActionType.SuspendWhitelist ? "High CPU load: " :
                           actionType == ActionType.TerminateWhitelist ? "Suspended: " :
                           "";

            string content = actionType == ActionType.BlockAllow ?
                             "Application at the following path initiated a network connection:\n" :
                             actionType == ActionType.UnblockAllow ?
                             "Application at the following path was blocked from connecting to the network:\n" :
                             actionType == ActionType.SuspendWhitelist ?
                             "Application at the following path is using a high percentage of processor time:\n" :
                             actionType == ActionType.TerminateWhitelist ?
                             "Application at the following path was suspended for using a high percentage of processor time:\n" :
                             null;

            string buttonLabel = actionType == ActionType.BlockAllow ? "Block" :
                                 actionType == ActionType.UnblockAllow ? "Unblock" :
                                 actionType == ActionType.SuspendWhitelist ? "Whitelist" :
                                 actionType == ActionType.TerminateWhitelist ? "Whitelist" :
                                 null;

            SolidColorBrush iconColor = actionType == ActionType.BlockAllow ?
                                        new SolidColorBrush(Color.FromArgb(255, 0, 182, 0)) :
                                        actionType == ActionType.UnblockAllow ?
                                        new SolidColorBrush(Color.FromArgb(255, 182, 0, 0)) :
                                        actionType == ActionType.SuspendWhitelist ?
                                        new SolidColorBrush(Color.FromArgb(255, 0, 150, 182)) :
                                        actionType == ActionType.TerminateWhitelist ?
                                        new SolidColorBrush(Color.FromArgb(255, 204, 80, 0)) :
                                        new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

            iconColor.Freeze();

            PackIconFontAwesomeKind iconKind = actionType == ActionType.BlockAllow ?
                                               PackIconFontAwesomeKind.InfoCircleSolid :
                                               actionType == ActionType.UnblockAllow ?
                                               PackIconFontAwesomeKind.TimesCircleSolid :
                                               actionType == ActionType.SuspendWhitelist ?
                                               PackIconFontAwesomeKind.InfoCircleSolid :
                                               actionType == ActionType.TerminateWhitelist ?
                                               PackIconFontAwesomeKind.MoonSolid :
                                               PackIconFontAwesomeKind.CircleSolid;

            var n = new NotificationItem
            {
                ApplicationName = applicationName,
                ApplicationPath = applicationPath,
                Title           = title + applicationName,
                Content         = content + applicationPath,
                IconKind        = iconKind,
                IconColor       = iconColor,
                ButtonLabel     = buttonLabel,
                Type            = (int)actionType,
                NotActivated    = notActivated,
                Time            = time
            };

            NotificationList.Add(n);
        }
        private void SaveNotification()
        {
            vm.IsLoading = true;

            var saveOC = vm.Notifications.Where(t => t.HasChanges).ToObservableCollection();
            NotificationList deletedList = new NotificationList();
            vm.Notifications.Where(x => x.IsDeleted).ToList().ForEach(x=>
            {
                deletedList.Add(x);
            });

             App.Instance.StaticServiceData.SaveNotification(saveOC, (error) =>
            {
                if (error != null)
                    MessageBox.Show(AppResources.SaveFailed);
                else
                {
                    Model.Reminders.DeleteReminder(deletedList);
                    Model.Reminders.SetupReminders();
                }

                vm.IsLoading = false;

            });

            pivotContainer.SelectedIndex = 1;
            save.IsEnabled = vm.Notifications.HasItemsWithChanges() && vm.IsLoading == false;
        }