コード例 #1
0
        public void thread2()
        {
            int arraycount = 0;
            string temp = null;
            string tempf = null;
            int start = pcount  / 8+1;
            int end = pcount * 2 / 8;
            /*for (int i = start; i <= end; i++)
            {
                temp = this.doc1.Paragraphs[i].Range.Text.Trim();//变量i为第i段
                MatchCollection matches = Regex.Matches(temp, pattern1);
                if (matches.Count > 0)
                {
                    arraycount++;
                    //Console.WriteLine(arraycount);
                }
            }

            hahabaseobject[] myarray = new hahabaseobject[arraycount + 1];
            int arraycount1 = arraycount;*/
            arraycount = 0;
            for (int i = start; i <= end; i += 1)
            {
                //textBox1.Text = i.ToString();
                //Console.WriteLine(i);
                temp = doc1.Paragraphs[i].Range.Text.Trim();//变量i为第i段

                MatchCollection matches = Regex.Matches(temp, pattern1);

                if (matches.Count > 0)
                {
                    hahabaseobject newobject = new hahabaseobject();
                    newobject.Allocation="";
                    newobject.Category="";
                    newobject.Contribution="";
                    newobject.description="";
                    newobject.Implement="";
                    newobject.Priority="";
                    newobject.othercontext="";
                    newobject.title = temp;//还没转换好
                    int endj = 0;
                    for (int j = i + 1; j <= end; j++)
                    {
                        temp = doc1.Paragraphs[j].Range.Text.Trim();//变量i为第i段
                        MatchCollection matchesj = Regex.Matches(temp, pattern3);
                        if (matchesj.Count > 0)//写到段落存储,回去再写
                        {
                            endj = j;
                            break;
                        }
                    }
                    //textBox1.Text = i.ToString();
                    newobject.description = doc1.Paragraphs[i + 1].Range.Text;
                    int arraycontentcount = 1;
                    for (int k = i + 1; k <= pcount; k++)
                    {
                        temp = doc1.Paragraphs[k].Range.Text;

                        int startflag = 0;
                        MatchCollection matchesjinghao = Regex.Matches(temp, pattern4);
                        //textBox1.Text = matchesjinghao.Count.ToString();
                        if (matchesjinghao.Count < 1 && startflag < 1)
                        {
                            newobject.description = newobject.description + "\n" + temp;
                        }
                        else
                        {
                            startflag = 1;
                            int poseuql = temp.IndexOf('=');
                            tempf = temp.Substring(1, poseuql - 2);
                            temp = temp.Substring(poseuql + 1, temp.Length - poseuql - 1);

                            if (matchesjinghao.Count >= 1)
                            {
                                if (tempf == "Implement")
                                {
                                    newobject.Implement = temp;

                                }
                                if (tempf == "Priority")
                                {
                                    newobject.Priority = temp;
                                }
                                if (tempf == "Contribution")
                                {
                                    newobject.Contribution = temp;
                                }
                                if (tempf == "Category")
                                {
                                    newobject.Category = temp;
                                }
                                if (tempf == "Allocation")
                                {
                                    newobject.Allocation = temp;
                                }
                                if (tempf == "Source")
                                {
                                    newobject.sources = temp;
                                }

                                arraycontentcount++;

                            }

                        }
                        //newobject.arraycontent[6] = doc.Paragraphs[endj].Range.Text;//将end赋值给newobject
                        if (newobject.sources != null)
                        {
                            break;
                        }

                    }
                    if (newobject.sources != null)
                    {
                        MatchCollection matchessourse = Regex.Matches(newobject.sources, pattern2);
                        newobject.othercontext = matchessourse.Count.ToString();

                        for (int ksourse = 0; ksourse < matchessourse.Count; ksourse++)
                        {
                            //newobject.source[ksourse] =matchessourse[ksourse].Value;
                            newobject.Source.Add(matchessourse[ksourse].Value);
                        }//将sourse转化成数组格式
                        /*myarray[arraycount] = newobject;
                        arraycount++;*/
                        aaa.finalstrings.Add(newobject);
                    }
                }
            }
            /*int trueaccount = 0;
            for (int k = 0; k < arraycount1; k++)
            {
                if (myarray[k] != null)
                {
                    trueaccount++;
                }
            }
            hahabaseobject[] mytruearray = new hahabaseobject[trueaccount];
            //trueaccount = 0;
            for (int k = 0; k <= trueaccount; k++)
            {
                if (myarray[k] != null)
                {
                    mytruearray[k] = myarray[k];
                    //trueaccount++;
                }
            }
            if (trueaccount > 0)
            {
                aaa.finalstrings.Add(mytruearray);
            }*/
            /*string2 = JsonTools.ObjectToJson(mytruearray);
            int strlen = string2.Length;
            //strlen = strlen;
            if (strlen == 2)
            { string2 = ""; }
            else
            {
                string2 = string2.Substring(1, strlen - 2) + ',';
            }
            //string2 = string2.Substring(1, strlen - 2) + ',';
            threadsig2 = 1;*/
        }
