Esempio n. 1
0
        public ActionResult Close_Ticket_R(FormCollection collection = null)
        {
            if (collection != null)
            {
                string   id_ticket            = Utilities.Elements_Form_Post(collection, "id_ticket");
                string   tip_mov              = Utilities.Elements_Form_Post(collection, "tipo_mov");
                string   chk_exposicion_equip = Utilities.Elements_Form_Post(collection, "chk_exposicion_equip");
                string   observations         = Utilities.Elements_Form_Post(collection, "observaciones");
                string   email      = Utilities.Elements_Form_Post(collection, "email");
                string   e_faltante = Utilities.Elements_Form_Post(collection, "e_faltante");
                DateTime now        = DateTime.Now;

                string membershipNumber = Utilities.Elements_Form_Post(collection, "membership_number");
                string local_name       = Utilities.Elements_Form_Post(collection, "local_name");
                string info_t           = membershipNumber + " " + local_name;

                TicketLog ticketL = new TicketLog()
                {
                    id   = id_ticket,
                    type = Get_Type_Tiquet(tip_mov),
                    equipment_exposition = chk_exposicion_equip,
                    extra_1 = observations,
                    date    = now,
                    extra_3 = e_faltante
                };

                //acciones para cerrar el tiquet
                Insert_Log_Ticket(ticketL);
                Change_Status_Ticket(id_ticket, "R");
                Send_Email(id_ticket, email, info_t);
            }
            return(Redirect_Index());
        }
        public async Task <TicketLog> UpdateTicketFields(int ticketId, IList <TicketFieldModel> ticketFields, bool isNewTicket)
        {
            TicketLog log = null;

            //Update ticketFields in the database
            foreach (var ticketField in ticketFields)
            {
                _ticketFieldRepository.UpdateOrInsert(ticketField);
            }

            if (!isNewTicket)
            {
                var user = GetCurrentUser();
                //Add record to the TicketsLog table
                log = _ticketLogRepository.Insert(ticketId, (int)LogEntryTypeId.TicketEdited, "Ticket was updated", $"Ticket was updated by {user.Name}", user.Id);
                _ticketRepository.UpdateTicketDate(ticketId);

                //Find and Complile email template (replace all %field% with values)
                var emailTemplates = _emailTemplateRepository.GetEmailTemplatesByAction(EmailActionId.TicketEdited);

                var substitutions = _ticketFieldRepository.GetTicketFieldsSubstitutions(ticketId, GetTicketUrl(ticketId));

                await SendEmails(ticketId, emailTemplates, substitutions);
            }
            return(log);
        }
Esempio n. 3
0
 public TicketLogDTO ConvertTicketLog(TicketLog log)
 {
     if (log != null)
     {
         TicketLogDTO dto = new TicketLogDTO(log);
         return(dto);
     }
     throw new ArgumentNullException();
 }
