public TimeSpan GetTaskDueTime()
        {
            TimeSpan dueTime         = TimeSpan.Zero;
            long     currentDateTime = LibDateUtils.GetCurrentDateTime();
            int      curDate         = LibDateUtils.GetLibTimePart(currentDateTime, LibDateTimePartEnum.Date);
            int      currentTime     = LibDateUtils.GetLibTimePart(currentDateTime, LibDateTimePartEnum.Time);

            if (TaskDefine.ExecTime.Count > 0) //指定时间点执行情况
            {
                for (int i = 0; i < TaskDefine.ExecTime.Count; i++)
                {
                    int execTime = TaskDefine.ExecTime[i];
                    if (execTime < 9999)
                    {
                        execTime *= 100;
                    }
                    if (currentTime < execTime)
                    {
                        long endTime = (long)curDate * 1000000 + execTime;
                        dueTime = LibDateUtils.LibDateToDateTime(endTime) - LibDateUtils.LibDateToDateTime(currentDateTime);
                        break;
                    }
                    if (TaskDefine.ExecTime.Count == i + 1)
                    {
                        if (TaskDefine.TaskType == LibTaskType.None)
                        {
                            long startTime = (long)curDate * 1000000 + execTime;
                            long endTime   = (long)LibDateUtils.AddDayToLibDate(LibDateUtils.LibDateToDateTime(curDate), 1) * 1000000 + TaskDefine.ExecTime[0] * 100;
                            dueTime = LibDateUtils.LibDateToDateTime(endTime) - LibDateUtils.LibDateToDateTime(startTime);
                        }
                    }
                }
            }
            else if (TaskDefine.IntervalTime != 0)//间隔时间执行情况
            {
                dueTime = new TimeSpan(0, TaskDefine.IntervalTime, 0);
            }
            return(dueTime);
        }
Exemple #2
0
        private string GetFilterCondition()
        {
            string filter = string.Empty;

            if (this.DataSet.Tables[0].ExtendedProperties.ContainsKey(TableProperty.FilterSetting))
            {
                FilterSetting filterSetting = this.DataSet.Tables[0].ExtendedProperties[TableProperty.FilterSetting] as FilterSetting;
                if (filterSetting != null)
                {
                    DataTable table = this.DataSet.Tables[0];
                    if (table.Columns.Contains(filterSetting.Name))
                    {
                        if (table.Columns[filterSetting.Name].ExtendedProperties.ContainsKey(FieldProperty.ControlType))
                        {
                            //TODO需考虑节假日的情况,例如周五看到明天的数据,应该是看到周一的数据
                            LibControlType controlType = (LibControlType)table.Columns[filterSetting.Name].ExtendedProperties[FieldProperty.ControlType];
                            if (controlType == LibControlType.Date)
                            {
                                int currentDate = LibDateUtils.GetCurrentDate();
                                if (filterSetting.Day == 0)
                                {
                                    filter = string.Format("A.{0} = {1}", filterSetting.Name, currentDate);
                                }
                                else
                                {
                                    int otherDate = LibDateUtils.AddDayToLibDate(currentDate, filterSetting.Day);
                                    if (currentDate < otherDate)
                                    {
                                        filter = string.Format("A.{0} >= {1} and A.{0} <= {2}", filterSetting.Name, currentDate, otherDate);
                                    }
                                    else
                                    {
                                        filter = string.Format("A.{0} >= {1} and A.{0} <= {2}", filterSetting.Name, otherDate, currentDate);
                                    }
                                }
                            }
                            else if (controlType == LibControlType.DateTime)
                            {
                                int currentDate = LibDateUtils.GetCurrentDate();
                                if (filterSetting.Day == 0)
                                {
                                    filter = string.Format("A.{0} >= {1}000000 and A.{0}<={2}999999", filterSetting.Name, currentDate);
                                }
                                else
                                {
                                    int otherDate = LibDateUtils.AddDayToLibDate(currentDate, filterSetting.Day);
                                    if (currentDate < otherDate)
                                    {
                                        filter = string.Format("A.{0} >= {1}000000 and A.{0} <= {2}999999", filterSetting.Name, currentDate, otherDate);
                                    }
                                    else
                                    {
                                        filter = string.Format("A.{0} >= {1}000000 and A.{0} <= {2}999999", filterSetting.Name, otherDate, currentDate);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(filter);
        }