예제 #1
0
    static void Set(string cls, string state, string[] attributes)
    {
        ByteBuffer fbfr = ATMI.tpalloc("FML32", null, 1024);

        try {
            TPFBuilder.I.FaddString(ref fbfr, TMIB.TA_OPERATION, "SET");
            TPFBuilder.I.FaddString(ref fbfr, TMIB.TA_CLASS, cls);
            if (state != null)
            {
                TPFBuilder.I.FaddString(ref fbfr, TMIB.TA_STATE, state);
                if (state.Equals("CLEANING"))
                {
                    TPFBuilder.I.FaddInt(ref fbfr, TMIB.TA_FLAGS, TMIB.QMIB_FORCECLOSE);
                }
            }
            foreach (string attribute in attributes)
            {
                int    eqPos   = attribute.IndexOf('=');
                string key     = attribute.Substring(0, eqPos);
                string val     = attribute.Substring(eqPos + 1);
                int    fieldID = FML32.Fldid(key);
                TPFBuilder.I.FaddString(ref fbfr, fieldID, val);
            }
            try {
                Console.WriteLine("INFO: Executing " + cls + ".SET(" + state + ", "
                                  + ToString(attributes) + ")");
                ATMI.tpadmcall(fbfr, ref fbfr, 0);
            } catch (TPEMIB) {
                Console.WriteLine("ERROR: " + FML32.ToString(fbfr));
                Environment.Exit(1);
            }
        } finally {
            ATMI.tpfree(fbfr);
        }
    }