Esempio n. 1
0
        public SimpleResponse<int> GetCompanyExtentCount(GetFilteredExtentRequest request)
        {
            try
            {
                var scope = 0;
                if (request.Scope.HasValue)
                    scope = request.Scope.Value;

                var innerSelect = GetCompanyCountInnerSelectSQL(scope, request.CompanyID);
                try
                {
                    var response = GenericGetExtentWithCustomSelectCount<Company>(
                                request.CompanyID,
                                request.CreatedAfter, request.CreatedBefore,
                                request.ModifiedAfter, request.ModifiedBefore,
                                request.Deleted, request.Active, request.Template, request.Path,
                                null, null,
                                innerSelect, request.Conditions, request.LogicalOperator);

                    return response;
                }
                catch (Exception ex)
                {
                    return ErrorHandler.Handle<SimpleResponse<int>>(ex);
                }
            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<SimpleResponse<int>>(ex);
            }
        }
Esempio n. 2
0
        public GetListResponse<Profile> GetProfileExtent(GetFilteredExtentRequest request)
        {
            var scope = 0;
            if (request.Scope.HasValue)
                scope = request.Scope.Value;
            //note! Areatype select is typically part of the request.Conditions, scope is currently not used
            var innerSelect = GetProfileInnerSelectSQL(scope, request.CompanyID);

            try
            {
                var response = GenericGetExtentWithCustomSelect<Profile>(
                            request.CompanyID,
                            request.CreatedAfter, request.CreatedBefore,
                            request.ModifiedAfter, request.ModifiedBefore,
                            request.Deleted, request.Active, request.Template, request.Path,
                            request.Limit, request.Offset, request.SortColumns,
                            null, null,
                            innerSelect, request.Conditions, request.LogicalOperator);
                return response;
            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<GetListResponse<Profile>>(ex);
            }
        }
        public SimpleResponse<int> GetScheduledReportTaskExtentCount(GetFilteredExtentRequest request)
        {
            var scope = 0;
            if (request.Scope.HasValue)
                scope = request.Scope.Value;

            //for reports from group - not used currently
            //var groupID = request.OwnerID.HasValue ? request.OwnerID.Value : Guid.Empty;

            var innerSelect = GetScheduledReportTaskCountInnerSelectSQL(scope, request.CompanyID);

            try
            {
                var response = GenericGetExtentWithCustomSelectCount<ScheduledTask>(
                            request.CompanyID,
                            request.CreatedAfter, request.CreatedBefore,
                            request.ModifiedAfter, request.ModifiedBefore,
                            request.Deleted, request.Active, request.Template, request.Path,
                            null, null,
                            innerSelect, request.Conditions, request.LogicalOperator);
                return response;
            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<SimpleResponse<int>>(ex);
            }
        }
Esempio n. 4
0
 public GetListResponse<Contact> GetContactExtent(GetFilteredExtentRequest req)
 {
     try
     {
         var response = GenericGetExtent<Contact>(
                     req.CompanyID,
                     req.CreatedAfter, req.CreatedBefore,
                     req.ModifiedAfter, req.ModifiedBefore,
                     req.Deleted, req.Active, req.Template, req.Path,
                     req.Limit, req.Offset, req.SortColumns,
                     null, null);
         return response;
     }
     catch (Exception ex)
     {
         return ErrorHandler.Handle<GetListResponse<Contact>>(ex);
     }
 }
