Esempio n. 1
0
        public void CreateManyStoriesPerAccount(int count, int wordsperstory)
        {
            Random r        = new Random();
            IList  accounts = Session.CreateCriteria(typeof(Account)).List();

            foreach (Account a in accounts)
            {
                for (int i = 0; i < count; i++)
                {
                    TransitAccountStory s = new TransitAccountStory();
                    s.Name = Guid.NewGuid().ToString();

                    List <string> words = new List <string>(wordsperstory);

                    for (int w = 0; w < wordsperstory; w++)
                    {
                        StringBuilder word = new StringBuilder();
                        int           len  = r.Next() % 10 + 1;
                        for (int l = 0; l < len; l++)
                        {
                            word.Append((char)(r.Next() % 26 + 'a'));
                        }

                        s.Summary = s.Summary + word.ToString() + (w == 0 ? "" : " ");
                    }

                    ManagedAccount      ma = new ManagedAccount(Session, a);
                    ManagedAccountStory ms = new ManagedAccountStory(Session);
                    ms.CreateOrUpdate(s, ma.GetSecurityContext());
                }
            }
        }
Esempio n. 2
0
        public void CreateManyStoriesPerAccount(int count, int wordsperstory)
        {
            Random r = new Random();
            IList accounts = Session.CreateCriteria(typeof(Account)).List();

            foreach (Account a in accounts)
            {
                for (int i = 0; i < count; i++)
                {
                    TransitAccountStory s = new TransitAccountStory();
                    s.Name = Guid.NewGuid().ToString();

                    List<string> words = new List<string>(wordsperstory);

                    for (int w = 0; w < wordsperstory; w++)
                    {
                        StringBuilder word = new StringBuilder();
                        int len = r.Next() % 10 + 1;
                        for (int l = 0; l < len; l++)
                        {
                            word.Append((char)(r.Next() % 26 + 'a'));
                        }

                        s.Summary = s.Summary + word.ToString() + (w == 0 ? "" : " ");
                    }

                    ManagedAccount ma = new ManagedAccount(Session, a);
                    ManagedAccountStory ms = new ManagedAccountStory(Session);
                    ms.CreateOrUpdate(s, ma.GetSecurityContext());
                }
            }
        }