Exemplo n.º 1
0
 public override void ViewWillAppear(bool animated)
 {
     base.ViewWillAppear(animated);
     if (Profile.Instance != null)
     {
         RemoteService.UpdateMessagesList += UpdateInfo;
         UpdateInfo();
         if (Profile.Instance.Status == "Student")
         {
             NewTicket.Enabled = true;
             NewTicket.Title   = "New";
         }
         else
         {
             NewTicket.Enabled = true;
             NewTicket.Title   = "Search";
         }
     }
     else
     {
         NewTicket.Enabled     = false;
         RemoteService.Tickets = new List <Ticket>();
         TicketsTable.Source   = new TicketsTableSource(this);
         TicketsTable.ReloadData();
     }
 }
Exemplo n.º 2
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     TicketsTable.Source          = new TicketsTableSource(this);
     refreshControl               = new UIRefreshControl();
     refreshControl.ValueChanged += refreshTable;
     TicketsTable.AddSubview(refreshControl);
     NewTicket.Enabled = false;
     storyboard        = UIStoryboard.FromName("Main", null);
 }
Exemplo n.º 3
0
 private void UpdateInfo()
 {
     new Thread(new ThreadStart(async() =>
     {
         await RemoteService.GetInfo();
         InvokeOnMainThread(() =>
         {
             TicketsTable.Source = new TicketsTableSource(this);
             TicketsTable.ReloadData();
         });
     }))
     .Start();
 }
Exemplo n.º 4
0
        async Task CreateSpecificTicket(UIAlertAction action)
        {
            Console.WriteLine("Created new ticket");
            Console.WriteLine(action.Title);
            string currentTime = string.Format($"{DateTime.Now.Day:d2}.{DateTime.Now.Month:d2}.{DateTime.Now.Year} {DateTime.Now.Hour:d2}:{DateTime.Now.Minute:d2}:{DateTime.Now.Second:d2}");
            Ticket ticket      = new Ticket()
            {
                UserId          = Profile.Instance.UserId,
                Topic           = action.Title,
                OpenTime        = currentTime,
                Status          = "Open",
                LastMessageText = "You created new ticket. Please share your issue!",
                LastMessageTime = currentTime,
                FullName        = Profile.Instance.Name
            };
            Ticket updatedTicket = await RemoteService.CreateTicket(ticket);

            if (updatedTicket == null)
            {
                await RemoteService.DeleteTicket(ticket);

                return;
            }
            Message date = new Message()
            {
                Text     = $"{DateTime.Now.Day:d2}.{DateTime.Now.Month:d2}.{DateTime.Now.Year}",
                Sender   = "System",
                SendTime = currentTime,
                UserId   = Profile.Instance.UserId,
                TicketId = updatedTicket.Id
            };
            Message message = new Message()
            {
                Text     = "You created new ticket. Please share your issue!",
                Sender   = "System",
                SendTime = currentTime,
                UserId   = Profile.Instance.UserId,
                TicketId = updatedTicket.Id
            };

            new Thread(new ThreadStart(async() =>
            {
                await RemoteService.SendMessage(date);
                await RemoteService.SendMessage(message);
                InvokeOnMainThread(() =>
                {
                    refreshTable(new object(), new EventArgs());
                    TicketsTable.ReloadData();
                });
            })).Start();
        }
Exemplo n.º 5
0
 void refreshTable(object sender, EventArgs e)
 {
     new Thread(new ThreadStart(async() =>
     {
         if (Profile.Instance != null)
         {
             await RemoteService.GetInfo();
         }
         InvokeOnMainThread(() =>
         {
             TicketsTable.Source = new TicketsTableSource(this);
             TicketsTable.ReloadData();
             refreshControl.EndRefreshing();
         });
     }))
     .Start();
 }