Esempio n. 5
0
        public GetListResponse<History> GetHistoryExtent(GetFilteredExtentRequest request)
        {
            try
            {
                var response = new GetListResponse<History>();
                var db = ImardaDatabase.CreateDatabase(Util.GetConnName<History>());

                Guid? companyID = request.CompanyID;
                DateTime? createdAfter = request.ModifiedAfter;
                DateTime? createdBefore = request.ModifiedBefore;
                bool? deleted = request.Deleted;
                bool? active = request.Active;
                Guid? ownerID = request.OwnerID;
                int? ownerType = request.OwnerType;

                var scope = 0;
                if (request.Scope.HasValue)
                    scope = request.Scope.Value;

                int startNum = 1;
                int endNum = Int32.MaxValue;
                if (request.Offset.HasValue)
                {
                    startNum = request.Offset.Value;
                    if (startNum < 1) startNum = 1;
                    if (request.Limit.HasValue && request.Limit.Value > 0)
                        endNum = startNum + request.Limit.Value - 1;
                }

                var whereClause = "";
                var con = "";
                //these are 'AND'd together
                string[] filters =
                {
                    companyID.HasValue && companyID.Value != Guid.Empty ? string.Format(" [CompanyID] = '{0}' ", companyID.Value.ToString()) : null,
                    createdAfter.HasValue ? string.Format(" [DateCreated] >= '{0}' ", createdAfter.Value.ToString("s")) : null,
                    createdBefore.HasValue ? string.Format(" [DateCreated] <= '{0}' ", createdBefore.Value.ToString("s")) : null,
                    deleted.HasValue ? " [Deleted] = " + (deleted.Value ? '1' : '0') : null,
                    active.HasValue ? " [Active] = " + (active.Value ? '1' : '0') : null,
                    ownerID.HasValue ? string.Format(" [OwnerID] = '{0}' ", ownerID.ToString()) : null,
                    ownerType.HasValue ? string.Format(" [OwnerType] = '{0}' ", ownerType.ToString()) : null,
                };
                var filterClause = new StringBuilder();
                con = "";
                foreach (var filter in filters)
                {
                    if (filter != null)
                    {
                        filterClause.Append(con).Append(filter);
                        con = " AND ";
                    }
                }
                var conditionClause = new StringBuilder();
                con = "";
                //add any further conditions these ar OR'd together	currently
                foreach (Condition condition in request.Conditions)
                {
                    var part = condition.GetSQL();
                    conditionClause.Append(con).Append(part);
                    con = " OR ";
                }
                if (conditionClause.Length > 0)
                    filterClause.Append(string.Format(" OR ( {0} )", conditionClause.ToString()));
                whereClause = filterClause.ToString();

                var sortClause = "";
                con = "";
                foreach (SortColumn sortColumn in request.SortColumns)
                {
                    var part = sortColumn.FieldName;
                    sortClause += con + part;
                    if (sortColumn.SortDescending) sortClause += " DESC";
                    con = ", ";
                }
                if (string.IsNullOrEmpty(sortClause))
                    sortClause = "ID"; //we need some column for the OVER part

                var query = GetFilteredHistoryExtentSQL(scope, startNum, endNum, whereClause, sortClause);
                using (IDataReader dr = db.ExecuteDataReader(CommandType.Text, query))
                {
                    response.List = new List<History>();
                    while (dr.Read())
                    {
                        response.List.Add(GetFromData<History>(dr));
                    }
                    return response;
                }

            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<GetListResponse<History>>(ex);
            }
        }
        public GetListResponse<SecurityEntity> GetSecurityEntityExtent(GetFilteredExtentRequest request)
        {
            var scope = 0;
            if (request.Scope.HasValue)
                scope = request.Scope.Value;

            //for users from fleet
            var fleetID = request.OwnerID.HasValue ? request.OwnerID.Value : Guid.Empty;

            var innerSelect = GetSecurityEntityInnerSelectSQL(scope, request.CompanyID);

            try
            {
                var response = GenericGetExtentWithCustomSelect<SecurityEntity>(
                            request.CompanyID,
                            request.CreatedAfter, request.CreatedBefore,
                            request.ModifiedAfter, request.ModifiedBefore,
                            request.Deleted, request.Active, request.Template, request.Path,
                            request.Limit, request.Offset, request.SortColumns,
                            null, null,
                            innerSelect, request.Conditions, request.LogicalOperator);
                return response;
            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<GetListResponse<SecurityEntity>>(ex);
            }
        }