예제 #1
0
파일: Program.cs 프로젝트: dmdaher/Trak
        //PARSE THE STRING
        //LOOK FOR KEYWORDS LIKE Milestone, Estimated Start Time, Resources,
        //get the value after keyword and put that in variable to add to SP list
        public void parseEmail(Program prog, ExchangeService service)
        {
            //Program prog = new Program();
            string       aLine          = null;
            StringReader strReader      = new StringReader(this.getMBody());
            int          actualCount    = 0;
            int          milestoneCount = 0;

            Console.WriteLine("the private variable is: " + this.mProjectTitle);
            aLine = strReader.ReadLine();
            while (aLine != null)
            {
                //aLine.ToLower();
                //aLine = aLine.Replace(" ", String.Empty);

                aLine.Trim();
                if (aLine != null && aLine != "")
                {
                    //aParagraph = aParagraph + aLine + " ";
                    //Console.WriteLine("the line is: " + aLine);
                    string parsedValue = valueParser(aLine);
                    parsedValue = parsedValue.Trim();
                    if (aLine.Contains("Milestone"))
                    {
                        this.mCurrMilestone = new Milestone(0, "", "");
                        //setting milestone converts the string milestone to a milestone number
                        prog.setMMilestoneNum(parsedValue);
                        int pos = Convert.ToInt32(parsedValue);
                        this.mCurrMilestone.setNumber(pos);
                        Console.WriteLine("milestone is SET! " + prog.getMMilestoneNum(pos));
                        milestoneCount++;
                        //mMilestoneCurrentNum = pos;
                    }
                    //gets milestone command
                    //if command is remove, sets comment to ""
                    else if (aLine.Contains("Command"))
                    {
                        prog.setMMilestoneCommand(parsedValue);
                        this.mCurrMilestone.setCommand(parsedValue);
                        if (parsedValue == "Remove")
                        {
                            prog.setMMilestoneComment("");
                            this.mCurrMilestone.setComment("");
                            this.setMilestone();
                        }
                        Console.WriteLine("milestoneCommand is READY! " + prog.getMMilestoneCommand(mMilestoneCurrentNum));
                    }
                    //gets milestone comment and adds it to correlated position with command and num
                    //if there is no comment like when a remove command is given, comment is set to "" in command if statement
                    else if (aLine.Contains("Comment"))
                    {
                        prog.setMMilestoneComment(parsedValue);
                        Console.WriteLine("milestone is PERFECT! " + prog.getMMilestoneComment(mMilestoneCurrentNum));
                        this.mCurrMilestone.setComment(parsedValue);
                        this.setMilestone();
                    }
                    //calls helper function to retrieve estimated date and times
                    else if (aLine.Contains("Estimated"))
                    {
                        helperEstimatedParser(aLine, prog);
                    }
                    //gets actual date and time
                    else if (actualCount == 0)
                    {
                        helperActualParser(prog);
                        actualCount++;
                    }
                    //gets milestone comment
                    else if (aLine.Contains("Resources"))
                    {
                        prog.setMResources(parsedValue);
                        Console.WriteLine("Found the resources needed to be... " + prog.getMResources());
                    }
                    else if (aLine.Contains("Time Spent"))
                    {
                        prog.setMTimeSpent(parsedValue);
                        Console.WriteLine("Found the time spent as...  " + prog.getMTimeSpent());
                    }
                    else if (aLine.Contains("Current Status"))
                    {
                        prog.setMCurrentStatus(parsedValue);
                        Console.WriteLine("Found the current status as...  " + prog.getMCurrentStatus());
                    }
                    else if (aLine.Contains("Status Reason"))
                    {
                        prog.setMStatusReason(parsedValue);
                        Console.WriteLine("Found the status reason as...  " + prog.getMStatusReason());
                    }
                }
                aLine = strReader.ReadLine();
            }
            Sharepoint sp = new Sharepoint(prog);

            try
            {
                bool        isNewList  = false;
                EmailErrors emailError = sp.getMEmailErrors();
                isNewList = sp.TryGetList(prog.getMProjectTitle());
                sp.addAllData(prog.getMProjectTitle());
                //Dictionary<int, Milestone> newMilestoneObjMap = new Dictionary<int, Milestone>();
                this.setMilestoneObjMap(new Dictionary <int, Milestone>());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }