public void Execute(ISession session, long taskId, DateTime sentDate)
        {
            bool closeSession = false;
            if (session == null)
            {
                session = _businessSafeSessionManager.Session;
                closeSession = true;
            }

            var systemUser = session.Load<UserForAuditing>(SystemUser.Id);

            var taskDueTomorrowEscalation = new EscalationTaskDueTomorrow()
            {
                TaskId = taskId,
                TaskDueTomorrowEmailSentDate = sentDate,
                CreatedBy = systemUser,
                CreatedOn = DateTime.Now
            };
            session.Save(taskDueTomorrowEscalation);

            //Log4NetHelper.Log.Debug("Saved EscalationTaskDueTomorrow sent indicator");

            if (closeSession)
            {
                session.Close();
            }
        }
Exemplo n.º 2
0
        public void Init() {
            var builder = new ContainerBuilder();
            // builder.RegisterModule(new ImplicitCollectionSupportModule());
            builder.RegisterModule(new ContentModule());
            builder.RegisterType<DefaultContentManager>().As<IContentManager>().SingleInstance();
            builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();

            builder.RegisterType<AlphaHandler>().As<IContentHandler>();
            builder.RegisterType<BetaHandler>().As<IContentHandler>();
            builder.RegisterType<GammaHandler>().As<IContentHandler>();
            builder.RegisterType<DeltaHandler>().As<IContentHandler>();
            builder.RegisterType<EpsilonHandler>().As<IContentHandler>();
            builder.RegisterType<FlavoredHandler>().As<IContentHandler>();
            builder.RegisterType<StyledHandler>().As<IContentHandler>();

            builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));

            _session = _sessionFactory.OpenSession();
            builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();

            _session.Delete(string.Format("from {0}", typeof(GammaRecord).FullName));
            _session.Delete(string.Format("from {0}", typeof(DeltaRecord).FullName));
            _session.Delete(string.Format("from {0}", typeof(EpsilonRecord).FullName));
            _session.Delete(string.Format("from {0}", typeof(ContentItemVersionRecord).FullName));
            _session.Delete(string.Format("from {0}", typeof(ContentItemRecord).FullName));
            _session.Delete(string.Format("from {0}", typeof(ContentTypeRecord).FullName));
            _session.Flush();
            _session.Clear();

            _container = builder.Build();
            _manager = _container.Resolve<IContentManager>();

        }
Exemplo n.º 3
0
 public PostComment GetPostComment(ISession session)
 {
     PostComment ei = (Id != 0) ? (PostComment)session.Load(typeof(PostComment), Id) : new PostComment();
     ei.Comment = (Comment)session.Load(typeof(Comment), CommentId);
     ei.Post = (Post)session.Load(typeof(Post), PostId);
     return ei;
 }
Exemplo n.º 4
0
        public static RCVHead CreatePurchaseRCV(ISession session, int userId, string poNumber, string note)
        {
            RCVHead head = new RCVHead();
            head._refOrderType = head._originalOrderType = POHead.ORDER_TYPE;
            head._refOrderNumber = head._orginalOrderNumber = poNumber.Trim().ToUpper();
            #region ���
            //��ʱ������ɹ��ջ����������òɹ������ķ�ʽ
            if (string.IsNullOrEmpty(head._refOrderNumber))
                throw new Exception("�ɹ�����Ϊ��");
            POHead po = POHead.Retrieve(session, head._refOrderNumber);
            if (po == null)
                throw new Exception(string.Format("�ɹ�����{0}������", head._refOrderNumber));
            if (po.Status != POStatus.Release)
                throw new Exception(string.Format("�ɹ�����{0}���Ƿ���״̬�������Խ����ջ���ҵ", head._refOrderNumber));
            if (po.ApproveResult != ApproveStatus.Approve)
                throw new Exception(string.Format("�ɹ�����{0}��û�����ǩ�ˣ������Խ����ջ���ҵ", head._refOrderNumber));
            #endregion
            head._orderTypeCode = RCVHead.ORD_TYPE_PUR;
            head._orderNumber = ERPUtil.NextOrderNumber(head._orderTypeCode);
            head._objectID = po.VendorID;
            head._locationCode = po.LocationCode;
            head._createUser = userId;
            head._note = note.Trim();
            EntityManager.Create(session, head);

            return head;
        }
 public void RecreateDb(ISession session)
 {
     InitSessionFactory();
     var sessionSource = new SessionSource(_fluentConfiguration);
     sessionSource.BuildSchema(session);
     session.Flush();
 }
