Exemple #1
0
 public JsonResult TestMsg()
 {
     try
     {
         List <Notification.Notification> notifications = new List <Notification.Notification>();
         Notification.Notification        n             = new Notification.Notification()
         {
             SenderID    = this.UserValidator.UserID,
             ReceiverID  = this.UserValidator.UserID,
             SendTime    = System.DateTime.Now,
             State       = Notification.NotificationState.Unread,
             Title       = "回复了您: ",
             SchemaCode  = "",
             BizObjectId = "",
             Type        = Notification.NotifyType.Internal
         };
         notifications.Add(n);
         this.Engine.Notifier.Send(notifications.ToArray());
         return(Json("success"));
     }
     catch (Exception ex)
     {
         return(Json("false"));
     }
 }
 private Notification.Notification validation(RequestBankTransferDto requestBankTransferDto)
 {
     Notification.Notification notification = new Notification.Notification();
     if (requestBankTransferDto == null || requestBankTransferDto.getRequestBodyType() == RequestBodyType.INVALID)
     {
         notification.addError("Invalid JSON data in request body.");
     }
     return(notification);
 }
Exemple #3
0
 public void AddNotification(Notification.Notification newnot)
 {
     Notification.Notification[] temp = new Notification.Notification[++NotificationCount];
     if (notifications != null)
     {
         notifications.CopyTo(temp, 0);
     }
     temp[temp.Length - 1] = newnot;
     notifications         = temp;
 }
Exemple #4
0
        public void addNotification(ref Notification.Notification notification)
        {
            var newNotification = new Notification.Notification[NotificationCount + 1];

            for (int i = 0; i < PostCount; i++)
            {
                newNotification[i] = Notifications[i];
            }
            newNotification[PostCount] = notification;
            NotificationCount++;

            Notifications = newNotification;
        }
        public void performTransfer(RequestBankTransferDto requestBankTransferDto,
                                    Func <string, BankAccount> delagatefindByNumberLocked, Action <BankAccount> delegateUpdate)
        {
            Notification.Notification notification = this.validation(requestBankTransferDto);
            if (notification.hasErrors())
            {
                throw new ArgumentException(notification.errorMessage());
            }
            BankAccount originAccount      = delagatefindByNumberLocked(requestBankTransferDto.fromAccountNumber);
            BankAccount destinationAccount = delagatefindByNumberLocked(requestBankTransferDto.toAccountNumber);

            this.transferDomainService.performTransfer(originAccount, destinationAccount, requestBankTransferDto.amount);
            delegateUpdate(originAccount);
            delegateUpdate(destinationAccount);
        }
Exemple #6
0
        public void AddNotification(ref Notification.Notification notification)
        {
            var newLength = (Notifications != null) ? Notifications.Length + 1 : 1;
            var temp      = new Notification.Notification[newLength];

            if (temp == null)
            {
                throw new DatabaseException("Can not allocate new memory!");
            }

            if (Notifications != null)
            {
                Array.Copy(Notifications, temp, Notifications.Length);
            }

            temp[newLength - 1] = notification;

            Notifications = temp;
        }
Exemple #7
0
        public void RemoveNotification(int id)
        {
            var notificationIndex = Array.FindIndex(Notifications, notification => notification.Id == id);

            if (notificationIndex < 0)
            {
                throw new DatabaseException($"There is no admin associated this id -> {id}");
            }

            var temp = new Notification.Notification[Notifications.Length - 1];

            if (temp != null)
            {
                Array.Copy(Notifications, temp, notificationIndex);
                Array.Copy(Notifications, notificationIndex + 1, temp, notificationIndex, Notifications.Length - notificationIndex - 1);
            }

            Notifications = temp;
        }
Exemple #8
0
        public static ToDoListElement buildInstance(Notification.Notification input, string idTrasmissione)
        {
            ToDoListElement res = new ToDoListElement();

            res.Mittente  = input.PRODUCER;
            res.DataDoc   = input.DTA_EVENT.ToShortDateString();
            res.Ragione   = getLabelTypeEvent(input.TYPE_EVENT);
            res.Extension = (!string.IsNullOrEmpty(input.EXTENSION) ? input.EXTENSION : "-");
            res.Oggetto   = input.ITEMS.ITEM3;
            if (input.TYPE_EVENT.ToUpper().Contains("TRASM_"))
            {
                res.IdTrasm = idTrasmissione;
            }
            else
            {
                res.IdTrasm = string.Empty;
            }
            res.IdEvento = input.ID_EVENT;
            if (!string.IsNullOrEmpty(input.ITEMS.ITEM2))
            {
                res.Segnatura = input.ITEMS.ITEM2;
                string lblTipoProto = res.Segnatura.Substring(res.Segnatura.IndexOf("(") + 1, (res.Segnatura.IndexOf(")") - (res.Segnatura.IndexOf("(") + 1)));
                string tipoProto    = GetTipoProto(lblTipoProto);
                res.Segnatura = res.Segnatura.Replace("(" + lblTipoProto + ")", "");
                res.TipoProto = tipoProto;
            }
            else
            {
                res.Segnatura = null;
                res.TipoProto = "G";
            }
            res.Id = input.ID_OBJECT;
            if (input.DOMAINOBJECT.Equals("DOCUMENTO"))
            {
                res.Tipo = ElementType.DOCUMENTO;
            }
            else if (input.DOMAINOBJECT.Equals("FASCICOLO"))
            {
                res.Tipo = ElementType.FASCICOLO;
            }
            return(res);
        }