Esempio n. 4
0
        public ActionResult Close_Ticket_V(FormCollection collection = null)
        {
            if (collection != null)
            {
                string id_ticket         = Utilities.Elements_Form_Post(collection, "id_ticket");
                string tip_mov           = Utilities.Elements_Form_Post(collection, "tipo_mov");
                string solucion          = Utilities.Elements_Form_Post(collection, "solucion");
                string diagnostico       = Utilities.Elements_Form_Post(collection, "diagnostico");
                string averia            = Utilities.Elements_Form_Post(collection, "averia");
                string chk_pruebas       = Utilities.Elements_Form_Post(collection, "chk_pruebas");
                string chk_mantenimiento = Utilities.Elements_Form_Post(collection, "chk_mantenimiento");
                string radio_polvo       = Utilities.Elements_Form_Post(collection, "radio_polvo");
                string radio_plaga       = Utilities.Elements_Form_Post(collection, "radio_plaga");
                string radio_voltaje     = Utilities.Elements_Form_Post(collection, "radio_voltaje");
                string radio_grasa       = Utilities.Elements_Form_Post(collection, "radio_grasa");
                string radio_humedad     = Utilities.Elements_Form_Post(collection, "radio_humedad");
                string radio_otra        = Utilities.Elements_Form_Post(collection, "radio_otra");
                string exposicion_otra   = Utilities.Elements_Form_Post(collection, "exposicion_otra");
                string e_faltante        = Utilities.Elements_Form_Post(collection, "e_faltante");

                string mantenimiento = Utilities.Elements_Form_Post(collection, "chk_mantenimiento_general");
                string email         = Utilities.Elements_Form_Post(collection, "email");

                string exposicion = radio_polvo + ',' + radio_plaga + ',' + radio_voltaje + ',' + radio_grasa + ',' + radio_humedad;
                exposicion = (radio_otra != "") ? (exposicion + ',' + radio_otra) : exposicion;

                string membershipNumber = Utilities.Elements_Form_Post(collection, "membership_number");
                string local_name       = Utilities.Elements_Form_Post(collection, "local_name");
                string info_t           = membershipNumber + " " + local_name;

                DateTime  now     = DateTime.Now;
                TicketLog ticketL = new TicketLog()
                {
                    id                     = id_ticket,
                    type                   = Get_Type_Tiquet(tip_mov),
                    damage                 = averia,
                    diagnostic             = diagnostico,
                    solution               = solucion,
                    equipment_exposition   = exposicion,
                    equipment_exposition_2 = exposicion_otra,
                    mainmaintenance        = chk_mantenimiento,
                    tests                  = chk_pruebas,
                    date                   = now,
                    extra_2                = mantenimiento,
                    extra_3                = e_faltante
                };

                //acciones para cerrar el tiquet
                Insert_Log_Ticket(ticketL);
                Change_Status_Ticket(id_ticket, "R");
                Send_Email(id_ticket, email, info_t);
            }
            return(Redirect_Index());
        }
Esempio n. 5
0
        private TicketLog GetTicketLogFromTicket(Ticket ticket, string action, string comments)
        {
            TicketLog ticketlog = new TicketLog();

            ticketlog.TicketId  = ticket.TicketId;
            ticketlog.Action    = action;
            ticketlog.Comments  = comments;
            ticketlog.AddedById = ticket.AddedById;
            ticketlog.AddedOn   = ticket.AddedOn;
            ticketlog.Status    = ticket.Status;
            return(ticketlog);
        }
        public void WriteTicketLog(User user, TicketAction action, Ticket onTicket)
        {
            if (user != null && onTicket != null)
            {
                TicketLog curLog = new TicketLog()
                {
                    Action   = action,
                    TicketId = onTicket.Id,
                    Time     = DateTime.Now,
                    User     = user
                };
                switch (action)
                {
                case TicketAction.CreateComment:
                {
                    curLog.Text = string.Format("{0} {1} left a comment.", user.Name, user.Surname);
                    break;
                }

                case TicketAction.DeleteComment:
                {
                    curLog.Text = string.Format("{0} {1} deleted a comment.", user.Name, user.Surname);
                    break;
                }

                case TicketAction.CreateTicket:
                {
                    curLog.Text = string.Format("{0} {1} created a new ticket.", user.Name, user.Surname);
                    break;
                }

                case TicketAction.DeleteTicket:
                {
                    curLog.Text = string.Format("{0} {1} deleted a ticket.", user.Name, user.Surname);
                    break;
                }

                case TicketAction.EditTicket:
                {
                    curLog.Text = string.Format("{0} {1} edited a ticket.", user.Name, user.Surname);
                    break;
                }

                case TicketAction.StateChange:
                {
                    curLog.Text = string.Format("{0} {1} changed ticket's state.", user.Name, user.Surname);
                    break;
                }
                }
                onTicket.Logs.Add(curLog);
            }
        }
