Exemple #1
0
        public string EditTicket(UpdateTicket model, string userId, string userName)
        {
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                var currentTicket = db.Issues.Find(model.IssueId);
                currentTicket.IssueDesc   = model.IssueDescription;
                currentTicket.IssueTypeId = model.IssueTypeId;

                var _issueId   = model.IssueId;
                var _issueDesc = model.IssueDescription;
                _username = userName;
                _email    = userName;
                EmailManager.SendEmailEditTicket(_email, _username, _issueId, _issueDesc);

                TimeLineLog tl = new TimeLineLog()
                {
                    Description  = "Issue Edited! Issue on: " + DateTime.Now + " User : "******" , Short Desc: " + model.IssueDescription,
                    EntryType    = "new",
                    TimeHappened = DateTime.Now,
                    Title        = "Issue Edited!",
                    UserName     = userName
                };
                db.TimeLineLogs.Add(tl);
                try
                {
                    db.SaveChanges();
                    return("ok");
                }
                catch (Exception ex)
                {
                    return("An error occured while updating ticket. => " + ex.Message);
                }
            }
        }
Exemple #2
0
        public static void UserOperations(string UserFullName, string ByUser, Operations operation, string message = "")
        {
            TimeLineLog tl = new TimeLineLog()
            {
                Notes        = "Notes : " + message == "" ? "No message" : message,
                TimeHappened = DateTime.Now,
                UserName     = ByUser
            };

            if (operation == Operations.New)
            {
                tl.Description = "New User has been created! Name :  " + UserFullName;
                tl.Title       = "New user  has been created";
                tl.EntryType   = Operations.New.ToString();
            }

            if (operation == Operations.Edit)
            {
                tl.Description = "User has been updated! Name :  " + UserFullName;
                tl.EntryType   = Operations.Edit.ToString();
                tl.Title       = "User has been updated";
            }

            if (operation == Operations.Delete)
            {
                tl.Description = "User has been deleted! Name :  " + UserFullName;
                tl.Title       = "A user has been deleted";
                tl.EntryType   = Operations.Delete.ToString();
            }
            var context = GlobalHost.ConnectionManager.GetHubContext <EchoHub>();


            context.Clients.All.newEntryTimeLine(tl);
            _adapter.AddNewEntry(tl);
        }
Exemple #3
0
        internal static void ErrorOperations(string ByUser, Operations operations, string result, int entityId = 0)
        {
            TimeLineLog tl = new TimeLineLog()
            {
                TimeHappened = DateTime.Now,
                UserName     = ByUser,
                Description  = result,
                EntryId      = entityId,
                EntryType    = operations.ToString()
            };

            if (operations == Operations.Delete)
            {
                tl.Title = "Error while deleting";
            }
            if (operations == Operations.Edit)
            {
                tl.Title = "Error while Editing/Updating";
            }
            if (operations == Operations.New)
            {
                tl.Title = "Error while Adding";
            }

            var context = GlobalHost.ConnectionManager.GetHubContext <EchoHub>();

            context.Clients.All.newEntryTimeLine(tl);
            _adapter.AddNewEntry(tl);
        }
Exemple #4
0
        public static void AssigmentOperations(string ByUser, Operations operation, int issue_id, string staff_name, string message = "")
        {
            TimeLineLog tl = new TimeLineLog()
            {
                Notes        = "Notes : " + message == "" ? "No notes" : message,
                TimeHappened = DateTime.Now,
                UserName     = ByUser
            };

            if (operation == Operations.New)
            {
                tl.Description = "New Assigment has been created! By :  " + ByUser + " , to issue :" + issue_id + " , Tech Name : " + staff_name;
                tl.Title       = "Assigment has been created";
                tl.EntryType   = Operations.New.ToString();
            }

            if (operation == Operations.Edit)
            {
                tl.Description = "An Assigment has been Updated! By :  " + ByUser + " , issue :" + issue_id + " , Tech Name : " + staff_name;
                tl.Title       = "A ticket has been updated";
                tl.EntryType   = Operations.Edit.ToString();
            }

            if (operation == Operations.Delete)
            {
                tl.Description = "An Assigment has been deleted! By :  " + ByUser + " , issue :" + issue_id + " , Tech Name : " + staff_name;
                tl.Title       = "A user has been deleted";
                tl.EntryType   = Operations.Delete.ToString();
            }
            var context = GlobalHost.ConnectionManager.GetHubContext <EchoHub>();

            context.Clients.All.newEntryTimeLine(tl);
            _adapter.AddNewEntry(tl);
        }
        public void NewEntryOnTimeLine(TimeLineLog tl)
        {
            var allAdmins = Clients.All;

            allAdmins.newEntryTimeLine(tl);

            // Trace.WriteLine("I'm here");
        }