Exemple #9
0
        public static void Start(ref Database.Database db, ref Session.LoginAccountSession session)
        {
            var userMenuLoop = true;

            while (userMenuLoop)
            {
                ConsoleInterface.PrintMenu(ConsoleInterface.UserMenuOptions);

                switch ((UserMenuOptions)ConsoleInterface.InputChoice(ConsoleInterface.UserMenuOptions.Length))
                {
                case UserMenuOptions.SHOWALLPOSTS:
                {
                    try
                    {
                        Console.Clear();
                        db.ShowAllPosts(true);
                        ConsoleHelper.ClearConsole();
                    }
                    catch (Exception e)
                    {
                        var line = Console.CursorTop;
                        Console.ForegroundColor = ConsoleColor.DarkRed;
                        Console.WriteLine(e.Message);
                        ConsoleHelper.ClearConsole(line - 1, 10);
                    }
                    break;
                }

                case UserMenuOptions.SHOW:
                {
                    try
                    {
                        Console.Clear();
                        db.ShowAllPosts();

                        var id = 0;
                        while (true)
                        {
                            try
                            {
                                Console.Write("ID: ");
                                id = Convert.ToInt32(Console.ReadLine());
                                break;
                            }
                            catch (Exception e)
                            {
                                var line = Console.CursorTop;
                                Console.ForegroundColor = ConsoleColor.DarkRed;
                                Console.WriteLine(e.Message);
                                ConsoleHelper.ClearConsole(line - 1, 10);
                            }
                        }
                        Console.Clear();

                        var post = db.GetPost(id);
                        Console.WriteLine(post);

                        post.IncreaseView();

                        var newNotf = new Notification.Notification()
                        {
                            FromUser = session.User as User.User, Text = $"{(session.User as User.User).Username} viewed this post [id] ->{post.Id}"
                        };

                        db.AddNotification(ref newNotf);

                        Mail.SendMail(db.Admins[0].Email, "New views!", newNotf.Text);

                        ConsoleHelper.ClearConsole();
                    }
                    catch (Exception e)
                    {
                        var line = Console.CursorTop;
                        Console.ForegroundColor = ConsoleColor.DarkRed;
                        Console.WriteLine(e.Message);
                        ConsoleHelper.ClearConsole(line - 1, 10);
                    }
                    break;
                }

                case UserMenuOptions.LIKE:
                {
                    try
                    {
                        Console.Clear();
                        db.ShowAllPosts();

                        var id = 0;
                        while (true)
                        {
                            try
                            {
                                Console.Write("ID: ");
                                id = Convert.ToInt32(Console.ReadLine());
                                break;
                            }
                            catch (Exception e)
                            {
                                var line = Console.CursorTop;
                                Console.ForegroundColor = ConsoleColor.DarkRed;
                                Console.WriteLine(e.Message);
                                ConsoleHelper.ClearConsole(line - 1, 10);
                            }
                        }
                        Console.Clear();
                        var post = db.GetPost(id);
                        post++;

                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        Console.WriteLine("Post liked!");
                        Console.ResetColor();

                        var newNotf = new Notification.Notification()
                        {
                            FromUser = session.User as User.User, Text = $"{(session.User as User.User).Username} liked this post [id] ->{post.Id}"
                        };

                        db.AddNotification(ref newNotf);

                        Mail.SendMail(db.Admins[0].Email, "New likes!", newNotf.Text);


                        ConsoleHelper.ClearConsole();
                    }
                    catch (Exception e)
                    {
                        var line = Console.CursorTop;
                        Console.ForegroundColor = ConsoleColor.DarkRed;
                        Console.WriteLine(e.Message);
                        ConsoleHelper.ClearConsole(line - 1, 10);
                    }
                    break;
                }

                case UserMenuOptions.CREATEPOST:
                {
                    Console.Clear();

                    Console.Write("Content: ");

                    var content = string.Empty;

                    do
                    {
                        content = Console.ReadLine();
                    } while (String.IsNullOrWhiteSpace(content));

                    var newPost = new Post.Post()
                    {
                        Username = (session.User as User.User).Username, Content = content
                    };

                    (session.User as User.User).AddPost(ref newPost);
                    break;
                }

                case UserMenuOptions.LOGOUTUSER:
                {
                    session.Logout();
                    userMenuLoop = false;
                    break;
                }

                default:
                    break;
                }
            }
        }
Exemple #10
0
 public void WriteNotification(Admin.Admin admin, Notification.Notification newnot)
 {
     admin.AddNotification(newnot);
 }
Exemple #11
0
        public void AddNotification(string className, string message)
        {
            var notification = new Notification.Notification(className, message);

            Notifications.Add(notification);
        }