示例#1
0
    // The DOWNLOAD service routine

    public static void DOWNLOAD(TPSVCINFO rqst)
    {
        if ((rqst.flags & ATMI.TPSENDONLY) == 0)
        {
            TUX.userlog("ERROR: Client not in receive mode");
            ATMI.tpreturn(ATMI.TPFAIL, 0, null, 0, 0); // Return null message as client is not in receive mode
            return;
        }

        string fileName = StringUtils.ReadStringBuffer(rqst.data, rqst.len);

        try
        {
            FileStream fs = File.OpenRead(fileName);
            try
            {
                Send(fs, rqst.cd);
            }
            finally
            {
                fs.Close();
            }
            ATMI.tpreturn(ATMI.TPSUCCESS, 0, null, 0, 0);
        }
        catch (FileNotFoundException eFileNotFound)
        {
            ServerUtils.ReturnReply(ATMI.TPFAIL, 0, eFileNotFound.Message);
        }
    }
示例#2
0
        public static void TEST(TPSVCINFO svcInfo)
        {
            string message = "Installation OK";

            byte[]     bytes = Encoding.Default.GetBytes(message);
            ByteBuffer reply = ATMI.tpalloc("STRING", null, bytes.Length + 1);

            reply.PutBytes(bytes);
            reply.PutByte(bytes.Length, 0);
            ATMI.tpreturn(ATMI.TPSUCCESS, 0, reply, 0, 0);
        }
示例#3
0
    // The TOUPPER service routine

    public static void TOUPPER(TPSVCINFO rqst)
    {
        ByteBuffer data = rqst.data;

        byte[] bytes = new byte[rqst.len - 1];
        data.GetBytes(bytes);
        string s = Encoding.Default.GetString(bytes);

        s = s.ToUpper();

        bytes = Encoding.Default.GetBytes(s);
        data.PutBytes(bytes);
        data.PutByte(bytes.Length, 0);

        ATMI.tpreturn(ATMI.TPSUCCESS, 0, data, 0, 0);
    }
示例#4
0
    // Returns a STRING message from a service routine.

    public static void ReturnReply(int rval, int rcode, string message)
    {
        bool       returned = false;
        ByteBuffer reply    = StringUtils.NewStringBuffer(message);

        try
        {
            ATMI.tpreturn(ATMI.TPFAIL, rcode, reply, 0, 0);
            returned = true;
        }
        finally
        {
            if (!returned)
            {
                ATMI.tpfree(reply);
            }
        }
    }
示例#5
0
    public static void PUBLISH_TIME(TPSVCINFO svcinfo)
    {
        ByteBuffer message = StringUtils.NewStringBuffer("It is now " + DateTime.Now);

        try
        {
            ATMI.tppost("TIME", message, 0, 0);
        }
        catch (TPENOENT)
        {
            // EventBroker not running yet (ignored)
        }
        finally
        {
            ATMI.tpfree(message);
        }

        Thread.Sleep(1000);

        ATMI.tpacall("PUBLISH_TIME", null, 0, ATMI.TPNOREPLY);

        ATMI.tpreturn(ATMI.TPSUCCESS, 0, null, 0, 0);
    }
示例#6
0
    public static void FML32_TOUPPER(TPSVCINFO rqst)
    {
        ByteBuffer fbfr = rqst.data;

        int fldid = FML32.FIRSTFLDID;
        int occ   = 0;

        while (FML32.Fnext(fbfr, ref fldid, ref occ))
        {
            int occur = FML32.Foccur(fbfr, fldid);
            if (FML32.Fldtype(fldid) == FML32.FLD_STRING)
            {
                for (int i = 0; i < occur; i++)
                {
                    string s = FML32.FgetString(fbfr, fldid, i);
                    s = s.ToUpper();
                    FML32.Fchg(fbfr, fldid, i, s);
                }
            }
            occ = occur; // Skip to next field id
        }

        ATMI.tpreturn(ATMI.TPSUCCESS, 0, fbfr, 0, 0);
    }