Exemple #6
0
 public void AddNewEntry(TimeLineLog t)
 {
     using (_db = new ApplicationDbContext())
     {
         _db.TimeLineLogs.Add(t);
         _db.SaveChanges();
     }
 }
Exemple #7
0
        public string AddTicket(CreateIssueViewModel model, string userId, string userName)
        {
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                //create the res before the issue to stuff the id into the issue when it is made
                Resolution resolution = new Resolution()
                {
                    IsResolved = false
                };

                resolution = db.Resolutions.Add(resolution);
                db.SaveChanges();
                int resolutionId = resolution.ResolutionId;

                //create the issue
                var added = db.Issues.Add(new Issue
                {
                    DateReported = DateTime.Now,
                    ResolutionId = resolutionId,
                    IssueDesc    = model.IssueDescription,
                    UserId       = userId,
                    IssueTypeId  = model.SelectedIssueTypeId
                });

                var _issueDesc = model.IssueDescription;
                _username = GetUserDisplayName(userId);
                _email    = userName;
                EmailManager.SendEmailNewTicket(_email, _username, _issueDesc);

                TimeLineLog tl = new TimeLineLog()
                {
                    Description  = "New issue created! Issue on: " + DateTime.Now + " User : "******" , Short Desc: " + model.IssueDescription,
                    EntryType    = "new",
                    TimeHappened = DateTime.Now,
                    Title        = "New issue created!",
                    UserName     = userName
                };
                db.TimeLineLogs.Add(tl);

                try
                {
                    db.SaveChanges();
                    return(added.IssueId.ToString());
                }
                catch (Exception ex)
                {
                    return("Ann error occured while creating ticket . user : "******" => " + ex.Message);
                }
            }
        }
        public ActionResult Contact(ContactIssueViewModel model)
        {
            ViewBag.Message = "Thanks, we got your message.";

            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                //create the res before the issue to stuff the id into the issue when it is made
                Resolution resolution = new Resolution()
                {
                    IsResolved = false
                };

                resolution = db.Resolutions.Add(resolution);
                db.SaveChanges();
                int resolutionId = resolution.ResolutionId;

                //create the issue
                db.Issues.Add(new Issue
                {
                    DateReported = DateTime.Now,
                    ResolutionId = resolutionId,
                    IssueDesc    = model.IssueDescription,
                    UserId       = User.Identity.GetUserId(),
                    IssueTypeId  = 1
                });

                _username = User.Identity.Name;
                _email    = User.Identity.GetUserId();
                EmailManager.SendEmailNewTicket(_email, _username, model.IssueDescription);

                TimeLineLog tl = new TimeLineLog()
                {
                    Description  = "New issue created! Issue on: " + DateTime.Now + " User : "******" , Short Desc: " + model.IssueDescription,
                    EntryType    = "new",
                    TimeHappened = DateTime.Now,
                    Title        = "New issue created!",
                    UserName     = User.Identity.Name
                };
                db.TimeLineLogs.Add(tl);


                db.SaveChanges();
            }

            return(View());
        }
Exemple #9
0
        public static void TicketOperations(string ByUser, Operations operation, int ticket_id, string message = "")
        {
            TimeLineLog tl = new TimeLineLog()
            {
                Notes        = "Notes : " + message == "" ? "No notes" : message,
                TimeHappened = DateTime.Now,
                UserName     = ByUser
            };

            if (operation == Operations.New)
            {
                tl.Description = "New Ticket has been created! By :  " + ByUser;
                tl.Title       = "New ticket has been created";
                tl.EntryType   = Operations.New.ToString();
            }

            if (operation == Operations.Edit)
            {
                tl.Description = "Ticket (" + ticket_id + ") has been updated! By :  " + ByUser;
                tl.Title       = "A ticket has been updated";
                tl.EntryType   = Operations.Edit.ToString();
            }

            if (operation == Operations.Delete)
            {
                tl.Description = "Ticket (" + ticket_id + ") has been deleted! By :  " + ByUser;
                tl.Title       = "A user has been deleted";
                tl.EntryType   = Operations.Delete.ToString();
            }

            var context = GlobalHost.ConnectionManager.GetHubContext <EchoHub>();

            context.Clients.All.newEntryTimeLine(tl);

            _adapter.AddNewEntry(tl);
            if (operation == Operations.New)
            {
                context.Clients.All.newTicketAdded();
            }
        }