Example #1
0
        public override void InstallResources(IStatelessSession session)
        {
            using (var transaction = session.BeginTransaction()) {
                NewResource(LikeConstants.Fields.Liker.Label, "توسط");

                NewResource(LikeConstants.Fields.LikeDateUtc.Label, "تاریخ لایک");

                transaction.Commit();
            }
        }
        public virtual void Save <TEntitySource>(IEnumerable <TEntitySource> list, int batchSize)
        {
            if (_statelessSession == null)
            {
                throw new InvalidOperationException("stateless connection not created for batch insert");
            }

            using (var transaction = _statelessSession.BeginTransaction())
            {
                _statelessSession.SetBatchSize(batchSize);

                foreach (var entity in list)
                {
                    _statelessSession.Insert(entity);
                }

                transaction.Commit();
            }
        }
Example #3
0
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(OwnableConstantsBase <OwnableBase> .Fields.OwnerId.Label, "آدرس آی پی");

                transaction.Commit();
            }
        }
Example #4
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    using (IStatelessSession session = mysqlDataAccess.GetStatelessSession())
                        using (var transaction = session.BeginTransaction())
                        {
                            var command = await session.CreateCriteria <TbCommand>()
                                          // .Add(Restrictions.Ge("date", "2019-10-01 15:18:00"))
                                          // .AddOrder(NHibernate.Criterion.Order.Desc("date"))
                                          .UniqueResultAsync <TbCommand>();

                            if (command == null || command.Date == LastReadingCommandDate)
                            {
                                /// 제어 명령이 없으면 SOC 프로텍션 기능 실행
                                await SOCProtectFunction(stoppingToken);

                                continue;
                            }

                            LastReadingCommandDate = command.Date;

                            _logger.LogInformation($"command pcs1: {command.Ess1} pcs2: {command.Ess2} pcs3: {command.Ess3} pcs4: {command.Ess4}");
                            /// 1단계 SOC 내의 명령인지 체크
                            bool[] ValidSocs = new bool[]
                            {
                                await ValidatingSOC(1, command.Ess1),
                                await ValidatingSOC(2, command.Ess2),
                                await ValidatingSOC(3, command.Ess3),
                                await ValidatingSOC(4, command.Ess4)
                            };


                            bool pcs1_ok = ValidSocs[0];
                            bool pcs2_ok = ValidSocs[1];
                            bool pcs3_ok = ValidSocs[2];
                            bool pcs4_ok = ValidSocs[3];


                            await SendCommandWhenOK(ValidSocs[0], 1, command.Ess1, stoppingToken);
                            await SendCommandWhenOK(ValidSocs[1], 2, command.Ess2, stoppingToken);
                            await SendCommandWhenOK(ValidSocs[2], 3, command.Ess3, stoppingToken);
                            await SendCommandWhenOK(ValidSocs[3], 4, command.Ess4, stoppingToken);

                            await Task.Delay(1000, stoppingToken);
                        }
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, ex.Message);
                }
            }
        }
Example #5
0
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(ComponentModelConstants.MetadataComponentModel.Metadata.Title, "متادیتا");
                NewResource(ComponentModelConstants.MetadataComponentModel.Metadata.Description, "در صورت لزوم با مقداردهی فیلد های ذیل، امکان شناسایی سریعتر مطلب مورد نظر توسط موتور های جستجو را فراهم سازید. توجه کنید که هرگونه تفریط در بکارگیری کلمات غیر متعارف/غیر مرتبط ممکن است نتیجه برعکس را در پی داشته باشد!");

                transaction.Commit();
            }
        }
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(PictureConstants.Fields.MimeType.Label, "قالب");
                NewResource(PictureConstants.Fields.FileName.Label, "نام سند");

                transaction.Commit();
            }
        }
