Пример #1
0
 private static MethodCall GetSetMotdMethodCall(int p_Required, string p_Motd)
 {
     MethodCall mc = new MethodCall(Toco.SET_MOTD_METHOD);
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_Required));
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_STRING, p_Motd));
     return mc;
 }
Пример #2
0
 private void AddMethodCall(MethodCall p_MethodCall)
 {
     m_MethodCalls.Add(p_MethodCall);
 }
Пример #3
0
 private static MethodCall GetProfileMethodCall(Int32 p_Nid)
 {
     // prepare call
     MethodCall mc = new MethodCall(Toco.PROFILE_METHOD);
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_Nid));
     return mc;
 }
Пример #4
0
 private static MethodCall GetScrapsMethodCall(Int32 p_Nid, Int32 p_UnixTimeStamp, Int32 p_NoteId, Int32 p_Offset, Int32 p_Qty)
 {
     MethodCall mc = new MethodCall(Toco.SCRAPS_METHOD);
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_Nid));
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_UnixTimeStamp));
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_NoteId));
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_Qty));
     return mc;
 }
Пример #5
0
 private static MethodCall GetMsgMethodCall(int p_Nid, int p_UnixTimeStamp, int p_MsgId, int p_Offset, int p_Qty, int p_Folder)
 {
     MethodCall mc = new MethodCall(Toco.MSG_METHOD);
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_Nid));
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_UnixTimeStamp));
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_MsgId));
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_Qty));
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_Folder));
     return mc;
 }
Пример #6
0
 private static MethodCall GetLoginMethodCall(String p_User, String p_Password, Int32 p_Nid)
 {
     // prepare call
     MethodCall mc = new MethodCall(Toco.LOGIN_METHOD);
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_STRING, p_User));
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_STRING, p_Password));
     if (p_Nid > 0)
     {
         mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_Nid.ToString()));
     }
     return mc;
 }
Пример #7
0
 private static MethodCall GetFlushMethodCall(int p_Required)
 {
     MethodCall mc = new MethodCall(Toco.FLUSH_METHOD);
     mc.AddParameter(new Value(tocorre.XmlRpc.Type.XMLRPC_TYPE_INTEGER, p_Required));
     return mc;
 }
Пример #8
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;
        }
Пример #9
0
 public Call(String p_Url, MethodCall p_MethodCall)
 {
     this._url = p_Url;
     this._method_call = p_MethodCall;
 }