Exemplo n.º 6
0
 public void HandleEvent(TransferPokemonEvent evt, ISession session)
 {
     Logger.Write(
         session.Translation.GetTranslation(TranslationString.EventPokemonTransferred, evt.Id, evt.Cp,
             evt.Perfection.ToString("0.00"), evt.BestCp, evt.BestPerfection.ToString("0.00"), evt.FamilyCandies),
         LogLevel.Transfer);
 }
Exemplo n.º 7
0
 public void HandleEvent(EggIncubatorStatusEvent evt, ISession session)
 {
     Logger.Write(evt.WasAddedNow
         ? session.Translation.GetTranslation(TranslationString.IncubatorPuttingEgg, evt.KmRemaining)
         : session.Translation.GetTranslation(TranslationString.IncubatorStatusUpdate, evt.KmRemaining),
         LogLevel.Egg);
 }
Exemplo n.º 8
0
        private void IsExistsCode(ISession session, VendorInfo vi)
        {
            ICriteria criteria = session.CreateCriteria(typeof(VendorInfo));

            ICriterion criterion = null;
            if (vi.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(vi.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("VendorCode", vi.VendorCode);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.VendorInfoCodeIsExistsException();//供应商Code已经存在
            }
        }
Exemplo n.º 9
0
        private void IsExistsCode(ISession session, Storehouse sh)
        {
            ICriteria criteria = session.CreateCriteria(typeof(Storehouse));

            ICriterion criterion = null;
            if (sh.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(sh.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("StoreCode", sh.StoreCode);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.StorehouseCodeIsExistsException();//库存Code已经存在
            }
        }
        public void OnStartUp()
        {
            SetRootPathProject();

            XmlTextReader configReader = new XmlTextReader(new MemoryStream(NHibernate.Test.Properties.Resources.Configuration));
            DirectoryInfo dir = new DirectoryInfo(this.rootPathProject + ".Hbm");
            Console.WriteLine(dir);

            builder = new NhConfigurationBuilder(configReader, dir);

            builder.SetProperty("connection.connection_string", GetConnectionString());

            try
            {
                builder.BuildSessionFactory();
                sessionFactory = builder.SessionFactory;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
            
            sessionProvider = new SessionManager(sessionFactory);
            currentPagedDAO = new EnterprisePagedDAO(sessionProvider);
            currentRootPagedDAO = new EnterpriseRootDAO<object>(sessionProvider);
            currentSession = sessionFactory.OpenSession();
        }
        internal static bool ChangeCommitted(this ISessionPersistentObject al,CRUD Operation, IImportContext iic,  ISession session)
        {
            if (al == null)
                throw new Exception("Algo Error");

            bool needtoregister = false;

            IObjectStateCycle oa = al;

            switch (Operation)
            {
                case CRUD.Created:
                    needtoregister = true;
                    session.Save(al);
                    break;

                case CRUD.Update:
                    session.Update(al);         
                    oa.HasBeenUpdated();
                    break;

                case CRUD.Delete:
                    session.Delete(al);
                    oa.SetInternalState(ObjectState.Removed,iic);
                    break;
            }

            al.Context = null;

            return needtoregister;
        }
Exemplo n.º 12
0
 public static void CreateVoyages(ISession session)
 {
    session.Save(V100);
    session.Save(V200);
    session.Save(V300);
    session.Save(V400);
 }
 public void Set(ISession value)
 {
     if (value != null)
     {
         HttpContext.Current.Items.Add("NhbSession", value);
     }
 }
Exemplo n.º 14
0
 public Action GetInsertAction(ISession session, object bindableStatement, ConsistencyLevel consistency, int rowsPerId)
 {
     Action action = () =>
     {
         Trace.TraceInformation("Starting inserting from thread {0}", Thread.CurrentThread.ManagedThreadId);
         var id = Guid.NewGuid();
         for (var i = 0; i < rowsPerId; i++)
         {
             var paramsArray = new object[] { id, DateTime.Now, DateTime.Now.ToString() };
             IStatement statement = null;
             if (bindableStatement is SimpleStatement)
             {
                 statement = ((SimpleStatement)bindableStatement).Bind(paramsArray).SetConsistencyLevel(consistency);
             }
             else if (bindableStatement is PreparedStatement)
             {
                 statement = ((PreparedStatement)bindableStatement).Bind(paramsArray).SetConsistencyLevel(consistency);
             }
             else
             {
                 throw new Exception("Can not bind a statement of type " + bindableStatement.GetType().FullName);
             }
             session.Execute(statement);
         }
         Trace.TraceInformation("Finished inserting from thread {0}", Thread.CurrentThread.ManagedThreadId);
     };
     return action;
 }
 public void Store(ISession session)
 {
     if (_nhSessions.Contains(GetThreadName()))
         _nhSessions[GetThreadName()] = session;
     else
         _nhSessions.Add(GetThreadName(), session);
 }
Exemplo n.º 16
0
 public NativeToplistBrowse(ISession session, ToplistType toplistType, int region, object userData = null)
     : base(session, IntPtr.Zero)
 {
     _toplistType = toplistType;
     _region = region;
     _userData = userData;
 }
Exemplo n.º 17
0
        public SessionHandler(ILogger<SessionHandler> logger,
            IEnvironment environment,
            IFileSystem fileSystem,
            IKeyValueStore keyValueStore,
            IMessageBus messageBus,
            ISession session,
            ITorrentInfoRepository torrentInfoRepository,
            ITorrentMetadataRepository metadataRepository)
        {
            if (logger == null) throw new ArgumentNullException("logger");
            if (environment == null) throw new ArgumentNullException("environment");
            if (fileSystem == null) throw new ArgumentNullException("fileSystem");
            if (keyValueStore == null) throw new ArgumentNullException("keyValueStore");
            if (messageBus == null) throw new ArgumentNullException("messageBus");
            if (session == null) throw new ArgumentNullException("session");
            if (torrentInfoRepository == null) throw new ArgumentNullException("torrentInfoRepository");
            if (metadataRepository == null) throw new ArgumentNullException("metadataRepository");

            _logger = logger;
            _environment = environment;
            _fileSystem = fileSystem;
            _keyValueStore = keyValueStore;
            _messageBus = messageBus;
            _session = session;
            _torrentInfoRepository = torrentInfoRepository;
            _metadataRepository = metadataRepository;
            _muted = new List<string>();
            _alertsThread = new Thread(ReadAlerts);
        }
Exemplo n.º 18
0
 public static void AppsOnDeriveRevenues(ISession session)
 {
     foreach (Party party in session.Extent<Party>())
     {
         party.AppsOnDeriveRevenue();
     }
 }
Exemplo n.º 19
0
 public void Init(IEnumerable<Type> dataMigrations) {
    
     var builder = new ContainerBuilder();
     _folders = new StubFolders();
     var contentDefinitionManager = new Mock<IContentDefinitionManager>().Object;
     
     builder.RegisterInstance(new ShellSettings { DataTablePrefix = "TEST_"});
     
     builder.RegisterType<SqlServerDataServicesProvider>().As<IDataServicesProvider>();
     builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>();
     builder.RegisterType<NullInterpreter>().As<IDataMigrationInterpreter>();
     builder.RegisterInstance(_folders).As<IExtensionFolders>();
     builder.RegisterInstance(contentDefinitionManager).As<IContentDefinitionManager>();
     builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
     builder.RegisterType<DataMigrationManager>().As<IDataMigrationManager>();
     builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
     builder.RegisterType<StubCacheManager>().As<ICacheManager>();
     builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
     builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
     _session = _sessionFactory.OpenSession();
     builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>().As<ITransactionManager>();
     foreach(var type in dataMigrations) {
         builder.RegisterType(type).As<IDataMigration>();
     }
     _container = builder.Build();
     _container.Resolve<IExtensionManager>();
     _dataMigrationManager = _container.Resolve<IDataMigrationManager>();
     _repository = _container.Resolve<IRepository<DataMigrationRecord>>();
     _transactionManager = _container.Resolve<ITransactionManager>();
     InitDb();
 }
Exemplo n.º 20
0
        public void Init() {
            _contentDefinitionManager = new Mock<IContentDefinitionManager>();

            var builder = new ContainerBuilder();
            builder.RegisterType<DefaultContentManager>().As<IContentManager>();
            builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
            builder.RegisterInstance(_contentDefinitionManager.Object);
            builder.RegisterInstance(new Mock<IContentDisplay>().Object);

            builder.RegisterType<AlphaPartHandler>().As<IContentHandler>();
            builder.RegisterType<BetaPartHandler>().As<IContentHandler>();
            builder.RegisterType<GammaPartHandler>().As<IContentHandler>();
            builder.RegisterType<DeltaPartHandler>().As<IContentHandler>();
            builder.RegisterType<EpsilonPartHandler>().As<IContentHandler>();
            builder.RegisterType<FlavoredPartHandler>().As<IContentHandler>();
            builder.RegisterType<StyledHandler>().As<IContentHandler>();
            builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
            builder.RegisterType<ShapeTableLocator>().As<IShapeTableLocator>();
            builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
            builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();

            builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();

            builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));

            _session = _sessionFactory.OpenSession();
            builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();

            _container = builder.Build();
            _manager = _container.Resolve<IContentManager>();
        }
        public RemoveFromFriendsResponse RemoveFromFriends(ISession session, RemoveFromFriendsRequest request)
        {
            var response = request.CreateResponse<RemoveFromFriendsResponse>();
            response.Success = true;
            
            if (session.User.Friends.All(i => i.Id != request.TargetUserId))
            {
                response.Success = false;
                return response;
            }

            using (var uow = UnitOfWorkFactory.Create())
            {
                uow.Attach(session.User);
                var friend = uow.UsersRepository.FirstMatching(UserSpecification.Id(request.TargetUserId));
                if (friend == null)
                {
                    response.Success = false;
                }
                else
                {
                    session.User.Friends.Remove(friend);
                    uow.Commit();
                }
            } 
            return response;
        }
 void session_PlayTokenLost(ISession sender, SessionEventArgs e)
 {
     this.ParentForm.BeginInvoke(new MethodInvoker(delegate()
         {
             CF_displayMessage("Play token lost! What do we do???" + Environment.NewLine + e.Status.ToString() + Environment.NewLine + e.Message);
         }));
 }
Exemplo n.º 23
0
        public SessionAccess(ISession session)
        {
            if (session == null)
                throw new ArgumentNullException("session");

            this.session = session;
        }
Exemplo n.º 24
0
        private ISession getExistingOrNewSession(NHibernate.ISessionFactory factory)
        {
            if (HttpContext.Current != null)
            {
                ISession session = GetExistingWebSession();
                if (session == null)
                {
                    session = openSessionAndAddToContext(factory);
                }
                else if (!session.IsOpen)
                {
                    session = openSessionAndAddToContext(factory);
                }

                return session;
            }

            if (currentSession == null)
            {
                currentSession = factory.OpenSession();
            }
            else if (!currentSession.IsOpen)
            {
                currentSession = factory.OpenSession();
            }

            return currentSession;
        }
Exemplo n.º 25
0
        public EmployeeRepository(ISession session)
        {
            if (session == null)
                throw new ArgumentNullException("session");

                this.session = session;
        }
Exemplo n.º 26
0
        /// <summary>
        /// Requests a full set of information about an ICQ account
        /// </summary>
        /// <param name="sess">A <see cref="ISession"/> object</param>
        /// <param name="screenname">The account for which to retrieve information</param>
        public static void GetAllICQInfo(ISession sess, string screenname)
        {
            if (!ScreennameVerifier.IsValidICQ(screenname))
            {
                throw new ArgumentException(screenname + " is not a valid ICQ screenname", "screenname");
            }

            SNACHeader sh = new SNACHeader();
            sh.FamilyServiceID = (ushort) SNACFamily.ICQExtensionsService;
            sh.FamilySubtypeID = (ushort) ICQExtensionsService.MetaInformationRequest;
            sh.Flags = 0x0000;
            sh.RequestID = Session.GetNextRequestID();

            ByteStream stream = new ByteStream();
            stream.WriteUshort(0x0001);
            stream.WriteUshort(0x000A);
            stream.WriteUshort(0x0008);
            stream.WriteUint(uint.Parse(sess.ScreenName));
            stream.WriteUshortLE(0x07D0);
            stream.WriteUshortLE((ushort) sh.RequestID);
            stream.WriteUshort(0x04B2);
            stream.WriteUint(uint.Parse(screenname));

            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream));
        }