Example #7
0
 public void Save(IEnumerable <RandomNumber> randomNumbers)
 {
     using (var transaction = session.BeginTransaction(IsolationLevel.ReadCommitted))
     {
         session.SetBatchSize((int)batchSize);
         foreach (var entity in randomNumbers)
         {
             session.Insert(entity);
         }
         transaction.Commit();
     }
 }
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(UserContentConstantsBase <UserContentBase> .Fields.CreationHistory.Label, "آدرس آی پی");
                NewResource(UserContentConstantsBase <UserContentBase> .Fields.ModificationHistory.Label, "آدرس آی پی");
                NewResource(UserContentConstantsBase <UserContentBase> .Fields.VisibilityHistory.Label, "آدرس آی پی");

                transaction.Commit();
            }
        }
        public override void InstallResources(IStatelessSession session)
        {
            using (var transaction = session.BeginTransaction()) {
                NewResource(TicketStatusConstants.Fields.SystemName.Label, "پاسخ دهنده");
                NewResource(TicketStatusConstants.Fields.DisplayName.Label, "پاسخ دهنده");
                NewResource(TicketStatusConstants.Fields.Description.Label, "پاسخ دهنده");

                NewResource(TicketStatusConstants.Fields.Tickets.Label, "پاسخ دهنده");

                transaction.Commit();
            }
        }
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(ResourceValueConstants.Fields.Value.Label, "کلید");

                NewResource(ResourceValueConstants.Fields.Key.Label, "کلید");

                transaction.Commit();
            }
        }
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(NewsletterSubscriptionConstants.Fields.Email.Label, "ارسال به");

                NewResource(NewsletterSubscriptionConstants.Fields.Guid.Label, "ارسال به");

                transaction.Commit();
            }
        }
		public void InitId()
		{
			Paper paper;

			using (IStatelessSession ss = sessions.OpenStatelessSession())
			{
				ITransaction tx;
				using (tx = ss.BeginTransaction())
				{
					paper = new Paper {Color = "White"};
					ss.Insert(paper);
					Assert.IsTrue(paper.Id != 0);
					tx.Commit();
				}
				using (tx = ss.BeginTransaction())
				{
					ss.Delete(ss.Get<Paper>(paper.Id));
					tx.Commit();
				}
			}
		}
        public override void InstallEntities(IStatelessSession session)
        {
            using (var transaction = session.BeginTransaction()) {
                session.Insert(new Category {
                    Title    = "به زودی...",
                    Metadata = new MetadataComponent {
                        Slug = "coming-soon"
                    }
                });

                transaction.Commit();
            }
        }
        public override void InstallEntities(IStatelessSession session)
        {
            using (var transaction = session.BeginTransaction()) {
                session.Insert(new Language {
                    SystemName  = "FA",
                    DisplayName = "Persian",
                    NativeName  = "فارسی",
                    CultureCode = "fa"
                });

                transaction.Commit();
            }
        }
Example #15
0
        public void Add1(int amount)
        {
            var obs = CreateObjectAdd(amount);

            using (ITransaction tran = statelesssession.BeginTransaction())
            {
                foreach (var ob in obs)
                {
                    statelesssession.Insert(ob);
                }
                tran.Commit();
            }
        }
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(MetadataComponentConstants.Fields.Title.Label, "عنوان");
                NewResource(MetadataComponentConstants.Fields.Slug.Label, "اسلاگ");
                NewResource(MetadataComponentConstants.Fields.Keywords.Label, "کلمات کلیدی");
                NewResource(MetadataComponentConstants.Fields.Description.Label, "توضیحات");

                transaction.Commit();
            }
        }
Example #17
0
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(PageConstants.Fields.Title.Label, "عنوان");
                NewResource(PageConstants.Fields.Body.Label, "بدنه");

                NewResource(PageConstants.Fields.Group.Label, "گروه");

                transaction.Commit();
            }
        }
