Example #1
0
        public int Exists(
    ref int nStop,
    string strDateRangeString,
    out List<DateExist> dates,
    out string strError)
        {
            strError = "";
            dates = new List<DateExist>();
            // int nRet = 0;

            string strStartDate = "";
            string strEndDate = "";

            try
            {
                // 将日期字符串解析为起止范围日期
                // throw:
                //      Exception
                ParseDateRange(strDateRangeString,
                    out strStartDate,
                    out strEndDate);
            }
            catch (Exception ex)
            {
                strError = ExceptionUtil.GetAutoText(ex);
                return -1;
            }

            DateTime start;
            DateTime end;

            start = DateTimeUtil.Long8ToDateTime(strStartDate);

            if (strEndDate == "")
            {
                end = start;
                strEndDate = strStartDate;
            }
            else
            {
                end = DateTimeUtil.Long8ToDateTime(strEndDate);

                TimeSpan delta = end - start;
                if (delta.Days < 0)
                {
                    // 交换两个时间
                    DateTime temp = end;
                    end = start;
                    start = temp;
                }
            }

            int nCount = 0; // 实际存在多少天
            DateTime current = start;
            for (; ; )
            {
                if (nStop != 0)
                {
                    strError = "用户中断";
                    return -1;
                }

                string strDate = DateTimeUtil.DateTimeToString8(current);
                string strFilename = this.StatisDir + "\\" + strDate + ".xml";

                if (File.Exists(strFilename) == true)
                {
                    nCount++;

                    DateExist exist = new DateExist();
                    exist.Date = strDate;
                    exist.Exist = true;
                    dates.Add(exist);
                }

                if (current >= end)
                    break;

                current = current.AddDays(1);
            }

            return 0;
        }
Example #2
0
        public int Exists(
            ref int nStop,
            string strDateRangeString,
            out List <DateExist> dates,
            out string strError)
        {
            strError = "";
            dates    = new List <DateExist>();
            // int nRet = 0;

            string strStartDate = "";
            string strEndDate   = "";

            try
            {
                // 将日期字符串解析为起止范围日期
                // throw:
                //      Exception
                ParseDateRange(strDateRangeString,
                               out strStartDate,
                               out strEndDate);
            }
            catch (Exception ex)
            {
                strError = ExceptionUtil.GetAutoText(ex);
                return(-1);
            }

            DateTime start;
            DateTime end;

            start = DateTimeUtil.Long8ToDateTime(strStartDate);

            if (strEndDate == "")
            {
                end        = start;
                strEndDate = strStartDate;
            }
            else
            {
                end = DateTimeUtil.Long8ToDateTime(strEndDate);

                TimeSpan delta = end - start;
                if (delta.Days < 0)
                {
                    // 交换两个时间
                    DateTime temp = end;
                    end   = start;
                    start = temp;
                }
            }

            int      nCount  = 0; // 实际存在多少天
            DateTime current = start;

            for (; ;)
            {
                if (nStop != 0)
                {
                    strError = "用户中断";
                    return(-1);
                }

                string strDate     = DateTimeUtil.DateTimeToString8(current);
                string strFilename = this.StatisDir + "\\" + strDate + ".xml";

                if (File.Exists(strFilename) == true)
                {
                    nCount++;

                    DateExist exist = new DateExist();
                    exist.Date  = strDate;
                    exist.Exist = true;
                    dates.Add(exist);
                }

                if (current >= end)
                {
                    break;
                }

                current = current.AddDays(1);
            }

            return(0);
        }