Exemplo n.º 27
0
 public RegionRepository(ISession session)
 {
     DataTable table;
     _ds = new DataSet("Province");
     DataSet p = session.CreateObjectQuery("select PRV_ID as Province_ID,PRV_CODE as \"Code\",PRV_NAME as \"Name\",PRV_ALIAS as \"Alias\" from Province")
         .Attach(typeof(Province))
         .DataSet();
     table = p.Tables[0];
     table.TableName = "p";
     table.Constraints.Add("PK_p", table.Columns["Province_ID"], true);
     p.Tables.Clear();
     _ds.Tables.Add(table);
     DataSet c = session.CreateObjectQuery("select PRV_ID as Province_ID,CITY_ID as City_ID,CITY_CODE as City_Code,CITY_NAME as \"Name\" from City")
         .Attach(typeof(City))
         .DataSet();
     table = c.Tables[0];
     table.TableName = "c";
     table.Constraints.Add("PK_c", table.Columns["City_ID"], true);
     c.Tables.Clear();
     _ds.Tables.Add(table);
     DataSet d = session.CreateObjectQuery("select CITY_ID as City_ID,DST_ID as District_ID,DST_NAME as \"Name\",DST_ZIPCODE as Zip_Code,DST_SHIP_TO as Door2Door from District")
         .Attach(typeof(District))
         .DataSet();
     table = d.Tables[0];
     table.TableName = "d";
     table.Constraints.Add("PK_d", table.Columns["District_ID"], true);
     d.Tables.Clear();
     _ds.Tables.Add(table);
 }
 void session_MessageToUser(ISession sender, SessionEventArgs e)
 {
     this.ParentForm.BeginInvoke(new MethodInvoker(delegate()
         {
             CF_displayMessage(e.Message);
         }));
 }
