Exemplo n.º 1
0
        public List <Group> GetAllActiveGroups()
        {
            var result = new Result();

            var groupList = new List <Group>();

            try
            {
                var whereColumns = new List <ConditionColumn>
                {
                    new ConditionColumn
                    {
                        ColumnName = GlobalAppSettings.DbColumns.DB_Group.IsActive,
                        Condition  = Conditions.Equals,
                        Value      = true
                    }
                };


                result =
                    _dataProvider.ExecuteReaderQuery(
                        _queryBuilder.SelectAllRecordsFromTable(GlobalAppSettings.DbColumns.DB_Group.DB_TableName, whereColumns));
                if (result.Status)
                {
                    groupList =
                        result.DataTable.AsEnumerable()
                        .Select(row => new Group
                    {
                        GroupId          = row.Field <int>(GlobalAppSettings.DbColumns.DB_Group.GroupId),
                        GroupName        = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Name),
                        GroupDescription = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Description),
                        GroupColor       = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Color),
                        CanDelete        =
                            (row.Field <int>(GlobalAppSettings.DbColumns.DB_Group.GroupId) == 1) ? false : true
                    }).ToList();
                }
                return(groupList);
            }
            catch (Exception e)
            {
                LogExtension.LogError("Error while getting group list", e,
                                      MethodBase.GetCurrentMethod(), " Status - " + result.Status);
                return(groupList);
            }
        }
