public static void ShutDown() { if (_sessionContext != null) ((IDisposable) _sessionContext).Dispose(); _sessionContext = null; }
public void SaveWriteOff(SessionContext sessionContext, EVehicleWriteOff obj) { using (IRepository repository = SessionManager.CreateRepository(sessionContext.TenantCode)) { repository.Save(obj); } }
public ISession LogOn (string user) { ISession session = new SessionImpl (); SessionContext ctx = new SessionContext (session); CallContext.SetData ("session_ctx", ctx); return session; }
private static SessionContext GetSessionContext(string currentAssemblyLocation) { var configReader = new FilesystemConfigReader(new Filesystem(), new ConfigParser()); ConfigSettings settings = configReader.GetConfig(currentAssemblyLocation); if (!settings.AssemblyLocations.Any()) settings = configReader.GetConfig(Directory.GetCurrentDirectory()); if (!settings.AssemblyLocations.Any() && !_assemblies.Any()) { var message = "No storevil assemblies were found.\r\nCurrent location:" + currentAssemblyLocation + "\r\nCurrent directory:" + Directory.GetCurrentDirectory(); _nunitAssertWrapper.Ignore(message); } var assemblyRegistry = new AssemblyRegistry(_assemblies.Select(x=>x.Location).Union(settings.AssemblyLocations)); ParameterConverter.AddCustomConverters(assemblyRegistry); _sessionContext = new SessionContext(assemblyRegistry); _extensionMethodHandler = new ExtensionMethodHandler(assemblyRegistry); return _sessionContext; }
public void Returns_a_default_context_with_only_object_if_no_contexts_added() { var mapper = new SessionContext(); var result = mapper.GetContextForStory(); result.ImplementingTypes.Count().ShouldEqual(1); }
public void Should_Map_By_ContextAttribute() { var mapper = new SessionContext(); mapper.AddContext<TestMappingContext>(); var context = mapper.GetContextForStory(); context.ImplementingTypes.First().ShouldEqual(typeof (TestMappingContext)); }
public static void EndSession() { if (_sessionContext == null) return; _sessionContext.Dispose(); _sessionContext = null; }
public void Should_Register_Assembly_Types() { var mapper = new SessionContext(); mapper.AddAssembly(GetType().Assembly); var context = mapper.GetContextForStory(); context.ImplementingTypes.ShouldContain(typeof (TestMappingContext)); }
public EVehicleWriteOff Get(SessionContext sessionContext, Guid id) { using (IRepository repository = SessionManager.CreateRepository(sessionContext.TenantCode)) { return repository.Get<EVehicleWriteOff>(id); } }
public void Update(SessionContext SessionContext, EVehicleWriteOff VehicleWriteOff) { using (IRepository repository = SessionManager.CreateRepository(SessionContext.TenantCode)) { repository.Update(VehicleWriteOff); } }
public void Abolish(SessionContext sessionContext, EVehicleWriteOff vehicleWriteOff) { vehicleWriteOff.IsBlankOut = 1; using (IRepository repository = SessionManager.CreateRepository(sessionContext.TenantCode)) { repository.Update(vehicleWriteOff); } }
public void MyTestInitialize() { Context = new SessionContext(); SessionFactoryManager.BuildSchema(SessionFactoryManager.Test, Context.CurrentSession()); Context.CurrentSession().Transaction.Begin(); var fact = Context.CurrentSession().SessionFactory; ObjectFactory.Configure(x => x.For<ISessionFactory>().Use(fact)); }
protected DriverBase(IEventBus eventBus) { //ResultListener = resultListener; _eventBus = eventBus; var assemblyRegistry = new AssemblyRegistry(GetAssemblies()); ScenarioInterpreter = new ScenarioInterpreter(new InterpreterForTypeFactory(assemblyRegistry), new MostRecentlyUsedContext(), new DefaultLanguageService()); LineExecuter = new ScenarioLineExecuter(ScenarioInterpreter, _eventBus); _context = new SessionContext(assemblyRegistry); ParameterConverter.AddCustomConverters(assemblyRegistry); }
public void Throws_an_exception_with_a_message_indicating_the_problem() { var sessionContext = new SessionContext(); sessionContext.AddContext<ScenarioLifetimeTestMappingContext>(); sessionContext.AddContext<SessionLifetimeDependingOnScenarioLifetime>(); var scenarioContext = sessionContext.GetContextForStory().GetScenarioContext(); var ex = Expect.ThisToThrow<ConflictingLifetimeException>(()=>scenarioContext.GetContext(typeof(SessionLifetimeDependingOnScenarioLifetime))); ex.Message.ShouldContain(typeof(SessionLifetimeDependingOnScenarioLifetime).ToString()); ex.Message.ShouldContain(typeof(ScenarioLifetimeTestMappingContext).ToString()); }
public IList<EVehicleWriteOff> GetIsAbolishedVehicleWriteOffList(SessionContext SessionContext) { Query query = new Query(typeof(EVehicleWriteOff)); Expression exp = Expression.CreateExpression(EVehicleAccident.Properties.IsBlankOut, BinaryOperatorType.EqualTo, true); query.Expression = exp; using (IRepository repository = SessionManager.CreateRepository(SessionContext.TenantCode)) { return repository.List<EVehicleWriteOff>(query); } }
void RemoveSession(SessionContext session) { sessionToHandlesMap.Remove(session); if (OperationContext.Current != null) sessions.Remove(OperationContext.Current.SessionId); else sessions.Remove(session.SessionId); UpdateGlobalSendEmptyFrames(); UpdateGlobalImageSetting(ImageType.Binarized); UpdateGlobalImageSetting(ImageType.Normalized); }
public void CreateSession() { string sessionId = OperationContext.Current.SessionId; if (sessions.ContainsKey(sessionId)) throw new MultitouchException(string.Format("session '{0}' is already created", sessionId)); SessionContext context = new SessionContext(sessionId, OperationContext.Current.GetCallbackChannel<IApplicationInterfaceCallback>()); sessions.Add(sessionId, context); sessionToHandlesMap.Add(context, new HashSet<IntPtr>()); UpdateGlobalSendEmptyFrames(); UpdateGlobalImageSetting(ImageType.Binarized); UpdateGlobalImageSetting(ImageType.Normalized); }
public IList<EVehicleWriteOff> Search(SessionContext sessionContext,PES.Logistics.Entity.SearchCriteria criteria) { Query query = new Query(typeof(EVehicleWriteOff)); query.Expression = criteria.Expression; using (IRepository repository = SessionManager.CreateRepository(sessionContext.TenantCode)) { IList<EVehicleWriteOff> list = repository.List<EVehicleWriteOff>(query); criteria.RecordCount = list.Count; } criteria.PageIndex = (criteria.PageIndex - 1) * criteria.PageSize; query.Index = criteria.PageIndex; query.Count = criteria.PageSize; using (IRepository repository = SessionManager.CreateRepository(sessionContext.TenantCode)) { return repository.List<EVehicleWriteOff>(query); } }
/// <summary> /// Create a new instance of the EmployeePresenter /// </summary> /// <param name="view">View to bind to</param> public EmployeePresenter(IViewEmployee view) { // Bind to all view events _view = view; _view.Add += View_Add; _view.Get += View_Get; _view.GetAll += View_GetAll; _view.Remove += View_Remove; _view.Edit += View_Edit; _view.Update += View_Update; // Configure a new repository var sessionFactManager = new SessionFactoryManager(); SessionContext = new SessionContext(sessionFactManager); _employeeRepository = new EmployeeRepository<Employee>(SessionContext); }
/// <summary> /// Creates a new instance of the store presenter /// </summary> /// <param name="view">View to bind to</param> public StorePresenter(IViewStore view) { // Bind to all view events _view = view; _view.Add += View_Add; _view.Get += View_Get; _view.GetAll += View_GetAll; _view.Remove += View_Remove; _view.Edit += View_Edit; _view.Update += View_Update; // Create new repository var sessionFactManager = new SessionFactoryManager(); SessionContext = new SessionContext(sessionFactManager); _storeRepository = new StoreRepository<Store>(SessionContext); }
public IList<VRealTimeInfo> GetRealTimeInfo(string[] arrVehicleCode, SessionContext sessionContext) { IList<VRealTimeInfo> list = GetRealTimeInfo(arrVehicleCode, sessionContext, false,false); if (list != null && list.Count > 0) { IVehicleMobileRelationService service = new VehicleMobileRelationService(); IList<Guid> ltVehicleCode = service.GetUsingVehicleCode(sessionContext.TenantCode); if (ltVehicleCode != null && ltVehicleCode.Count > 0) { foreach (var item in list) { if (ltVehicleCode.Contains(item.VehicleInfo.Code)) { item.CanMobilePosition = true; } } } } return list; }
public void MyTestCleanup() { try { if (_commit) { Context.CurrentSession().Transaction.Commit(); } else Context.CurrentSession().Transaction.Rollback(); } catch (Exception) { Context.CurrentSession().Transaction.Rollback(); throw; } finally { Context.Dispose(); Context = null; } }
public IResponse Execute(SessionContext sessionContext, string parameter) { System.Environment.Exit(0); return(new Response(ResponseType.Ok)); }
public void SetupContext() { Mapper = new SessionContext(); Mapper.AddContext<TestStoryLifetimeMappingContext>(); }
public PiranhaMessage(SessionContext sessionContext) { SessionContext = sessionContext; Writer = Unpooled.Buffer(5); }
public static IMultiCriteria MultiCriteria <T>(this SessionContext sc) { return(sc.Session.CreateMultiCriteria()); }
public VTenant GetSelectedTenant(SessionContext passport) { var lastSelectTenantCode = CacheDataManager.GetCookieLastSelectTenantCode(passport.UserName); if (!string.IsNullOrEmpty(lastSelectTenantCode) && lastSelectTenantCode != passport.TenantCode) { // 如果选择的租户已被删除或不存在,则需要重新选择自己 var tenant = DACFacade.Movo.TenantDAC.Select(lastSelectTenantCode); if (tenant != null) { if (tenant.TenantType != EnumTenantType.OperatingMerchant) { tenant = DACFacade.Movo.TenantDAC.Select(tenant.SuperTenantID); } return new VTenant { TenantCode = tenant.TenantCode, TenantName = tenant.TenantName }; } } return new VTenant { TenantCode = passport.TenantCode, TenantName = passport.TenantName, }; }
public RestoreOperation(IFeatureConfigurationBackup backup, ILogger logger, SessionContext sessionContext) { this.backup = backup; this.logger = logger; this.sessionContext = sessionContext; }
public ShortcutRepository(SessionContext sessionContext, TemplateProcessor templateProcessor, ResourceRepository resourceRepository) { _sessionContext = sessionContext ?? throw new ArgumentNullException(nameof(sessionContext)); _templateProcessor = templateProcessor ?? throw new ArgumentNullException(nameof(templateProcessor)); _resourceRepository = resourceRepository ?? throw new ArgumentNullException(nameof(resourceRepository)); }
public SharedSessionContext(SessionContext context, IPayloadCache payloadCache, CancellationToken cancellationToken) { _context = context; _payloadCache = payloadCache; _cancellationToken = cancellationToken; }
// NH Extensions public static ICriteria Criteria <T>(this SessionContext sc) where T : class { return(sc.Session.CreateCriteria <T>()); }
public static Department Get(SessionContext context, long id) { return(context.PersistenceSession.Get <Department>(id)); }
Task Delete(SessionContext context, Queue queue) { LogContext.Debug?.Log("Delete Queue {Queue}", queue); return(context.DeleteQueue(queue.EntityName)); }
public static IList <Department> GetByMinistry(SessionContext context, long ministryId) { return(context.PersistenceSession.QueryOver <Department>() .Where(x => x.Ministry.ID == ministryId) .List()); }
public static IList <Department> GetAll(SessionContext context) { return(context.PersistenceSession.QueryOver <Department>().List()); }
public PiranhaMessage(SessionContext sessionContext, IByteBuffer buffer) { SessionContext = sessionContext; Reader = buffer; }
public TestInitialStateBootstrapper(FileSystem fileSystem, SystemVariableMockup systemVariable, SessionContext sessionContext, UserspaceRepository userspaceRepository, WorkspaceRepository workspaceRepository) : base(sessionContext, userspaceRepository, workspaceRepository) { _fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); _systemVariable = systemVariable ?? throw new ArgumentNullException(nameof(systemVariable)); }
Task Delete(SessionContext context, Topic topic) { LogContext.Debug?.Log("Delete Topic {Topic}", topic); return(context.DeleteTopic(topic.EntityName)); }
public DoSpellCommand(SessionContext ctx, IByteBuffer buffer) : base(ctx, buffer) { Type = 1; }
Task Declare(SessionContext context, Queue queue) { LogContext.Debug?.Log("Get queue {Queue}", queue); return(context.GetQueue(queue.EntityName)); }
/// <summary> /// 新增客户 /// </summary> public void AddCustomer(SessionContext passport, string userName, string password, string tenantName, string phoneNumber, string email) { var selected = this.GetSelectedTenant(passport); var parentMerchant = DACFacade.Movo.TenantDAC.Select(selected.TenantCode); if (parentMerchant == null) throw new BusinessException("父级运营商不存在!"); //if (parentMerchant.OperatorLevel + 1 > 5) throw new BusinessException("新增失败,子运营商不能多于5级!"); var existUser = DACFacade.Movo.UserDAC.SelectByName(userName); if (existUser != null) { throw new BusinessException("用户名" + userName + "已经存在,请重新输入!"); } var existTenant = DACFacade.Movo.TenantDAC.SelectByName(tenantName); if (existTenant != null) { throw new BusinessException("公司名称" + tenantName + "已经存在,请重新输入!"); } // 构建Tenant var tenant = new ETenant(); tenant.TenantCode = DACFacade.Movo.IdentityNoDAC.GetTenantSerialNo(); tenant.TenantName = tenantName; tenant.SuperTenantID = parentMerchant.TenantCode; tenant.CreateTime = DateTime.Now; tenant.ExpireTime = null; tenant.ContactName = string.Empty; tenant.PhoneNumber = phoneNumber; tenant.TenantType = EnumTenantType.EndCustomer; tenant.IsFreeze = false; tenant.QQ = string.Empty; tenant.Email = email; tenant.RegisterUserCode = DACFacade.Movo.IdentityNoDAC.GetUserSerialNo(); tenant.RegisterUserName = userName; tenant.OperatorLevel = null; tenant.LogoUrl = null; // 构建UserGroup var userGroup = new EUserGroup() { UserGroupID = DACFacade.Movo.IdentityNoDAC.GetUserGroupID(), UserGroupName = "管理员", TenantCode = tenant.TenantCode, IsAdminGroup = true, }; // 构建User var user = new EUser(); user.UserCode = tenant.RegisterUserCode; user.UserName = userName; user.UserGroupID = userGroup.UserGroupID; user.TenantCode = tenant.TenantCode; if (!string.IsNullOrEmpty(password)) user.PassWord = password; user.RealName = userName; user.Mobile = string.Empty; user.IsRegisterUser = true; user.LastLoginTime = null; user.CreateTime = DateTime.Now; // 构建VehicleGroup var vehGroup = new EVehicleGroup() { GroupID = DACFacade.Movo.IdentityNoDAC.GetVehicleGroupID(), GroupName = userName, TenantCode = tenant.TenantCode, }; using (var trans = DACFacade.Movo.TenantDAC.BeginTransaction()) { try { DACFacade.Movo.UserDAC.Insert(trans, user); DACFacade.Movo.UserGroupDAC.Insert(trans, userGroup); DACFacade.Movo.VehicleGroupDAC.Insert(trans, vehGroup); DACFacade.Movo.TenantDAC.Insert(trans, tenant); DACFacade.Movo.TenantDAC.CommitTransaction(trans); } catch { DACFacade.Movo.TenantDAC.RollbackTransaction(trans); throw; } } }
Task Declare(SessionContext context, Topic topic) { LogContext.Debug?.Log("Get topic {Topic}", topic); return(context.GetTopic(topic.EntityName)); }
public void SetupContext() { var mapper = new SessionContext(); mapper.AddContext<ScenarioLifetimeTestMappingContext>(); StoryContext = mapper.GetContextForStory(); }
async Task ConfigureTopology(SessionContext context) { await Task.WhenAll(_brokerTopology.Topics.Select(topic => Declare(context, topic))).ConfigureAwait(false); await Task.WhenAll(_brokerTopology.Queues.Select(queue => Declare(context, queue))).ConfigureAwait(false); }
/// <summary> /// 获取选定的租户直到当前登录租户的父子链 /// </summary> public IList<ETenant> GetTenantDescendants(SessionContext passport, string tenantCode) { var result = new List<ETenant>(); var item = DACFacade.Movo.TenantDAC.Select(tenantCode); result.Insert(0, item); while (!string.IsNullOrEmpty(item.SuperTenantID) && item.TenantCode != passport.TenantCode) { item = DACFacade.Movo.TenantDAC.Select(item.SuperTenantID); result.Insert(0, item); } return result; }
public ExportedCommand(SessionContext sessionContext) : base(sessionContext) { }
public static IQuery Query(this SessionContext sc, string queryString) { return(sc.Session.CreateQuery(queryString)); }
public SectorCommandMessage(SessionContext ctx, IByteBuffer reader) : base(ctx, reader) { Id = 12904; }
public static ISessionContext SessionContext(string location) { return _sessionContext = _sessionContext ?? GetSessionContext(location); }
public IdentityStatesService(DatabaseContext context, SessionContext sessionContext) { _context = context; _sessionContext = sessionContext; }
private void CallSwisscomWsAsync(IndexViewModel model, string datenbankBez, string mandantUrl) { if (BypassMobileId) { CallSwisscomWsMockAsync(model, datenbankBez, mandantUrl); return; } var ctxt = new SessionContext() { DatenbankId = model.datenbankId, Handynummer = model.handynummer, IsAdmin = model.isAdmin, Shortname = model.shortname }; Session["SessionContext"] = ctxt; var certDir = Server.MapPath("~/Certificates"); Task.Run(() => { var message = string.Format("DIALOG: {0}", ConfigurationManager.AppSettings["MobileIdText"]); var mid = new SwisscomMobileID(true, true, model.handynummer, message, "de", Server.MapPath("/"), certDir); try { var entities = new DialogConfigBLEntities(); using (entities) { var req = new MIDRequest() { DatenbankId = model.datenbankId, Erfolgreich = false, Handynummer = model.handynummer, Hash = "", IsAdmin = model.isAdmin, RequestId = model.requestId, ResponseMessage = "", Shortname = model.shortname, Status = "pending", Url = "", Token = "" }; entities.MIDRequests.Add(req); entities.SaveChanges(); var returnCode = 0; mid.Execute(out returnCode); // ... // ... // ... var q = from x in entities.MIDRequests where x.RequestId == model.requestId select x; if (q.Any()) { var x = q.First(); x.Status = "ready"; x.Erfolgreich = false; x.ResponseMessage = ""; //x.Url = "http://" + mandantUrl; x.Url = mandantUrl.StartsWith("http") ? mandantUrl : "http://" + mandantUrl; x.Shortname = model.shortname; var enUs = new CultureInfo("en-us"); var data = string.Format( "<?xml version='1.0' encoding='utf-8' ?>" + "<data>" + "<user>{0}</user>" + "<database>{1}</database>" + "<module>{2}</module>" + "<timestamp>{3}</timestamp>" + "</data>", model.shortname, datenbankBez, model.module, DateTime.Now.ToString(enUs.DateTimeFormat)); x.Token = Convert.ToBase64String(Encoding.UTF8.GetBytes(data)); x.Hash = Sign(x.Token, _TokenSigningCertificate2); x.Handynummer = model.handynummer; x.DatenbankId = model.datenbankId; switch (returnCode) { case RETURN_OK: x.ResponseMessage = "Mobile ID korrekt eingegeben."; x.Erfolgreich = true; break; case RETURN_REJECT: x.ResponseMessage = "MID Abfrage abgelehnt/storniert."; break; case RETURN_FAIL: x.ResponseMessage = "Ausnahme während der Bearbeitung der Abfrage. Mögliche Ursache: Mobile-ID beim Provider nicht aktiviert."; break; case RETURN_INVALID: x.ResponseMessage = "Ungültige Abfrage/Konfiguration."; break; case RETURN_BLOCKED: x.ResponseMessage = "Benutzer oder Token blockiert."; break; case RETURN_NOTFOUND: x.ResponseMessage = "Benutzer nicht gefunden."; break; } entities.SaveChanges(); } } } catch (Exception ex) { var entities = new DialogConfigBLEntities(); using (entities) { var q = from x in entities.MIDRequests where x.RequestId == model.requestId select x; if (q.Any()) { var x = q.First(); x.Erfolgreich = false; x.ResponseMessage = "Ausnahme: " + ex.Message; x.Status = "ready"; entities.SaveChanges(); } } } }); }
public SharedSessionContext(SessionContext context, CancellationToken cancellationToken) { _context = context; _cancellationToken = cancellationToken; }
public Task All(SessionContext context, Func <TupleContext <T>, Task> callback) { return(context.WorkingMemory.Access(this, x => x.ForEach(context, callback))); }
public static IMultiQuery MultiQuery(this SessionContext sc) { return(sc.Session.CreateMultiQuery()); }
public void SetupContext() { Context = new SessionContext(); Context.AddContext<TestSessionLifetimeMappingContext>(); }
public static IList <Ministry> GetAll(SessionContext context) { return(context.PersistenceSession.QueryOver <Ministry>().List()); }
public Task Insert(SessionContext context, ITuple tuple, T fact) { return(TaskUtil.Completed); }
public static Ministry Get(SessionContext context, long id) { return(context.PersistenceSession.Get <Ministry>(id)); }
protected virtual void ProcessMessage(SessionContext ctx) { if (ctx == null) return; TaskFactory factory = Task.Factory; if (IsOrderlyProcess && ctx.Session != null) factory = WebMessage.GetSingleTaskFactory(ctx.Session); if (factory != null) { factory.StartNew((Action<object>)((param) => { DispatchMessage(param); }), ctx); } else DispatchMessage(ctx); }
public bool CheckLayoutAvailability(SessionContext sessionContext, BaseResolveContext resolveContext, out string messsage) { messsage = null; return(true); }