public HxXWDocument(String udName, HxXWDatabase db, int idIUnit, bool bLock) { _idIUnit = -1; _doc = null; _isLoaded = false; _isNew = false; _isLocked = false; _udName = udName; _db = db; if(idIUnit > -1){ //try to load document load(idIUnit, bLock); } }
virtual protected void decodeResponse(HxXWResponse r) { //FIX: 08/05/2013 check for namespace of Response root element XmlElement root = (XmlElement)r.xQuery("//Response"); String xmlNs = null; if(root != null){ //we have so check eventual attribude xmlns:xw xmlNs = root.GetAttribute("xmlns:xw"); } XmlNode entries = r.xQuery("//Document"); if (entries != null) { _idIUnit = Convert.ToInt32(entries.Attributes["idIUnit"].Value); }else throw new Exception("Incorrect XML document!"); XmlElement node = (XmlElement) r.xQuery("//" + _udName); if (node != null) { XmlDocument d = new XmlDocument(); d.AppendChild(d.ImportNode(node, true)); _doc = new HxXML(d.OuterXml); }else throw new Exception("Incorrect XML document!"); }
public void load(int idIUnit, bool bLock) { if(idIUnit > -1){ //try to load document try{ HxXWResponse resp = _db.loadDocument(idIUnit, bLock, false, false); decodeResponse(resp); _isLoaded = true; _isNew = false; _isLocked = bLock; }catch{ _isLoaded = false; _isNew = false; _doc = null; _isLocked = false; } } }
public void create(String xml) { _doc = new HxXML(xml); _idIUnit = -1; _isLoaded = false; _isNew = true; }
// desktopRule have to be HxXML !!! public HxXML getDesktop(bool custom, String desktopRule, String followDsk, bool forceLoad) { HxXML d = null; try { String dskid = GetMD5Hash("CustomDsk" + this.ID + followDsk + desktopRule); if(!forceLoad){ //first look for cached String cdsk = (String)(this.session["dskid"]); if(cdsk == null){ HxXML src = getWSDesktop(desktopRule, custom); XmlNode srcNode = src.xQuery("/Scrivania"); d = new HxXML("<dsk dbid=\"" + this.ID + "\" follow=\"" + followDsk + "\"/>"); srcNode = d.dom.ImportNode(srcNode, true); d.dom.DocumentElement.AppendChild(srcNode); }else{ d = new HxXML(cdsk); } }else{ HxXML src = getWSDesktop(desktopRule, custom); XmlNode srcNode = src.xQuery("/Scrivania"); d = new HxXML("<dsk dbid=\"" + this.ID + "\" follow=\"" + followDsk + "\"/>"); d.dom.DocumentElement.AppendChild(d.dom.ImportNode(srcNode, true)); //srcNode = d.dom.ImportNode(srcNode, true); //d.dom.DocumentElement.AppendChild(srcNode); //cache desktop this.session["dskid"] = d.xml; } //finish return d; }catch (Exception e) { throw new Exception("HxXWDatabase exception : " + e.Message); } }