public TransactionEventInfo(PaoTransaction trans , bool screenshot = false , bool snapshot = false) : base(null, trans.ToString(), screenshot, snapshot) { Transaction = (PaoTransaction)IOPublic.ObjectClone(trans); if (trans.Status is TransStatus_Running) { Type = EventType_TransactionRunning; } else if (trans.Status is TransStatus_Committed) { Type = EventType_TransactionCommitted; } else if (trans.Status is TransStatus_Excepted) { Type = EventType_TransactionExcepted; InnerExceptionInfo = new ExceptionEventInfo(trans.Status.As <TransStatus_Excepted>().Exception); } else if (trans.Status is TransStatus_Failed) { Type = EventType_TransactionFailed; } else if (trans.Status is TransStatus_Rollbacked) { Type = EventType_TransactionRollbacked; } else if (trans.Status is TransStatus_RollbackExcepted) { Type = EventType_TransactionRollbackExcepted; InnerExceptionInfo = new ExceptionEventInfo(trans.Status.As <TransStatus_RollbackExcepted>().Exception); } }
private void TraverseConfigRows(ConfigDataSet.T_ConfigDataTable configTable, Func <PaoObject, bool> traverseMethod, string configName) { var dataRows = configTable.Cast <ConfigDataSet.T_ConfigRow>(); // 首先取出优先级较高的扩展配置 foreach (var extendRow in dataRows) { bool useConfig = false; if (!extendRow.IsFilterNull()) { var filter = (IClientFilter)IOPublic.Deserialize(extendRow.Filter); if (filter.Predicate(SecurityPublic.CurrentUser.UserID , SecurityPublic.CurrentUser.ComputerID)) { useConfig = true; } } else { useConfig = true; } if (useConfig) { var configObject = (PaoObject)IOPublic.Deserialize(extendRow.Config); if (!traverseMethod(configObject)) { return; } } } }
private void ButtonProperty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { UIPublic.ShowWaitingForm(); var propertyValue = EditValue; var objectType = propertyValue.GetType(); BaseObjectEditControl editControl = null; // 如果不是PaoObject类型,则显示默认编辑控件 if (!objectType.IsAddonType()) { editControl = EditorPublic.CreateEditControl(objectType) as BaseObjectEditControl; } if (editControl == null) { var editController = EditorPublic.GetOrCreateEditControllerFromStorage <ObjectLayoutEditController>(objectType); editControl = editController.CreateEditControl(objectType) as BaseObjectEditControl; } editControl.EditValue = IOPublic.ObjectClone(propertyValue); UIPublic.CloseWaitingForm(); if (WinFormPublic.ShowDialog(editControl) == DialogReturn.OK) { EditValue = editControl.EditValue; } SetControlStatus(); }
/// <summary> /// 创建事件 /// </summary> /// <param name="source">源</param> /// <param name="message">消息</param> /// <param name="type">事件类型</param> /// <param name="screenshot">是否截屏</param> /// <param name="snapshot">是否进行快照</param> /// <returns></returns> public EventInfo(string type , string message , bool screenshot = false , bool snapshot = false) { Source = "PAO"; Time = DateTime.Now; Message = message; Type = type; ScreenShot = screenshot ? UIPublic.ScreenShot() : (Image)null; AssetSnapshot = snapshot ? IOPublic.ObjectClone(PaoApplication.Default) : null; }
protected override void OnSetController(BaseController value) { var controller = value as ObjectConfigController; object addon; if (controller.ConfigFile.IsNullOrEmpty()) { addon = PaoApplication.Default; } else { addon = IOPublic.ReadObjectFromFile(controller.ConfigFile); } ObjectTreeEditControl.EditValue = addon; }
private void Requery() { if (FilePath == null) { return; } string filePath = AppPublic.GetAbsolutePath(FilePath); if (!File.Exists(filePath)) { return; } _DataTable = IOPublic.ReadObjectFromFile(filePath) as DataTable; }
/// <summary> /// 保存配置 /// </summary> /// <param name="dirPath">目录路径</param> public static void SaveConfigStorages(string dirPath) { if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } if (ConfigStorages == null) { return; } foreach (var configStorage in ConfigStorages.Values) { var fileName = String.Format("{0}.config", configStorage.StorageName); IOPublic.WriteObjectToFile(Path.Combine(dirPath, fileName), configStorage); } }
protected override RepositoryItem OnCreateRepositoryItem(Type objectType) { var repositoryItem = new RepositoryItemButtonEdit(); WinFormPublic.AddClearButton(repositoryItem); repositoryItem.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; repositoryItem.ButtonClick += (sender, e) => { var edit = (ButtonEdit)sender; if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis) { var editValue = edit.EditValue; BaseObjectEditControl editControl = CreateEditControl(objectType) as BaseObjectEditControl; if (edit.EditValue.IsNotNull()) { editControl.EditValue = IOPublic.ObjectClone(editValue); } else { editControl.EditValue = null; } if (WinFormPublic.ShowDialog(editControl) == DialogReturn.OK) { edit.EditValue = editControl.EditValue; } } }; repositoryItem.CustomDisplayText += (sender, e) => { if (e.Value.IsNull()) { e.DisplayText = "[空]"; } else if (e.Value.GetType().IsAddonListType() || e.Value.GetType().IsAddonDictionaryType()) { e.DisplayText = e.Value.GetType().GetTypeString(); } else { e.DisplayText = e.Value.ToString(); } }; return(repositoryItem); }
public void SaveLocalConfig(PaoObject configObject) { var dataService = DataService.Value; dataService.ExecuteBySql(Sql_DisableCurrentLocalConfig , new DataParameter("@ConfigName", configObject.ID) , new DataParameter("@ComputerID", SecurityPublic.CurrentUser.ComputerID) , new DataParameter("@SoftwareID", PaoApplication.Default.SoftwareID)); var configTable = new ConfigDataSet.T_ConfigDataTable(); var configRow = configTable.AddT_ConfigRow(Guid.NewGuid() , PaoApplication.Default.SoftwareID , SecurityPublic.CurrentUser.ComputerID , configObject.ID , Int32.MaxValue , DateTime.Now , DateTime.MaxValue , null , IOPublic.Serialize <byte[]>(configObject)); dataService.UpdateTable(configTable, "T_Config"); }
public void SaveGlobalConfig(PaoObject configObject, int priority, IClientFilter clientFilter) { var dataService = DataService.Value; SecurityPublic.DemandPermission(ID, Permission_SaveGlobalConfig); dataService.ExecuteBySql(Sql_DisableCurrentLocalConfig , new DataParameter("@ConfigName", configObject.ID) , new DataParameter("@SoftwareID", PaoApplication.Default.SoftwareID)); var configTable = new ConfigDataSet.T_ConfigDataTable(); var configRow = configTable.AddT_ConfigRow(Guid.NewGuid() , PaoApplication.Default.SoftwareID , null , configObject.ID , priority , DateTime.Now , DateTime.MaxValue , IOPublic.Serialize <byte[]>(clientFilter) , IOPublic.Serialize <byte[]>(configObject)); dataService.UpdateTable(configTable, "T_Config"); }
/// <summary> /// 设置配置 /// </summary> /// <param name="id">配置ID</param> /// <param name="configObject">配置对象</param> public void SetConfig(string id, object configObject) { if (Configs == null) { Configs = new Dictionary <string, object>(); } if (configObject.IsNull()) { return; } var cloneObject = IOPublic.ObjectClone(configObject); if (Configs.ContainsKey(id)) { Configs[id] = cloneObject; } else { Configs.Add(id, cloneObject); } }
/// <summary> /// 读取配置 /// </summary> /// <param name="dirPath">目录路径</param> public static void LoadConfigStorages(string dirPath) { ConfigStorages = new Dictionary <string, Config.ConfigStorage>(); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } var filePaths = Directory.GetFiles(dirPath, "*.config"); foreach (var filePath in filePaths) { try { var configStorage = IOPublic.ReadObjectFromFile(filePath) as ConfigStorage; if (configStorage != null) { ConfigStorages.Add(configStorage.StorageName, configStorage); } } catch (Exception err) { EventPublic.Exception(err); } } }
/// <summary> /// 启动应用程序 /// </summary> /// <param name="loadFromConfig">从配置加载</param> /// <param name="configFileName">配置文件名,此文件应该放于应用程序目录</param> /// <param name="createApplicationFunc">应用创建函数</param> /// <param name="applicationPrepareFunc">准备应用程序</param> /// <param name="overwriteConfigFile">覆盖配置文件</param> public static void StartApplication(bool loadFromConfig , string configFileName , Func <PaoApplication> createApplicationFunc , Action <PaoApplication> applicationPrepareFunc , bool overwriteConfigFile = false) { _AppDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; string configFilePath = Path.Combine(_AppDirectory, configFileName); //首先添加默认的日志记录器 EventPublic.ClearEventProcessor(); EventPublic.AddEventProcessor(DebugLogger.Default); EventPublic.AddEventProcessor(EventLogger.Default); PaoApplication app = null; TransactionPublic.Run("插件引擎启动", () => { TransactionPublic.Run("加载插件库", () => { AddonPublic.AddDirectory(AppDirectory); string libPathString = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath; if (!libPathString.IsNullOrEmpty()) { string[] libPaths = libPathString.Split(';'); foreach (var libDir in libPaths) { var libPath = GetAbsolutePath(libDir); AddonPublic.AddDirectory(libPath); } } // 重建插件类型列表 AddonPublic.RebuildAddonTypeList(); }); TransactionPublic.Run("加载配置", () => { if (createApplicationFunc == null) { throw new Exception("创建配置的方法不能为空"); } if (loadFromConfig && !File.Exists(configFilePath)) { app = IOPublic.ReadObjectFromFile(configFilePath).As <PaoApplication>(); } else { // 用应用创建函数启动应用 app = createApplicationFunc(); if (overwriteConfigFile || !File.Exists(configFilePath)) { // 保存配置文件 IOPublic.WriteObjectToFile(configFilePath, app); } } if (applicationPrepareFunc != null) { applicationPrepareFunc(app); } }); }); app.Start(); }
protected override T OnCreateInstance() { return(IOPublic.ReadObjectFromFile(FilePath).As <T>()); }
private void ButtonSaveConfig_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { IOPublic.ExportObject(PaoApplication.Default); }
/// <summary> /// 导出当前对象 /// </summary> public void ExportSelectedObject() { IOPublic.ExportObject(this.EditValue); }