示例#1
0
        public void MakeTicket()
        {
            TicketProcess ticketProcess = new TicketProcess();

            int count = ticketProcess.GetTickets().Count;

            Ticket ticket = new Ticket();

            ticket.SenderName = "Sender";
            ticket.SenderAddress = "*****@*****.**";
            ticket.Subject = "Subject";
            ticket.Body = "Body";
            ticket.Source = new Source()
            {
                Provider = "System.Data.SqlClient",
                Value = "select top 1000 userName as name, userEmail as address from Member where userEmail like '*****@*****.**'",
                ConnectionString = "Data Source=tiger02;Initial Catalog=ALToolsMember;Integrated Security=False;User Id=svcinfra;Password=dkdlvhsy10;MultipleActiveResultSets=True"
            };

            string fileName = string.Empty;

            ticketProcess.SaveTicket(ticket);

            Assert.IsTrue(Directory.GetFiles(PathInfo.Ticket).Length == ++count);

            ticketProcess = new TicketProcess();

            Assert.IsTrue(ticketProcess.GetTickets().Count > 0);
        }
示例#2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Ticket ticket = new Ticket();

            ticket.SenderName = txtSenderName.Text.Trim();
            ticket.SenderAddress = txtSenderAddress.Text.Trim();

            if (rdoRecipeints.SelectedIndex >= 0)
            {
                ticket.Source = sourceList[rdoRecipeints.SelectedValue];
            }
            else
            {
                List<string> recipients = new List<string>();
                foreach (string r in txtRecipientAddress.Text.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    recipients.Add(r.Trim());
                }

                ticket.Source = new Source
                {
                    Provider = "System.String[]",
                    Value = string.Join(";", recipients),
                    ConnectionString = "NODATA"
                };
            }

            ticket.Subject = txtSubject.Text.Trim();
            ticket.Body = txtHtml.Text;

            TicketProcess ticketProcess = new TicketProcess();

            ticketProcess.SaveTicket(ticket); // TODO: check result is success?

            try
            {
                history.SetHistory(ticket);
                history.ClearHistory(100);
            }
            catch { }

            Response.Redirect("~/Logs.aspx", false);
        }
示例#3
0
        public bool RemoveTicket(Ticket ticket)
        {
            lock (lockObj)
            {
                try
                {
                    File.Move(
                        System.IO.Path.Combine(PathInfo.Ticket, ticket.FileName),
                        System.IO.Path.Combine(PathInfo.Trash, ticket.FileName)
                        );
                    return true;
                }
                catch (Exception e)
                {
                    LogProcess.Error(e);
                }

                return false;
            }
        }
示例#4
0
        public Ticket GetHistoryToTicket(int id)
        {
            Ticket ticket = null;

            DataTable dt = GetDatabase().GetDataTable(
                "select Id, SenderName, SenderAddress, Subject, Body, Timestamp from History where Id = " + id.ToString()
                );

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    ticket = new Ticket();
                    ticket.SenderAddress = HttpContext.Current.Server.HtmlDecode(dr["SenderAddress"].ToString());
                    ticket.SenderName = HttpContext.Current.Server.HtmlDecode(dr["SenderName"].ToString());
                    ticket.Subject = HttpContext.Current.Server.HtmlDecode(dr["Subject"].ToString());
                    ticket.Body = HttpContext.Current.Server.HtmlDecode(dr["Body"].ToString());

                    break;
                }
            }

            return ticket;
        }
示例#5
0
        public Ticket SaveTicket(Ticket ticket)
        {
            lock (lockObj)
            {
                ticket.FileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + Guid.NewGuid().ToString("N").Substring(0, 16) + ".ticket";

                try
                {
                    using (FileStream stream = new FileStream(System.IO.Path.Combine(PathInfo.Ticket, ticket.FileName), FileMode.CreateNew))
                    {
                        DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Ticket));

                        ticket.Source = ticket.Source.EncryptedSource;
                        serializer.WriteObject(stream, ticket);
                    }

                    return ticket;
                }
                catch (Exception e)
                {
                    LogProcess.Error(e);

                    return null;
                }
            }
        }
示例#6
0
        public bool SetHistory(Ticket ticket)
        {
            Dictionary<string, string> data = new Dictionary<string, string>();
            data.Add("SenderName", HttpContext.Current.Server.HtmlEncode(ticket.SenderName));
            data.Add("SenderAddress", HttpContext.Current.Server.HtmlEncode(ticket.SenderAddress));
            data.Add("Subject", HttpContext.Current.Server.HtmlEncode(ticket.Subject));
            data.Add("Body", HttpContext.Current.Server.HtmlEncode(ticket.Body));
            data.Add("Timestamp", DateTime.Now.Ticks.ToString());

            return GetDatabase().Insert("History", data);
        }