public static PackageContentType GetContentType(string filePath) { FileStream fs = null; int firstByte; try { fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); firstByte = sr.Read(); } catch { return(PackageContentType.Wrong); } finally { if (fs != null) { fs.Close(); } } if (firstByte == 60) { PackageBody body = GinSerializer.Deserialize <PackageBody>(filePath); return(body.ContentType); } if (firstByte == 31) { return(PackageContentType.Packed); } return(PackageContentType.Wrong); }
private void InitMetadata() { GinMetaData metadata = GinMetaData.GetInstance(); string pluginsPath = Path.Combine(_ginRoot, "Plugins"); metadata.Plugin(pluginsPath); GinSerializer.IncludeTypes(metadata.IncludedTypes); }
public void Save(IExecutionContext context) { string transactionsPath = context.ExecutedPackage.TransactionsPath; string transactionPath = Path.Combine(transactionsPath, TransactionName + @"\"); Directory.CreateDirectory(transactionPath); string dataFilePath = Path.Combine(transactionPath, @"data.xml"); GinSerializer.Serialize(this, dataFilePath); }
private void InitMetadata() { string ginPath = ConfigurationManager.AppSettings["ROOT_PATH"]; if (!Directory.Exists(ginPath)) { Directory.CreateDirectory(ginPath); } string rootPath = GetRootPath(); string pluginPath = Path.Combine(rootPath, @"Plugins"); _metaData = GinMetaData.GetInstance(); _metaData.Plugin(pluginPath); GinSerializer.IncludeTypes(_metaData.IncludedTypes); }
public override CommandResult Do(IExecutionContext context) { object absoluteObject = context.GetResult(ObjectName); string tempPath = Path.Combine(context.TempPath, Guid.NewGuid().ToString("N") + ".dat"); if (absoluteObject is DataTable) { DataTable dataTable = (DataTable)absoluteObject; dataTable.WriteXml(tempPath); } else { GinSerializer.Serialize(absoluteObject, tempPath); } string objectStringValue = IOUtil.ReadFile(tempPath); File.Delete(tempPath); context.Log.AddLogInformation(ObjectName + "=" + objectStringValue); return(CommandResult.Next); }
private void InitMetadata() { _executionContext.Log.AddLogInformation("Вход в InitMetadata()"); LogMessage("Загружаются метаданные..."); string exePath = GetExePath(); string pluginPath = Path.Combine(exePath, @"Plugins"); _executionContext.Log.AddLogInformation("exePath = <" + exePath + ">; pluginPath = <" + pluginPath + ">;"); _executionContext.Log.AddLogInformation("Запрашиваем экземпляр метаданных"); GinMetaData metaData = GinMetaData.GetInstance(); _executionContext.Log.AddLogInformation("Получили экземпляр метаданных"); _executionContext.Log.AddLogInformation("Команд - " + (metaData.Commands != null ? metaData.Commands.Count.ToString() : "0")); _executionContext.Log.AddLogInformation("Типов - " + (metaData.IncludedTypes != null ? metaData.IncludedTypes.Length.ToString() : "0")); _executionContext.Log.AddLogInformation("Загружаем плагины из папки <" + pluginPath + ">"); metaData.Plugin(pluginPath); _executionContext.Log.AddLogInformation("Команд - " + (metaData.Commands != null ? metaData.Commands.Count.ToString() : "0")); _executionContext.Log.AddLogInformation("Типов - " + (metaData.IncludedTypes != null ? metaData.IncludedTypes.Length.ToString() : "0")); GinSerializer.IncludeTypes(metaData.IncludedTypes); _executionContext.Log.AddLogInformation("Загрузили типы в GinSerializer"); LogMessage("Метаданные загружены"); _executionContext.Log.AddLogInformation("Выход из InitMetadata()"); }