예제 #1
0
        public int ImportCampaignAccountLocation(string ticket, int campaign_id, string country, string state, string city)
        {
            int userid = ManagedAccount.GetAccountIdFromTicket(ticket);

            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session           = SnCore.Data.Hibernate.Session.Current;
                ManagedSecurityContext sec = new ManagedSecurityContext(session, ticket);

                ITransaction trans = session.BeginTransaction();

                AccountActivityQueryOptions options = new AccountActivityQueryOptions();
                options.City         = city;
                options.Country      = country;
                options.State        = state;
                options.PicturesOnly = false;
                options.BloggersOnly = false;

                int count = 0;

                try
                {
                    IQuery query = session.CreateQuery(options.CreateQuery());
                    IEnumerator <Account> enumerator = query.Enumerable <Account>().GetEnumerator();

                    while (enumerator.MoveNext())
                    {
                        ManagedAccount ma = new ManagedAccount(session, enumerator.Current);

                        if (!ma.HasVerifiedEmail(sec))
                        {
                            continue;
                        }

                        CampaignAccountRecepient existing = session.CreateCriteria(typeof(CampaignAccountRecepient))
                                                            .Add(Expression.Eq("Account.Id", ma.Id))
                                                            .Add(Expression.Eq("Campaign.Id", campaign_id))
                                                            .UniqueResult <CampaignAccountRecepient>();

                        if (existing != null)
                        {
                            continue;
                        }

                        ManagedCampaignAccountRecepient newrecepient        = new ManagedCampaignAccountRecepient(session);
                        TransitCampaignAccountRecepient newtransitrecepient = new TransitCampaignAccountRecepient();
                        newtransitrecepient.AccountId  = ma.Id;
                        newtransitrecepient.CampaignId = campaign_id;
                        newtransitrecepient.Created    = newtransitrecepient.Modified = DateTime.UtcNow;
                        newtransitrecepient.Sent       = false;
                        newrecepient.CreateOrUpdate(newtransitrecepient, sec);
                        count++;
                    }

                    trans.Commit();
                    SnCore.Data.Hibernate.Session.Flush();
                }
                catch
                {
                    trans.Rollback();
                    throw;
                }

                return(count);
            }
        }
예제 #2
0
 public List <TransitAccountActivity> GetAccountActivity(string ticket, AccountActivityQueryOptions queryoptions, ServiceQueryOptions options)
 {
     return(WebServiceImpl <TransitAccountActivity, ManagedAccountActivity, Account> .GetList(
                ticket, options, queryoptions.CreateQuery()));
 }
예제 #3
0
        public int ImportCampaignAccountLocation(string ticket, int campaign_id, string country, string state, string city)
        {
            int userid = ManagedAccount.GetAccountIdFromTicket(ticket);
            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session = SnCore.Data.Hibernate.Session.Current;
                ManagedSecurityContext sec = new ManagedSecurityContext(session, ticket);

                ITransaction trans = session.BeginTransaction();

                AccountActivityQueryOptions options = new AccountActivityQueryOptions();
                options.City = city;
                options.Country = country;
                options.State = state;
                options.PicturesOnly = false;
                options.BloggersOnly = false;

                int count = 0;

                try
                {
                    IQuery query = session.CreateQuery(options.CreateQuery());
                    IEnumerator<Account> enumerator = query.Enumerable<Account>().GetEnumerator();

                    while (enumerator.MoveNext())
                    {
                        ManagedAccount ma = new ManagedAccount(session, enumerator.Current);

                        if (!ma.HasVerifiedEmail(sec))
                            continue;

                        CampaignAccountRecepient existing = session.CreateCriteria(typeof(CampaignAccountRecepient))
                            .Add(Expression.Eq("Account.Id", ma.Id))
                            .Add(Expression.Eq("Campaign.Id", campaign_id))
                            .UniqueResult<CampaignAccountRecepient>();

                        if (existing != null)
                            continue;

                        ManagedCampaignAccountRecepient newrecepient = new ManagedCampaignAccountRecepient(session);
                        TransitCampaignAccountRecepient newtransitrecepient = new TransitCampaignAccountRecepient();
                        newtransitrecepient.AccountId = ma.Id;
                        newtransitrecepient.CampaignId = campaign_id;
                        newtransitrecepient.Created = newtransitrecepient.Modified = DateTime.UtcNow;
                        newtransitrecepient.Sent = false;
                        newrecepient.CreateOrUpdate(newtransitrecepient, sec);
                        count++;
                    }

                    trans.Commit();
                    SnCore.Data.Hibernate.Session.Flush();
                }
                catch
                {
                    trans.Rollback();
                    throw;
                }

                return count;
            }
        }
예제 #4
0
 public List<TransitAccountActivity> GetAccountActivity(string ticket, AccountActivityQueryOptions queryoptions, ServiceQueryOptions options)
 {
     return WebServiceImpl<TransitAccountActivity, ManagedAccountActivity, Account>.GetList(
         ticket, options, queryoptions.CreateQuery());
 }