Exemplo n.º 29
0
 private static bool turnOnStatistics(ISession session)
 {
     var onOff = session.SessionFactory.Statistics.IsStatisticsEnabled;
     session.SessionFactory.Statistics.IsStatisticsEnabled = true;
     session.SessionFactory.Statistics.Clear();
     return onOff;
 }
Exemplo n.º 30
0
        public async Task<LoginResult> Login(ISession session)
        {
            string username = null;
            bool isUsernameValid = false;

            while (!isUsernameValid)
            {
                await session.SendAsync("Please enter your username:"******"Invalid username.");
                }
            }
            
            return new LoginResult(true, true, username);
        }
 public static void Set <T>(this ISession session, string key, T value)
 {
     session.SetString(key, JsonConvert.SerializeObject(value));
 }
Exemplo n.º 32
0
 public ManagedFeature(ISession session)
     : base(session)
 {
 }
Exemplo n.º 33
0
 // We can call ".SetObjectAsJson" just like our other session set methods, by passing a key and a value
 public static void SetObjectAsJson(this ISession session, string key, object value)
 {
     // This helper function simply serializes theobject to JSON and stores it as a string in session
     session.SetString(key, JsonConvert.SerializeObject(value));
 }
Exemplo n.º 34
0
        public void OnStatisticChanged(ISession session)
        {
            var manager = TinyIoCContainer.Current.Resolve <MultiAccountManager>();

            if (MultipleBotConfig.IsMultiBotActive(session.LogicSettings, manager) && manager.AllowSwitch())
            {
                var config = session.LogicSettings.MultipleBotConfig;

                if (config.PokestopSwitch > 0 && config.PokestopSwitch <= TotalPokestops)
                {
                    session.CancellationTokenSource.Cancel();

                    //Activate switcher by pokestop
                    throw new ActiveSwitchByRuleException()
                          {
                              MatchedRule  = SwitchRules.Pokestop,
                              ReachedValue = TotalPokestops
                          };
                }

                if (config.PokemonSwitch > 0 && config.PokemonSwitch <= TotalPokemons)
                {
                    session.CancellationTokenSource.Cancel();
                    //Activate switcher by pokestop
                    throw new ActiveSwitchByRuleException()
                          {
                              MatchedRule  = SwitchRules.Pokemon,
                              ReachedValue = TotalPokemons
                          };
                }

                if (config.EXPSwitch > 0 && config.EXPSwitch <= TotalExperience)
                {
                    session.CancellationTokenSource.Cancel();
                    //Activate switcher by pokestop
                    throw new ActiveSwitchByRuleException()
                          {
                              MatchedRule  = SwitchRules.EXP,
                              ReachedValue = TotalExperience
                          };
                }

                // When bot starts OR did the account switch by time, random time for Runtime has not been set. So we need to set it
                if (!isRandomTimeSet)
                {
                    Random random = new Random();
                    newRandomSwitchTime = config.RuntimeSwitch + random.Next((config.RuntimeSwitchRandomTime * -1), config.RuntimeSwitchRandomTime);
                    isRandomTimeSet     = true;
                }

                var totalMin = (DateTime.Now - _initSessionDateTime).TotalMinutes;
                if (newRandomSwitchTime > 0 && newRandomSwitchTime <= totalMin)
                {
                    // Setup random time to false, so that next account generates new random runtime
                    isRandomTimeSet = false;

                    session.CancellationTokenSource.Cancel();
                    //Activate switcher by pokestop
                    throw new ActiveSwitchByRuleException()
                          {
                              MatchedRule  = SwitchRules.Runtime,
                              ReachedValue = Math.Round(totalMin, 1)
                          };
                }
            }
        }
