/// <summary>
        /// Get the text for the preview card for the result.
        /// </summary>
        /// <param name="ticket">Ticket object for ask an expert action.</param>
        /// <param name="commandId">Command id which indicate the action.</param>
        /// <param name="localTimestamp">Local time stamp.</param>
        /// <returns>Command id as string.</returns>
        private static string GetPreviewCardText(TicketEntity ticket, string commandId, DateTimeOffset?localTimestamp)
        {
            var ticketStatus = commandId != OpenCommandId ? $"<div style='white-space:nowrap'>{HttpUtility.HtmlEncode(Cards.CardHelper.GetTicketDisplayStatusForSme(ticket))}</div>" : string.Empty;
            var cardText     = $@"<div>
                                <div style='white-space:nowrap'>
                                        {HttpUtility.HtmlEncode(Cards.CardHelper.GetFormattedDateInUserTimeZone(ticket.DateCreated, localTimestamp))} 
                                        | {HttpUtility.HtmlEncode(ticket.RequesterName)}
                                </div> {ticketStatus}
                         </div>";

            return(cardText.Trim());
        }
Esempio n. 2
0
        /// <summary>
        /// Store or update ticket entity in table storage
        /// </summary>
        /// <param name="ticket">ticketEntity.</param>
        /// <returns><see cref="Task"/> that represents configuration entity is saved or updated.</returns>
        public Task SaveOrUpdateTicketAsync(TicketEntity ticket)
        {
            ticket.PartitionKey = PartitionKey;
            ticket.RowKey       = ticket.TicketId;

            if (ticket.Status > (int)TicketState.MaxValue)
            {
                throw new TicketValidationException($"The ticket status ({ticket.Status}) is not valid.");
            }

            return(this.StoreOrUpdateTicketEntityAsync(ticket));
        }