コード例 #2
0
        public void thread1()
        {
            string temp = null;
            string tempf = null;
            int start = 1;
            int end = pcount/8;
            for (int i = start; i <= end; i += 1)
            {
                temp = doc.Paragraphs[i].Range.Text.Trim();//变量i为第i段

                MatchCollection matches = Regex.Matches(temp, pattern1);

                if (matches.Count > 0)
                {
                    hahabaseobject newobject = new hahabaseobject();
                    newobject.Allocation="";
                    newobject.Category="";
                    newobject.Contribution="";
                    newobject.description="";
                    newobject.Implement="";
                    newobject.Priority="";
                    newobject.othercontext="";
                    newobject.title = temp;//还没转换好
                    int endj = 0;
                    int flag = 1;
                    for (int j = i + 1; j <= end; j++)
                    {
                        temp = doc.Paragraphs[j].Range.Text.Trim();//变量i为第i段
                        MatchCollection matchesj = Regex.Matches(temp, pattern3);
                        if (matchesj.Count > 0)//写到段落存储,回去再写
                        {
                            endj = j;
                            break;
                        }
                    }
                    //textBox1.Text = i.ToString();
                    newobject.description = doc.Paragraphs[i + 1].Range.Text;
                    int arraycontentcount = 1;
                        for (int k = i + 1; k <=pcount; k++)
                        {
                            temp = doc.Paragraphs[k].Range.Text;

                            int startflag = 0;
                            MatchCollection matchesjinghao = Regex.Matches(temp, pattern4);
                            //textBox1.Text = matchesjinghao.Count.ToString();
                            if (matchesjinghao.Count < 1 && startflag < 1)
                            {
                                newobject.description = newobject.description + "\n" + temp;
                            }
                            else
                            {
                                startflag = 1;
                                int poseuql = temp.IndexOf('=');
                                tempf = temp.Substring(1, poseuql - 2);
                                temp = temp.Substring(poseuql + 1, temp.Length - poseuql - 1);

                                if (matchesjinghao.Count >= 1)
                                {
                                    if (tempf == "Implement")
                                    {
                                        newobject.Implement = temp;

                                    }
                                    if (tempf == "Priority")
                                    {
                                        newobject.Priority = temp;
                                    }
                                    if (tempf == "Contribution")
                                    {
                                        newobject.Contribution = temp;
                                    }
                                    if (tempf == "Category")
                                    {
                                        newobject.Category = temp;
                                    }
                                    if (tempf == "Allocation")
                                    {
                                        newobject.Allocation = temp;
                                    }
                                    if (tempf == "Source")
                                    {
                                        newobject.sources = temp;
                                    }
                                    arraycontentcount++;

                                }

                            }
                            if (newobject.sources != null)
                            {
                                break;
                            }
                        }

                    if (newobject.sources != null)
                    {
                        MatchCollection matchessourse = Regex.Matches(newobject.sources, pattern2);
                        newobject.othercontext = matchessourse.Count.ToString();

                        for (int ksourse = 0; ksourse < matchessourse.Count; ksourse++)
                        {
                            //newobject.source[ksourse] =matchessourse[ksourse].Value;
                            newobject.Source.Add(matchessourse[ksourse].Value);
                        }

                        aaa.finalstrings.Add(newobject);
                    }
                }
            }
        }