Exemplo n.º 1
0
        public static void DirectProfile(Int32 p_Nid)
        {
            // prepare call
            MethodCall mc = Toco.GetProfileMethodCall(p_Nid);

            // replace later with properties
            Call c = new Call("http://www.tocorre.com/ext/rpc/rpc_api.php", mc);

            MethodResponse mr = c.Execute();

            Console.WriteLine(mr.ToString());
        }
Exemplo n.º 2
0
        // Execute multi :(
        public List<Tocobject> ExecuteSystemMultiCall()
        {
            MethodCall mc = new MethodCall(Toco.SYSTEM_MULTI_CALL_METHOD);

            // prepare unique parameter with multiple calls
            Value varray = new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_ARRAY);
            foreach (MethodCall mcc in m_MethodCalls)
            {
                Value vcall = new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_STRUCT);
                vcall.AddToStruct("methodName", new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_STRING, mcc.method_name));
                Value vparams = new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_ARRAY);
                foreach (Value param in mcc.parameters)
                {
                    vparams.AddToArray(param);
                }
                vcall.AddToStruct("params", vparams);
                varray.AddToArray(vcall);
            }
            mc.AddParameter(varray);
            Call c = new Call("http://www.tocorre.com/ext/rpc/rpc_api.php", mc);
            MethodResponse mr = c.Execute();

            // unique return is an array type Value. Each array element has a Value
            // corresponding to the return value of the nth method call queued
            List<Tocobject> ret = new List<Tocobject>();

            Int32 i = 0;
            foreach (MethodCall mcc in m_MethodCalls)
            {
                Value v = mr.values[0].array_value[i];
                switch (mcc.method_name)
                {
                    case LOGIN_METHOD:
                        if (v.type == tocorre.XmlRpc.Type.XMLRPC_TYPE_ARRAY)
                            ret.Add(Session.FromValue(v.array_value[0]));
                        else
                            ret.Add(new Session(true, v));
                        break;
                    case PROFILE_METHOD:
                        if (v.type == tocorre.XmlRpc.Type.XMLRPC_TYPE_ARRAY)
                            ret.Add(GenericValue.FromValue(v.array_value[0]));
                        else
                            ret.Add(new GenericValue(true, v));
                        break;
                    case SCRAPS_METHOD:
                        if (v.type == tocorre.XmlRpc.Type.XMLRPC_TYPE_ARRAY)
                            ret.Add(Scrap.FromValue(v.array_value[0]));
                        else
                            ret.Add(new Scrap(true, v));
                        break;
                    case MSG_METHOD:
                        if (v.type == tocorre.XmlRpc.Type.XMLRPC_TYPE_ARRAY)
                            ret.Add(Msgs.FromValue(v.array_value[0]));
                        else
                            ret.Add(new Msgs(true, v));
                        break;
                    case FLUSH_METHOD:
                        if (v.type == tocorre.XmlRpc.Type.XMLRPC_TYPE_ARRAY)
                            ret.Add(GenericValue.FromValue(v.array_value[0]));
                        else
                            ret.Add(new GenericValue(true, v));

                        break;
                    case SET_MOTD_METHOD:
                        if (v.type == tocorre.XmlRpc.Type.XMLRPC_TYPE_ARRAY)
                            ret.Add(GenericValue.FromValue(v.array_value[0]));
                        else
                            ret.Add(new GenericValue(true, v));
                        break;
                    default:
                        throw new Exception("Unexpected method name: " + mcc.method_name);
                }
                i++;
            }

            return ret;
        }
Exemplo n.º 3
0
 public static Session DirectLogin(String p_User, String p_Password, Int32 p_Nid)
 {
     MethodCall mc = Toco.GetLoginMethodCall(p_User, p_Password, p_Nid);
     // replace later with properties
     Call c = new Call("http://www.tocorre.com/ext/rpc/rpc_api.php", mc);
     MethodResponse mr = c.Execute();
     return Session.FromValue(mr.values[0]);
 }