Esempio n. 3
0
 /// <summary>
 /// Gets the current status of the ticket to display in the SME team.
 /// </summary>
 /// <param name="ticket">The current ticket information.</param>
 /// <returns>A status string.</returns>
 public static string GetTicketDisplayStatusForSme(TicketEntity ticket)
 {
     if (ticket.Status == (int)TicketState.Open)
     {
         return(ticket.IsAssigned() ?
                string.Format(Resource.SMETicketAssignedStatus, ticket.AssignedToName) :
                Resource.SMETicketUnassignedStatus);
     }
     else
     {
         return(Resource.SMETicketClosedStatus);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Gets the ticket status for the user notifications.
 /// </summary>
 /// <param name="ticket">The current ticket information.</param>
 /// <returns>A status string.</returns>
 public static string GetUserTicketDisplayStatus(TicketEntity ticket)
 {
     if (ticket?.Status == (int)TicketState.Open)
     {
         return(ticket.IsAssigned() ?
                Strings.AssignedUserNotificationStatus :
                Strings.UnassignedUserNotificationStatus);
     }
     else
     {
         return(Strings.ClosedUserNotificationStatus);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Gets the current status of the ticket to display in the SME team.
 /// </summary>
 /// <param name="ticket">The current ticket information.</param>
 /// <returns>A status string.</returns>
 public static string GetTicketDisplayStatusForSme(TicketEntity ticket)
 {
     if (ticket?.Status == (int)TicketState.Open)
     {
         return(ticket.IsAssigned() ?
                string.Format(CultureInfo.InvariantCulture, Strings.SMETicketAssignedStatus, ticket?.AssignedToName) :
                Strings.SMETicketUnassignedStatus);
     }
     else
     {
         return(Strings.SMETicketClosedStatus);
     }
 }
Esempio n. 6
0
 private void SetTicket2Cache(string cacheName, TicketEntity token)
 {
     onRemove = new CacheItemRemovedCallback(this.RemovedCallback);
     try
     {
         HttpContext.Current.Cache.Insert(cacheName, token, null, DateTime.Now.Add(new TimeSpan(1, 0, 0)), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, onRemove);
         //logs.Fatal("SetTicket2Cache >> " + cacheName);
     }
     catch (Exception e)
     {
         //NCD.WebLog.SysWebLog.WriteLog("error:" + e.ToString());
     }
 }
Esempio n. 7
0
        public Ticket UpdateTicket(JObject item, int id)
        {
            TicketEntity ticketEntity = _ticketRepository.UpdateTicket(item, id);

            if (ticketEntity != null)
            {
                Ticket ticket = _ticketRepository.GetById(id).ToDomain();
                return(ticket);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 8
0
        private async Task DetermineTicketResultAsync(TicketEntity ticket)
        {
            var isWon = _ticketValidator.CheckIsTicketWon(ticket);

            SetTicketResults(isWon, ticket);

            if (isWon)
            {
                var price = ticket.Stake * ticket.TotalConfirmedRate;
                await ModifyUserAccountBalanceAsync(ticket.UserId, price);
            }

            await _ticketRepository.SaveChangesAsync();
        }
Esempio n. 9
0
 public static DataSet InsertTicket(TicketEntity ticket)
 {
     try
     {
         {
             string sql = "insert into ticket(serial_no , customer_id,  price) values ('" + ticket.SerialNo + "','" + ticket.CustomerId + "','" + ticket.Price + "');";
             MessageBox.Show("data inserted");
             return(DataAccess.GetDataSet(sql));
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Esempio n. 10
0
 public void Load(string filename)
 {
     using (StreamReader reader = new StreamReader(filename, Encoding.UTF8))
     {
         while (reader.Peek() >= 0)
         {
             var line = reader.ReadLine().Trim();
             if (line == "")
             {
                 continue;
             }
             Tickets.Add(TicketEntity.FromCSV(line));
         }
     }
 }
Esempio n. 11
0
        private JwtSecurityToken GetTokenAsync(TicketEntity signUpTicket)
        {
            var claims = new List <Claim>
            {
                new Claim(JwtRegisteredClaimNames.Sub, signUpTicket.Key.ToString()),
                new Claim(JwtRegisteredClaimNames.Jti, signUpTicket.Name),
                new Claim(ClaimCulture, signUpTicket.Culture)
            };

            var key         = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(AuthenticationConfig.SecurityKey));
            var credentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
            var audience    = ApplicationSettings.Name.IsEmpty() ? "XCommon" : ApplicationSettings.Name;

            return(new JwtSecurityToken(audience, audience, claims, expires: DateTime.Now.AddDays(AuthenticationConfig.Expiration), signingCredentials: credentials));
        }
Esempio n. 12
0
        private TicketEntity GetFromWeixin()
        {
            AccessTokenObject tokenObject = new Token().Get();
            string            requestUri  = GZH.CL.Config.ConfigSetting.GetWeixinWeb().TicketUrl;

            requestUri += "?access_token=" + tokenObject.access_token + "&type=jsapi";

            //logs.Fatal("TicketUrl requestUri:"+ requestUri);

            TicketEntity r = JsonHelper.ScriptDeserialize <TicketEntity>(HttpService.Get(requestUri));

            //logs.Fatal("TicketEntity GetFromWeixin():" + r.ticket);

            return(r);
        }
Esempio n. 13
0
        public TicketEntity CreateTicket(TicketEntity TicketEntity)
        {
            int TicketId;

            if (Tickets.Count() == 0)
            {
                TicketId = 1;
            }
            else
            {
                TicketId = Tickets.OrderByDescending(c => c.Id).FirstOrDefault().Id + 1;
            }
            TicketEntity.Id = TicketId;
            Tickets.Add(TicketEntity);
            return(TicketEntity);
        }
Esempio n. 14
0
        private ClaimsPrincipal GetClaimsPrincipal(TicketEntity signUpTicket)
        {
            var audience = ApplicationSettings.Name.IsEmpty() ? "XCommon" : ApplicationSettings.Name;

            var userIdentity = new ClaimsIdentity(audience);
            var claims       = new List <Claim>
            {
                new Claim(ClaimTypes.NameIdentifier, signUpTicket.Key.ToString()),
                new Claim(ClaimTypes.Name, signUpTicket.Name),
                new Claim(ClaimCulture, signUpTicket.Culture)
            };

            userIdentity.AddClaims(claims);

            return(new ClaimsPrincipal(userIdentity));
        }
Esempio n. 15
0
        /// <summary>
        /// To Add or update the ticket
        /// </summary>
        /// <param name="loginUserId">user who create this</param>
        /// <param name="ticketModel">model object</param>
        /// <returns></returns>
        public async Task <TicketModel> SaveTicket(int loginUserId, TicketModel ticketModel)
        {
            TicketEntity response = null;

            if (ticketModel.Id.HasValue && ticketModel.Id > 0)
            {
                response = await Task.Run(() => this.UpdateTicket(loginUserId, ticketModel));
            }
            else
            {
                response = await Task.Run(() => this.AddTicket(loginUserId, ticketModel));
            }

            ticketModel.Id = response?.Id;
            return(ticketModel);
        }
Esempio n. 16
0
 public ActionResult EditarTicket(TicketEntity model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             new TicketBusiness().Salvar(model, this.UsuarioId);
             return(RedirectToAction("Index"));
         }
         catch (TicketException ex)
         {
             ModelState.AddModelError("ex", ex.Message);
         }
     }
     return(View("PrincipalTicket", model));
 }
Esempio n. 17
0
        public void Delete(int id)
        {
            using var transaction = _context.Database.BeginTransaction();
            try
            {
                TicketEntity ticket = _context.Tickets.FirstOrDefault(item => item.TicketId == id);
                _context.Tickets.Remove(ticket);
                _context.SaveChanges();

                transaction.Commit();
            }
            catch (Exception e)
            {
                transaction.Rollback();
            }
        }
Esempio n. 18
0
 /// <summary>
 /// REGISTRO DE TICKETS
 /// </summary>
 /// <param name="oBe"></param>
 public void SHPR_CREATE_TICKET(TicketEntity oBe)
 {
     try
     {
         oDb  = oDg.getDataBase();
         oCon = oDg.getConnection();
         if (oCon.State == ConnectionState.Closed)
         {
             oCon.Open();
         }
         using (var obts = oCon.BeginTransaction())
         {
             try
             {
                 using (var ocmd = oDb.GetStoredProcCommand("usp_InsertTicket",
                                                            oBe.TIC_PRI_Id,
                                                            oBe.TIC_PRO_Id,
                                                            1,
                                                            oBe.TIC_SER_Id,
                                                            oBe.TIC_EMP_Id,
                                                            oBe.TIC_USU_Id,
                                                            oBe.TIC_Descripcion,
                                                            1))
                 {
                     ocmd.CommandTimeout = 2000;
                     oDb.ExecuteNonQuery(ocmd, obts);
                     //oBe.NUM_TOKE = Convert.ToInt32(oDb.GetParameterValue(ocmd, "@P0005NUM_TOKE"));
                     obts.Commit();
                 }
             }
             catch (Exception ex)
             {
                 obts.Rollback();
                 throw new ArgumentException(ex.Message);
             }
         }
     }
     catch (Exception ex)
     {
         throw new ArgumentException(ex.Message);
     }
     finally
     {
         oCon.Close();
     }
 }
        /// <summary>
        /// Sends ticket card in SME team chat.
        /// </summary>
        /// <param name="turnContext">Context object containing information cached for a single turn of conversation with a user.</param>
        /// <param name="smeTeamCard">Card to be sent to SME team.</param>
        /// <param name="expertTeamId">Expert team's id.</param>
        /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
        /// <param name="ticket">Ticket that has to be updated with conversation info.</param>
        /// <returns>A task that represents the work queued to execute.</returns>
        private async Task SendTicketCardToSMETeamAsync(
            ITurnContext <IMessageActivity> turnContext,
            Attachment smeTeamCard,
            string expertTeamId,
            CancellationToken cancellationToken,
            TicketEntity ticket)
        {
            var resourceResponse = await this.notificationService.NotifyInTeamChatAsync(turnContext, smeTeamCard, expertTeamId, cancellationToken).ConfigureAwait(false);

            // If a ticket was created, update the ticket with the conversation info.
            if (ticket != null)
            {
                ticket.SmeCardActivityId       = resourceResponse.ActivityId;
                ticket.SmeThreadConversationId = resourceResponse.Id;
                await this.ticketsProvider.UpsertTicketAsync(ticket).ConfigureAwait(false);
            }
        }
        public HttpResponseMessage SHPR_TICKET_EDIT(TicketEntity oBe)
        {
            try
            {
                if (string.IsNullOrWhiteSpace((string)HttpContext.Current.Session["username"]))
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Acceso no autorizado."));
                }

                if (oBe.TIC_CodigoEstado != 2)
                {
                    if (oBe.TIC_SER_Id == 0)
                    {
                        throw new ArgumentException("Seleccione un servicio.");
                    }
                    if (oBe.TIC_PRO_Id == 0)
                    {
                        throw new ArgumentException("Seleccione un problema.");
                    }
                    if (oBe.TIC_PRI_Id == 0)
                    {
                        throw new ArgumentException("Seleccione una prioridad.");
                    }
                    if (string.IsNullOrEmpty(oBe.TIC_Descripcion))
                    {
                        throw new ArgumentException("Especifique una descripción.");
                    }

                    /*if (string.IsNullOrEmpty(oBe.TIC_USU_RESP_Description))
                     *  throw new ArgumentException("Especifique un responsable del ticket.");
                     */
                }

                var oBr = new TicketRule();

                /*oBe.COD_USUA_CREA = (string)HttpContext.Current.Session["username"];
                *  oBe.COD_USUA_MODI = (string)HttpContext.Current.Session["username"];*/
                oBr.SHPR_TICKET_EDIT(oBe);
                return(Request.CreateResponse(HttpStatusCode.OK, "Operación concretada con exito."));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Esempio n. 21
0
        /// <summary>
        /// method to convert the model to entity
        /// </summary>
        /// <param name="loginUserId">user who create this</param>
        /// <param name="ticketModel">model object</param>
        /// <returns></returns>
        private TicketEntity MapModelToEntity(int loginUserId, TicketModel ticketModel)
        {
            var ticket = new TicketEntity
            {
                ClientId             = ticketModel.ClientId,
                Title                = ticketModel.Title,
                Description          = ticketModel.Description,
                Complexity           = 1,
                Priority             = 1,
                Notes                = ticketModel.Notes,
                CreatedBy            = loginUserId,
                CreatedDate          = DateTime.Now,
                StatusId             = ticketModel.StatusId,
                AssignedTechnicianId = ticketModel.AssigedTechnicianId ?? loginUserId,
            };

            return(ticket);
        }
        public HttpResponseMessage P0005SHPR_ENTERPRISE_LIST(TicketEntity oBe)
        {
            try
            {
                if (string.IsNullOrWhiteSpace((string)HttpContext.Current.Session["username"]))
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Acceso no autorizado."));
                }

                var oBr   = new TicketRule();
                var oList = oBr.SHPR_ENTERPRISE_LIST(oBe);
                return(Request.CreateResponse(HttpStatusCode.OK, oList));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Esempio n. 23
0
        public int Insert(TicketEntity entity)
        {
            using var transaction = _context.Database.BeginTransaction();
            try
            {
                _context.Tickets.Add(entity);
                _context.SaveChanges();

                transaction.Commit();
                return(entity.TicketId);
            }
            catch (Exception e)
            {
                transaction.Rollback();

                return(-1);
            }
        }
Esempio n. 24
0
 public void SHPR_TICKET_EDIT(TicketEntity oBe)
 {
     try
     {
         oDb  = oDg.getDataBase();
         oCon = oDg.getConnection();
         if (oCon.State == ConnectionState.Closed)
         {
             oCon.Open();
         }
         using (var obts = oCon.BeginTransaction())
         {
             try
             {
                 using (var ocmd = oDb.GetStoredProcCommand("up_ActualizarTicket",
                                                            oBe.TIC_Id,
                                                            oBe.TIC_SER_Id,
                                                            oBe.TIC_PRO_Id,
                                                            oBe.TIC_PRI_Id,
                                                            oBe.TIC_USU_RESP_Id,
                                                            oBe.TIC_Descripcion,
                                                            oBe.TIC_CodigoEstado))
                 {
                     ocmd.CommandTimeout = 2000;
                     oDb.ExecuteNonQuery(ocmd, obts);
                     obts.Commit();
                 }
             }
             catch (Exception ex)
             {
                 obts.Rollback();
                 throw new ArgumentException(ex.Message);
             }
         }
     }
     catch (Exception ex)
     {
         throw new ArgumentException(ex.Message);
     }
     finally
     {
         oCon.Close();
     }
 }
Esempio n. 25
0
 /// <summary>
 /// Gets the ticket status for the user notifications.
 /// </summary>
 /// <param name="ticket">The current ticket information.</param>
 /// <returns>A status string.</returns>
 public static string GetUserTicketDisplayStatus(TicketEntity ticket)
 {
     if (ticket?.Status == (int)TicketState.UnAssigned)
     {
         return(Strings.UnassignedUserNotificationStatus);
     }
     else if (ticket?.Status == (int)TicketState.Assigned)
     {
         return(Strings.AssignedUserNotificationStatus);
     }
     else if (ticket?.Status == (int)TicketState.Pending)
     {
         return(Strings.PendingUserNotificationStatus);
     }
     else
     {
         return(Strings.ClosedUserNotificationStatus);
     }
 }
Esempio n. 26
0
 /// <summary>
 /// Gets the current status of the ticket to display in the SME team.
 /// </summary>
 /// <param name="ticket">The current ticket information.</param>
 /// <param name="payload">Payload from the response card.</param>
 /// <returns>A status string.</returns>
 public static string GetTicketDisplayStatusForSme(TicketEntity ticket, UpdateTicketResponsePayload payload)
 {
     if (ticket?.Status == (int)TicketState.Answered && payload == null)
     {
         return(string.Format(CultureInfo.InvariantCulture, Strings.SMETicketAnsweredStatus, ticket?.AssignedToName));
     }
     else if (ticket?.Status == (int)TicketState.UnAnswered)
     {
         return(Strings.SMETicketUnansweredStatus);
     }
     else if (payload.Action == UpdateTicketResponsePayload.UpdateResponseAction)
     {
         return(string.Format(CultureInfo.InvariantCulture, Strings.SMETicketAnsweredAndUpdatedStatus, ticket?.AssignedToName));
     }
     else
     {
         return(string.Format(CultureInfo.InvariantCulture, Strings.SMETicketAnsweredStatus, ticket?.AssignedToName));
     }
 }
Esempio n. 27
0
        public static bool CreateTicketBL(TicketEntity newTicket)
        {
            bool userAdded = false;

            try
            {
                TicketsDAL ticketDAL = new TicketsDAL();
                userAdded = ticketDAL.CreateTicketDAL(newTicket);
            }
            catch (MovieExceptions)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(userAdded);
        }
Esempio n. 28
0
        // MP-846 Admin database cleanup and code cleanup.-CLIENT
        internal int UpdateTicketFileForClients(TicketEntity obj)
        {
            int result = 0;

            try
            {
                StoredProcedureEntity sproc = new StoredProcedureEntity();
                sproc.StoredProcedureName = "capp.UpdateTicketFile";
                sproc.StoredProceduresParameter.Add(GetParam("@Id", obj.Id.ToString(), SQLServerDatatype.IntDataType));
                sproc.StoredProceduresParameter.Add(GetParam("@Files", (obj.Files != null) ? obj.Files.ToString().Trim() : "", SQLServerDatatype.VarcharDataType));
                result = Convert.ToInt32(sql.ExecuteScalar(CommandType.StoredProcedure, sproc));
            }
            catch (Exception)
            {
                throw;
            }

            return(result);
        }
Esempio n. 29
0
 /// <summary>
 /// Gets the current status of the ticket to display in the SME team.
 /// </summary>
 /// <param name="ticket">The current ticket information.</param>
 /// <returns>A status string.</returns>
 public static string GetTicketDisplayStatusForSme(TicketEntity ticket)
 {
     if (ticket?.Status == (int)TicketState.UnAssigned)
     {
         return(Strings.SMETicketUnassignedStatus);
     }
     else if (ticket?.Status == (int)TicketState.Assigned)
     {
         return(string.Format(CultureInfo.InvariantCulture, Strings.SMETicketAssignedStatus, ticket?.AssignedToName));
     }
     else if (ticket?.Status == (int)TicketState.Pending)
     {
         return(string.Format(CultureInfo.InvariantCulture, Strings.SMETicketPendingStatus, ticket?.AssignedToName));
     }
     else
     {
         return(Strings.SMETicketResolvedStatus);
     }
 }
Esempio n. 30
0
        public ActionResult InserirTicket(TicketEntity entity)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    new TicketBusiness().Salvar(entity, this.UsuarioId);
                    return(RedirectToAction("EditarTicket", new { @id = entity.TicketId }));
                }
                catch (TicketException ex)
                {
                    ModelState.AddModelError("ex", ex.Message);
                }
            }
            TicketModel model = new TicketModel();

            model.TicketEntity = entity;
            return(View("PrincipalTicket", model));
        }