コード例 #1
0
        private IConsoleCommand RegisterConsoleCommand(string name, string help, Delegate command, CommandDelegateType type, EConsoleVariableFlags flags)
        {
            ManagedCommand managedCommand = new ManagedCommand(command, type);

            if (managedCommand.Command != null && managedCommand.NativeCallback != null)
            {
                using (FStringUnsafe nameUnsafe = new FStringUnsafe(name))
                    using (FStringUnsafe helpUnsafe = new FStringUnsafe(help))
                    {
                        IntPtr address = IntPtr.Zero;
                        switch (type)
                        {
                        case CommandDelegateType.Default:
                            address = Native_IConsoleManager.RegisterConsoleCommandDefault(
                                Address, ref nameUnsafe.Array, ref helpUnsafe.Array, managedCommand.NativeCallback, flags);
                            break;

                        case CommandDelegateType.WithArgs:
                            address = Native_IConsoleManager.RegisterConsoleCommandWithArgs(
                                Address, ref nameUnsafe.Array, ref helpUnsafe.Array, managedCommand.NativeCallback, flags);
                            break;

                        case CommandDelegateType.WithWorld:
                            address = Native_IConsoleManager.RegisterConsoleCommandWithWorld(
                                Address, ref nameUnsafe.Array, ref helpUnsafe.Array, managedCommand.NativeCallback, flags);
                            break;

                        case CommandDelegateType.WithWorldAndArgs:
                            address = Native_IConsoleManager.RegisterConsoleCommandWithWorldAndArgs(
                                Address, ref nameUnsafe.Array, ref helpUnsafe.Array, managedCommand.NativeCallback, flags);
                            break;

                        case CommandDelegateType.WithOutputDevice:
                            address = Native_IConsoleManager.RegisterConsoleCommandWithOutputDevice(
                                Address, ref nameUnsafe.Array, ref helpUnsafe.Array, managedCommand.NativeCallback, flags);
                            break;
                        }
                        if (address != IntPtr.Zero)
                        {
                            managedCommand.NativeCommand = new IConsoleCommand(address);
                            managedCommands[address]     = managedCommand;
                            return(managedCommand.NativeCommand);
                        }
                    }
            }
            return(null);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
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;
      }
コード例 #5
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 ();
	}
      }
コード例 #6
0
		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;
		}
コード例 #7
0
		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 ();
			}
		}
コード例 #8
0
		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 ();
				}
			}
		}