Exemple #1
0
        private void fillHashFromSQL(Dictionary <int, string> ht, Hashtable rev, string sql)
        {
            ManagedCommand cmd = new ManagedCommand(connection);

            cmd.SetParameters(null);
            try
            {
                cmd.Execute(sql);
                while (cmd.Fetch())
                {
                    int    k    = 0;
                    string v    = null;
                    object data = cmd.GetColumnData(0, cmd.GetColumnMetaData());
                    if (data != null)
                    {
                        k = (int)data;
                    }
                    data = cmd.GetColumnData(1, cmd.GetColumnMetaData());
                    if (data != null && data is string)
                    {
                        v = (string)data;
                    }
                    ht[k]  = v;
                    rev[v] = k;
                }
            }
            finally
            {
                cmd.CloseCursor(true);
                cmd.Dispose();
            }
        }
        public override void Enlist(object distributedTransaction)
        {
            ITransaction transaction = (ITransaction)distributedTransaction;

            if (transaction == null)
            {
                Future future = new Future(Service.TransactionEnlist, (int)DtpFlags.SQL_TP_UNENLIST, null);
                object result = null;
                try
                {
                    futures.Add(future);
                    future.SendRequest(Session);
                    result = future.GetNextResult(Session, futures);
                }
                finally
                {
                    futures.Remove(future);
                }
                if (result != null && result is object[])
                {
                    object[] results = (object[])result;
                    errors.AddServerError((string)results[1], null, (string)results[2]);
                    Diagnostics.HandleErrors(CLI.ReturnCode.SQL_ERROR, this);
                }
            }
            else
            {
                byte[] whereabouts            = GetServerDtcWhereabouts();
                DTC.ITransactionExport export = DTC.GetTransactionExport(transaction, whereabouts);
                byte[] cookie         = DTC.GetTransactionCookie(transaction, export);
                string cookie_encoded = Encode(cookie);

                ManagedCommand cmd = new ManagedCommand(this);
                cmd.SetParameters(null);
                try
                {
                    cmd.Execute("select mts_enlist_transaction('" + cookie_encoded + "')");
                    if (cmd.Fetch())
                    {
                        autocommit = false;
                    }
                }
                finally
                {
                    cmd.CloseCursor(true);
                    cmd.Dispose();
                }
            }
        }