Exemplo n.º 35
0
 public async Task <LevelUpRewardsResponse> GetLevelUpRewards(ISession ctx)
 {
     return(await ctx.Inventory.GetLevelUpRewards(LevelForRewards).ConfigureAwait(false));
 }
Exemplo n.º 36
0
        public async Task <StatsExport> GetCurrentInfo(ISession session, Inventory inventory)
        {
            var stats = await inventory.GetPlayerStats().ConfigureAwait(false);

            StatsExport output = null;
            var         stat   = stats.FirstOrDefault();

            if (stat != null)
            {
                var ep      = stat.NextLevelXp - stat.Experience;
                var time    = Math.Round(ep / (TotalExperience / GetRuntime()), 2);
                var hours   = 0.00;
                var minutes = 0.00;

                var TotXP = 0;

                for (int i = 0; i < stat.Level + 1; i++)
                {
                    TotXP = TotXP + Statistics.GetXpDiff(i);
                }

                if (double.IsInfinity(time) == false && time > 0)
                {
                    hours   = Math.Truncate(TimeSpan.FromHours(time).TotalHours);
                    minutes = TimeSpan.FromHours(time).Minutes;
                }

                if (LevelForRewards == -1 || stat.Level >= LevelForRewards)
                {
                    if (session.LogicSettings.SkipCollectingLevelUpRewards)
                    {
                        Logger.Write("Current Lvl: " + stat.Level + ". Skipped collecting level up rewards.", LogLevel.Info);
                    }
                    else
                    {
                        LevelUpRewardsResponse Result = await inventory.GetLevelUpRewards(stat.Level).ConfigureAwait(false);

                        if (Result.ToString().ToLower().Contains("awarded_already"))
                        {
                            LevelForRewards = stat.Level + 1;
                        }

                        if (Result.ToString().ToLower().Contains("success"))
                        {
                            Logger.Write($"{session.Profile.PlayerData.Username} has leveled up: " + stat.Level, LogLevel.Info);
                            LevelForRewards = stat.Level + 1;

                            RepeatedField <ItemAward> items = Result.ItemsAwarded;
                            string Rewards = "";

                            if (items.Any <ItemAward>())
                            {
                                Logger.Write("- Received Items -", LogLevel.Info);
                                Rewards = "\nItems Recieved:";
                                foreach (ItemAward item in items)
                                {
                                    Logger.Write($"{item.ItemCount,2:#0}x {item.ItemId}'s", LogLevel.Info);
                                    Rewards += $"\n{item.ItemCount,2:#0}x {item.ItemId}'s";
                                }
                            }

                            if (session.LogicSettings.NotificationConfig.EnablePushBulletNotification)
                            {
                                await PushNotificationClient.SendNotification(session, $"{session.Profile.PlayerData.Username} has leveled up.", $"Trainer just reached level {stat.Level}{Rewards}", true).ConfigureAwait(false);
                            }
                        }
                    }
                }

                output = new StatsExport
                {
                    Level             = stat.Level,
                    HoursUntilLvl     = hours,
                    MinutesUntilLevel = minutes,
                    LevelXp           = TotXP,
                    CurrentXp         = stat.Experience,
                    PreviousXp        = stat.PrevLevelXp,
                    LevelupXp         = stat.NextLevelXp
                };
            }
            return(output);
        }
