Exemple #1
0
	    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!");
	    }
Exemple #2
0
        public HxXWPerson(Session session, HxXWDatabase acl, bool forceLoad)
        {
		    String locuser = "";
            String matricola = "";
            String possibleDocwayIIdUnit = "";
            XmlNode node = null;

            _session = session;
		    if(_session != null){
                Object tmp = null;
			    if(!forceLoad)
				    tmp = _session["ACL_USER"];
    			
			    if(tmp == null){
                    acl.open();
                    //try check user by iIdUnit first
                    possibleDocwayIIdUnit = _session.AsString("DOCWAY_USER_IIDUNIT");
                    if (possibleDocwayIIdUnit == "")
                    {
                        //first try to take session user
                        locuser = _session.AsString("DOCWAY_USER_NAME");
                        if (locuser == "")
                        {
                            //try current auth user
                            locuser = Environment.UserName;
                            int idx = locuser.LastIndexOf('\\');
                            if (idx > -1)
                                locuser = locuser.Substring(idx + 1);
                        }
                        /*
                         * try to check up user for matricola containig it can be user$matricola
                         */
                        string[] v = locuser.Split(new Char[] { '$' });
                        string mq = "";
                        if(v.Length == 2){
						    locuser = v[0];
						    matricola = v[1]; //[/persona_interna/@matricola/]
						    mq = "and [/persona_interna/@matricola/]=\""+v[1]+"\"";
					    }else{
						    locuser = v[0];
						    matricola = "";
					    }

                        _presp = acl.loadFirst("[persint_loginname]=\"" + locuser + "\"" + mq, false);
                        //verify last result size
                        if (acl.lastResultSize > 1)
                        {
                            _isUnique = false;
                            return; //escape function
                        }
                        //take iIdUnit
					    node = _presp.xQuery("//Document");
					    if (node != null) {
						    possibleDocwayIIdUnit = node.Attributes["idIUnit"].Value;
					    }

                        //take persona interna
                        node = _presp.xQuery("//persona_interna");
                        if (node == null)
                        {
                            //we didnt find user in ACL so lets try default one
                            locuser = ConfigData.Open().application.AsString("xDocDefaultDocwayUser") ?? "";
                            if (locuser == "") throw new Exception("Missing user to log on!");
                            _presp = acl.loadFirst("[persint_loginname]=\"" + locuser + "\"", false);
                            //take iIdUnit
                            node = _presp.xQuery("//Document");
                            if (node != null)
                            {
                                possibleDocwayIIdUnit = node.Attributes["idIUnit"].Value;
                            }
                            //take persona interna
                            node = _presp.xQuery("//persona_interna");
                        }
                    }
                    else
                    {
                        //we have iIdUnit in session
                        ///first try to take session user
                        locuser = _session.AsString("DOCWAY_USER_NAME");
                        if (locuser == "")
                        {
                            //try current auth user
                            locuser = Environment.UserName;
                            int idx = locuser.LastIndexOf('\\');
                            if (idx > -1)
                                locuser = locuser.Substring(idx + 1);
                        }
					    //in case of matricola presence
					    string[] v = locuser.Split(new Char[] { '$' });
                        string mq = "";
                        if(v.Length == 2){
						    locuser = v[0];
						    matricola = v[1]; //[/persona_interna/@matricola/]
						    mq = "and [/persona_interna/@matricola/]=\""+v[1]+"\"";
					    }else{
						    locuser = v[0];
						    matricola = "";
					    }

					    //load record by iIdUnit
					    _presp = acl.loadDocument(Convert.ToInt32(possibleDocwayIIdUnit), false, true, false);
                        node = _presp.xQuery("//persona_interna");
                    }

                    //if we find user work on it
                    if (node != null)
                    {
                        _params = new XDocBase.Web.CONTAINER.Map();
                        _params["nome"] = node.Attributes["nome"].Value;
                        _params["cognome"] = node.Attributes["cognome"].Value;
                        _params["cod_uff"] = node.Attributes["cod_uff"].Value;
                        _params["AmmAoo"] = (String)node.Attributes["cod_amm"].Value + (String)node.Attributes["cod_aoo"].Value;
                        _params["matricola"] = node.Attributes["matricola"].Value;
                        matricola = node.Attributes["matricola"].Value;
                        _params["cgnno"] = _params["cognome"] + " " + _params["nome"];
                        _params["nocgn"] = _params["nome"] + " " + _params["cognome"];

                        //make list of inserable repertories
                        /* xpath for to take some repertory right
                         * //right[starts-with(@cod,'DW-DOCINTRANET') and ends-with(@cod,'-V-InsRep')]
                         */
                        //take all rights TRUE and put them in ',' separated string
                        //right[text()='TRUE' or text()='true']
                        XmlNodeList entries = _presp.xQueryExt("//right[text()='TRUE' or text()='true']");
                        String rights = "";

                        foreach (XmlNode n in entries)
                        {
                            rights += n.Attributes["cod"].Value + ",";
                        }
                        _params["rights"] = rights;

                        if (_params["cod_uff"].ToString().Length > 0)
                        {
                            _uresp = acl.loadFirst("[struint_coduff]=\"" + _params["cod_uff"] + "\"", false);
                            node = _uresp.xQuery("//struttura_interna/nome");
                            if (node != null)
                            {
                                if (node.LastChild != null)
                                    _params["uff_name"] = node.LastChild.Value;
                                else
                                    _params["uff_name"] = node.Value;
                            }
                        }
                        _session["ACL_USER"] = _params;
                        _session["DOCWAY_USER_NAME"] = locuser+"$"+matricola;
                        _session["DOCWAY_USER_IIDUNIT"] = possibleDocwayIIdUnit;
                    }
                    else
                    {
                        throw new Exception("Persona [" + locuser + "] non trovata in ACL!"); 
                    }
				    
			    }else{
				    _params = (XDocBase.Web.CONTAINER.Map)tmp;
			    }
		    }
	    }
Exemple #3
0
        protected HxXWResponse getWSTitlePage(String titleRule, int What, int currentPage)
        {
            bool done = false;
            int tries = xDocUnSucessfullTryesCount;
            String s = "";
            while (!done && tries > 0)
            {
                try
                {
                    //mark try
                    --tries;
                    //get title page
                    switch (What)
                    {
                        case 0:
                            s = ewws.firstTitlePage(getTitleRule(titleRule));
                            break;
                        case 1:
                            s = ewws.prevTitlePage(getTitleRule(titleRule));
                            break;
                        case 2:
                            s = ewws.nextTitlePage(getTitleRule(titleRule));
                            break;
                        case 3:
                            s = ewws.lastTitlePage(getTitleRule(titleRule));
                            break;
                        case 4:
                        default:
                            s = ewws.titlePage(currentPage, getTitleRule(titleRule));
                            break;

                    }
                    done = true;
                }
                catch (Exception e)
                {
                    if (e.Message.Contains("Connessione inattiva!"))
                    {
                        init();
                    }
                    else
                    {
                        throw e;
                    }
                }
            }

            if (!done || (s == ""))
            {
                throw new Exception("Can't load titles!");
            }
            HxXWResponse ret = new HxXWResponse(s); 
            session["currentPage"] = ret.pageIndex;
            return ret;
        }
 override protected void decodeResponse(HxXWResponse r)
 {
     base.decodeResponse(r);
     _nrecord = _doc.dom.DocumentElement.Attributes["nrecord"].Value;
 }