Ejemplo n.º 1
0
        public B1Session LoginServer(string usrName = "manager", string pwd = @"L4nd3$", string db = @"SBOLANDE")
        {
            B1Session session = null;

            try
            {
                //Discard last login information
                sessionGuid = string.Empty;

                Uri login = new Uri(urlSl + "Login");
                //Use : UriOperationParameter for querying options.
                //Use : BodyOperationParameter for sending JSON body.
                BodyOperationParameter[] body = new BodyOperationParameter[3];
                body[0] = new BodyOperationParameter("UserName", usrName);
                body[1] = new BodyOperationParameter("Password", pwd);
                body[2] = new BodyOperationParameter("CompanyDB", db);

                //Both HTTP & HTTPs protocols are supported.
                session = (B1Session)serviceContainer.Execute <B1Session>(login, "POST", true, body).SingleOrDefault();
                if (null != session)
                {
                    sessionGuid = session.SessionId;
                }
            }
            catch (Exception ex)
            {
                sessionGuid = string.Empty;       //clear the last time's session id
                throw ex;
            }
            return(session);
        }
        public bool Login(string usrName = "EO2", string pwd = "Exp3rt0n3$", string db = "BANKINTER_TEST_1")
        {
            B1Session b1Session = null;

            try
            {
                b1Session = service.LoginServer(usrName, pwd, db);
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
            return(b1Session != null);
        }