Exemplo n.º 37
0
 public MunicipioRepositoryReadOnly(ISession session) : base(session)
 {
 }
        public static T Get <T>(this ISession session, string key)
        {
            var value = session.GetString(key);

            return((value == null || value == "") ? default(T) : JsonConvert.DeserializeObject <T>(value));
        }
 public ProductRepository(ISession session)
 {
     _session = session;
 }
 public TestSessionLocator(ISession session)
 {
     _session = session;
 }
Exemplo n.º 41
0
 public IModel CreateModel(ISession session, ConsumerWorkService workService)
 {
     return(new Model(session, workService));
 }
 public ProductRepository()
 {
     _session = SesionFactoryUpdate.GetSession();/// initializam sesiunea....
 }
        public static T GetJson <T> (this ISession session, string key)
        {
            var sessionData = session.GetString(key);

            return(sessionData == null ? default(T) : JsonSerializer.Deserialize <T>(sessionData));
        }
Exemplo n.º 44
0
 public IdentityService(ISession session) : base(session)
 {
 }
Exemplo n.º 45
0
 public KeepAliveHandler(ISession session, byte[] recv) : base(session, recv)
 {
 }
Exemplo n.º 46
0
 public IModel CreateModel(ISession session)
 {
     return(new Model(session));
 }
