void m_List_DeleteButtonClick(object sender, CustomEventArgs <ObjectStorageFileDescription> e) { var current = m_List.CurrentObject; if (current != null) { StorageActionArgs args = new StorageActionArgs(); args.ActionType = StorageActionTypes.Delete; args.ContentType = ContentType; args.FileDescription = m_List.CurrentObject; m_StorageManager.Invoke(XmlSerializationUtility.Obj2XmlStr(args, Common.Namespace), args); } }
/// <summary> /// /// </summary> /// <param name="BoundaryString"></param> /// <returns></returns> private MemoryStream GetPOSTData(string BoundaryString, YouTubeVideoFileInfo YouTubeFileInfo) { //byte[] buffer; string strPostData = string.Empty; MemoryStream ms = new MemoryStream(); StringBuilder strPostDataBuilder = new StringBuilder(); strPostDataBuilder.AppendLine("--" + BoundaryString); strPostDataBuilder.AppendLine("Content-Type: application/atom+xml; charset=UTF-8"); strPostDataBuilder.AppendLine(); #region YouTube feed initialization YouTubeAPI.Feed.entry entry = new YouTubeAPI.Feed.entry(YouTubeAPI.Feed.feedType.upload); entry.group.title.type = "plain"; entry.group.title.Text = YouTubeFileInfo.Title; //"Bad Wedding Toast"; entry.group.description.type = "plain"; entry.group.description.Text = YouTubeFileInfo.Description; //"I gave a bad toast at my friend's wedding."; entry.group.category.scheme = "http://gdata.youtube.com/schemas/2007/categories.cat"; entry.group.category.Text = EnumToString.Get(typeof(YouTubeCategories), YouTubeFileInfo.Category); //"People"; entry.group.keywords.Text = YouTubeFileInfo.Keywords; #endregion XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(); namespaces.Add("media", "http://search.yahoo.com/mrss/"); namespaces.Add("yt", "http://gdata.youtube.com/schemas/2007"); string strSRZD = XmlSerializationUtility.ObjectToXmlString(entry, namespaces); strPostDataBuilder.Append("<?xml version=\"1.0\"?>"); strPostDataBuilder.AppendLine(strSRZD); //Console.WriteLine("************************************"); //Console.WriteLine(strPostDataBuilder.ToString()); //Console.WriteLine("************************************"); strPostDataBuilder.AppendLine("--" + BoundaryString); strPostDataBuilder.AppendLine("Content-Type: video/mpeg"); strPostDataBuilder.AppendLine("Content-Transfer-Encoding: binary"); strPostDataBuilder.AppendLine(); //>>Test //using (StreamWriter streamWriter = new StreamWriter("Atom.xml")) //{ // streamWriter.Write(strPostDataBuilder.ToString()); //} //<<Test ms.Write(Encoding.UTF8.GetBytes(strPostDataBuilder.ToString()), 0, Encoding.UTF8.GetByteCount(strPostDataBuilder.ToString())); byte[] fileToUpload = FileUtils.GetFile(YouTubeFileInfo.FilePath); ms.Write(fileToUpload, 0, fileToUpload.Length); ms.Write(Encoding.UTF8.GetBytes("\n--" + BoundaryString + "--"), 0, Encoding.UTF8.GetByteCount("\n--" + BoundaryString + "--")); return(ms); }
void service_GetMembersDataCompleted(object sender, Ranet.AgOlap.OlapWebService.GetMembersDataCompletedEventArgs e) { InvokeResultDescriptor result = XmlSerializationUtility.XmlStr2Obj <InvokeResultDescriptor>(e.Result); if (result != null) { //if (result.IsArchive) //{ // result.Content = ZipCompressor.DecompressFromBase64String(result.Content); // result.IsArchive = false; //} Raise_DataLoaded(new DataLoaderEventArgs(result, e.Error, e.UserState)); } }
public void Show() { m_Dlg.Show(); m_List.Initialize(null); if (m_StorageManager != null) { m_List.IsWaiting = true; StorageActionArgs args = new StorageActionArgs(); args.ActionType = StorageActionTypes.GetList; args.ContentType = ContentType; m_StorageManager.Invoke(XmlSerializationUtility.Obj2XmlStr(args, Common.Namespace), args); } }
String PerformStorageAction(String schema) { InvokeResultDescriptor result = new InvokeResultDescriptor(); String res = String.Empty; try { StorageActionArgs args = XmlSerializationUtility.XmlStr2Obj <StorageActionArgs>(schema); if (args != null) { FileStorageProvider storageProvider = new FileStorageProvider(); switch (args.ActionType) { case StorageActionTypes.Save: args.FileDescription.ContentFileName = args.FileDescription.Description.Name + ".content." + FileStorageProvider.GetFilteExtension(args.ContentType); storageProvider.Save(HttpContext.Current.User, args.FileDescription.Description.Name + "." + FileStorageProvider.GetFilteExtension(args.ContentType), XmlSerializationUtility.Obj2XmlStr(args.FileDescription)); storageProvider.Save(HttpContext.Current.User, args.FileDescription.ContentFileName, args.Content); break; case StorageActionTypes.Load: res = storageProvider.Load(HttpContext.Current.User, args.FileDescription.ContentFileName); break; case StorageActionTypes.GetList: res = XmlSerializationUtility.Obj2XmlStr(storageProvider.GetList(HttpContext.Current.User, "*." + FileStorageProvider.GetFilteExtension(args.ContentType)), Common.Namespace); break; case StorageActionTypes.Clear: res = XmlSerializationUtility.Obj2XmlStr(storageProvider.Clear(HttpContext.Current.User, "*." + FileStorageProvider.GetFilteExtension(args.ContentType))); break; case StorageActionTypes.Delete: storageProvider.Delete(HttpContext.Current.User, args.FileDescription.Description.Name + "." + FileStorageProvider.GetFilteExtension(args.ContentType)); storageProvider.Delete(HttpContext.Current.User, args.FileDescription.ContentFileName); res = XmlSerializationUtility.Obj2XmlStr(storageProvider.GetList(HttpContext.Current.User, "*." + FileStorageProvider.GetFilteExtension(args.ContentType)), Common.Namespace); break; } } result.Content = res; } catch (Exception) { throw; } return(InvokeResultDescriptor.Serialize(result)); }
void OlapDataLoader_DataLoaded(object sender, DataLoaderEventArgs e) { bool stopWaiting = true; try { if (e.Error != null) { LogManager.LogError(this, e.Error.ToString()); return; } if (e.Result.ContentType == InvokeContentType.Error) { LogManager.LogError(this, e.Result.Content); return; } MdxQueryArgs mdx_args = e.UserState as MdxQueryArgs; if (mdx_args != null) { CellSetData cs_descr = CellSetData.Deserialize(e.Result.Content); InitializeTuple(cs_descr); // Зачитываем метаданные куба в целом stopWaiting = false; LogManager.LogInformation(this, this.Name + " - Loading cube metadata."); MetadataQuery args = CommandHelper.CreateGetCubeMetadataArgs(Connection, CubeName, MetadataQueryType.GetCubeMetadata_AllMembers); OlapDataLoader.LoadData(args, args); } MetadataQuery metadata_args = e.UserState as MetadataQuery; if (metadata_args != null) { CubeDefInfo cs_descr = XmlSerializationUtility.XmlStr2Obj <CubeDefInfo>(e.Result.Content); m_CopyControl.InitializeMetadata(cs_descr); } } finally { if (stopWaiting) { IsWaiting = false; } } }
private static WebConfiguration CreateConfig() { XmlNode section = (XmlNode)ConfigurationManager.GetSection(ElementName); if (section == null) { return(new WebConfiguration()); } var schema = new WebConfigurationSchema(); return((WebConfiguration)XmlSerializationUtility.DeserializeUsingSchema( new XmlNodeReader(section), // "web.config/configuration/" + ElementName, // TODO: context is no longer supported, verify that node has correct BaseURI typeof(WebConfiguration), SchemaUri, schema.LoadSchemaSet())); }
public void WithNamespaceAndSchemaSet_HavingInvalidDataTypeInXmlFragment() { try { XmlSerializationUtility.DeserializeUsingSchema( GetReaderForDefaultFragment("data"), typeof(SampleClass), "http://www.re-motion.org/core/unitTests", GetXmlSchemaSet()); } catch (XmlSchemaValidationException e) { // Assert.AreEqual (2, e.LineNumber); // Assert.AreEqual (26, e.LinePosition); Assert.That(e.SourceUri, Is.EqualTo("test.xml")); throw; } }
void LoadDialog_DialogOk(object sender, EventArgs e) { ObjectLoadDialog dlg = sender as ObjectLoadDialog; if (dlg == null) { return; } if (dlg.CurrentObject != null && !String.IsNullOrEmpty(dlg.CurrentObject.ContentFileName)) { StorageActionArgs args = new StorageActionArgs(); args.ActionType = StorageActionTypes.Load; args.ContentType = StorageContentTypes.ValueCopySettings; args.FileDescription = dlg.CurrentObject; StorageManager.Invoke(XmlSerializationUtility.Obj2XmlStr(args, Common.Namespace), args); } }
public static void TestEntryFeed() { YouTubeAPI.Feed.entry entry = new YouTubeAPI.Feed.entry(YouTubeAPI.Feed.feedType.upload); entry.group.title.type = "plain"; entry.group.title.Text = "Bad Wedding Toast"; entry.group.description.type = "plain"; entry.group.description.Text = "I gave a bad toast at my friend's wedding."; entry.group.category.scheme = "http://gdata.youtube.com/schemas/2007/categories.cat"; entry.group.category.Text = EnumToString.Get(typeof(YouTubeCategories), YouTubeCategories.PeopleAndBlogs); entry.group.keywords.listKeywords.Add("toast"); entry.group.keywords.listKeywords.Add("wedding"); XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(); namespaces.Add("media", "http://search.yahoo.com/mrss/"); namespaces.Add("yt", "http://gdata.youtube.com/schemas/2007/"); string strSRZD = XmlSerializationUtility.ObjectToXmlString(entry, "http://www.w3.org/2005/Atom", namespaces); Console.WriteLine(strSRZD); }
public async Task WhenValidRequestIsMade_ShouldReturnAddress() { Environment.SetEnvironmentVariable("UspsSettings:UserName", "633FMCON0605"); var address = new AddressValidateRequest { Address = new AddressXML { Address1 = "5525 W 99th Pl", Address2 = "", City = "Oak Lawn", Id = "0", State = "IL", Zip4 = "", Zip5 = "60453" }, UserId = _options.Value.UserName }; var xml = XmlSerializationUtility.GetXmlString(address); var url2 = $"https://secure.shippingapis.com/shippingApi.dll?API=verify&XML={xml}"; var http = new HttpClient(); var response = await http.GetAsync(url2); var stream = await response.Content.ReadAsStreamAsync(); XDocument doc = XDocument.Load(stream); IEnumerable <XElement> nodes = doc.Root.Elements().Descendants("Error"); Assert.Empty(nodes); stream.Position = 0; var obj = XmlSerializationUtility.Deserialize <AddressValidateResponse>(stream); Assert.NotNull(obj); }
void SaveAsDialog_DialogOk(object sender, EventArgs e) { ObjectSaveAsDialog dlg = sender as ObjectSaveAsDialog; if (dlg == null) { return; } String str = String.Empty; ValueCopySettingsWrapper wrapper = m_CopyControl.GetCopySettings(); if (wrapper != null) { str = XmlSerializationUtility.Obj2XmlStr(wrapper, Common.Namespace); } StorageActionArgs args = new StorageActionArgs(); args.ActionType = StorageActionTypes.Save; args.Content = str; args.ContentType = StorageContentTypes.ValueCopySettings; ObjectDescription descr = dlg.Object; if (descr != null && !String.IsNullOrEmpty(descr.Name)) { if (String.IsNullOrEmpty(descr.Caption)) { descr.Caption = descr.Name; } args.FileDescription = new ObjectStorageFileDescription(descr); StorageManager.Invoke(XmlSerializationUtility.Obj2XmlStr(args, Common.Namespace), args); } else { MessageBox.Show(Localization.ObjectSaveDialog_NameIsEmpty_Message, Localization.Warning, MessageBoxButton.OK); } }
public void WhenXMLIsSerialized_ShouldMatchUspsSchema() { var expectedXML = "<AddressValidateRequest USERID=\"xxx\"><Address ID=\"0\"><Address1>123 Main St</Address1>" + "<Address2 /><City>Bedrock</City><State>IL</State><Zip5>90210</Zip5><Zip4 /></Address></AddressValidateRequest>"; var address = new AddressValidateRequest { Address = new AddressXML { Address1 = "123 Main St", Address2 = "", City = "Bedrock", Id = "0", State = "IL", Zip4 = "", Zip5 = "90210" }, UserId = "xxx" }; var xml = XmlSerializationUtility.GetXmlString <AddressValidateRequest>(address); Assert.Equal(expectedXML, xml); }
protected virtual object LoadConfiguration(string configurationFile, Type type, XmlSchemaSet schemas) { ArgumentUtility.CheckNotNullOrEmpty("configurationFile", configurationFile); ArgumentUtility.CheckNotNull("type", type); ArgumentUtility.CheckNotNull("schemas", schemas); using (XmlTextReader reader = new XmlTextReader(configurationFile)) { return(XmlSerializationUtility.DeserializeUsingSchema(reader, type, schemas)); } // try // { // return XmlSerializationUtility.DeserializeUsingSchema (reader, _configurationFile, _type, _schemas); // } // catch (XmlSchemaException e) // { // throw CreateMappingException (e, "Error while reading mapping: {0}", e.Message); // } // catch (XmlException e) // { // throw CreateMappingException (e, "Error while reading mapping: {0}", e.Message); // } }
String GetLevelProperties(MetadataQuery args) { OlapMetadataProvider provider = new OlapMetadataProvider(new ConnectionInfo(args.Connection, GetConnectionString(args.Connection))); // Делать коллекцию с ключем "Имя свойства" нельзя, т.к. свойства KEY1, KEY2 и т.д. есть не у всех уровней и например в контроле выбора элемента измерения при построении уловия поиска придется проверять для каких уровней они есть, а для каких нету List <LevelPropertyInfo> list = new List <LevelPropertyInfo>(); if (String.IsNullOrEmpty(args.LevelUniqueName)) { Dictionary <String, LevelInfo> levels = provider.GetLevels(args.CubeName, args.DimensionUniqueName, args.HierarchyUniqueName); foreach (LevelInfo li in levels.Values) { Dictionary <String, LevelPropertyInfo> properties = provider.GetLevelProperties(args.CubeName, args.DimensionUniqueName, args.HierarchyUniqueName, li.UniqueName); foreach (LevelPropertyInfo pi in properties.Values) { list.Add(pi); } } } else { Dictionary <string, LevelPropertyInfo> properties = provider.GetLevelProperties(args.CubeName, args.DimensionUniqueName, args.HierarchyUniqueName, args.LevelUniqueName); foreach (LevelPropertyInfo pi in properties.Values) { list.Add(pi); } } return(XmlSerializationUtility.Obj2XmlStr(list, Common.Namespace)); }
public void WithoutXmlRootAttributeAndWithoutXmlTypeAttribute() { XmlSerializationUtility.GetNamespace(typeof(SampleTypeWithoutXmlAttributes)); }
public void WithXmlRootAttributeWithoutNamespace() { XmlSerializationUtility.GetNamespace(typeof(SampleTypeWithXmlRootWithoutNamespace)); }
private String ExportToExcel(String schema) { InvokeResultDescriptor result = new InvokeResultDescriptor(); String res = String.Empty; try { String sessionId = String.Empty; String connection = String.Empty; try { MdxQueryArgs args = XmlSerializationUtility.XmlStr2Obj <MdxQueryArgs>(schema); if (args != null) { sessionId = args.SessionId; connection = args.Connection; DefaultQueryExecuter queryExecuter = new DefaultQueryExecuter(GetConnection(args.Connection)); if (args.Queries.Count > 0) { res = queryExecuter.GetCellSetDescription(args.Queries[0], ref sessionId); } } } catch (AdomdConnectionException connection_ex) { result.Content = connection_ex.Message; result.ContentType = InvokeContentType.Error; } catch (AdomdErrorResponseException response_ex) { result.Content = response_ex.Message; result.ContentType = InvokeContentType.Error; } catch (AdomdUnknownResponseException unknown_ex) { result.Content = unknown_ex.Message; result.ContentType = InvokeContentType.Error; } catch (InvalidOperationException invalid_ex) { result.Content = invalid_ex.Message; result.ContentType = InvokeContentType.Error; } if (!String.IsNullOrEmpty(res)) { CellSetData cs = CellSetData.Deserialize(res); PivotDataProvider pivotProvider = new PivotDataProvider(new CellSetDataProvider(cs)); res = ExportHelper.ExportToExcel(pivotProvider); } result.Content = res; if (UseCompress) { // Архивация строки String compesed = ZipCompressor.CompressAndConvertToBase64String(res); result.Content = compesed; result.IsArchive = true; } result.ContentType = InvokeContentType.MultidimData; result.Headers.Add(new Header(InvokeResultDescriptor.SESSION_ID, sessionId)); result.Headers.Add(new Header(InvokeResultDescriptor.CONNECTION_ID, connection)); } catch (Exception) { throw; } return(InvokeResultDescriptor.Serialize(result)); }
String ExecuteQuery(String schema) { InvokeResultDescriptor result = new InvokeResultDescriptor(); String res = String.Empty; try { String sessionId = String.Empty; MdxQueryArgs args = XmlSerializationUtility.XmlStr2Obj <MdxQueryArgs>(schema); if (args != null) { sessionId = args.SessionId; DefaultQueryExecuter queryExecuter = new DefaultQueryExecuter(GetConnection(args.Connection)); if (args.Queries.Count > 0) { result.ContentType = InvokeContentType.MultidimData; switch (args.Type) { case QueryTypes.Update: case QueryTypes.CommitTransaction: case QueryTypes.RollbackTransaction: List <String> results = new List <String>(); result.ContentType = InvokeContentType.UpdateResult; foreach (var query in args.Queries) { try { // Method return a value of one (1). queryExecuter.ExecuteNonQuery(query, ref sessionId); results.Add(String.Empty); } catch (AdomdConnectionException connection_ex) { results.Add(connection_ex.Message); } catch (AdomdErrorResponseException response_ex) { results.Add(response_ex.Message); } catch (AdomdUnknownResponseException unknown_ex) { results.Add(unknown_ex.Message); } catch (InvalidOperationException invalid_ex) { results.Add(invalid_ex.Message); } } res = XmlSerializationUtility.Obj2XmlStr(results, Common.Namespace); break; case QueryTypes.Select: try { res = queryExecuter.GetCellSetDescription(args.Queries[0], ref sessionId); } catch (AdomdConnectionException connection_ex) { res = connection_ex.Message; result.ContentType = InvokeContentType.Error; } catch (AdomdErrorResponseException response_ex) { res = response_ex.Message; result.ContentType = InvokeContentType.Error; } catch (AdomdUnknownResponseException unknown_ex) { res = unknown_ex.Message; result.ContentType = InvokeContentType.Error; } catch (InvalidOperationException invalid_ex) { res = invalid_ex.Message; result.ContentType = InvokeContentType.Error; } break; case QueryTypes.DrillThrough: try { var table = queryExecuter.ExecuteReader(args.Queries[0], ref sessionId); if (table != null) { res = XmlSerializationUtility.Obj2XmlStr(DataTableHelper.Create(table)); } } catch (AdomdConnectionException connection_ex) { res = connection_ex.Message; result.ContentType = InvokeContentType.Error; } catch (AdomdErrorResponseException response_ex) { res = response_ex.Message; result.ContentType = InvokeContentType.Error; } catch (AdomdUnknownResponseException unknown_ex) { res = unknown_ex.Message; result.ContentType = InvokeContentType.Error; } catch (InvalidOperationException invalid_ex) { res = invalid_ex.Message; result.ContentType = InvokeContentType.Error; } break; } } } result.Content = res; System.Diagnostics.Debug.WriteLine("CellSetData size: " + res.Length); if (UseCompress) { DateTime start = DateTime.Now; // Архивация строки String compesed = ZipCompressor.CompressAndConvertToBase64String(res); System.Diagnostics.Debug.WriteLine("CellSetData compression time: " + (DateTime.Now - start).ToString()); System.Diagnostics.Debug.WriteLine("CellSetData compressed size: " + compesed.Length); result.Content = compesed; result.IsArchive = true; } result.Headers.Add(new Header(InvokeResultDescriptor.SESSION_ID, sessionId)); result.Headers.Add(new Header(InvokeResultDescriptor.CONNECTION_ID, args.Connection)); } catch (Exception ex) { throw; } return(InvokeResultDescriptor.Serialize(result)); }
String GetMetaData(String schema) { InvokeResultDescriptor result = new InvokeResultDescriptor(); String res = null; try { MetadataQuery args = XmlSerializationUtility.XmlStr2Obj <MetadataQuery>(schema); if (args != null) { switch (args.QueryType) { case MetadataQueryType.GetCubes: res = GetCubes(args); break; case MetadataQueryType.GetMeasures: res = GetMeasures(args); break; case MetadataQueryType.GetKPIs: res = GetKPIs(args); break; case MetadataQueryType.GetLevels: res = GetLevels(args); break; case MetadataQueryType.GetDimensions: res = GetDimensions(args); break; case MetadataQueryType.GetHierarchies: res = GetHierarchies(args); break; case MetadataQueryType.GetDimension: res = GetDimension(args); break; case MetadataQueryType.GetHierarchy: res = GetHierarchy(args); break; case MetadataQueryType.GetMeasureGroups: res = GetMeasureGroups(args); break; case MetadataQueryType.GetLevelProperties: res = GetLevelProperties(args); break; case MetadataQueryType.GetCubeMetadata: case MetadataQueryType.GetCubeMetadata_AllMembers: res = GetCubeMetadata(args); break; } } result.Content = res; if (UseCompress) { // Архивация строки String compesed = ZipCompressor.CompressAndConvertToBase64String(res); result.Content = compesed; result.IsArchive = true; } result.ContentType = InvokeContentType.MultidimData; } catch (AdomdConnectionException connection_ex) { result.Content = connection_ex.Message; result.ContentType = InvokeContentType.Error; } catch (AdomdErrorResponseException response_ex) { result.Content = response_ex.Message; result.ContentType = InvokeContentType.Error; } catch (OlapMetadataResponseException metadata_ex) { result.Content = metadata_ex.Message; result.ContentType = InvokeContentType.Error; } catch (Exception) { throw; } return(InvokeResultDescriptor.Serialize(result)); }
public void WithXmlRootAttributeWithTypeAlsoHavingAnXmlTypeAttribute() { Assert.That(XmlSerializationUtility.GetNamespace(typeof(SampleTypeWithXmlRootAndXmlType)), Is.EqualTo("http://root-namespace")); }
void OlapDataLoader_DataLoaded(object sender, DataLoaderEventArgs e) { // Exception if (e.Error != null) { LogManager.LogError(this, e.Error.ToString()); return; } // Exception or Message from Olap-Service if (e.Result.ContentType == InvokeContentType.Error) { LogManager.LogError(this, e.Result.Content); return; } if (e.Result != null) { String connectionId = String.Empty; if (e.Result.Headers.Contains(InvokeResultDescriptor.CONNECTION_ID)) { Header connection_header = e.Result.Headers[InvokeResultDescriptor.CONNECTION_ID]; if (connection_header != null) { connectionId = connection_header.Value; } } if (connectionId == Connection) { // Commit or Rollback Transaction MdxQueryArgs query_args = e.UserState as MdxQueryArgs; if (query_args != null) { if (query_args.Type == QueryTypes.CommitTransaction || query_args.Type == QueryTypes.RollbackTransaction) { if (e.Result.ContentType == InvokeContentType.UpdateResult) { List <String> results = XmlSerializationUtility.XmlStr2Obj <List <String> >(e.Result.Content); if (results != null) { var errors = results.Where(res => !String.IsNullOrEmpty(res)); StringBuilder sb = new StringBuilder(); //if (errors.Count() == 0) // AnalysisTransactionManager.CloseTransaction(Connection); //else //{ foreach (var error in errors) { sb.AppendLine(error); } if (!String.IsNullOrEmpty(sb.ToString())) { LogManager.LogError(this, sb.ToString()); } //} // В случае ошибки считаем что транзакция закрыта. И кэш чистим. OlapTransactionManager.CloseTransaction(Connection); } } } } } } }
public void WithXmlTypeAttribute() { Assert.That(XmlSerializationUtility.GetNamespace(typeof(SampleTypeWithXmlType)), Is.EqualTo("http://type-namespace")); }
public static CellSetData Parse(string xml) { return(XmlSerializationUtility.XmlStr2Obj <CellSetData>(xml)); }
/// <summary> /// Converts an address domain model to an XML string /// </summary> /// <param name="address"></param> /// <returns></returns> private string GetAddressAsXml(AddressDomainModel addressDomainModel) { var addressValidateRequest = addressDomainModel.ToAddressValidateRequest(_options.Value.UserName); return(XmlSerializationUtility.GetXmlString(addressValidateRequest)); }
public List <ObjectStorageFileDescription> GetList(IPrincipal currentPrincipal, string mask) { try { System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Storage.FileStorageProvider Getting List by Mask: '{1}' started.", DateTime.Now.ToString(), mask); List <ObjectStorageFileDescription> result = new List <ObjectStorageFileDescription>(); if (string.IsNullOrEmpty(mask)) { throw new ArgumentNullException("mask"); } string folder = string.Empty; if (GetFolderForPrincipal(currentPrincipal, ref folder)) { String[] files = Directory.GetFiles(folder, mask, SearchOption.TopDirectoryOnly); if (files != null) { for (int i = 0; i < files.Length; i++) { String file = files[i]; if (!file.Contains(".content.")) { string path = Path.Combine(folder, file); if (File.Exists(path)) { using (var sr = new StreamReader(File.OpenRead(path))) { string str = sr.ReadToEnd(); sr.Close(); if (!String.IsNullOrEmpty(str)) { // Пытаемся преобразовать в описатель ObjectStorageFileDescription descr = XmlSerializationUtility.XmlStr2Obj <ObjectStorageFileDescription>(str); if (descr != null) { // Если файла с содержимым не существует, то имя файла скидываем if (!String.IsNullOrEmpty(descr.ContentFileName)) { string content_path = Path.Combine(folder, descr.ContentFileName); if (!File.Exists(content_path)) { descr.ContentFileName = String.Empty; } } result.Add(descr); } } } } } } } } return(result); } finally { System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Storage.FileStorageProvider Getting List completed. \r\n", DateTime.Now.ToString()); } }
public static DataTableWrapper Parse(string xml) { return(XmlSerializationUtility.XmlStr2Obj <DataTableWrapper>(xml)); }