Example #18
0
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(ControlHelpersConstants.Pager.Labels.Previous, "→ قبلی");
                NewResource(ControlHelpersConstants.Pager.Labels.Next, "بعدی ←");
                NewResource(ControlHelpersConstants.Pager.Texts.Format, "نمایش {0} - {1} از {2}");
                NewResource(ControlHelpersConstants.Pager.Texts.SingleFormat, "نمایش {0} - {1}");

                transaction.Commit();
            }
        }
Example #19
0
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(CreationHistoryComponentConstants.Fields.Creator.Label, "عنوان");
                NewResource(CreationHistoryComponentConstants.Fields.CreatorIp.Label, "عنوان");

                NewResource(CreationHistoryComponentConstants.Fields.CreateDateUtc.Label, "عنوان");

                transaction.Commit();
            }
        }
Example #20
0
        public void SaveBulk(List <Sms> objectList)
        {
            using (IStatelessSession statelessSession = sessionFactory.OpenStatelessSession())

                using (ITransaction transaction = statelessSession.BeginTransaction())
                {
                    foreach (var item in objectList)
                    {
                        statelessSession.Insert(item);
                    }
                    transaction.Commit();
                }
        }
Example #21
0
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(GenreConstants.Fields.Title.Label, "عنوان");
                NewResource(GenreConstants.Fields.Description.Label, "توضیحات");

                NewResource(GenreConstants.Fields.Tracks.Label, "توضیحات");

                transaction.Commit();
            }
        }
Example #22
0
        /// <summary>
        /// Removes the stale persisted grants.
        /// </summary>
        protected virtual async Task RemoveGrantsAsync()
        {
            const string deleteExpiredGrantsHql = "delete PersistedGrant pg where pg.ID in (:expiredGrantsIDs)";

            var expiredTokenFound = int.MaxValue;

            while (expiredTokenFound >= _options.TokenCleanupBatchSize)
            {
                using (var tx = _session.BeginTransaction())
                {
                    var expiredGrantsQuery = _session.QueryOver <PersistedGrant>()
                                             .Where(g => g.Expiration < DateTime.UtcNow)
                                             .OrderBy(g => g.Expiration).Asc
                                             .Take(_options.TokenCleanupBatchSize);

                    var expiredGrants = await expiredGrantsQuery.ListAsync();

                    var expiredGrantsIDs = expiredGrants.Select(pg => pg.ID).ToArray();
                    expiredTokenFound = expiredGrantsIDs.Length;

                    if (expiredTokenFound > 0)
                    {
                        _logger.LogInformation($"Removing {expiredTokenFound} expired grants");

                        await _session.CreateQuery(deleteExpiredGrantsHql)
                        .SetParameterList("expiredGrantsIDs", expiredGrantsIDs)
                        .ExecuteUpdateAsync();

                        await tx.CommitAsync();

                        if (_operationalStoreNotification != null)
                        {
                            await _operationalStoreNotification.PersistedGrantsRemovedAsync(expiredGrants);
                        }
                    }
                }
            }
        }
        public override void InstallResources(IStatelessSession session)
        {
            using (var transaction = session.BeginTransaction()) {
                NewResource(TicketResponseConstants.Fields.Responder.Label, "پاسخ دهنده");
                NewResource(TicketResponseConstants.Fields.InResponseTo.Label, "در پاسخ به");

                NewResource(TicketResponseConstants.Fields.ResponseDateUtc.Label, "موضوع");

                NewResource(TicketResponseConstants.Fields.Subject.Label, "موضوع");
                NewResource(TicketResponseConstants.Fields.Body.Label, "توضیحات");

                transaction.Commit();
            }
        }
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(LanguageConstants.Fields.SystemName.Label, "نام");
                NewResource(LanguageConstants.Fields.DisplayName.Label, "نام");
                NewResource(LanguageConstants.Fields.Description.Label, "نام");

                NewResource(LanguageConstants.Fields.CultureCode.Label, "آدرس ایمیل");

                transaction.Commit();
            }
        }