Exemplo n.º 47
0
 public SessionFlushedEvent(ISession session)
 {
     Session = session;
 }
 public static void SetJson(this ISession session, string key, object value)
 {
     session.SetString(key, JsonSerializer.Serialize(value));
 }
Exemplo n.º 49
0
 public DescontoRepository(ISession session) : base(session)
 {
 }
Exemplo n.º 50
0
        public void TestReceiveBrowseReceive()
        {
            using (IConnection connection = CreateConnection())
            {
                using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
                {
                    IDestination     destination = session.GetQueue("TEST.ReceiveBrowseReceive");
                    IMessageProducer producer    = session.CreateProducer(destination);
                    IMessageConsumer consumer    = session.CreateConsumer(destination);
                    connection.Start();

                    IMessage[] outbound = new IMessage[] { session.CreateTextMessage("First Message"),
                                                           session.CreateTextMessage("Second Message"),
                                                           session.CreateTextMessage("Third Message") };

                    // lets consume any outstanding messages from previous test runs
                    while (consumer.Receive(TimeSpan.FromMilliseconds(1000)) != null)
                    {
                    }

                    producer.Send(outbound[0]);
                    producer.Send(outbound[1]);
                    producer.Send(outbound[2]);

                    IMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));

                    // Get the first.
                    Assert.AreEqual(((ITextMessage)outbound[0]).Text, ((ITextMessage)msg).Text);
                    consumer.Close();

                    IQueueBrowser browser     = session.CreateBrowser((IQueue)destination);
                    IEnumerator   enumeration = browser.GetEnumerator();

                    // browse the second
                    Assert.IsTrue(enumeration.MoveNext(), "should have received the second message");
                    Assert.AreEqual(((ITextMessage)outbound[1]).Text, ((ITextMessage)enumeration.Current).Text);

                    // browse the third.
                    Assert.IsTrue(enumeration.MoveNext(), "Should have received the third message");
                    Assert.AreEqual(((ITextMessage)outbound[2]).Text, ((ITextMessage)enumeration.Current).Text);

                    // There should be no more.
                    bool tooMany = false;
                    while (enumeration.MoveNext())
                    {
                        Debug.WriteLine("Got extra message: " + ((ITextMessage)enumeration.Current).Text);
                        tooMany = true;
                    }
                    Assert.IsFalse(tooMany);

                    //Reset should take us back to the start.
                    enumeration.Reset();

                    // browse the second
                    Assert.IsTrue(enumeration.MoveNext(), "should have received the second message");
                    Assert.AreEqual(((ITextMessage)outbound[1]).Text, ((ITextMessage)enumeration.Current).Text);

                    // browse the third.
                    Assert.IsTrue(enumeration.MoveNext(), "Should have received the third message");
                    Assert.AreEqual(((ITextMessage)outbound[2]).Text, ((ITextMessage)enumeration.Current).Text);

                    // There should be no more.
                    tooMany = false;
                    while (enumeration.MoveNext())
                    {
                        Debug.WriteLine("Got extra message: " + ((ITextMessage)enumeration.Current).Text);
                        tooMany = true;
                    }
                    Assert.IsFalse(tooMany);

                    browser.Close();

                    // Re-open the consumer.
                    consumer = session.CreateConsumer(destination);

                    // Receive the second.
                    Assert.AreEqual(((ITextMessage)outbound[1]).Text, ((ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(1000))).Text);
                    // Receive the third.
                    Assert.AreEqual(((ITextMessage)outbound[2]).Text, ((ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(1000))).Text);
                    consumer.Close();
                }
            }
        }
