public ActionResult Create(CreateTicketViewModel model)
        {
            var zendesk = "https://eswebtech.zendesk.com/";
            //set up the api
            var api = new ZendeskApi(string.Format("{0}api/v2", zendesk), "*****@*****.**", "pa55word");

            //create the user if they don't already exist
            var user = api.Users.SearchByEmail(model.RequesterEmail);
            if (user == null || user.Users.Count < 1)
                api.Users.CreateUser(new User()
                                         {
                                             Name = model.RequesterEmail,
                                             Email = model.RequesterEmail
                                         });

            //setup the ticket
            var ticket = new Ticket()
            {
                Subject = model.Subject,
                Description = model.Description,
                Priority = model.TicketPriority,
                Requester = new Requester() { Email = model.RequesterEmail }
            };

            //create the new ticket
            var res = api.Tickets.CreateTicket(ticket).Ticket;

            return View("Index", new CreateTicketViewModel() {TicketId = res.Id.ToString(), ZendeskUrl = zendesk});
        }
        public ActionResult Create(CreateTicketViewModel model)
        {
            var zendesk = ConfigurationManager.AppSettings["ZendeskUrl"];
            var zendeskUser = ConfigurationManager.AppSettings["ZendeskUser"];
            var zendeskPassword = ConfigurationManager.AppSettings["ZendeskPassword"];

            //set up the api
            var api = new ZendeskApi(zendesk, zendeskUser, zendeskPassword);

            //create the user if they don't already exist
            var user = api.Users.SearchByEmail(model.RequesterEmail);
            if (user == null || user.Users.Count < 1)
                api.Users.CreateUser(new User()
                                         {
                                             Name = model.RequesterEmail,
                                             Email = model.RequesterEmail
                                         });

            //setup the ticket
            var ticket = new Ticket()
            {
                Subject = model.Subject,
                Description = model.Description,
                Priority = model.TicketPriority,
                Requester = new Requester() { Email = model.RequesterEmail }
            };

            //create the new ticket
            var res = api.Tickets.CreateTicket(ticket).Ticket;

            return View("Index", new CreateTicketViewModel() {TicketId = res.Id.ToString(), ZendeskUrl = zendesk});
        }
示例#3
0
        /// <summary>
        /// UpdateTicket a ticket or add comments to it. Keep in mind that somethings like the description can't be updated.
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="comment"></param>
        /// <returns></returns>
        public IndividualTicketResponse UpdateTicket(Ticket ticket, Comment comment=null)
        {
            if (comment != null)
                ticket.Comment = comment;
            var body = new { ticket };

            return GenericPut<IndividualTicketResponse>(string.Format("{0}/{1}.json", _tickets, ticket.Id), body);    
        }
示例#4
0
        public void UpdateTicketPriority(Int64 identifier, String priority)
        {
            var api = ZendeskProject.GetApi();

            var ticket = new Ticket
            {
                Id = identifier,
                Priority = priority,
            };

            var ticketResponse = api.Tickets.UpdateTicket(ticket);
        }
示例#5
0
        public Int64 CreateTicket(String subject, String message, String priority, String tag)
        {
            var api = ZendeskProject.GetApi();

            var ticket = new Ticket
            {
                Subject = subject,
                Comment = new Comment { Body = message },
                Priority = priority,
                Tags = new[] { tag },
            };

            var ticketResponse = api.Tickets.CreateTicket(ticket);

            return ticketResponse.Ticket.Id.Value;
        }
示例#6
0
        /// <summary>
        /// Sends the events.
        /// </summary>
        /// <param name="events">The events that need to be send.</param>
        /// <remarks>
        /// <para>
        /// The subclass must override this method to process the buffered events.
        /// </para>
        /// </remarks>
        protected override void SendBuffer(LoggingEvent[] events)
        {
            ZenDesk client = new ZenDesk(Url, User, Password);
            Parallel.ForEach(events, loggingEvent =>
                {
                    StringWriter writer = new StringWriter();
                    Layout.Format(writer, loggingEvent);

                    Ticket ticket = new Ticket
                        {
                            Description = writer.ToString(),
                            Subject = string.Format("{0} {1} {2} {3}",
                            loggingEvent.TimeStamp,
                            loggingEvent.ThreadName,
                            loggingEvent.Level,
                            loggingEvent.LoggerName),
                            Tags = Tags.Split(';'),
                            RequesterId = RequesterId
                        };
                    client.Tickets.CreateTicket(ticket);
                });
        }
示例#7
0
 public IndividualTicketResponse CreateTicket(Ticket ticket)
 {
     var body = new {ticket};
     return GenericPost<IndividualTicketResponse>(_tickets + ".json", body);
 }