Example #25
0
        public async Task InitIdAsync()
        {
            Paper paper;

            using (IStatelessSession ss = Sfi.OpenStatelessSession())
            {
                ITransaction tx;
                using (tx = ss.BeginTransaction())
                {
                    paper = new Paper {
                        Color = "White"
                    };
                    await(ss.InsertAsync(paper));
                    Assert.IsTrue(paper.Id != 0);
                    await(tx.CommitAsync());
                }
                using (tx = ss.BeginTransaction())
                {
                    await(ss.DeleteAsync(await(ss.GetAsync <Paper>(paper.Id))));
                    await(tx.CommitAsync());
                }
            }
        }
Example #26
0
        public void AddProducts(int HowMany)
        {
            ISessionFactory sessionFactory = new Configuration().Configure().BuildSessionFactory();

            using (IStatelessSession statelessSession = sessionFactory.OpenStatelessSession())
                using (ITransaction transaction = statelessSession.BeginTransaction())
                {
                    for (int i = 0; i < HowMany; i++)
                    {
                        statelessSession.Insert(new Product());
                    }
                    transaction.Commit();
                }
        }
Example #27
0
        private void SaveLog(IStatelessSession session, TermLog entity)
        {
            if (session == null) return;

            using (var tx = session.BeginTransaction())
            {
                var currentEmployee = ApplicationCache.Get<Entity>(Global.LoginEmployee);
                if (currentEmployee != null)
                    entity.AlterEmployeeId = currentEmployee.Id;
                session.Insert(entity);
                
                tx.Commit();
            }
        }
Example #28
0
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(OrderNoteConstants.Fields.Note.Label, "یادداشت");

                NewResource(OrderNoteConstants.Fields.IsPublic.Label, "نمایش به سفارش دهنده");

                NewResource(OrderNoteConstants.Fields.Order.Label, "مربوط به");

                transaction.Commit();
            }
        }
