Example #1
0
        public IEnumerable <DataEntity> ExecuteQuery(Query query)
        {
            IEnumerable <DataEntity> results = null;
            string         entityName        = query.RootEntity.ObjectDefinitionFullName;
            DayForceFilter filter            = null;

            if (query.Constraints != null)
            {
                filter = ScribeUtils.CreateFilter(query);
            }


            switch (entityName)
            {
            case ConstantUtils.Employee_Entity:
                List <Employees> employeeEntity = new List <Employees>();
                employeeEntity = _dayforceClient.GetEmployees(_connectionInfo, filter);
                results        = ScribeUtils.ToDataEntities <Employees>(employeeEntity);

                break;

            case ConstantUtils.EmployeeDetails_Entity:
                List <EmployeeDetails> employeeDetailsEntity = new List <EmployeeDetails>();
                employeeDetailsEntity = _dayforceClient.GetEmployeeDetails(_connectionInfo, filter);
                results = ScribeUtils.ToDataEntities <EmployeeDetails>(employeeDetailsEntity);

                break;

            default:
                break;
            }

            return(results);
        }
Example #2
0
        internal OperationResult ExecuteOperation(OperationInput operationInput)
        {
            var operationResult = new OperationResult();
            // arrays to keep track of the operations statuses
            var operationSuccess = new List <bool>();
            var entitiesAffected = new List <int>();
            var errorList        = new List <ErrorResult>();
            var entities         = new List <DataEntity>();

            switch (operationInput.Name)
            {
            case "Create":
                foreach (var scribeEntity in operationInput.Input)
                {
                    var returnEntity = new DataEntity();
                    try
                    {
                        if (scribeEntity.ObjectDefinitionFullName == Utils.ConstantUtils.EmployeeCreateFlat_Entity)
                        {
                            var candidate = ScribeUtils.EntityToObject <EmployeeCreateFlat>(scribeEntity);
                            _dayforceClient.CreateEmployee(_connectionInfo, candidate);
                        }

                        operationSuccess.Add(true);
                        errorList.Add(null);
                        entitiesAffected.Add(1);
                        entities.Add(returnEntity);
                    }
                    catch (Exception ex)
                    {
                        //add an error to our collections:
                        var errorResult = new ErrorResult
                        {
                            Description = string.Format("An error returned from DayForce in Create Action: {0}", ex.Message),
                            Detail      = ex.StackTrace,
                        };
                        operationSuccess.Add(false);
                        errorList.Add(errorResult);
                        entitiesAffected.Add(0);
                        entities.Add(null);
                    }
                }
                break;
            }

            //Completed the requests, hand back the results:
            operationResult.Success         = operationSuccess.ToArray();
            operationResult.ObjectsAffected = entitiesAffected.ToArray();
            operationResult.ErrorInfo       = errorList.ToArray();
            operationResult.Output          = entities.ToArray();

            return(operationResult);
        }