Exemplo n.º 51
0
 /// <summary> Constructor </summary>
 public Repository(ISessionFactory sessionFactory)
 {
     _session     = sessionFactory.OpenSession();
     _transaction = null;
 }
Exemplo n.º 52
0
 public UsuarioRepository(ISession session) : base(session)
 {
 }
Exemplo n.º 53
0
 public IEnumerable <PurchaseFamily> Execute(ISession session)
 {
     return(session.Query <PurchaseFamily>());
 }
 public UnSubmitReportCommandHandler(ISession session)
 {
     _session = session;
 }
Exemplo n.º 55
0
 public CandleController(ShopItemsContext dbContext, IHttpContextAccessor accessor)
 {
     _dbContext = dbContext;
     _session   = accessor.HttpContext.Session;
 }
 public AmazonMarketPlaceTypeRepository(ISession session)
     : base(session)
 {
 }
Exemplo n.º 57
0
 public void OnStopAfter(ISession ssn)
 {
     _logger.Info($"Stop Session(After) : Count({Program.server.sessionCount})");
 }
Exemplo n.º 58
0
 public AsistenteCP(ISession sessionAux)
     : base(sessionAux)
 {
 }
Exemplo n.º 59
0
 public void OnStopBefore(ISession ssn)
 {
     _logger.Info($"Stop Session(Before) : {this}");
 }
Exemplo n.º 60
0
 public void OnError(ISession ssn, Exception ex)
 {
     _logger.Error(ex);
 }