Esempio n. 7
0
        //public async Task<IEnumerable<TicketLog>> FindPaginated(int pageIndex, int pageSize, string searchValue)
        //{
        //    try
        //    {
        //        IEnumerable<TicketLog> vList;
        //        if (String.IsNullOrEmpty(searchValue))
        //            vList = adbContext.ticketlog.Skip(pageIndex * pageSize).Take(pageSize).ToList();
        //        else
        //            vList = adbContext.ticketlog.Where(w => new[] { w.Action.ToLower() }.Any(a => a.Contains(searchValue.ToLower()))).Skip(pageIndex * pageSize).Take(pageSize).ToList();
        //        if (vList == null || vList.Count() == 0)
        //            throw new RecoredNotFoundException("Get Data Empty");

        //        return await Task.FromResult(vList);
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        public async Task Insert(TicketLog entity)
        {
            try
            {
                entity.AddedOn = DateTime.Now;
                adbContext.ticketlog.Add(entity);
                await Task.FromResult(adbContext.SaveChanges());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 8
0
        public void AddTicketMonthLogEdit(TicketMonth ticketMonthOld, TicketMonth ticketMonthNew, string actionType, string nameUserCreateLog, string Code)
        {
            using (DB db = new DB(Code))
            {
                try
                {
                    if (ticketMonthOld == null || ticketMonthNew == null)
                    {
                        Debug.WriteLine("TicketMonth null không thể tạo log");
                        return;
                    }

                    var dateTime  = DateTime.Now;
                    var ticketLog = new TicketLog()
                    {
                        RowID         = ticketMonthNew.RowID,
                        ProcessType   = actionType,
                        STT           = (ticketMonthOld.Stt != ticketMonthNew.Stt) ? ticketMonthOld.Stt + "->" + ticketMonthNew.Stt : ticketMonthNew.Stt + "",
                        ID            = (!(ticketMonthOld.ID + "").Equals(ticketMonthNew.ID + "")) ? ticketMonthOld.ID + "->" + ticketMonthNew.ID : ticketMonthNew.ID + "",
                        DateProcess   = dateTime,
                        Digit         = (!ticketMonthOld.Digit.Equals(ticketMonthNew.Digit + "")) ? ticketMonthOld.Digit + "->" + ticketMonthNew.Digit : ticketMonthNew.Digit + "",
                        TenKH         = (!(ticketMonthOld.TenKH + "").Equals(ticketMonthNew.TenKH + "")) ? ticketMonthOld.TenKH + "->" + ticketMonthNew.TenKH : ticketMonthNew.TenKH + "",
                        CMND          = (!(ticketMonthOld.CMND + "").Equals(ticketMonthNew.CMND + "")) ? ticketMonthOld.CMND + "->" + ticketMonthNew.CMND : ticketMonthNew.CMND + "",
                        Company       = (!(ticketMonthOld.Company + "").Equals(ticketMonthNew.Company + "")) ? ticketMonthOld.Company + "->" + ticketMonthNew.Company : ticketMonthNew.Company + "",
                        EMail         = (!(ticketMonthOld.Email + "").Equals(ticketMonthNew.Email + "")) ? ticketMonthOld.Email + "->" + ticketMonthNew.Email : ticketMonthNew.Email + "",
                        Address       = (!(ticketMonthOld.Address + "").Equals(ticketMonthNew.Address + "")) ? ticketMonthOld.Address + "->" + ticketMonthNew.Address : ticketMonthNew.Address + "",
                        CarKind       = (!(ticketMonthOld.CarKind + "").Equals(ticketMonthNew.CarKind + "")) ? ticketMonthOld.CarKind + "->" + ticketMonthNew.CarKind : ticketMonthNew.CarKind + "",
                        IDPart        = (ticketMonthOld.IDPart != ticketMonthNew.IDPart) ? ticketMonthOld.IDPart + "->" + ticketMonthNew.IDPart : ticketMonthNew.IDPart + "",
                        DateStart     = (!(ticketMonthOld.DateStart + "").Equals((ticketMonthNew.DateStart + ""))) ? (ticketMonthOld.DateStart + "") + "->" + (ticketMonthNew.DateStart + "") : ticketMonthNew.DateStart + "",
                        DateEnd       = (!(ticketMonthOld.DateEnd + "").Equals(ticketMonthNew.DateEnd + "")) ? ticketMonthOld.DateEnd + "" + "->" + (ticketMonthNew.DateEnd + "") : ticketMonthNew.DateEnd + "",
                        Note          = (!(ticketMonthOld.Note + "").Equals(ticketMonthNew.Note + "")) ? ticketMonthOld.Note + "->" + ticketMonthNew.Note : ticketMonthNew.Note + "",
                        Amount        = (!(ticketMonthOld.Amount + "").Equals(ticketMonthNew.Amount + "")) ? ticketMonthOld.Amount + "->" + ticketMonthNew.Amount : ticketMonthNew.Amount + "",
                        ChargesAmount = (!(ticketMonthOld.ChargesAmount + "").Equals(ticketMonthNew.ChargesAmount + "")) ? ticketMonthOld.ChargesAmount + "->" + ticketMonthNew.ChargesAmount : ticketMonthNew.ChargesAmount + "",
                        Account       = nameUserCreateLog,
                        Images        = ticketMonthOld.Images,
                        DayUnLimit    = String.Format("{0:MMM dd yyyy hh:mm tt}", ticketMonthNew.DayUnLimit.Value + "")
                    };
                    db.TicketLogs.Add(ticketLog);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Không thể tạo log: " + e.Message);
                    Debug.WriteLine("Không thể tạo log: " + e.StackTrace);
                }
            }
        }
Esempio n. 9
0
 public void AddTicketMonthLog(TicketMonth ticketMonth, string actionType, string nameUserCreateLog, string Code)
 {
     using (DB db = new DB(Code))
     {
         try
         {
             if (ticketMonth == null)
             {
                 Debug.WriteLine("TicketMonth null không thể tạo log");
                 return;
             }
             var dateTime  = DateTime.Now;
             var ticketLog = new TicketLog()
             {
                 RowID         = ticketMonth.RowID,
                 ProcessType   = actionType,
                 STT           = ticketMonth.Stt.ToString(),
                 ID            = ticketMonth.ID,
                 DateProcess   = dateTime,
                 Digit         = ticketMonth.Digit,
                 TenKH         = ticketMonth.TenKH,
                 CMND          = ticketMonth.CMND,
                 Company       = ticketMonth.Company,
                 EMail         = ticketMonth.Email,
                 Address       = ticketMonth.Address,
                 CarKind       = ticketMonth.CarKind,
                 IDPart        = ticketMonth.IDPart,
                 DateStart     = ticketMonth.DateStart.ToString(),
                 DateEnd       = ticketMonth.DateEnd.ToString(),
                 Note          = ticketMonth.Note,
                 Amount        = ticketMonth.Amount,
                 ChargesAmount = ticketMonth.ChargesAmount,
                 Account       = nameUserCreateLog,
                 Images        = ticketMonth.Images,
                 DayUnLimit    = String.Format("{0:MMM dd yyyy hh:mm tt}", ticketMonth.DayUnLimit.Value),
             };
             db.TicketLogs.Add(ticketLog);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             Debug.WriteLine("Không thể tạo log: " + e.Message);
             Debug.WriteLine("Không thể tạo log: " + e.StackTrace);
         }
     }
 }
        public async Task <JsonResult> GetLastTicketLog(int?ticketId)
        {
            if (ticketId != null && ticketId > 0)
            {
                User curUser = await userManager.GetCurrentUser();

                List <TicketLog> curTicketLogs = await db.TicketLogs.Where(x => x.TicketId == ticketId && x.User.Id == curUser.Id).ToListAsync();

                if (curTicketLogs != null)
                {
                    TicketLog lastLog = curTicketLogs.SingleOrDefault(x => x.Time.Ticks == curTicketLogs.Max(z => z.Time.Ticks));
                    if (lastLog != null)
                    {
                        TicketLogDTO tempDto = dtoConverter.ConvertTicketLog(lastLog);
                        return(Json(tempDto, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
Esempio n. 11
0
        public ActionResult Close_Ticket_I(FormCollection collection = null)
        {
            if (collection != null)
            {
                string id_ticket            = Utilities.Elements_Form_Post(collection, "id_ticket");
                string tip_mov              = Utilities.Elements_Form_Post(collection, "tipo_mov");
                string chk_connection       = Utilities.Elements_Form_Post(collection, "chk_conecion");
                string chk_detalle_install  = Utilities.Elements_Form_Post(collection, "chk_detalle_install");
                string chk_exposicion_equip = Utilities.Elements_Form_Post(collection, "chk_exposicion_equip");
                string chk_otros            = Utilities.Elements_Form_Post(collection, "chk_otros");
                string observations         = Utilities.Elements_Form_Post(collection, "observaciones");
                string membershipNumber     = Utilities.Elements_Form_Post(collection, "membership_number");
                string local_name           = Utilities.Elements_Form_Post(collection, "local_name");
                string info_t = membershipNumber + " " + local_name;
                //local_name
                string    email   = Utilities.Elements_Form_Post(collection, "email");
                DateTime  now     = DateTime.Now;
                TicketLog ticketL = new TicketLog()
                {
                    id                   = id_ticket,
                    type                 = Get_Type_Tiquet(tip_mov),
                    connetion            = chk_connection,
                    instalation_detaill  = chk_detalle_install,
                    equipment_exposition = chk_exposicion_equip,
                    others               = chk_otros,
                    extra_1              = observations,
                    date                 = now
                };

                //actualiza el status del afiliado a actualizado
                ClientController cc = new ClientController();
                cc.Update_Client(membershipNumber);

                //acciones para cerrar el tiquet
                Insert_Log_Ticket(ticketL);
                Change_Status_Ticket(id_ticket, "R");
                Send_Email(id_ticket, email, info_t);
            }
            return(Redirect_Index());
        }
Esempio n. 12
0
        //agrega una bitacora al tiquete cerrado
        private string Insert_Log_Ticket(TicketLog log)
        {
            BMS_DATA_DENTEntities connection = BDConnection.Get_Connection();
            string mjs = "";
            SGA_BITACORA_TICKET logT = new SGA_BITACORA_TICKET()
            {
                ID_TICKET                = log.id,
                TIPO_MOVIMIENTO          = log.type.ToString(),
                AVERIA_REPORTADA         = log.damage == null ? "" : log.damage.Trim(),
                DIAGNOSTICO              = log.diagnostic == null ? "" : log.diagnostic.Trim(),
                SOLUCION                 = log.solution == null ? "" : log.solution.Trim(),
                EXPOSICION_EQUIPO        = log.equipment_exposition,
                EXPOSICION_EQUIPO_2      = log.equipment_exposition_2,
                MANTENIMIENTO            = log.mainmaintenance,
                PRUEBAS                  = log.tests,
                TIPO_CONEXION            = log.connetion,
                DETALLE_INSTALACION      = log.instalation_detaill,
                EXPOSICION_EQUIPO_VISITA = log.visit_equipment_exposition,
                OTROS     = log.others,
                FECHA_DIG = log.date,
                EXTRA_1   = log.extra_1,
                EXTRA_2   = log.extra_2,
                EXTRA_3   = log.extra_3
            };

            connection.SGA_BITACORA_TICKET.Add(logT);
            try
            {
                connection.SaveChanges();
                mjs = "Successful";
            }
            catch (Exception e)
            {
                mjs = "Error " + e;
                Generate_Exception(mjs);
            }
            return(mjs);
        }
        private TicketScreenViewModel PrepareTicketScreenViewModel(TicketLog log, int ticketId, string userId,
                                                                   IList <string> roles)
        {
            var ticket = _ticketRepository.GetTicketById(ticketId);
            var showCustomerDetails = !ticket.DepartmentId.HasValue || _departmentRepository.GetItemById(ticket.DepartmentId.Value).CanSeeCustomerDetails;
            var result = new TicketScreenViewModel
            {
                Log                 = log,
                Ticket              = ticket,
                CustomFieldValues   = _ticketRepository.GetCustomFieldValues(ticketId),
                Attchments          = _ticketRepository.GetTicketAttachedFiles(ticketId),
                ShowCustomerDetails = showCustomerDetails,
            };

            result.Controls = GetMockControls(result.Ticket, userId, UserManager.GetRoles(userId));

            if (roles.Contains(TicRoles.Staff) || roles.Contains(TicRoles.Admin))
            {
                result.InstructionsTextHtml  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
                result.InstructionsLinksHtml = "<div class=\"col - lg - 11\"><a>Quick link 1</a></ div > ";
            }

            return(result);
        }
        public async Task <JsonResult> SubmitTicketFields(int ticketId, IList <TicketFieldModel> customFields, bool isNewTicket)
        {
            TicketLog log = null;

            if (isNewTicket)
            {
                var ticket     = _ticketRepository.GetBlankTicketById(ticketId);
                var ticketData = await _ticketService.CreateTicket(ticket);

                log = ticketData.LastLog;
            }

            var updateLog = await _ticketService.UpdateTicketFields(ticketId, customFields, isNewTicket);

            if (log == null)
            {
                log = updateLog;
            }

            var userId = User.Identity.GetUserId();
            var result = PrepareTicketScreenViewModel(log, ticketId, userId, UserManager.GetRoles(userId));

            return(Json(result));
        }
Esempio n. 15
0
 public App()
 {
     Log = new TicketLog();
     UsingTicketTracker = true;
 }