Example #29
0
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(UserConstants.Messages.SearchEngine, "امکان ثبت این کاربر (موتور جستجو) وجود ندارد.");
                NewResource(UserConstants.Messages.AlreadyRegistered, "این کاربر قبلا ثبت شده است.");
                NewResource(UserConstants.Messages.InvalidOldPassword, "گذرواژه قبلی صحیح نمی باشد.");
                NewResource(UserConstants.Messages.UserNameDisabled, "امکان تعیین نام کاربری وجود ندارد.");
                NewResource(UserConstants.Messages.ChangingUserNameNotAllowed, "امکان تغییر نام کاربری وجود ندارد.");
                NewResource(UserConstants.Messages.DeletionSystemAccountNotAllowed, "امکان حذف کاربر سیستمی وجود ندارد.");
                NewResource(UserConstants.Messages.InvalidUserNameOrEmail, "نام کاربری و/یا ایمیل صحیح نمی باشد.");
                NewResource(UserConstants.Messages.InvalidUserNameEmailOrPassword, "نام کاربری/ایمیل و/یا گذرواژه صحیح نمی باشد.");
                NewResource(UserConstants.Messages.YourAccountIsNotValid, "حساب کاربری مورد نظر مجاز نمی باشد.");
                NewResource(UserConstants.Messages.YourAccountIsNotActivatedYet, "حساب کاربری شما هنور فعال نشده است.");
                NewResource(UserConstants.Messages.YourAccountWasBlocked, "حساب کاربری شما مسدود شده است.");

                NewResource(UserConstants.Fields.SystemName.Label, "نام سیستمی");
                NewResource(UserConstants.Fields.UserName.Label, "نام کاربری");
                NewResource(UserConstants.Fields.Email.Label, "پست الکترونیکی");
                NewResource(UserConstants.Fields.Password.Label, "گذرواژه");
                NewResource(UserConstants.Fields.PasswordFormat.Label, "قالب گذرواژه");
                NewResource(UserConstants.Fields.PasswordFormat.Clear, "معمولی");
                NewResource(UserConstants.Fields.PasswordFormat.Hashed, "هش شده (غیر قابل بازگشت)");
                NewResource(UserConstants.Fields.PasswordFormat.Encrypted, "رمز نگاری شده");

                NewResource(UserConstants.Fields.LastLoginDateUtc.Label, "تاریخ آخرین ورود");
                NewResource(UserConstants.Fields.LastActivityDateUtc.Label, "تاریخ آخرین فعالیت");
                NewResource(UserConstants.Fields.AdminComment.Label, "توضیحات (مدیر)");
                NewResource(UserConstants.Fields.LastIpAddress.Label, "آخرین آدرس آی پی");

                NewResource(UserConstants.Fields.CurrentBlockType.Label, "جلوگیری از خرید");

                NewResource(UserConstants.Fields.Roles.Label, "نام سیستمی");
                NewResource(UserConstants.Fields.Activities.Label, "نام کاربری");
                NewResource(UserConstants.Fields.Logs.Label, "پست الکترونیکی");
                NewResource(UserConstants.Fields.ToDos.Label, "گذرواژه");
                NewResource(UserConstants.Fields.Tickets.Label, "توضیحات (مدیر)");
                NewResource(UserConstants.Fields.Responses.Label, "آخرین آدرس آی پی");
                NewResource(UserConstants.Fields.IncomingFriendRequests.Label, "توضیحات (مدیر)");
                NewResource(UserConstants.Fields.OutgoingFriendRequests.Label, "آخرین آدرس آی پی");
                NewResource(UserConstants.Fields.Blogs.Label, "توضیحات (مدیر)");
                NewResource(UserConstants.Fields.Orders.Label, "آخرین آدرس آی پی");
                NewResource(UserConstants.Fields.Likes.Label, "توضیحات (مدیر)");
                NewResource(UserConstants.Fields.Shares.Label, "آخرین آدرس آی پی");
                NewResource(UserConstants.Fields.VotingRecords.Label, "آخرین آدرس آی پی");

                transaction.Commit();
            }
        }
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var transaction = session.BeginTransaction()) {
                NewResource(UIElementConstantsBase <UIElementBase> .Fields.DisplayOrder.Label, "آدرس آی پی");

                NewResource(UIElementConstantsBase <UIElementBase> .Fields.Owner.Label, "تاریخ انتشار");

                NewResource(UIElementConstantsBase <UIElementBase> .Fields.DeletionHistory.Label, "آدرس آی پی");

                transaction.Commit();
            }
        }
        public override void InstallResources(IStatelessSession session)
        {
            UseSession(session);

            using (var osansaction = session.BeginTransaction()) {
                NewResource(OrderStatusConstants.Fields.SystemName.Label, "وضعیت (بانک)");
                NewResource(OrderStatusConstants.Fields.DisplayName.Label, "وضعیت (بانک)");
                NewResource(OrderStatusConstants.Fields.Description.Label, "شناسه خودگردان");

                NewResource(OrderStatusConstants.Fields.Orders.Label, "شناسه خودگردان");

                osansaction.Commit();
            }
        }
Example #32
0
        public IStatelessSession OpenStatelessSession()
        {
            if (_stateLessSession == null)
            {
                _stateLessSession = _sessionFactory.OpenStatelessSession();

                // Per fare tutto in fondo al commit
                //_session.FlushMode = FlushMode.Commit;

                //if (_transaction == null || !_transaction.IsActive)
                _transaction = _stateLessSession.BeginTransaction(IsolationLevel.ReadUncommitted);

                RefreshLanguageFilter();
            }

            return _stateLessSession;
        }
        public void Setup()
        {
            _sessionFactory = _configuration.BuildSessionFactory();
			_session = _sessionFactory.OpenStatelessSession();
            _transaction = _session.BeginTransaction();
        }