示例#8
0
        /// <summary>
        /// UpdateTicket a ticket or add comments to it. Keep in mind that somethings like the description can't be updated.
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="comment"></param>
        /// <returns></returns>
        public async Task<IndividualTicketResponse> UpdateTicketAsync(Ticket ticket, Comment comment=null)
        {
            if (comment != null)
                ticket.Comment = comment;
            var body = new { ticket };

            return await GenericPutAsync<IndividualTicketResponse>(string.Format("{0}/{1}.json", _tickets, ticket.Id), body);    
        }
示例#9
0
 public async Task<IndividualTicketResponse> CreateTicketAsync(Ticket ticket)
 {
     var body = new {ticket};
     return await GenericPostAsync<IndividualTicketResponse>(_tickets + ".json", body);
 }
示例#10
0
        public List<Appointment> AssignAppointment(string[] appointmentIds, string agentId)
        {
            if (appointmentIds == null)
                throw new ParamMissingException("[D] appointmentIds cannot be null.");
            if (string.IsNullOrWhiteSpace(agentId))
                throw new ParamMissingException("[D] agentId cannot be empty.");

            List<int> appointmentIdList = new List<int>(appointmentIds.Length);
            foreach (string appointmentId in appointmentIds)
                if (string.IsNullOrWhiteSpace(appointmentId) == false)
                    appointmentIdList.Add(int.Parse(appointmentId));

            User agent = Repository.Single<User>(x => x.UserId.Equals(agentId) && x.Deleted != true);
            if (agent == null)
                throw new InvalidValueException("Agent not found.");

            List<Appointment> dbAppointments = Repository.Query<Appointment>(x => x.Deleted != true &&
                                    appointmentIdList.Any<int>(y => y == x.AppointmentId), "User.Credential"
                                    , "Property.Building", "Property.Participants")
                                    .OrderBy(x => x.AppointmentDateTime)
                                    .ToList();

            // do not go further if apointments were not found.
            if (dbAppointments == null || dbAppointments.Count == 0)
                return dbAppointments;

            foreach (Appointment dbAppointment in dbAppointments)
            {
                dbAppointment.AgentId = agentId;
                dbAppointment.Modified = DateTime.UtcNow;

                ZendeskApi_v2.Models.Tickets.Ticket issue = new ZendeskApi_v2.Models.Tickets.Ticket();
                issue.Subject = string.Format(
                                            "Property viewing with {0} has been assigned to you.",
                                            dbAppointment.User.DisplayName);
                User booker = dbAppointment.User;
                Property property = dbAppointment.Property;
                string commentBody = string.Format(
                        "{0} has booked an appointment with you for {7}. You can contact them at "
                        + "{1}. Booked property is at {2} of type {3}. Once you have shown"
                        + " this property, please click on this link to mark this appointment "
                        + " as shown {4}{5}&ag={6}",
                        booker.DisplayName, booker.Credential.Email, property.FullStreetAddress
                        , property.PropertyType, "http://www.reop.com/api/appointments/shown?id="
                        , dbAppointment.AppointmentId, agentId, dbAppointment.AppointmentDateTime);
                issue.Comment = new ZendeskApi_v2.Models.Tickets.Comment
                {
                    Body = commentBody,
                };
                issue.AssigneeId = long.Parse(agent.ZenmateId);
                issue.Type = "task";
                issue.ExternalId = dbAppointments[0].AppointmentId;
                issue.DueAt = dbAppointments[0].AppointmentDateTime.Value;
                // TODO: This function is no longer used and has been changed after it
                //      was stopped being used. So its not tested. We need a different method in service
                //      for this. (aka assign agent a ticket).
                Services.Ticketing.CreateUserTicket(issue.AssigneeId.Value, agent.Credential.Email);
                //ZendeskApi_v2.Models.Tickets.IndividualTicketResponse response
                //    = api.Tickets.CreateTicket(issue);
            }
            Repository.Save();
            return dbAppointments;
        }
示例#11
0
        private static void SendTestTicket(ZendeskApi api)
        {
            Console.WriteLine("Create ticket");

            var ticket = new Ticket()
            {
                Subject = SubjectStart + DateTime.Now.Ticks,

                //Subject = "Request of order #"+DateTime.Now.Second,
                //Tags = new List<String>(new[] { "Request_of_order" }),

                Comment = new Comment()
                {
                    Body = "HELP ME!!!",
                },

                Priority = TicketPriorities.Urgent,
            };

            api.Tickets.CreateTicket(ticket);

            Console.WriteLine("Done");
        }