Exemplo n.º 2
0
        public EntityData <Group> GetActiveGroups(List <SortCollection> sorted, int?skip, int?take,
                                                  string searchKey = null, List <FilterCollection> filterCollection = null)
        {
            var skipValue        = skip.HasValue ? skip.Value : 0;
            var takeValue        = take.HasValue ? take.Value : 10;
            var orderby          = OrderByType.Asc;
            var searchDescriptor = new List <String> {
                "Name", "Description"
            };

            var whereColumns = new List <ConditionColumn>
            {
                new ConditionColumn
                {
                    ColumnName = GlobalAppSettings.DbColumns.DB_Group.IsActive,
                    Condition  = Conditions.Equals,
                    Value      = true
                }
            };



            var query = _queryBuilder.SelectAllRecordsFromTable(GlobalAppSettings.DbColumns.DB_Group.DB_TableName, whereColumns);



            var data =
                _dataProvider.ExecuteReaderQuery(_groupManagement.FilteringHelper(query, searchKey, filterCollection, sorted, searchDescriptor));

            var result = data.DataTable.AsEnumerable().Select(row => new Group
            {
                GroupId          = row.Field <int>(GlobalAppSettings.DbColumns.DB_Group.GroupId),
                GroupName        = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Name),
                GroupDescription = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Description),
                GroupColor       = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Color),
                CanDelete        =
                    (row.Field <int>(GlobalAppSettings.DbColumns.DB_Group.GroupId) == 1) ? false : true
            }).Skip(skipValue).Take(takeValue).ToList();


            return(new EntityData <Group>
            {
                result = result,
                count = data.DataTable.Rows.Count
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get the next Daily schedule value.
        /// </summary>
        /// <param name="schedule"></param>
        /// <param name="scheduledDate"></param>
        /// <returns>DateTime</returns>
        public DateTime?GetNextDailyScheduleDate(Schedule schedule, DateTime scheduledDate)
        {
            processDate  = scheduledDate;
            nextSchedule = processDate;

            if (schedule.DailySchedule != null)
            {
                nextTentativeDate = processDate;
                while (nextTentativeDate <= utc || nextTentativeDate < schedule.StartBoundary)
                {
                    nextTentativeDate = nextTentativeDate.AddDays(schedule.DailySchedule.DaysInterval);
                }

                switch (schedule.EndType)
                {
                case EndType.EndDate:
                    if (nextTentativeDate <= schedule.EndBoundary)
                    {
                        nextSchedule = nextTentativeDate;
                    }
                    else
                    {
                        nextSchedule = null;
                    }
                    break;

                case EndType.NoEndDate:
                    nextSchedule = nextTentativeDate;
                    break;

                case EndType.EndAfter:
                    DataTable dataTable    = new DataTable();
                    var       whereColumns = new List <ConditionColumn>();
                    whereColumns.Add(new ConditionColumn
                    {
                        ColumnName = GlobalAppSettings.DbColumns.DB_ScheduleLog.ScheduleId,
                        Condition  = Conditions.Equals,
                        Value      = schedule.ScheduleId
                    });
                    whereColumns.Add(new ConditionColumn
                    {
                        ColumnName      = GlobalAppSettings.DbColumns.DB_ScheduleLog.ExecutedDate,
                        Condition       = Conditions.GreaterThanOrEquals,
                        Value           = schedule.StartBoundary,
                        LogicalOperator = LogicalOperators.AND
                    });
                    whereColumns.Add(new ConditionColumn
                    {
                        ColumnName      = GlobalAppSettings.DbColumns.DB_ScheduleLog.IsOnDemand,
                        Condition       = Conditions.GreaterThanOrEquals,
                        Value           = false,
                        LogicalOperator = LogicalOperators.AND
                    });
                    try
                    {
                        dataTable =
                            dataProvider.ExecuteReaderQuery(
                                queryBuilder.SelectAllRecordsFromTable(
                                    GlobalAppSettings.DbColumns.DB_ScheduleLog.DB_TableName, whereColumns))
                            .DataTable;
                        var recurrenceCount = dataTable.Rows.Count;
                        if (recurrenceCount > 0)
                        {
                            if (recurrenceCount < schedule.Occurrences)
                            {
                                nextSchedule = nextTentativeDate;
                            }
                            else
                            {
                                nextSchedule = null;
                            }
                        }
                        else
                        {
                            nextSchedule = nextTentativeDate;
                        }
                    }
                    catch (SqlException e)
                    {
                    }
                    break;
                }
            }
            return(nextSchedule);
        }
Exemplo n.º 4
0
        public DateTime?GetNextYearlyScheduleDate(Schedule schedule, DateTime scheduledDate)
        {
            processDate  = scheduledDate;
            nextSchedule = processDate;
            var hours = processDate.Hour;
            var min   = processDate.Minute;

            if (schedule.YearlySchedule != null)
            {
                int            everyXYears = schedule.YearlySchedule.YearsInterval;
                int            xDayOfMonth = schedule.YearlySchedule.DayOfMonth;
                MonthOfTheYear monthOfYear = schedule.YearlySchedule.Month;

                if (processDate == schedule.StartBoundary)
                {
                    do
                    {
                        nextTentativeDate = GetNextDate(processDate, xDayOfMonth, monthOfYear, everyXYears);
                    } while (nextTentativeDate <= utc && nextTentativeDate < schedule.StartBoundary);
                }
                else
                {
                    do
                    {
                        processDate = processDate.AddYears(everyXYears);
                        int daysOfMonth = DateTime.DaysInMonth(processDate.Year, Convert.ToInt16(monthOfYear));
                        if (xDayOfMonth <= daysOfMonth)
                        {
                            nextTentativeDate = new DateTime(processDate.Year, Convert.ToInt16(monthOfYear), xDayOfMonth, processDate.Hour, processDate.Minute, processDate.Second);
                        }
                        else
                        {
                            nextTentativeDate = new DateTime(processDate.Year, Convert.ToInt16(monthOfYear), daysOfMonth);
                        }
                    } while (nextTentativeDate <= utc);
                }

                #region
                nextTentativeDate = new DateTime(nextTentativeDate.Year, nextTentativeDate.Month, nextTentativeDate.Day, hours, min, 0);
                switch (schedule.EndType)
                {
                case EndType.EndDate:
                    if (nextTentativeDate <= schedule.EndBoundary)
                    {
                        nextSchedule = nextTentativeDate;
                    }
                    else
                    {
                        nextSchedule = null;
                    }
                    break;

                case EndType.NoEndDate:
                    nextSchedule = nextTentativeDate;
                    break;

                case EndType.EndAfter:
                    DataTable dataTable    = new DataTable();
                    var       whereColumns = new List <ConditionColumn>();
                    whereColumns.Add(new ConditionColumn
                    {
                        ColumnName = GlobalAppSettings.DbColumns.DB_ScheduleLog.ScheduleId,
                        Condition  = Conditions.Equals,
                        Value      = schedule.ScheduleId
                    });
                    whereColumns.Add(new ConditionColumn
                    {
                        ColumnName      = GlobalAppSettings.DbColumns.DB_ScheduleLog.ExecutedDate,
                        Condition       = Conditions.GreaterThanOrEquals,
                        Value           = schedule.StartBoundary,
                        LogicalOperator = LogicalOperators.AND
                    });
                    whereColumns.Add(new ConditionColumn
                    {
                        ColumnName      = GlobalAppSettings.DbColumns.DB_ScheduleLog.IsOnDemand,
                        Condition       = Conditions.GreaterThanOrEquals,
                        Value           = false,
                        LogicalOperator = LogicalOperators.AND
                    });
                    try
                    {
                        dataTable =
                            dataProvider.ExecuteReaderQuery(
                                queryBuilder.SelectAllRecordsFromTable(
                                    GlobalAppSettings.DbColumns.DB_ScheduleLog.DB_TableName, whereColumns))
                            .DataTable;
                        var recurrenceCount = dataTable.Rows.Count;
                        if (recurrenceCount > 0)
                        {
                            if (recurrenceCount < schedule.Occurrences)
                            {
                                nextSchedule = nextTentativeDate;
                            }
                            else
                            {
                                nextSchedule = null;
                            }
                        }
                        else
                        {
                            nextSchedule = nextTentativeDate;
                        }
                    }
                    catch (SqlException e)
                    {
                    }
                    break;
                }
                #endregion
            }
            return(nextSchedule);
        }