Beispiel #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);
        }
Beispiel #2
0
        public void BuildQueue()
        {
            TicketTest ticketTest = new TicketTest();
            ticketTest.MakeTicket();

            //TicketInfo.GetTickets();
            TicketProcess ticketProcess = new TicketProcess();

            QueueProcess queueProcess = new QueueProcess();
            queueProcess.BuildQueueFromTicket(ticketProcess, 100);
        }
Beispiel #3
0
        public void GetTickets()
        {
            TicketProcess ticketProcess = new TicketProcess();
            List<Ticket> tickets = ticketProcess.GetTickets();

            Source source = tickets[0].DecryptedSource;

            Assert.IsTrue(!string.IsNullOrEmpty(source.Provider));
            Assert.IsTrue(!string.IsNullOrEmpty(source.Value));
            Assert.IsTrue(!string.IsNullOrEmpty(source.ConnectionString));
        }
Beispiel #4
0
        public void Process()
        {
            if (processing) { return; }
            lock (lockObj)
            {
                processing = true;
            }

            TicketProcess ticketProcess = new TicketProcess();
            QueueProcess queueProcess = new QueueProcess();

            queueProcess.BuildQueueFromTicket(
                ticketProcess,
                Convert.ToInt32(ConfigurationManager.AppSettings["BlockCount"])
                );

            processing = false;
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public void GetSourceFromTicket()
        {
            MakeTicket();

            TicketProcess ticketProcess = new TicketProcess();
            List<Ticket> tickets = ticketProcess.GetTickets();

            Source source = tickets[0].DecryptedSource;

            string value = source.Value;
            string connectionString = source.ConnectionString;

            if (source.Provider == "System.Data.SqlClient")
            {
                Database db = new SqlDatabase(source.ConnectionString);
                DataSet ds = db.ExecuteDataSet(CommandType.Text, source.Value);

                Assert.IsTrue(ds.Tables.Count > 0 && ds.Tables[0].Rows.Count >= 0);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
        public void BuildQueueFromTicket(TicketProcess ticketProcess, int blobkCount)
        {
            if (blobkCount <= 0)
            {
                blobkCount = BLOCKCOUNT;
            }
            List <Ticket> tickets = ticketProcess.GetTickets();

            if (tickets.Count() == 0)
            {
                return;
            }


            Ticket ticket = tickets[0];
            Source source = ticket.Source;

            try
            {
                source = source.DecryptedSource;
                string value            = source.Value;
                string connectionString = source.ConnectionString;

                if (source.Provider == "System.Data.SqlClient")
                {
                    Database db = new SqlDatabase(source.ConnectionString);
                    DataSet  ds = db.ExecuteDataSet(CommandType.Text, source.Value);
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        QueueProcess     queueProcess = new QueueProcess();
                        List <Recipient> recipients   = new List <Recipient>();

                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            string address = dr["address"].ToString();
                            string name    = dr["name"].ToString();

                            try
                            {
                                recipients.Add(new Recipient(name, address));
                            }
                            catch (Exception e)
                            {
                                LogProcess.Error(e, address + ", " + name);
                                continue;
                            }

                            if (recipients.Count >= blobkCount)
                            {
                                queueProcess.SaveQueue(new Queue()
                                {
                                    RecipientData = recipients.ToArray(),
                                    TicketData    = ticket
                                });
                                recipients = new List <Recipient>();
                            }
                        }


                        if (recipients.Count() > 0)
                        {
                            queueProcess.SaveQueue(new Queue()
                            {
                                RecipientData = recipients.ToArray(),
                                TicketData    = ticket
                            });

                            recipients = new List <Recipient>();
                        }
                    }
                }
                else if (source.Provider == "System.String[]")
                {
                    QueueProcess     queueProcess = new QueueProcess();
                    List <Recipient> recipients   = new List <Recipient>();

                    foreach (string recipient in source.Value.Trim().Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        string address = recipient.Trim();
                        recipients.Add(new Recipient(address, address));

                        if (recipients.Count >= blobkCount)
                        {
                            queueProcess.SaveQueue(new Queue()
                            {
                                RecipientData = recipients.ToArray(),
                                TicketData    = ticket
                            });
                            recipients = new List <Recipient>();
                        }
                    }

                    queueProcess.SaveQueue(new Queue()
                    {
                        RecipientData = recipients.ToArray(),
                        TicketData    = ticket
                    });
                    recipients = new List <Recipient>();
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
            catch (Exception e)
            {
                LogProcess.Error(e);
            }

            ticketProcess.RemoveTicket(ticket);
        }
Beispiel #8
0
        private void EmptyTicket()
        {
            TicketProcess ticketProcess = new TicketProcess();
            ticketProcess.EmptyTicket();

            Assert.IsTrue(ticketProcess.GetTickets().Count == 0);
        }
Beispiel #9
0
        public void RemoveTicket()
        {
            EmptyTicket();

            MakeTicket();

            TicketProcess ticketProcess = new TicketProcess();
            List<Ticket> tickets = ticketProcess.GetTickets();

            ticketProcess.RemoveTicket(tickets[0]);

            Assert.IsTrue(tickets.Count == (ticketProcess.GetTickets().Count + 1));
        }
Beispiel #10
0
        public void BuildQueueFromTicket(TicketProcess ticketProcess, int blobkCount)
        {
            if (blobkCount <= 0)
            {
                blobkCount = BLOCKCOUNT;
            }
            List<Ticket> tickets = ticketProcess.GetTickets();

            if (tickets.Count() == 0)
            {
                return;
            }

            Ticket ticket = tickets[0];
            Source source = ticket.Source;

            try
            {
                source = source.DecryptedSource;
                string value = source.Value;
                string connectionString = source.ConnectionString;

                if (source.Provider == "System.Data.SqlClient")
                {
                    Database db = new SqlDatabase(source.ConnectionString);
                    DataSet ds = db.ExecuteDataSet(CommandType.Text, source.Value);
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        QueueProcess queueProcess = new QueueProcess();
                        List<Recipient> recipients = new List<Recipient>();

                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            string address = dr["address"].ToString();
                            string name = dr["name"].ToString();

                            try
                            {
                                recipients.Add(new Recipient(name, address));
                            }
                            catch (Exception e)
                            {
                                LogProcess.Error(e, address + ", " + name);
                                continue;
                            }

                            if (recipients.Count >= blobkCount)
                            {
                                queueProcess.SaveQueue(new Queue()
                                {
                                    RecipientData = recipients.ToArray(),
                                    TicketData = ticket
                                });
                                recipients = new List<Recipient>();
                            }
                        }

                        if (recipients.Count() > 0)
                        {
                            queueProcess.SaveQueue(new Queue()
                            {
                                RecipientData = recipients.ToArray(),
                                TicketData = ticket
                            });

                            recipients = new List<Recipient>();
                        }
                    }
                }
                else if (source.Provider == "System.String[]")
                {
                    QueueProcess queueProcess = new QueueProcess();
                    List<Recipient> recipients = new List<Recipient>();

                    foreach (string recipient in source.Value.Trim().Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        string address = recipient.Trim();
                        recipients.Add(new Recipient(address, address));

                        if (recipients.Count >= blobkCount)
                        {
                            queueProcess.SaveQueue(new Queue()
                            {
                                RecipientData = recipients.ToArray(),
                                TicketData = ticket
                            });
                            recipients = new List<Recipient>();
                        }
                    }

                    queueProcess.SaveQueue(new Queue()
                    {
                        RecipientData = recipients.ToArray(),
                        TicketData = ticket
                    });
                    recipients = new List<Recipient>();
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
            catch (Exception e)
            {
                LogProcess.Error(e);
            }

            ticketProcess.RemoveTicket(ticket);
        }