예제 #1
0
 /// <summary>
 /// 使用指定的次数初始化触发器
 /// </summary>
 /// <param name="Count">重复执行计划任务的次数,
 /// 如果为<see langword="null"/>,代表执行无数次</param>
 public PlanTriggerTiming(int?Count = null)
 {
     if (Count != null)
     {
         ExceptionIntervalOut.Check(1, null, Count.Value);
     }
     this.Count = Count;
 }
예제 #2
0
        /// <summary>
        /// 指定开始和结束单元格的行列数,
        /// 并返回该单元格的数学地址
        /// </summary>
        /// <param name="beginRow">起始单元格的行数</param>
        /// <param name="beginColumn">起始单元格的列数</param>
        /// <param name="endRow">结束单元格的行数,
        /// 如果为<see langword="null"/>,则与<paramref name="beginRow"/>相同</param>
        /// <param name="endColumn">结束单元格的列数,
        /// 如果为<see langword="null"/>,则与<paramref name="beginColumn"/>相同</param>
        /// <returns></returns>
        public static ISizePosPixel AddressMathAbs(int beginRow, int beginColumn, int?endRow = null, int?endColumn = null)
        {
            var ER = endRow ?? beginRow;
            var EC = endColumn ?? beginColumn;

            ExceptionIntervalOut.Check(0, null, beginColumn, EC);
            return(SizePosPixel(Point(beginColumn, Abs(beginRow)), Point(EC, Abs(ER))));
        }
예제 #3
0
        /// <summary>
        /// 将列号转换为文本形式
        /// </summary>
        /// <param name="column">待转换的列号,从0开始</param>
        /// <returns>列号对应的A1格式地址</returns>
        internal static string ColumnToText(int column)
        {
            ExceptionIntervalOut.Check(0, null, column);
            const int begin = 'A';

            return(ToolBit.FromDecimal(column, 26).Integer.PackIndex(true).
                   Select(x => (char)(begin + (x.Index == 0 && x.Count > 1 ? x.Elements - 1 : x.Elements))).Join());
        }
예제 #4
0
 /// <summary>
 /// 使用指定的参数初始化对象
 /// </summary>
 /// <param name="Time">计划任务在一天内的什么时间执行</param>
 /// <param name="Months">枚举在几月份重复计划任务</param>
 /// <param name="Days">枚举在月份的第几天重复计划任务</param>
 /// <param name="Count">重复执行计划任务的次数,
 /// 如果为<see langword="null"/>,代表执行无数次</param>
 /// <param name="CreateDate">计划任务的创建日期,
 /// 如果为<see langword="null"/>,则使用当前日期</param>
 public PlanTriggerYears(TimeOfDay Time, IEnumerable <Month> Months, IEnumerable <int> Days, int?Count = null, DateTimeOffset?CreateDate = null)
     : base(Time, Count, CreateDate)
 {
     this.Months = Months.ToHashSet();
     this.Days   = Days.ToHashSet();
     Days.AnyCheck(nameof(Days));
     Months.AnyCheck(nameof(Months));
     Days.ForEach(x => ExceptionIntervalOut.Check(1, 31, x));
 }
예제 #5
0
        /// <summary>
        /// 计算年龄,未满一年的部分会被舍去
        /// </summary>
        /// <param name="birthday">生日</param>
        /// <param name="now">指定现在的日期,
        /// 如果为<see langword="null"/>,则自动获取</param>
        /// <returns></returns>
        public static int Age(DateTimeOffset birthday, DateTimeOffset?now = null)
        {
            var Now = now ?? DateTimeOffset.Now;

            ExceptionIntervalOut.Check(birthday, null, Now);
            var age = Now.Year - birthday.Year;

            return(Math.Max(0,
                            birthday.DayOfYear > Now.DayOfYear ? age - 1 : age)); //如果有未满一年的部分,则舍去
        }
예제 #6
0
 /// <summary>
 /// 根据起止行列号,返回行或列的地址
 /// </summary>
 /// <param name="begin">开始行列号,从0开始</param>
 /// <param name="end">结束行列号,从0开始</param>
 /// <param name="isRow">如果这个值为<see langword="true"/>,
 /// 代表要返回地址的对象是行,否则是列</param>
 /// <param name="isA1">如果这个值为<see langword="true"/>,则返回A1地址,否则返回R1C1地址</param>
 /// <returns></returns>
 public static string GetAddressRC(int begin, int end, bool isRow, bool isA1 = true)
 {
     ExceptionIntervalOut.Check(0, null, begin, end);
     begin++;
     end++;
     return((isRow, isA1) switch
     {
         (true, true) => $"{begin}:{end}",
         (false, true) => $"{ColumnToText(begin - 1)}:{ColumnToText(end - 1)}",
         (true, false) => $"R{begin}:R{end}",
         (false, false) => $"C{begin}:C{end}"
     });
예제 #7
0
        /// <summary>
        /// 创建一个在指定时间自动启动的定时器
        /// </summary>
        /// <param name="Interval">定时器触发的间隔</param>
        /// <param name="Repeat">指定定时器应该重复多少次,
        /// 如果为<see langword="null"/>,代表无限重复</param>
        /// <param name="Begin">定时器的开始时间,
        /// 如果为<see langword="null"/>,代表立即启动</param>
        /// <returns>新创建的定时器,当到达<paramref name="Begin"/>后,它会自动启动</returns>
        public static ITimer TimerAuto(TimeSpan Interval, int?Repeat = 1, DateTimeOffset?Begin = null)
        {
            var timer = Timer(Interval, Repeat);

            if (Begin == null)
            {
                timer.Start();
            }
            else
            {
                ExceptionIntervalOut.Check(DateTimeOffset.Now, null, Begin.Value);
                var delay = Timer(Begin.Value - DateTimeOffset.Now, 1);
                delay.Due += timer.Start;
                delay.Start();
            }
            return(timer);
        }
예제 #8
0
 /// <summary>
 /// 指定开始单元格的行列数,
 /// 以及单元格行数量和列数量,
 /// 并返回该单元格的数学地址
 /// </summary>
 /// <param name="beginRow">起始单元格的行数</param>
 /// <param name="beginColumn">起始单元格的列数</param>
 /// <param name="rowCount">单元格的行数量</param>
 /// <param name="columnCount">单元格的列数量</param>
 /// <returns></returns>
 public static ISizePosPixel AddressMathRel(int beginRow, int beginColumn, int rowCount = 1, int columnCount = 1)
 {
     ExceptionIntervalOut.Check(0, null, beginRow);
     ExceptionIntervalOut.Check(1, null, rowCount, columnCount);
     return(SizePosPixel(beginColumn, Abs(beginRow), columnCount, rowCount));
 }
예제 #9
0
 public Task PrintFromPage(Range?Page = null, int Number = 1, IPrinter?Printer = null)
 {
     ExceptionIntervalOut.Check(1, null, Number);
     return(PrintBase(Page, Number, Printer));
 }
예제 #10
0
 /// <summary>
 /// 使用指定的参数初始化对象
 /// </summary>
 /// <param name="pipes">数据将被添加到这些管道中</param>
 /// <param name="buffer">指定缓冲区的大小,以元素数量为单位,为提升性能,
 /// 数据先填充到缓冲区,然后再发送给数据管道</param>
 public DataAddDistribute(IEnumerable <IDataPipeAdd> pipes, int buffer)
 {
     ExceptionIntervalOut.Check(1, null, buffer);
     this.Pipes  = pipes.ToArray();
     this.Buffer = buffer;
 }