public FetchManySpecs(SqLiteNHibernateFixture fixture) : base(fixture)
        {
            using (var tx = Session.BeginTransaction()) {
                EmployerEntity       employer;
                PersonEntity         person;
                RepresentativeEntity representative;
                CarEntity            car;

                employer = new EmployerEntity();
                Session.Save(employer);

                representative = new RepresentativeEntity();
                Session.Save(representative);
                person = new PersonEntity {
                    Employer = employer, Representative = representative
                };
                representative.Constituents.Add(person);
                employer.Employees.Add(person);

                car = new CarEntity {
                    Owner = person
                };
                person.Cars.Add(car);
                car = new CarEntity {
                    Owner = person
                };
                person.Cars.Add(car);

                Session.Save(person);


                representative = new RepresentativeEntity();
                Session.Save(representative);
                person = new PersonEntity {
                    Employer = employer, Representative = representative
                };
                representative.Constituents.Add(person);
                employer.Employees.Add(person);

                car = new CarEntity {
                    Owner = person
                };
                person.Cars.Add(car);
                car = new CarEntity {
                    Owner = person
                };
                person.Cars.Add(car);

                Session.Save(person);

                tx.Commit();
            }

            Session.Clear();
            SessionFactory.Statistics.Clear();
        }
        private void SplitRepresentativeSpeechFromDocument()
        {
            HashSet <string> representativeMark = new HashSet <string>();

            mListRepresentativeInDocument.Clear();
            mSearchListRepresenative.Clear();
            foreach (DocumentParagraph para in this.mDocumentEntity.paragraphs)
            {
                if (para.belongTo != null && !representativeMark.Contains(Utils.FormatRepresentative(
                                                                              para.belongTo.name, para.belongTo.duty)))
                {
                    RepresentativeEntity entity = para.belongTo;
                    mListRepresentativeInDocument.Add(entity);
                    representativeMark.Add(Utils.FormatRepresentative(para.belongTo.name, para.belongTo.duty));
                }
            }
        }
Exemplo n.º 3
0
        private void generateDataTest()
        {
            mListRepresentative = new List <RepresentativeEntity>();
            RepresentativeEntity entity = new RepresentativeEntity();

            entity.name        = "Nguyễn Hoàng Anh";
            entity.duty        = "Bắc Giang";
            entity.legislature = "14";
            mListRepresentative.Add(entity);

            entity             = new RepresentativeEntity();
            entity.name        = "Hoàng Liên Sơn";
            entity.duty        = "Bộ trưởng Bộ Giáo dục & đạo tạo";
            entity.legislature = "14";
            mListRepresentative.Add(entity);

            BindingData(this.mListRepresentative);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Split the representative speech content in the document
        /// </summary>
        /// <param name="document"> Document that contains the whole content</param>
        /// <returns></returns>
        public static DocumentEntity ParsingDocument(Word.Document document,
                                                     List <RepresentativeEntity> representativeEntities)
        {
            DocumentEntity documentesEntity = new DocumentEntity();

            DocumentParagraph documentParagraph = new DocumentParagraph();

            documentesEntity.paragraphs.Add(documentParagraph);
            foreach (Word.Paragraph para in TextHelpers.GetText(document))
            {
                string styleName = ((Word.Style)para.get_Style()).NameLocal;
                if (styleName.Equals(Constants.RerpesentativeStyle))
                {
                    RepresentativeEntity entity = FindRepresentative(representativeEntities, para.Range.Text);
                    if (entity != null)
                    {
                        documentParagraph = new DocumentParagraph();
                        documentesEntity.paragraphs.Add(documentParagraph);
                        documentParagraph.belongTo           = entity;
                        documentParagraph.belongTo.fullTitle = Utils.FormatRepresentative(entity.name, entity.duty);
                    }
                    else
                    {
                        if (!para.Range.Text.Trim().Equals(""))
                        {
                            documentParagraph = new DocumentParagraph();
                            documentesEntity.paragraphs.Add(documentParagraph);
                            documentParagraph.belongTo           = new RepresentativeEntity();
                            documentParagraph.belongTo.fullTitle = para.Range.Text.Trim();
                        }
                    }
                }
                else if (!Constants.TitleStyles.Contains(styleName))
                {
                    ///Do not get the title content
                    if (!para.Range.Text.Trim().Equals(""))
                    {
                        documentParagraph.contents.Add(para.Range.Text);
                    }
                }
            }

            return(documentesEntity);
        }
Exemplo n.º 5
0
 public static bool CheckRepresentativeList(Word.Document document,
                                            List <RepresentativeEntity> representativeEntities, out string reprentativeName)
 {
     foreach (Word.Paragraph para in TextHelpers.GetText(document))
     {
         string styleName = ((Word.Style)para.get_Style()).NameLocal;
         if (styleName.Equals(Constants.RerpesentativeStyle) &&
             !para.Range.Text.Trim().Equals(""))
         {
             RepresentativeEntity entity = FindRepresentative(representativeEntities, para.Range.Text);
             if (entity == null)
             {
                 reprentativeName = para.Range.Text;
                 return(false);
             }
         }
     }
     reprentativeName = "";
     return(true);
 }