Пример #1
0
        public bool V1TestConnection(V1Connector CurrentV1Connection)
        {
            V1Logging Logs       = new V1Logging();
            bool      TestResult = false;
            IServices services   = new Services(CurrentV1Connection);

            try
            {
                Logs.LogEvent("Operation - Attempting Test Connection to VersionOne");

                Logs.LogEvent("Test - Testing URI - Pulling Meta");
                IAssetType defectType = services.Meta.GetAssetType("Scope");
                Logs.LogEvent("Test - Testing URI - SUCCESS");


                Logs.LogEvent("Test - Testing Token - Pulling Data");
                Oid        projectId = services.GetOid("Scope:0");
                IAssetType ScopeType = services.Meta.GetAssetType("Scope");
                Asset      NewScope  = services.New(defectType, projectId);

                Logs.LogEvent("Test - Testing Token - SUCCESS");

                TestResult = true;

                Logs.LogEvent("Operation - VersionOne Connection Test Complete - " + TestResult.ToString());
            }
            catch (Exception ex)
            {
                Logs.LogEvent("ERROR - Test Failure - " + ex.ToString());
                Logs.LogEvent("Operation - VersionOne Connection Test Complete - " + TestResult.ToString());
            }

            return(TestResult);
        }
Пример #2
0
        private static void CheckMail(Object source, ElapsedEventArgs e)
        {
            List <Message> Messages     = new List <Message>();
            V1Logging      Logs         = new V1Logging();
            bool           V1TestResult = false;
            V1_Connector   V1Connection = new V1_Connector();
            V1Connector    V1Instance   = V1Connection.ConnectToV1();
            MailChecker    GetMail      = new MailChecker();

            //System.IO.File.Create(AppDomain.CurrentDomain.BaseDirectory + "MailChecker.txt");

            //Messages = GetMail.FetchAllMessages("pop.mail.yahoo.com", 995, true, "*****@*****.**", "altec123");
            Messages = GetMail.FetchAllMessagesWithMultipleAccounts();
            Console.Write(Messages.ToString());

            // write an entry to the log
            eventLog1.WriteEntry("Operation - Email Checked, " + Messages.Count.ToString() + " Found");

            if (Messages.Count != 0)
            {
                V1TestResult = V1Connection.V1TestConnection(V1Instance);
            }

            if (Messages.Count != 0 && V1TestResult == true)
            {
                //NewConnection = V1Connection.ConnectToV1();
                V1Connection.CreateRequest(V1Instance, Messages);
            }

            Logs.LogEvent("Operation - V1 Request Asset Creator Check Complete.");
        }
Пример #3
0
        public void CreateDefect(V1Connector CurrentV1Connection, List <Message> CurrentEmails)
        {
            V1XMLHelper  V1XML        = new V1XMLHelper();
            V1Logging    Logs         = new V1Logging();
            string       ProjectScope = "Something for Testing";
            string       EmailBody;
            MessagePart  MessageParts;
            SMTPResponse V1Response = new SMTPResponse();
            MailChecker  MailCheck  = new MailChecker();

            IServices services = new Services(CurrentV1Connection);


            try
            {
                foreach (Message MailItem in CurrentEmails)
                {
                    for (int ToCtr = 0; ToCtr < MailItem.Headers.To.Count; ToCtr++)
                    {
                        ProjectScope = V1XML.GetProjectScope(MailItem.Headers.To[ToCtr].Address);
                        if (ProjectScope != null)
                        {
                            Oid                  projectId     = services.GetOid(ProjectScope);
                            IAssetType           defectType    = services.Meta.GetAssetType("Defect");
                            Asset                NewDefect     = services.New(defectType, projectId);
                            IAttributeDefinition nameAttribute = defectType.GetAttributeDefinition("Name");
                            NewDefect.SetAttributeValue(nameAttribute, MailItem.Headers.Subject.ToString());

                            MessageParts = MailItem.FindFirstHtmlVersion();
                            if (MessageParts == null)
                            {
                                MessageParts = MailItem.FindFirstPlainTextVersion();
                            }
                            EmailBody = MessageParts.GetBodyAsText();

                            Logs.LogEvent("Operation - Creating Defect for " + MailItem.Headers.To[ToCtr].Address);

                            IAttributeDefinition descriptionAttribute = defectType.GetAttributeDefinition("Description");
                            NewDefect.SetAttributeValue(descriptionAttribute, EmailBody);
                            IAttributeDefinition FoundByAttribute = defectType.GetAttributeDefinition("FoundBy");
                            NewDefect.SetAttributeValue(FoundByAttribute, MailItem.Headers.From.ToString());
                            services.Save(NewDefect);

                            IAttributeDefinition DefectIDAttribute = defectType.GetAttributeDefinition("Number");
                            Query IDQuery = new Query(NewDefect.Oid);
                            IDQuery.Selection.Add(DefectIDAttribute);
                            QueryResult ResultID = services.Retrieve(IDQuery);
                            Asset       defect   = ResultID.Assets[0];

                            //NewDefect.GetAttribute(DefectIDAttribute).Value
                            Logs.LogEvent("Operation - Sending Response to Defect Sender.");
                            //Commented out the Response back to the Sender per John Waedekin
                            //V1Response.SendResponse(MailItem, defect.GetAttribute(DefectIDAttribute).Value + " " + NewDefect.GetAttribute(nameAttribute).Value, ProjectScope);
                            MailCheck.DeleteMessagesOnServer(MailItem, ProjectScope);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logs.LogEvent("ERROR - Creating Defect - " + ex.InnerException.Message);
            }
        }