public static Collection Load(Guid id) { Collection result; try { Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (SorentoLib.Services.Datastore.Get<XmlDocument> (DatastoreAisle, id.ToString ()).SelectSingleNode ("(//scms.collection)[1]"))); result = new Collection (); result._id = new Guid ((string)item["id"]); if (item.ContainsKey ("createtimestamp")) { result._createtimestamp = int.Parse ((string)item["createtimestamp"]); } if (item.ContainsKey ("updatetimestamp")) { result._updatetimestamp = int.Parse ((string)item["updatetimestamp"]); } if (item.ContainsKey ("collectionschemaid")) { result._collectionschemaid = new Guid ((string)item["collectionschemaid"]); } if (item.ContainsKey ("title")) { result._title = (string)item["title"]; } if (item.ContainsKey ("sort")) { result._sort = int.Parse ((string)item["sort"]); } if (item.ContainsKey ("contents")) { foreach (XmlDocument content in (List<XmlDocument>)item["contents"]) { result._contents.Add (Content.FromXmlDocument (content)); } } } catch (Exception exception) { // LOG: LogDebug.ExceptionUnknown SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "SCMS.COLLECTION", exception.Message)); // EXCEPTION: Excpetion.CollectionLoadGuid throw new Exception (string.Format (Strings.Exception.CollectionLoadGuid, id.ToString ())); } return result; }
public static Collection FromXmlDocument(XmlDocument xmlDocument) { Hashtable item; Collection result; try { item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (xmlDocument.SelectSingleNode ("(//scms.collection)[1]"))); } catch { item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument); } if (item.ContainsKey ("id")) { try { result = Load (new Guid ((string)item["id"])); } catch { result = new Collection (); result._id = new Guid ((string)item["id"]); } } else { // EXCEPTION: Exception.CollectionFromXMLDocument throw new Exception (Strings.Exception.CollectionFromXMLDocument); } if (item.ContainsKey ("createtimestamp")) { result._createtimestamp = int.Parse ((string)item["createtimestamp"]); } if (item.ContainsKey ("updatetimestamp")) { result._updatetimestamp = int.Parse ((string)item["updatetimestamp"]); } if (item.ContainsKey ("title")) { result._title = (string)item["title"]; } if (item.ContainsKey ("collectionschemaid")) { result._collectionschemaid = new Guid ((string)item["collectionschemaid"]); } if (item.ContainsKey ("sort")) { result._sort = int.Parse ((string)item["sort"]); } if (item.ContainsKey ("contents")) { result._contents.Clear (); foreach (XmlDocument content in (List<XmlDocument>)item["contents"]) { result._contents.Add (Content.FromXmlDocument (content)); } } return result; }