/// <summary>序列化缓存信息</summary> /// <returns></returns> public virtual AccountCacheInfo Serialize(string appKey, string sessionId, IAccountInfo account) { AccountCacheInfo accountCache = new AccountCacheInfo(); accountCache.AccountIdentity = sessionId; accountCache.AppKey = appKey; accountCache.AccountCacheValue = account.LoginName; accountCache.AccountObject = this.SerializeObject(account); accountCache.AccountObjectType = KernelContext.ParseObjectType(account.GetType()); accountCache.IP = account.IP; accountCache.HttpUserAgent = HttpContext.Current == null ? string.Empty : HttpContext.Current.Request.UserAgent; accountCache.ValidFrom = DateTime.Now; accountCache.ValidTo = accountCache.ValidFrom.AddMonths(3); accountCache.Date = DateTime.Now; return(accountCache); }
public KSession(KernelContext context, KClientPort parentPort = null) : base(context) { ServerSession = new KServerSession(context, this); ClientSession = new KClientSession(context, this, parentPort); _hasBeenInitialized = true; }
public IActionResult StartValidation() { // We'll need to define this later; var blobContainer = "username"; var blobFolder = $"sessions/{Guid.NewGuid()}"; var writer = new ContextWriter(_storageService, blobContainer, blobFolder); var reader = new ContextReader(_storageService, blobContainer); var kernelContext = new KernelContext { OpenWriteData = writer.OpenWrite, WriteData = writer.Write, CloseWriteData = writer.CloseWrite, OpenReadData = reader.OpenRead, ReadData = reader.Read, CloseReadData = reader.CloseRead, LogDebug = Console.WriteLine }; using (var kernel = _cppKernelFactory.Create(kernelContext)) { kernel.StartValidation(); } return(Ok(new { blobContainer, blobFolder })); }
public KClientPort(KernelContext context, KPort parent, int maxSessions) : base(context) { _maxSessions = maxSessions; _parent = parent; _countIncLock = new object(); }
public KAddressArbiter(KernelContext context) { _context = context; _condVarThreads = new List <KThread>(); _arbiterThreads = new List <KThread>(); }
public static void Yield(KernelContext context) { KThread currentThread = KernelStatic.GetCurrentThread(); if (!currentThread.IsSchedulable) { return; } context.CriticalSection.Enter(); if (currentThread.SchedFlags != ThreadSchedState.Running) { context.CriticalSection.Leave(); return; } KThread nextThread = context.PriorityQueue.Reschedule(currentThread.DynamicPriority, currentThread.ActiveCore, currentThread); if (nextThread != currentThread) { context.ThreadReselectionRequested = true; } context.CriticalSection.Leave(); }
/// <summary>构造函数:TaskWorkService()</summary> public TaskWorkService() { // 创建对象构建器(Spring.NET) string springObjectFile = TasksConfigurationView.Instance.Configuration.Keys["SpringObjectFile"].Value; SpringObjectBuilder objectBuilder = SpringObjectBuilder.Create(TasksConfiguration.ApplicationName, springObjectFile); // 创建数据提供器 this.provider = objectBuilder.GetObject <ITaskWorkProvider>(typeof(ITaskWorkProvider)); // 创建提醒程序 var list = TasksConfigurationView.Instance.Configuration.Notifications; for (var i = 0; i < list.AllKeys.Length; i++) { var type = list[list.AllKeys[i]].Value; if (!string.IsNullOrEmpty(type)) { var obj = KernelContext.CreateObject(type); if (obj != null && obj is INotificationProvider) { this.notifications.Add(list.AllKeys[i], (INotificationProvider)obj); } } } }
public KServerPort(KernelContext context, KPort parent) : base(context) { _parent = parent; _incomingConnections = new LinkedList <KServerSession>(); _lightIncomingConnections = new LinkedList <KLightServerSession>(); }
public IProcessContext Create(KernelContext context, ulong pid, ulong addressSpaceSize, InvalidAccessHandler invalidAccessHandler, bool for64Bit) { MemoryManagerMode mode = context.Device.Configuration.MemoryManagerMode; if (!MemoryBlock.SupportsFlags(MemoryAllocationFlags.ViewCompatible)) { mode = MemoryManagerMode.SoftwarePageTable; } switch (mode) { case MemoryManagerMode.SoftwarePageTable: var memoryManager = new MemoryManager(context.Memory, addressSpaceSize, invalidAccessHandler); return(new ArmProcessContext <MemoryManager>(pid, _cpuEngine, _gpu, memoryManager, for64Bit)); case MemoryManagerMode.HostMapped: case MemoryManagerMode.HostMappedUnsafe: bool unsafeMode = mode == MemoryManagerMode.HostMappedUnsafe; var memoryManagerHostMapped = new MemoryManagerHostMapped(context.Memory, addressSpaceSize, unsafeMode, invalidAccessHandler); return(new ArmProcessContext <MemoryManagerHostMapped>(pid, _cpuEngine, _gpu, memoryManagerHostMapped, for64Bit)); default: throw new ArgumentOutOfRangeException(); } }
/// <summary>执行任务</summary> /// <param name="options"></param> static void RunTask(Options options) { DataDumpTask task = DataDumpConfiguration.Instance.Tasks[options.TaskName]; if (task == null) { Console.WriteLine("task : " + options.TaskName + " is null"); } else { Console.WriteLine("task : " + options.TaskName + " running..."); IDataDumpProvider provider = (IDataDumpProvider)KernelContext.CreateObject(task.DataDumpProvider); provider.Init(task); var result = provider.Generate(); Console.WriteLine("result => " + result); // 输出位置 string path = StringHelper.NullTo(options.OutputFile, task.OutputFile); if (!string.IsNullOrEmpty(path)) { path = Path.Combine(KernelConfigurationView.Instance.ApplicationPathRoot, path); File.WriteAllText(path, result, Encoding.UTF8); } } }
// ------------------------------------------------------- // 保存 删除 // ------------------------------------------------------- #region 函数:Save(BugCategoryInfo param) /// <summary>保存记录</summary> /// <param name="param">实例<see cref="BugCategoryInfo"/>详细信息</param> /// <returns>实例<see cref="BugCategoryInfo"/>详细信息</returns> public BugCategoryInfo Save(BugCategoryInfo param) { if (string.IsNullOrEmpty(param.Id)) { throw new Exception("实例标识不能为空。"); } bool isNewObject = !this.IsExist(param.Id); string methodName = isNewObject ? "新增" : "编辑"; IAccountInfo account = KernelContext.Current.User; if (methodName == "新增") { param.AccountId = account.Id; param.AccountName = account.Name; } this.provider.Save(param); // 保存实体数据操作记录 EntityLifeHistoryInfo history = new EntityLifeHistoryInfo(); history.Id = DigitalNumberContext.Generate("Key_Guid"); history.AccountId = account.Id; history.MethodName = methodName; history.EntityId = param.Id; history.EntityClassName = KernelContext.ParseObjectType(typeof(BugInfo)); history.ContextDiffLog = string.Empty; EntitiesManagement.Instance.EntityLifeHistoryService.Save(history); return(param); }
protected virtual void Dispose(bool disposing) { if (!_isDisposed && disposing) { _isDisposed = true; KProcess terminationProcess = new KProcess(KernelContext); KThread terminationThread = new KThread(KernelContext); terminationThread.Initialize(0, 0, 0, 3, 0, terminationProcess, ThreadType.Kernel, () => { // Force all threads to exit. lock (KernelContext.Processes) { // Terminate application. foreach (KProcess process in KernelContext.Processes.Values.Where(x => x.Flags.HasFlag(ProcessCreationFlags.IsApplication))) { process.Terminate(); } // The application existed, now surface flinger can exit too. SurfaceFlinger.Dispose(); // Terminate HLE services (must be done after the application is already terminated, // otherwise the application will receive errors due to service termination. foreach (KProcess process in KernelContext.Processes.Values.Where(x => !x.Flags.HasFlag(ProcessCreationFlags.IsApplication))) { process.Terminate(); } } // Exit ourself now! KernelStatic.GetCurrentThread().Exit(); }); terminationThread.Start(); // Wait until the thread is actually started. while (terminationThread.HostThread.ThreadState == ThreadState.Unstarted) { Thread.Sleep(10); } // Wait until the termination thread is done terminating all the other threads. terminationThread.HostThread.Join(); // Destroy nvservices channels as KThread could be waiting on some user events. // This is safe as KThread that are likely to call ioctls are going to be terminated by the post handler hook on the SVC facade. INvDrvServices.Destroy(); AudioManager.Dispose(); AudioOutputManager.Dispose(); AudioInputManager.Dispose(); AudioRendererManager.Dispose(); KernelContext.Dispose(); } }
public IAudioOut(KernelContext kernelContext, IAalOutput audioOut, KEvent releaseEvent, int track, int clientHandle) { _kernelContext = kernelContext; _audioOut = audioOut; _releaseEvent = releaseEvent; _track = track; _clientHandle = clientHandle; }
public override Lifecycle NewInstance(KernelContext context, Dependencies dependencies) { if (!IsCausalClusterInstance(context) && IsDefaultDatabase(dependencies.NeoStoreDataSource(), dependencies.Config)) { return(new OnlineBackupKernelExtension(dependencies.Config, dependencies.GraphDatabaseAPI, dependencies.LogService().InternalLogProvider, dependencies.Monitors(), dependencies.NeoStoreDataSource(), dependencies.FileSystemAbstraction())); } return(new LifecycleAdapter()); }
/// <summary>查询应用的权限信息</summary> /// <param name="applicationId">应用标识</param> /// <param name="authorityName">权限名称</param> /// <returns></returns> public IList <MembershipAuthorizationScopeObject> GetAuthorizationScopeObjects(string entityId, string authorityName) { return(MembershipManagement.Instance.AuthorizationObjectService.GetAuthorizationScopeObjects( string.Format("{0}_Scope", this.tableName), entityId, KernelContext.ParseObjectType(typeof(ApplicationSettingInfo)), authorityName)); }
/// <summary>初始化</summary> protected void Initialize() { // 绑定存储策略信息 this.storageStrategy = (IStorageStrategy)KernelContext.CreateObject(this.storageSchema.StrategyClassName); // 绑定存储节点信息 this.storageNodes = StorageContext.Instance.StorageNodeService.FindAllBySchemaId(storageSchema.Id); }
public KTransferMemory(KernelContext context, SharedMemoryStorage storage) : base(context) { _pageList = storage.GetPageList(); Permission = KMemoryPermission.ReadAndWrite; _hasBeenInitialized = true; _isMapped = false; }
/// <summary>获取实体类名称</summary> /// <param name="type"></param> /// <returns></returns> public string GetEntityClassName(Type type) { string objectType = KernelContext.ParseObjectType(type); EntitySchemaInfo param = Instance.EntitySchemaService.FindOneByEntityClassFullName(objectType); return(param == null ? objectType : param.EntityClassName); }
private KThread CreateIdleThread(KernelContext context, int cpuCore) { KThread idleThread = new KThread(context); idleThread.Initialize(0UL, 0UL, 0UL, PrioritiesCount, cpuCore, null, ThreadType.Dummy, IdleThreadLoop); return(idleThread); }
public static void EnableScheduling(KernelContext context, ulong scheduledCoresMask) { KScheduler currentScheduler = context.Schedulers[KernelStatic.GetCurrentThread().CurrentCore]; // Note that "RescheduleCurrentCore" will block, so "RescheduleOtherCores" must be done first. currentScheduler.RescheduleOtherCores(scheduledCoresMask); currentScheduler.RescheduleCurrentCore(); }
/// <summary>查询应用功能的权限信息</summary> /// <param name="entityId">应用功能标识</param> /// <param name="authorityName">权限名称</param> /// <returns></returns> public IList <MembershipAuthorizationScopeObject> GetAuthorizationScopeObjects(string entityId, string authorityName) { return(MembershipManagement.Instance.AuthorizationObjectService.GetAuthorizationScopeObjects( "tb_Application_Feature_Scope", entityId, KernelContext.ParseObjectType(typeof(ApplicationFeatureInfo)), authorityName)); }
public static void YieldWithLoadBalancing(KernelContext context) { KThread currentThread = KernelStatic.GetCurrentThread(); context.CriticalSection.Enter(); if (currentThread.SchedFlags != ThreadSchedState.Running) { context.CriticalSection.Leave(); return; } int prio = currentThread.DynamicPriority; int core = currentThread.ActiveCore; // Move current thread to the end of the queue. KThread nextThread = context.PriorityQueue.Reschedule(prio, core, currentThread); IEnumerable <KThread> SuitableCandidates() { foreach (KThread suggested in context.PriorityQueue.SuggestedThreads(core)) { int suggestedCore = suggested.ActiveCore; if (suggestedCore >= 0) { KThread selectedSuggestedCore = context.Schedulers[suggestedCore]._state.SelectedThread; if (selectedSuggestedCore == suggested || (selectedSuggestedCore != null && selectedSuggestedCore.DynamicPriority < 2)) { continue; } } // If the candidate was scheduled after the current thread, then it's not worth it, // unless the priority is higher than the current one. if (suggested.LastScheduledTime <= nextThread.LastScheduledTime || suggested.DynamicPriority < nextThread.DynamicPriority) { yield return(suggested); } } } KThread dst = SuitableCandidates().FirstOrDefault(x => x.DynamicPriority <= prio); if (dst != null) { context.PriorityQueue.TransferToCore(dst.DynamicPriority, core, dst); context.ThreadReselectionRequested = true; } else if (currentThread != nextThread) { context.ThreadReselectionRequested = true; } context.CriticalSection.Leave(); }
/// <summary>表单内容界面</summary> /// <returns></returns> public ActionResult Form(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[BugConfiguration.ApplicationName]; // 管理员身份标记 bool isAdminToken = ViewBag.isAdminToken = AppsSecurity.IsAdministrator(this.Account, application.ApplicationName); // ------------------------------------------------------- // 业务数据处理 // ------------------------------------------------------- JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); // 文档编辑模式 DocEditMode docEditMode = DocEditMode.Unkown; // 实体数据信息 BugInfo param = null; if (string.IsNullOrEmpty(id)) { param = new BugInfo(); param.Id = DigitalNumberContext.Generate("Table_Bug_Key_Id"); // 设置编辑模式【新建】 docEditMode = DocEditMode.New; } else { param = BugContext.Instance.BugService.FindOne(id); if (param == null) { ApplicationError.Write(404); } // 设置编辑模式【编辑】 docEditMode = DocEditMode.Edit; } // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- ViewBag.Title = string.Format("{0}-{1}-{2}", (string.IsNullOrEmpty(param.Title) ? "新问题" : param.Title), application.ApplicationDisplayName, this.SystemName); // 加载当前业务实体类名称 ViewBag.entityClassName = KernelContext.ParseObjectType(param.GetType()); // 加载当前业务实体数据 ViewBag.param = param; // 加载当前文档编辑模式 ViewBag.docEditMode = docEditMode; return(View("/views/main/bugs/bug-form.cshtml")); }
/// <summary>执行</summary> /// <returns></returns> public override object Execute() { // entityClassName this.target = KernelContext.CreateObject(this.className); Type type = this.target.GetType(); return(type.InvokeMember(this.methodName, BindingFlags.InvokeMethod, null, target, new object[] { doc })); }
internal CsvOutput(Config config, MetricRegistry registry, Log logger, KernelContext kernelContext, FileSystemAbstraction fileSystem, JobScheduler scheduler) { this._config = config; this._registry = registry; this._logger = logger; this._kernelContext = kernelContext; this._fileSystem = fileSystem; this._scheduler = scheduler; }
// ------------------------------------------------------- // 授权范围管理 // ------------------------------------------------------- #region 函数:HasAuthority(string entityId, string authorityName, IAccountInfo account) /// <summary>判断用户是否拥数据权限信息</summary> /// <param name="entityId">实体标识</param> /// <param name="authorityName">权限名称</param> /// <param name="account">帐号</param> /// <returns>布尔值</returns> public bool HasAuthority(string entityId, string authorityName, IAccountInfo account) { return(MembershipManagement.Instance.AuthorizationObjectService.HasAuthority( string.Format("{0}_Scope", this.tableName), entityId, KernelContext.ParseObjectType(typeof(ApplicationSettingInfo)), authorityName, account)); }
public static KAutoObject FindNamedObject(KernelContext context, string name) { if (context.AutoObjectNames.TryGetValue(name, out KAutoObject obj)) { return(obj); } return(null); }
public static KernelResult RemoveName(KernelContext context, string name) { if (!context.AutoObjectNames.TryRemove(name, out _)) { return(KernelResult.NotFound); } return(KernelResult.Success); }
/// <summary>配置应用的权限信息</summary> /// <param name="entityId">应用标识</param> /// <param name="authorityName">权限名称</param> /// <param name="scopeText">权限范围的文本</param> public void BindAuthorizationScopeObjects(string entityId, string authorityName, string scopeText) { MembershipManagement.Instance.AuthorizationObjectService.BindAuthorizationScopeObjects( string.Format("{0}_Scope", this.tableName), entityId, KernelContext.ParseObjectType(typeof(ApplicationSettingInfo)), authorityName, scopeText); }
/// <summary>查询应用的权限信息</summary> /// <param name="entityId">实体标识</param> /// <param name="authorityName">权限名称</param> /// <returns></returns> public IList <MembershipAuthorizationScopeObject> GetAuthorizationScopeObjects(string entityId, string authorityName) { return(MembershipManagement.Instance.AuthorizationObjectService.GetAuthorizationScopeObjects( this.ibatisMapper.CreateGenericSqlCommand(), string.Format("{0}_Scope", this.tableName), entityId, KernelContext.ParseObjectType(typeof(ForumCategoryInfo)), authorityName)); }