public string PostEmployee([FromBody] Employee employee)
        {
            IOpenErpLogin rpcClientLogin = XmlRpcProxyGen.Create <IOpenErpLogin>();

            rpcClientLogin.NonStandard = XmlRpcNonStandard.AllowStringFaultCode;

            //login
            int userId = rpcClientLogin.Login(db, username, password);

            //Add Contacts(Customers)
            IOpenErpAddFields rpcField      = XmlRpcProxyGen.Create <IOpenErpAddFields>();
            XmlRpcStruct      addPairFields = new XmlRpcStruct();

            addPairFields.Add("x_UUID", employee.UUID);
            addPairFields.Add("name", employee.Name);
            addPairFields.Add("email", employee.Email);
            addPairFields.Add("x_timestamp", employee.Timestamp);
            addPairFields.Add("x_version", employee.Version);
            addPairFields.Add("active", employee.Active);
            addPairFields.Add("employee", true);
            addPairFields.Add("login", employee.Email);
            addPairFields.Add("sel_groups_1_9_10", 1);
            addPairFields.Add("sel_groups_38_39", 38);

            int resAdd = rpcField.Create(db, userId, password, "res.users", "create", addPairFields);

            return("Employee created with id = " + resAdd);
        }
        public string PostCustomer([FromBody] Customer customer)
        {
            IOpenErpLogin rpcClientLogin = XmlRpcProxyGen.Create <IOpenErpLogin>();

            rpcClientLogin.NonStandard = XmlRpcNonStandard.AllowStringFaultCode;

            //login
            int userId = rpcClientLogin.Login(db, username, password);

            //Add Contacts(Customers)
            IOpenErpAddFields rpcField      = XmlRpcProxyGen.Create <IOpenErpAddFields>();
            XmlRpcStruct      addPairFields = new XmlRpcStruct();

            addPairFields.Add("x_UUID", customer.UUID);
            addPairFields.Add("name", customer.Name);
            addPairFields.Add("email", customer.Email);
            addPairFields.Add("x_timestamp", customer.Timestamp);
            addPairFields.Add("x_version", customer.Version);
            addPairFields.Add("active", customer.Active);
            addPairFields.Add("x_banned", customer.Banned);
            addPairFields.Add("x_dateofbirth", customer.DateOfBirth);
            addPairFields.Add("vat", customer.BtwNumber);
            addPairFields.Add("phone", customer.GsmNumber);
            addPairFields.Add("customer", true);

            int resAdd = rpcField.Create("testDB", userId, "test123", "res.partner", "create", addPairFields);

            return("Customer created with id = " + resAdd);
        }
Пример #3
0
        //Login
        private void button1_Click(object sender, EventArgs e)
        {
            //Login to openerp
            string usr  = textBox2.Text.ToString();
            string pass = textBox3.Text.ToString();
            string db   = textBox4.Text.ToString();

            IOpenErpLogin rpcClientLogin = XmlRpcProxyGen.Create <IOpenErpLogin>(); //add  XmlRpcProxyGen.CS File from src folder if required,

            rpcClientLogin.Url = "http://" + textBox1.Text.ToString() + ":8069/xmlrpc/common";
            UserId             = rpcClientLogin.login(db, usr, pass);
            richTextBox1.AppendText("Logueado como usuario con id: " + UserId.ToString() + " \r\n");
        }
        public string GetCustomers()
        {
            IOpenErpLogin rpcClientLogin = XmlRpcProxyGen.Create <IOpenErpLogin>();

            rpcClientLogin.NonStandard = XmlRpcNonStandard.AllowStringFaultCode;

            //login
            int userId = rpcClientLogin.Login(db, username, password);

            //if(userId > 0)
            //{
            //    return "login ok";
            //} else
            //{
            //    return "login failed";
            //}

            IOpenErpAddFields rpcField = XmlRpcProxyGen.Create <IOpenErpAddFields>();

            //get all customers
            object[] filter = new object[1];
            filter[0] = new object[3] {
                "customer", "=", "true"
            };

            //List fields = new object[1];
            //object[] fieldsParams = new object[2] { "name", "street" };
            //fields = new object[2] { "fields", fieldsParams };

            XmlRpcStruct[]          results   = rpcField.Searchread(db, userId, password, "res.partner", "search_read", filter);
            List <Dto.ShowCustomer> customers = new List <Dto.ShowCustomer>();

            foreach (var res in results)
            {
                string  test = JsonConvert.SerializeObject(res);
                JObject jo   = JObject.Parse(test);

                Dto.ShowCustomer tempCustomer = new Dto.ShowCustomer(jo["name"].ToString(), jo["x_UUID"].ToString(), Int32.Parse(jo["x_timestamp"].ToString()),
                                                                     Int32.Parse(jo["x_version"].ToString()), bool.Parse(jo["x_banned"].ToString()), bool.Parse(jo["active"].ToString()),
                                                                     jo["email"].ToString(), jo["mobile"].ToString(), jo["x_dateofbirth"].ToString(), jo["vat"].ToString());
                customers.Add(tempCustomer);
            }
            return(JsonConvert.SerializeObject(customers) + "\n");
            //return results;
        }
        public string Get()
        {
            IOpenErpLogin rpcClientLogin = XmlRpcProxyGen.Create <IOpenErpLogin>();

            rpcClientLogin.NonStandard = XmlRpcNonStandard.AllowStringFaultCode;

            //login
            int userid = rpcClientLogin.login("ErrasmusHB", "*****@*****.**", "kassa");

            if (userid > 0)
            {
                return("login succesful");
            }
            else
            {
                return("fout");
            }
        }
        public string GetEmployees()
        {
            IOpenErpLogin rpcClientLogin = XmlRpcProxyGen.Create <IOpenErpLogin>();

            rpcClientLogin.NonStandard = XmlRpcNonStandard.AllowStringFaultCode;

            //login
            int userId = rpcClientLogin.Login(db, username, password);

            IOpenErpAddFields rpcField = XmlRpcProxyGen.Create <IOpenErpAddFields>();

            //get all employees by name
            object[] filter = new object[1];
            filter[0] = new object[3] {
                "employee", "=", "true"
            };

            //List fields = new object[1];
            //object[] fieldsParams = new object[2] { "name", "street" };
            //fields = new object[2] { "fields", fieldsParams };

            XmlRpcStruct[]          results   = rpcField.Searchread(db, userId, password, "res.users", "search_read", filter);
            List <Dto.ShowEmployee> employees = new List <Dto.ShowEmployee>();

            foreach (var res in results)
            {
                string  test = JsonConvert.SerializeObject(res);
                JObject jo   = JObject.Parse(test);

                Dto.ShowEmployee tempEmployee = new Dto.ShowEmployee(jo["name"].ToString(), jo["email"].ToString(), Int32.Parse(jo["partner_id"][0].ToString()), jo["x_UUID"].ToString(),
                                                                     Int32.Parse(jo["x_timestamp"].ToString()), Int32.Parse(jo["x_version"].ToString()), bool.Parse(jo["x_banned"].ToString()), bool.Parse(jo["active"].ToString()));
                employees.Add(tempEmployee);
            }


            return(JsonConvert.SerializeObject(employees) + "\n");
        }