コード例 #1
0
        public static void TestReadVersion()
        {
            XmlRpcClient client = new XmlRpcClient();

            client.Url  = Url;
            client.Path = "common";

            XmlRpcResponse response = client.Execute("version");

            Console.WriteLine("version");
            Console.WriteLine("REQUEST: ");
            client.WriteRequest(Console.Out);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("RESPONSE: ");
            client.WriteResponse(Console.Out);

            Console.WriteLine();
            Console.WriteLine();
            if (response.IsFault())
            {
                Console.WriteLine(response.GetFaultString());
            }
            else
            {
                Console.WriteLine(response.GetString());
            }
        }
コード例 #2
0
ファイル: Master.cs プロジェクト: IAmUser4574/ROS.NET
        /// <summary>
        /// </summary>
        /// <param name="method"></param>
        /// <param name="request">Full request to send to the master </param>
        /// <param name="response">Full response including status code and status message. Initially empty.</param>
        /// <param name="payload">Location to store the actual data requested, if any.</param>
        /// <param name="wait_for_master">If you recieve an unseccessful status code, keep retrying.</param>
        /// <returns></returns>
        public static bool execute(string method, XmlRpcValue request, ref XmlRpcValue response, ref XmlRpcValue payload,
                                   bool wait_for_master)
        {
            try
            {
                DateTime startTime   = DateTime.Now;
                string   master_host = host;
                int      master_port = port;

                //EDB.WriteLine("Trying to connect to master @ " + master_host + ":" + master_port);
                XmlRpcClient client  = XmlRpcManager.Instance.getXMLRPCClient(master_host, master_port, "/");
                bool         printed = false;
                bool         ok      = true;
                while (!client.IsConnected && !ROS.shutting_down && !XmlRpcManager.Instance.shutting_down ||
                       !(ok = client.Execute(method, request, response) && XmlRpcManager.Instance.validateXmlrpcResponse(method, response, ref payload)))
                {
                    if (!wait_for_master)
                    {
                        XmlRpcManager.Instance.releaseXMLRPCClient(client);
                        return(false);
                    }
                    if (!printed)
                    {
                        EDB.WriteLine("[{0}] FAILED TO CONTACT MASTER AT [{1}:{2}]. {3}", method, master_host,
                                      master_port, (wait_for_master ? "Retrying..." : ""));
                        printed = true;
                    }
                    if (retryTimeout.TotalSeconds > 0 && DateTime.Now.Subtract(startTime) > retryTimeout)
                    {
                        EDB.WriteLine("[{0}] Timed out trying to connect to the master after [{1}] seconds", method,
                                      retryTimeout.TotalSeconds);
                        XmlRpcManager.Instance.releaseXMLRPCClient(client);
                        return(false);
                    }
                    Thread.Sleep(10);
                }
                if (ok && !firstsucces)
                {
                    firstsucces = true;
                    //EDB.WriteLine(string.Format("CONNECTED TO MASTER AT [{0}:{1}]", master_host, master_port));
                }
                XmlRpcManager.Instance.releaseXMLRPCClient(client);
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(false);
        }
コード例 #3
0
        public static void Test(String xmlcommand)
        {
            XmlRpcClient client = new XmlRpcClient();

            client.Url = Url;
            //client.Path = "common";

            XmlRpcRequest requestCreate = new XmlRpcRequest(xmlcommand);

            //XmlRpcResponse responseCreate = client.Execute(requestCreate);
            client.Execute(requestCreate); //xml malformed error
            client.WriteRequest(Console.Out);
            Console.ReadKey();
        }
コード例 #4
0
        private static bool Connect()
        {
            bool rc = false;

            try
            {
                var DBPath = rootFolder + "ICM802.mdb";

                conn = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;"
                                           + "Data Source=" + DBPath);
                conn.Open();

                client      = new XmlRpcClient();
                client.Url  = odooUrl;
                client.Path = "common";

                // LOGIN

                XmlRpcRequest requestLogin = new XmlRpcRequest("authenticate");
                requestLogin.AddParams(db, user, pass, XmlRpcParameter.EmptyStruct());

                responseLogin = client.Execute(requestLogin);

                if (responseLogin.IsFault())
                {
                    logger.Error("無法連線到 odoo 資料庫");
                }
                else
                {
                    rc = true;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
            }

            return(rc);
        }
コード例 #5
0
 public bool Execute(string method, XmlRpcValue parameters, XmlRpcValue result)
 {
     lock (client_lock)
         return(client.Execute(method, parameters, result));
 }
コード例 #6
0
        private static string AddToOdoo(object[] pressValues)
        {
            string timestampStr = "";

            try
            {
                string   gear_qr       = ((string)pressValues[0]).Trim();
                string   pinion_qr     = ((string)pressValues[1]).Trim();
                string   product_model = (string)pressValues[2];
                DateTime timestamp     = (DateTime)pressValues[3];
                timestampStr = timestamp.ToString();
                float  press_distance      = float.Parse((string)pressValues[4]);
                float  press_duration      = float.Parse((string)pressValues[5]);
                float  compressor_pressure = float.Parse((string)pressValues[6]);
                float  final_pressure      = float.Parse((string)pressValues[7]);
                float  pos1_pressure       = float.Parse((string)pressValues[8]);
                float  pos2_pressure       = float.Parse((string)pressValues[9]);
                float  pos3_pressure       = float.Parse((string)pressValues[10]);
                float  pos4_pressure       = float.Parse((string)pressValues[11]);
                float  pos5_pressure       = float.Parse((string)pressValues[12]);
                string result        = (string)pressValues[13];
                string ng_reason     = (string)pressValues[14];
                string chartFileName = GetChartFile(timestamp);
                if (chartFileName != "")
                {
                    try
                    {
                        string destDir = rootFolder + @"110438";
                        if (!Directory.Exists(destDir))
                        {
                            Directory.CreateDirectory(destDir);
                        }
                        File.Copy(rootFolder + @"JPG\" + chartFileName, destDir + @"\" + chartFileName);
                    }
                    catch (Exception e1)
                    {
                        logger.Error(e1.Message, e1);
                    }
                }
                logger.Info("QR1: " + gear_qr);
                logger.Info("QR2: " + pinion_qr);
                logger.Info("Time: " + timestamp.ToString());
                logger.Info("chart: " + chartFileName);

                if (gear_qr == "" && pinion_qr == "")
                {
                    logger.Warn("No QR code");
                }
                else
                {
                    client.Path = "object";

                    List <object> domain = new List <object>();
                    if (gear_qr != "")
                    {
                        domain.Add(XmlRpcParameter.AsArray("gear_qr", "=", gear_qr));
                    }
                    if (pinion_qr != "")
                    {
                        domain.Add(XmlRpcParameter.AsArray("pinion_qr", "=", pinion_qr));
                    }

                    if (domain.Count == 2)
                    {
                        domain.Insert(0, "|");
                    }
                    XmlRpcRequest requestSearch = new XmlRpcRequest("execute_kw");
                    requestSearch.AddParams(db, responseLogin.GetInt(), pass, "batom.tesla.qrcode", "search_read",
                                            XmlRpcParameter.AsArray(
                                                domain
                                                ),
                                            XmlRpcParameter.AsStruct(
                                                XmlRpcParameter.AsMember("fields", XmlRpcParameter.AsArray("gear_qr", "pinion_qr"))
                                                // ,XmlRpcParameter.AsMember("limit", 2)
                                                )
                                            );

                    XmlRpcResponse responseSearch = client.Execute(requestSearch);

                    if (responseSearch.IsFault())
                    {
                        logger.Error(responseSearch.GetFaultString());
                    }
                    else if (!responseSearch.IsArray())
                    {
                        logger.Error("查詢 odoo 資料庫異常");
                    }
                    else
                    {
                        int           qr_id     = -1; // used as the flag (ok: qr_id > 0)
                        List <Object> valueList = responseSearch.GetArray();
                        if (valueList.Count == 0)
                        {
                            Dictionary <string, object> values = new Dictionary <string, object>();
                            if (gear_qr != "")
                            {
                                values["gear_qr"] = gear_qr;
                            }
                            if (pinion_qr != "")
                            {
                                values["pinion_qr"] = pinion_qr;
                            }
                            XmlRpcRequest requestCreate = new XmlRpcRequest("execute_kw");
                            requestCreate.AddParams(db, responseLogin.GetInt(), pass, "batom.tesla.qrcode", "create",
                                                    XmlRpcParameter.AsArray(values)
                                                    );

                            XmlRpcResponse responseCreate = client.Execute(requestCreate);
                            if (responseCreate.IsFault())
                            {
                                logger.Error(responseCreate.GetFaultString());
                            }
                            else
                            {
                                qr_id = responseCreate.GetInt();
                            }
                        }
                        else
                        {
                            string db_gear_qr   = "";
                            string db_pinion_qr = "";
                            foreach (Dictionary <string, object> valueDictionary in valueList)
                            {
                                foreach (KeyValuePair <string, object> kvp in valueDictionary)
                                {
                                    if (kvp.Key == "id")
                                    {
                                        qr_id = (int)kvp.Value;
                                    }
                                    else if (kvp.Key == "gear_qr" && kvp.Value is string)
                                    {
                                        db_gear_qr = (string)kvp.Value;
                                    }
                                    else if (kvp.Key == "pinion_qr" && kvp.Value is string)
                                    {
                                        db_pinion_qr = (string)kvp.Value;
                                    }
                                }
                            }

                            if ((gear_qr == "" || gear_qr == db_gear_qr) &&
                                (pinion_qr == "" || pinion_qr == db_pinion_qr))
                            {
                                // existing qr record, do nothing
                            }
                            else if (ValueConflict(gear_qr, db_gear_qr) ||
                                     ValueConflict(pinion_qr, db_pinion_qr))
                            {
                                logger.Error("與資料庫中下列 QR code 組合衝突,無法儲存:\n" +
                                             "軸: " + db_pinion_qr + "\n" +
                                             "餅: " + db_gear_qr
                                             );
                            }
                            else
                            {
                                Dictionary <string, object> values = new Dictionary <string, object>();
                                if (gear_qr != "")
                                {
                                    values["gear_qr"] = gear_qr;
                                }
                                if (pinion_qr != "")
                                {
                                    values["pinion_qr"] = pinion_qr;
                                }
                                XmlRpcRequest requestWrite = new XmlRpcRequest("execute_kw");
                                requestWrite.AddParams(db, responseLogin.GetInt(), pass, "batom.tesla.qrcode", "write",
                                                       XmlRpcParameter.AsArray(XmlRpcParameter.AsArray(qr_id), values)
                                                       );

                                XmlRpcResponse responseWrite = client.Execute(requestWrite);

                                if (responseWrite.IsFault())
                                {
                                    logger.Error(responseWrite.GetFaultString());
                                    qr_id = -1;
                                }
                            }
                        }

                        if (qr_id > 0)
                        {
                            domain = new List <object>();
                            domain.Add(XmlRpcParameter.AsArray("timestamp", "=", timestampStr));
                            requestSearch = new XmlRpcRequest("execute_kw");
                            requestSearch.AddParams(db, responseLogin.GetInt(), pass, "batom.tesla.press_info", "search_read",
                                                    XmlRpcParameter.AsArray(
                                                        domain
                                                        ),
                                                    XmlRpcParameter.AsStruct(
                                                        XmlRpcParameter.AsMember("fields", XmlRpcParameter.AsArray("timestamp"))
                                                        // ,XmlRpcParameter.AsMember("limit", 2)
                                                        )
                                                    );

                            responseSearch = client.Execute(requestSearch);

                            if (responseSearch.IsFault())
                            {
                                logger.Error(responseSearch.GetFaultString());
                            }
                            else if (!responseSearch.IsArray())
                            {
                                logger.Error("查詢 odoo 資料庫異常");
                            }
                            else
                            {
                                valueList = responseSearch.GetArray();
                                if (valueList.Count > 0)
                                {
                                    logger.Warn("壓配資料已存在");
                                }
                                else
                                {
                                    Dictionary <string, object> values = new Dictionary <string, object>();
                                    values["qr_id"]               = qr_id;
                                    values["product_model"]       = product_model;
                                    values["timestamp"]           = timestampStr;
                                    values["press_distance"]      = press_distance;
                                    values["press_duration"]      = press_duration;
                                    values["compressor_pressure"] = compressor_pressure;
                                    values["final_pressure"]      = final_pressure;
                                    values["pos1_pressure"]       = pos1_pressure;
                                    values["pos2_pressure"]       = pos2_pressure;
                                    values["pos3_pressure"]       = pos3_pressure;
                                    values["pos4_pressure"]       = pos4_pressure;
                                    values["pos5_pressure"]       = pos5_pressure;
                                    values["result"]              = result;
                                    values["ng_reason"]           = ng_reason;
                                    values["chart_file_name"]     = chartFileName;
                                    if (chartFileName != "")
                                    {
                                        try
                                        {
                                            values["chart"] = Convert.ToBase64String(File.ReadAllBytes(rootFolder + @"JPG\" + chartFileName));
                                        }
                                        catch (Exception e2)
                                        {
                                            logger.Error(e2.Message, e2);
                                        }
                                    }
                                    else
                                    {
                                        values["chart"] = false;
                                    }
                                    XmlRpcRequest requestCreate = new XmlRpcRequest("execute_kw");
                                    requestCreate.AddParams(db, responseLogin.GetInt(), pass, "batom.tesla.press_info", "create",
                                                            XmlRpcParameter.AsArray(values)
                                                            );

                                    XmlRpcResponse responseCreate = client.Execute(requestCreate);
                                    if (responseCreate.IsFault())
                                    {
                                        logger.Error(responseCreate.GetFaultString());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
            }

            return(timestampStr);
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: eric0127/batom-QrRecorder
        private void Save()
        {
            string pressfit_qr = "";
            string gear_qr     = "";
            string pinion_qr   = "";

            if (txtPressfit.Text != null)
            {
                pressfit_qr = txtPressfit.Text.Trim();
            }
            if (txtGear.Text != null)
            {
                gear_qr = txtGear.Text.Trim();
            }
            if (txtPinion.Text != null)
            {
                pinion_qr = txtPinion.Text.Trim();
            }
            if (pressfit_qr == "" && gear_qr == "" && pinion_qr == "")
            {
                MessageBox.Show("請掃描 QR Code", "錯誤");
            }
            else
            {
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    XmlRpcClient client = new XmlRpcClient();
                    client.Url  = odooUrl;
                    client.Path = "common";

                    // LOGIN

                    XmlRpcRequest requestLogin = new XmlRpcRequest("authenticate");
                    requestLogin.AddParams(db, user, pass, XmlRpcParameter.EmptyStruct());

                    XmlRpcResponse responseLogin = client.Execute(requestLogin);

                    if (responseLogin.IsFault())
                    {
                        Cursor.Current = Cursors.Default;
                        MessageBox.Show("無法連線到資料庫,請通知 IT 人員", "錯誤");
                    }
                    else
                    {
                        client.Path = "object";

                        List <object> domain = new List <object>();
                        if (pressfit_qr != "")
                        {
                            domain.Add(XmlRpcParameter.AsArray("pressfit_qr", "=", pressfit_qr));
                        }
                        if (gear_qr != "")
                        {
                            domain.Add(XmlRpcParameter.AsArray("gear_qr", "=", gear_qr));
                        }
                        if (pinion_qr != "")
                        {
                            domain.Add(XmlRpcParameter.AsArray("pinion_qr", "=", pinion_qr));
                        }

                        if (domain.Count >= 2)
                        {
                            if (domain.Count == 3)
                            {
                                domain.Insert(0, "|");
                            }
                            domain.Insert(0, "|");
                        }
                        XmlRpcRequest requestSearch = new XmlRpcRequest("execute_kw");
                        requestSearch.AddParams(db, responseLogin.GetInt(), pass, "batom.tesla.qrcode", "search_read",
                                                XmlRpcParameter.AsArray(
                                                    domain
                                                    ),
                                                XmlRpcParameter.AsStruct(
                                                    XmlRpcParameter.AsMember("fields", XmlRpcParameter.AsArray("pressfit_qr", "gear_qr", "pinion_qr"))
                                                    // ,XmlRpcParameter.AsMember("limit", 2)
                                                    )
                                                );

                        XmlRpcResponse responseSearch = client.Execute(requestSearch);

                        if (responseSearch.IsFault())
                        {
                            MessageBox.Show(responseSearch.GetFaultString(), "錯誤");
                        }
                        else if (!responseSearch.IsArray())
                        {
                            Cursor.Current = Cursors.Default;
                            MessageBox.Show("查詢資料庫異常,請通知 IT 人員", "錯誤");
                        }
                        else
                        {
                            List <Object> valueList = responseSearch.GetArray();
                            if (valueList.Count == 0)
                            {
                                Dictionary <string, object> values = new Dictionary <string, object>();
                                if (pressfit_qr != "")
                                {
                                    values["pressfit_qr"] = pressfit_qr;
                                }
                                if (gear_qr != "")
                                {
                                    values["gear_qr"] = gear_qr;
                                }
                                if (pinion_qr != "")
                                {
                                    values["pinion_qr"] = pinion_qr;
                                }
                                XmlRpcRequest requestCreate = new XmlRpcRequest("execute_kw");
                                requestCreate.AddParams(db, responseLogin.GetInt(), pass, "batom.tesla.qrcode", "create",
                                                        XmlRpcParameter.AsArray(values)
                                                        );

                                XmlRpcResponse responseCreate = client.Execute(requestCreate);
                                if (responseCreate.IsFault())
                                {
                                    MessageBox.Show(responseCreate.GetFaultString(), "錯誤");
                                }
                                else
                                {
                                    AutoClosingMessageBox.Show("已儲存", "完成", 1000);
                                    ClearFields();
                                }
                            }
                            else
                            {
                                string db_pressfit_qr = "";
                                string db_gear_qr     = "";
                                string db_pinion_qr   = "";
                                int    id             = -1;
                                foreach (Dictionary <string, object> valueDictionary in valueList)
                                {
                                    foreach (KeyValuePair <string, object> kvp in valueDictionary)
                                    {
                                        if (kvp.Key == "id")
                                        {
                                            id = (int)kvp.Value;
                                        }
                                        else if (kvp.Key == "pressfit_qr" && kvp.Value is string)
                                        {
                                            db_pressfit_qr = (string)kvp.Value;
                                        }
                                        else if (kvp.Key == "gear_qr" && kvp.Value is string)
                                        {
                                            db_gear_qr = (string)kvp.Value;
                                        }
                                        else if (kvp.Key == "pinion_qr" && kvp.Value is string)
                                        {
                                            db_pinion_qr = (string)kvp.Value;
                                        }
                                    }
                                }

                                if ((pressfit_qr == "" || pressfit_qr == db_pressfit_qr) &&
                                    (gear_qr == "" || gear_qr == db_gear_qr) &&
                                    (pinion_qr == "" || pinion_qr == db_pinion_qr))
                                {
                                    Cursor.Current = Cursors.Default;
                                    MessageBox.Show("QR code 組合已存在", "錯誤");
                                }
                                else if (ValueConflict(pressfit_qr, db_pressfit_qr) ||
                                         ValueConflict(gear_qr, db_gear_qr) ||
                                         ValueConflict(pinion_qr, db_pinion_qr))
                                {
                                    Cursor.Current = Cursors.Default;
                                    MessageBox.Show("與資料庫中下列 QR code 組合衝突,無法儲存:\n\n" +
                                                    "總成:" + db_pressfit_qr + "\n" +
                                                    "軸: " + db_pinion_qr + "\n" +
                                                    "餅: " + db_gear_qr,
                                                    "錯誤"
                                                    );
                                }
                                else
                                {
                                    Dictionary <string, object> values = new Dictionary <string, object>();
                                    if (pressfit_qr != "")
                                    {
                                        values["pressfit_qr"] = pressfit_qr;
                                    }
                                    if (gear_qr != "")
                                    {
                                        values["gear_qr"] = gear_qr;
                                    }
                                    if (pinion_qr != "")
                                    {
                                        values["pinion_qr"] = pinion_qr;
                                    }
                                    XmlRpcRequest requestWrite = new XmlRpcRequest("execute_kw");
                                    requestWrite.AddParams(db, responseLogin.GetInt(), pass, "batom.tesla.qrcode", "write",
                                                           XmlRpcParameter.AsArray(XmlRpcParameter.AsArray(id), values)
                                                           );

                                    XmlRpcResponse responseWrite = client.Execute(requestWrite);

                                    if (responseWrite.IsFault())
                                    {
                                        MessageBox.Show(responseWrite.GetFaultString(), "錯誤");
                                    }
                                    else
                                    {
                                        AutoClosingMessageBox.Show("已儲存", "完成", 1000);
                                        ClearFields();
                                    }
                                }
                            }
                        }
                        Cursor.Current = Cursors.Default;
                    }
                }
                catch
                {
                    MessageBox.Show("無法儲存,請通知IT人員", "錯誤");
                }
            }
        }
コード例 #8
0
        public static void TestReadRecords()
        {
            XmlRpcClient client = new XmlRpcClient();

            client.Url  = Url;
            client.Path = "common";

            // LOGIN

            XmlRpcRequest requestLogin = new XmlRpcRequest("authenticate");

            requestLogin.AddParams(db, user, pass, XmlRpcParameter.EmptyStruct());

            XmlRpcResponse responseLogin = client.Execute(requestLogin);

            // Console.WriteLine("authenticate");
            // Console.WriteLine("REQUEST: ");
            // client.WriteRequest(Console.Out);

            // Console.WriteLine();
            // Console.WriteLine();
            // Console.WriteLine("RESPONSE: ");
            // client.WriteResponse(Console.Out);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("LOGIN: "******"object";

            XmlRpcRequest requestSearch = new XmlRpcRequest("execute_kw");

            requestSearch.AddParams(db, responseLogin.GetInt(), pass, "res.partner", "search",
                                    XmlRpcParameter.AsArray(
                                        XmlRpcParameter.AsArray(
                                            XmlRpcParameter.AsArray("is_company", "=", true), XmlRpcParameter.AsArray("customer", "=", true)
                                            )
                                        )
                                    );

            requestSearch.AddParamStruct(
                XmlRpcParameter.AsMember("limit", 2)
                );

            XmlRpcResponse responseSearch = client.Execute(requestSearch);

            // Console.WriteLine();
            // Console.WriteLine();
            // Console.WriteLine("search");
            // Console.WriteLine("REQUEST: ");
            // client.WriteRequest(Console.Out);

            // Console.WriteLine();
            // Console.WriteLine();
            // Console.WriteLine("RESPONSE: ");
            // client.WriteResponse(Console.Out);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("SEARCH: ");
            if (responseSearch.IsFault())
            {
                Console.WriteLine(responseSearch.GetFaultString());
            }
            else
            {
                Console.WriteLine(responseSearch.GetString());
            }

            // READ

            XmlRpcRequest requestRead = new XmlRpcRequest("execute_kw");

            requestRead.AddParams(db, responseLogin.GetInt(), pass, "res.partner", "read",
                                  XmlRpcParameter.AsArray(
                                      responseSearch.GetArray()
                                      )
                                  );

            requestRead.AddParamStruct(XmlRpcParameter.AsMember("fields",
                                                                XmlRpcParameter.AsArray("name")
                                                                )
                                       );

            XmlRpcResponse responseRead = client.Execute(requestRead);

            // Console.WriteLine();
            // Console.WriteLine();
            // Console.WriteLine("read");
            // Console.WriteLine("REQUEST: ");
            // client.WriteRequest(Console.Out);

            // Console.WriteLine();
            // Console.WriteLine();
            // Console.WriteLine("RESPONSE: ");
            // client.WriteResponse(Console.Out);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("READ: ");
            if (responseRead.IsFault())
            {
                Console.WriteLine(responseRead.GetFaultString());
            }
            else
            {
                Console.WriteLine(responseRead.GetString());
            }
        }
コード例 #9
0
        public static void TestCreateRecord()
        {
            XmlRpcClient client = new XmlRpcClient();

            client.Url  = Url;
            client.Path = "common";

            // LOGIN

            XmlRpcRequest requestLogin = new XmlRpcRequest("authenticate");

            requestLogin.AddParams(db, user, pass, XmlRpcParameter.EmptyStruct());

            XmlRpcResponse responseLogin = client.Execute(requestLogin);

            Console.WriteLine("authenticate");
            Console.WriteLine("REQUEST: ");
            client.WriteRequest(Console.Out);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("RESPONSE: ");
            client.WriteResponse(Console.Out);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("LOGIN: "******"object";

            XmlRpcRequest requestCreate = new XmlRpcRequest("execute_kw");

            requestCreate.AddParams(db, responseLogin.GetInt(), pass, "res.partner", "create",
                                    XmlRpcParameter.AsArray(
                                        XmlRpcParameter.AsStruct(
                                            XmlRpcParameter.AsMember("name", "Albert Einstein")
                                            , XmlRpcParameter.AsMember("image", Convert.ToBase64String(File.ReadAllBytes("img/einstein.jpg")))
                                            , XmlRpcParameter.AsMember("email", "*****@*****.**")
                                            )
                                        )
                                    );

            XmlRpcResponse responseCreate = client.Execute(requestCreate);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("create");
            Console.WriteLine("REQUEST: ");
            client.WriteRequest(Console.Out);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("RESPONSE: ");
            client.WriteResponse(Console.Out);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("READ: ");
            if (responseCreate.IsFault())
            {
                Console.WriteLine(responseCreate.GetFaultString());
            }
            else
            {
                Console.WriteLine(responseCreate.GetString());
            }
        }