Exemple #3
0
        private long rdfMakeObj(object box, string rtype, string lang)
        {
            long ro_id = 0;
            VirtuosoParameterCollection p0 = new VirtuosoParameterCollection(null);

            p0.Add("box", box);
            p0.Add("type", rtype);
            p0.Add("lang", lang);

            ManagedCommand cmd0 = new ManagedCommand(connection);

            cmd0.SetParameters(p0);
            try
            {
                cmd0.Execute("DB.DBA.RDF_MAKE_OBJ_OF_TYPEDSQLVAL (?, ?, ?)");
            }
            finally
            {
                cmd0.CloseCursor(true);
                cmd0.Dispose();
            }

            VirtuosoParameterCollection p1 = new VirtuosoParameterCollection(null);

            p1.Add("box", box);

            ManagedCommand cmd1 = new ManagedCommand(connection);

            cmd1.SetParameters(p1);
            try
            {
                cmd1.Execute("select rdf_box_ro_id (?)");
                while (cmd1.Fetch())
                {
                    object data = cmd1.GetColumnData(0, cmd1.GetColumnMetaData());
                    if (data != null)
                    {
                        ro_id = (long)data;
                    }
                }
            }
            finally
            {
                cmd1.CloseCursor(true);
                cmd1.Dispose();
            }
            return(ro_id);
        }
        public override void SetCurrentCatalog(string name)
        {
            VirtuosoParameterCollection p = new VirtuosoParameterCollection(null);

            p.Add("name", name);

            ManagedCommand cmd = new ManagedCommand(this);

            cmd.SetParameters(p);
            try
            {
                cmd.Execute("set_qualifier(?)");
            }
            finally
            {
                cmd.CloseCursor(true);
                cmd.Dispose();
            }
        }
        private byte[] GetServerDtcWhereabouts()
        {
            ManagedCommand cmd = new ManagedCommand(this);

            cmd.SetParameters(null);
            try
            {
                cmd.Execute("select mts_get_rmcookie()");
                if (cmd.Fetch())
                {
                    object data = cmd.GetColumnData(0, cmd.GetColumnMetaData());
                    if (data != null && data is string)
                    {
                        return(Decode((string)data));
                    }
                }
            }
            finally
            {
                cmd.CloseCursor(true);
                cmd.Dispose();
            }
            return(null);
        }
      private long rdfMakeObj (object box, string rtype, string lang)
      {
	long ro_id = 0;
	VirtuosoParameterCollection p0 = new VirtuosoParameterCollection (null);
        p0.Add("box", box);
	p0.Add("type", rtype);
        p0.Add("lang", lang);

	ManagedCommand cmd0 = new ManagedCommand (connection);
	cmd0.SetParameters (p0);
	try
	{
		cmd0.Execute ("DB.DBA.RDF_MAKE_OBJ_OF_TYPEDSQLVAL (?, ?, ?)");
	}
	finally
	{
		cmd0.CloseCursor (true);
		cmd0.Dispose ();
	}

	VirtuosoParameterCollection p1 = new VirtuosoParameterCollection (null);
        p1.Add("box", box);

	ManagedCommand cmd1 = new ManagedCommand (connection);
	cmd1.SetParameters (p1);
	try
	{
		cmd1.Execute ("select rdf_box_ro_id (?)");
                while(cmd1.Fetch())
                {
		    object data = cmd1.GetColumnData (0, cmd1.GetColumnMetaData ());
		    if (data != null)
			  ro_id = (long) data;
                }
	}
	finally
	{
		cmd1.CloseCursor (true);
		cmd1.Dispose ();
	}
	return ro_id;
      }
      private void fillHashFromSQL (Dictionary<int,string> ht, Hashtable rev, string sql) 
      {
	ManagedCommand cmd = new ManagedCommand (connection);
	cmd.SetParameters (null);
	try
	{
		cmd.Execute (sql);
                while(cmd.Fetch())
                {
                    int k = 0;
                    string v = null;
		    object data = cmd.GetColumnData (0, cmd.GetColumnMetaData ());
		    if (data != null)
			  k = (int) data;
		    data = cmd.GetColumnData (1, cmd.GetColumnMetaData ());
		    if (data != null && data is string)
			  v = (string) data;
		    ht[k] =  v;
                    rev[v] = k;
                }
	}
	finally
	{
		cmd.CloseCursor (true);
		cmd.Dispose ();
	}
      }
		private byte[] GetServerDtcWhereabouts ()
		{
			ManagedCommand cmd = new ManagedCommand (this);
			cmd.SetParameters (null);
			try
			{
				cmd.Execute ("select mts_get_rmcookie()");
				if (cmd.Fetch ())
				{
					object data = cmd.GetColumnData (0, cmd.GetColumnMetaData ());
					if (data != null && data is string)
						return Decode ((string) data);
				}
			}
			finally
			{
				cmd.CloseCursor (true);
				cmd.Dispose ();
			}
			return null;
		}
		public override void SetCurrentCatalog (string name)
		{
			VirtuosoParameterCollection p = new VirtuosoParameterCollection (null);
			p.Add ("name", name);

			ManagedCommand cmd = new ManagedCommand (this);
			cmd.SetParameters (p);
			try
			{
				cmd.Execute ("set_qualifier(?)");
			}
			finally
			{
				cmd.CloseCursor (true);
				cmd.Dispose ();
			}
		}
		public override void Enlist (object distributedTransaction)
		{
			ITransaction transaction = (ITransaction) distributedTransaction;
			if (transaction == null)
			{
				Future future = new Future (Service.TransactionEnlist, (int) DtpFlags.SQL_TP_UNENLIST, null);
				object result = null;
				try
				{
					futures.Add (future);
					future.SendRequest (Session);
					result = future.GetNextResult (Session, futures);
				}
				finally
				{
					futures.Remove (future);
				}
				if (result != null && result is object[])
				{
					object[] results = (object[]) result;
					errors.AddServerError ((string) results[1], null, (string) results[2]);
					Diagnostics.HandleErrors (CLI.ReturnCode.SQL_ERROR, this);
				}
			}
			else
			{
				byte[] whereabouts = GetServerDtcWhereabouts ();
				DTC.ITransactionExport export = DTC.GetTransactionExport (transaction, whereabouts);
				byte[] cookie = DTC.GetTransactionCookie (transaction, export);
				string cookie_encoded = Encode (cookie);

				ManagedCommand cmd = new ManagedCommand (this);
				cmd.SetParameters (null);
				try
				{
					cmd.Execute ("select mts_enlist_transaction('" + cookie_encoded + "')");
					if (cmd.Fetch ())
					{
						autocommit = false;
					}
				}
				finally
				{
					cmd.CloseCursor (true);
					cmd.Dispose ();
				}
			}
		}