예제 #1
0
    private HxXWDatabaseRecord(Session session, String ID, String connection, Boolean clone)
    {
        this.session = session;
        this.objDatabase = null;
        this.isClone = clone;
        this.connection = connection;

        //take connection string   host:port:db
        string[] v = connection.Split(new Char[] { ':' });
        if (v.Length != 3)
            throw new Exception("Incorrect DB connection string! [" + connection + "]");

        ConfigData cfg = ConfigData.Open();
        this.ID = ID;
        this.label = ID;
        this.db_host = v[0];
        this.db_port = v[1];
        this.db_usr = cfg.application["xDocUser"] ?? "lettore";
        this.db_pwd = cfg.application["xDocPass"] ?? "reader";
        this.db_name = v[2];
        this.db_encoding = cfg.application["xDocEncoding"] ?? "utf-8";
        this.titlePageSize = cfg.application["xDocIndexPageSize"].AsInt32;
        this.indexPageSize = cfg.application["xDocTitlesPageSize"].AsInt32;
        this.bDefault = ID == "MAIN" ? true : false;
    }
예제 #2
0
	    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);
		    }
	    }
예제 #3
0
        public HxXWDocwayDocument(HxXWDatabase db, HxXWPerson pe, String nrecord, bool bLock) : base("doc", db, -1, bLock)
        {
            _person = pe;
            _nrecord = nrecord;
            _udName = "doc";
            _db = db;

            //look for document in case of wanted $nrecord
            if (nrecord.Length > 0)
            {
                load(nrecord, bLock);
            }
            else
            {
                _idIUnit = -1;
            }
        }
예제 #4
0
 public HxXWDocument(String udName, HxXWDatabase db) : this(udName, db, -1, false)
 {
 }
예제 #5
0
 public HxXWDocument(String udName, HxXWDatabase db, int idIUnit) : this(udName, db, idIUnit, false)
 {
 }
예제 #6
0
    public HxXWDatabase getDbObj()
	{
		if(this.objDatabase == null)
			this.objDatabase = new HxXWDatabase(this.session, this.ID, this.db_host, this.db_port, this.db_usr, this.db_pwd, this.db_name, this.db_encoding, this.titlePageSize, this.indexPageSize);
		return this.objDatabase;
	}
예제 #7
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;
			    }
		    }
	    }
예제 #8
0
 public HxXWPerson(Session session, HxXWDatabase acl) : this(session, acl, false)
 {
 }
예제 #9
0
 public HxXWDocwayDocument(HxXWDatabase db, HxXWPerson pe, String nrecord)
     : this(db, pe, nrecord, false)
 {
 }
예제 #10
0
 public HxXWDocwayDocument(HxXWDatabase db, HxXWPerson pe)
     : this(db, pe, "", false)
 {
 }