コード例 #1
0
        public IEnumerable <Deca_RT_Ticket> Get(string username, string password, string fromDate, string toDay)
        {
            var data = new List <Deca_RT_Ticket>();

            if (username == "ocmcustomer" && password == "005ab6f1f7db9df17bb643bf335f30bf67f83379")
            {
                data = Deca_RT_Ticket.GetAllDeca_RT_Tickets_ViewAll_Dynamic_API(fromDate, toDay);
            }
            return(data);
        }
コード例 #2
0
        public Deca_RT_Ticket Get(string username, string password, string id)
        {
            var data = new Deca_RT_Ticket();

            if (username == "ocmcustomer" && password == "005ab6f1f7db9df17bb643bf335f30bf67f83379")
            {
                data = Deca_RT_Ticket.GetDeca_RT_Ticket(id);
            }
            return(data);
        }
コード例 #3
0
        public void CronEmail()
        {
            using (var dbConn = Helpers.OrmliteConnection.openConn())
            {
                //get list email seen
                var seenUids = dbConn.GetFirstColumn <string>("SELECT Uid FROM Deca_Email_SeenUids");
                //new list email
                var data = new List <Email>();

                Pop3Client pop3Client = new Pop3Client();
                pop3Client.Connect("pop.gmail.com", 995, true);
                pop3Client.Authenticate("*****@*****.**", "umycvtjuhcndujnh", AuthenticationMethod.UsernameAndPassword);
                //seenUUIDs
                //get list uuid
                List <string> uids = pop3Client.GetMessageUids();

                // All the new messages not seen by the POP3 client
                for (int i = 0; i < uids.Count; i++)
                {
                    string currentUidOnServer = uids[i];
                    if (!seenUids.Contains(currentUidOnServer))
                    {
                        // We have not seen this message before.
                        // Download it and add this new uid to seen uids

                        // the uids list is in messageNumber order - meaning that the first
                        // uid in the list has messageNumber of 1, and the second has
                        // messageNumber 2. Therefore we can fetch the message using
                        // i + 1 since messageNumber should be in range [1, messageCount]
                        Message unseenMessage = pop3Client.GetMessage(i + 1);

                        Email email = new Email()
                        {
                            MessageNumber = i,
                            Subject       = unseenMessage.Headers.Subject,
                            DateSent      = unseenMessage.Headers.DateSent,
                            From          = string.Format("<a href = 'mailto:{1}'>{0}</a>", unseenMessage.Headers.From.DisplayName, unseenMessage.Headers.From.Address),
                        };
                        MessagePart body = unseenMessage.FindFirstHtmlVersion();
                        body = unseenMessage.FindFirstPlainTextVersion();
                        if (body != null)
                        {
                            email.Body = body.GetBodyAsText();
                        }
                        List <MessagePart> attachments = unseenMessage.FindAllAttachments();

                        email.Attachments = attachments;

                        data.Add(email);

                        // Add the uid to the seen uids, as it has now been seen
                        //seenUids.Add(currentUidOnServer);
                        dbConn.Insert(new Deca_Email_SeenUids {
                            Uid = uids[i], CreatedAt = DateTime.Now
                        });
                    }

                    //insert ticket
                }
                var checktype = Deca_RT_Type.GetDeca_RT_Type("TIC0004");
                foreach (var item in data)
                {
                    var w = new Deca_RT_Ticket();
                    w.Status         = "New";
                    w.TypeID         = checktype.TypeID;
                    w.Title          = item.Subject;
                    w.Detail         = item.Body;
                    w.Requestor      = "cronSystemFromEmail";
                    w.Assignee       = "";
                    w.preAssignee    = "";
                    w.Owner          = checktype.Owner;
                    w.OrganizationID = "";
                    w.CustomerID     = item.From;
                    w.Priority       = "TPRI002";
                    w.Impact         = "TIMP002";
                    w.RowCreatedUser = "******";
                    w.RowCreatedTime = DateTime.Now;
                    var id = w.Save();
                    if (id != "")
                    {
                        //save logs

                        Deca_RT_Log savelog = new Deca_RT_Log();
                        savelog.TicketID       = id;
                        savelog.Activites      = "Add New Ticket";
                        savelog.RowCreatedTime = DateTime.Now;
                        savelog.RowCreatedUser = "******";
                        savelog.Save();
                    }

                    foreach (var attachment in item.Attachments)
                    {
                        string pathForSaving = Server.MapPath("~/UploadFileTicket/" + id);
                        if (this.CreateFolderIfNeeded(pathForSaving))
                        {
                            var          filePath     = Path.Combine(pathForSaving, attachment.FileName);
                            FileStream   Stream       = new FileStream(filePath, FileMode.Create);
                            BinaryWriter BinaryStream = new BinaryWriter(Stream);
                            BinaryStream.Write(attachment.Body);
                            BinaryStream.Close();
                        }
                    }
                }
            }
        }
コード例 #4
0
 public IHttpActionResult Post([FromBody] Ticket_Request_API data)
 {
     if (String.IsNullOrEmpty(data.ticket.ticketType) || String.IsNullOrEmpty(data.ticket.title) || String.IsNullOrEmpty(data.ticket.detail) ||
         String.IsNullOrEmpty(data.ticket.priority) || String.IsNullOrEmpty(data.ticket.impact) || //|| String.IsNullOrEmpty(data.ticket.status)
         String.IsNullOrEmpty(data.ticket.customerId) || String.IsNullOrEmpty(data.ticket.customerName) || String.IsNullOrEmpty(data.ticket.customerSource) ||
         String.IsNullOrEmpty(data.ticket.requestFrom))
     {
         return(BadRequest("missing required params"));
     }
     else if (!"TPRI001,TPRI002,TPRI003".Split(',').Contains(data.ticket.priority))
     {
         return(BadRequest("priority is not valid"));
     }
     else if (!"TIMP001,TIMP002,TIMP003".Split(',').Contains(data.ticket.impact))
     {
         return(BadRequest("impact is not valid"));
     }
     //sha-1 ocmcustomer2015
     if (data.username == "ocmcustomer" && data.password == "005ab6f1f7db9df17bb643bf335f30bf67f83379")
     {
         var checktype = Deca_RT_Type.GetDeca_RT_Type(data.ticket.ticketType);
         if (checktype == null)
         {
             return(BadRequest("ticketType is not valid"));
         }
         var w = new Deca_RT_Ticket();
         w.Status         = "New";
         w.TypeID         = checktype.TypeID;
         w.Title          = data.ticket.title;
         w.Detail         = data.ticket.detail;
         w.Requestor      = data.ticket.customerSource;
         w.Assignee       = "";
         w.preAssignee    = "";
         w.Owner          = checktype.Owner;
         w.OrganizationID = "";
         w.CustomerID     = data.ticket.customerId;
         w.CustomerName   = data.ticket.customerName;
         w.Priority       = data.ticket.priority;
         w.Impact         = data.ticket.impact;
         w.CustomerSource = data.ticket.customerSource;
         w.RequestFrom    = data.ticket.requestFrom;
         w.RowCreatedUser = data.ticket.customerSource;
         w.RowCreatedTime = DateTime.Now;
         var id = w.Save();
         if (id != "")
         {
             //save logs
             Deca_RT_Log savelog = new Deca_RT_Log();
             savelog.TicketID       = id;
             savelog.Activites      = "Add New Ticket";
             savelog.RowCreatedTime = DateTime.Now;
             savelog.RowCreatedUser = data.ticket.customerSource;
             savelog.Save();
         }
         return(Ok(id));
     }
     else
     {
         return(BadRequest("username & password is not valid"));
     }
 }