/// <summary>
        /// 根据RFC配置信息,打开RFC链接
        /// </summary>
        /// <param name="Connection"></param>
        /// <returns></returns>
        public ReturnResult ERGetPConnection(ERPGetConnection Connection)
        {
            ReturnResult consap        = new ReturnResult();
            R3Connection ConnectionSAP = new R3Connection();

            try
            {
                string connString = BuildConneciton(Connection);
                ConnectionSAP = new R3Connection(connString);

                if (!ConnectionSAP.Ping())
                {
                    ConnectionSAP.Open();
                    consap.Status = true;
                }
            }
            catch (Exception ex)
            {
                ConnectionSAP.Close();
                consap.Message = ex.Message;
                consap.Status  = false;
                this.logHandler.Error(MethodBase.GetCurrentMethod().Name, "Call ERGetPConnection Fail: " + ex.Message);
            }
            consap.Anything = ConnectionSAP;
            return(consap);
        }
Exemplo n.º 2
0
        public List <EmployeeBasic> getEmployeeBasicList(string surname, string lastname, string job, string organisation)
        {
            string surnameSearch      = surname.Equals(string.Empty) ? "*" : surname;
            string lastnameSearch     = lastname.Equals(string.Empty) ? "*" : lastname;
            string jobSearch          = job.Equals(string.Empty) ? "*" : job;
            string organisationSearch = organisation.Equals(string.Empty) ? "*" : organisation;

            List <EmployeeBasic> result = new List <EmployeeBasic>();
            var connection = new R3Connection(_configManager.getConnectionString());

            try
            {
                connection.Open();

                var function = connection.CreateFunction(Constants.BAPI_EMPLOYEE_GETLIST);
                function.Exports[Constants.SEARCH_DATE].ParamValue    = DateTime.Now.ToShortDateString();
                function.Exports[Constants.JOB_SEARK].ParamValue      = jobSearch;
                function.Exports[Constants.JOB_SEARK].ParamValue      = jobSearch;
                function.Exports[Constants.ORG_SEARK].ParamValue      = organisationSearch;
                function.Exports[Constants.SUR_NAME_SEARK].ParamValue = surnameSearch;
                function.Exports[Constants.LST_NAME_SEARK].ParamValue = lastnameSearch;

                function.Execute();

                var table = function.Tables[Constants.EMPLOYEE_LIST];

                if (table != null && table.Rows.Count > 0)
                {
                    foreach (RFCStructure row in table.Rows)
                    {
                        var PERNR    = (string)row[Constants.PERNR];
                        var ENAME    = (string)row[Constants.ENAME];
                        var ORG_ID   = (string)row[Constants.ORG_ID];
                        var ORG_TEXT = (string)row[Constants.ORG_TEXT];
                        var JOB_ID   = (string)row[Constants.JOB_ID];
                        var JOB_TEXT = (string)row[Constants.JOB_TEXT];

                        EmployeeBasic empBasic = new EmployeeBasic()
                        {
                            Name             = ENAME,
                            JobID            = JOB_ID,
                            JobName          = JOB_TEXT,
                            OrganisationID   = ORG_TEXT,
                            OrganisationName = ORG_TEXT,
                            PersonalNumber   = PERNR
                        };

                        result.Add(empBasic);
                    }
                }
            }
            catch (Exception ex)
            {
                _loggingManager.ThrowException(ex, DOTNETSAPErrorSeverity.High);
            }
            finally
            {
                if (connection != null && connection.Ping())
                {
                    connection.Close();
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public EmployeeDetail getEmployeeDetailedInfo(string personalNr)
        {
            EmployeeDetail result = null;

            if (!personalNr.Equals(string.Empty))
            {
                var connection = new R3Connection(_configManager.getConnectionString());

                try
                {
                    connection.Open();

                    var function = connection.CreateFunction(Constants.BAPI_PERSDATA_GETDETAILEDLIST);
                    function.Exports[Constants.EMPLOYEENUMBER].ParamValue = personalNr;

                    function.Execute();

                    var table = function.Tables[Constants.PERSONALDATA];

                    if (table != null || table.Rows.Count > 0)
                    {
                        foreach (RFCStructure row in table.Rows)
                        {
                            var NAMeOFFORMOFADD = (string)row[Constants.NAMeOFFORMOFADD];
                            var FIRSTNAME       = (string)row[Constants.FIRSTNAME];
                            var LASTNAME        = (string)row[Constants.LASTNAME];
                            var NAMEOFLANGUAGE  = (string)row[Constants.NAMEOFLANGUAGE];
                            var NAMEOFNATIONALI = (string)row[Constants.NAMEOFNATIONALITY];
                            var DATEOFBIRTH     = (string)row[Constants.DATEOFBIRTH];
                            var BIRTHPLACE      = (string)row[Constants.BIRTHPLACE];
                            var NAMEOFGENDER    = (string)row[Constants.NAMEOFGENDER];
                            var NAMEOFCOUNTRYOF = (string)row[Constants.NAMEOFCOUNTRYOF];

                            result = new EmployeeDetail()
                            {
                                Country     = NAMEOFCOUNTRYOF,
                                DateOfBith  = DATEOFBIRTH,
                                FirstName   = FIRSTNAME,
                                Gender      = NAMEOFGENDER,
                                Language    = NAMEOFLANGUAGE,
                                LastName    = LASTNAME,
                                NamePrefix  = NAMeOFFORMOFADD,
                                Nationality = NAMEOFNATIONALI,
                                PlaceOfBith = BIRTHPLACE
                            };
                        }
                    }
                }
                catch (Exception ex)
                {
                    _loggingManager.ThrowException(ex, DOTNETSAPErrorSeverity.High);
                }
                finally
                {
                    if (connection != null && connection.Ping())
                    {
                        connection.Close();
                    }
                }
            }
            return(result);
        }