Ejemplo n.º 1
0
        internal PolicySummaryArgs(string[] args)
        {
            if (args.Length != 2)
            {
                throw new ArgumentException();
            }

            SummaryMode = ReadSummaryMode(args);

            InputFile = args[1];
          
            if (!File.Exists(InputFile))
            {
                throw new ArgumentException(InputFile);
            }
        }
Ejemplo n.º 2
0
        public static void ReportErrors(ILogger logger, TestPhase phase, OutputMode outputMode, SummaryMode summaryMode)
        {
            if (summaryMode == SummaryMode.Never)
            {
                return;
            }

            bool hasErrors = logger.GetMessages(Severity.Error).Count > 0;

            if (!hasErrors && summaryMode == SummaryMode.Error)
            {
                return;
            }

            IList <string> errors = logger.GetMessages(Severity.Error, Severity.Warning);

            if (!errors.Any())
            {
                return;
            }

            string hint = outputMode > OutputMode.Info
                ? ""
                : Resources.EnableDebugMode;
            string jointErrors = string.Join(Environment.NewLine, errors);
            string phaseString = (phase == TestPhase.TestDiscovery) ? Resources.TestDiscovery : Resources.TestExecution;

            string message = $"{Environment.NewLine}================{Environment.NewLine}"
                             + String.Format(Resources.ErrorAndWarning, phaseString, hint, Environment.NewLine)
                             + jointErrors;

            if (hasErrors)
            {
                logger.LogError(message);
            }
            else
            {
                logger.LogWarning(message);
            }
        }
        /// <summary>
        /// 获取指定日期的领料名细
        /// </summary>
        /// <param name="beginDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <param name="orderMode">模式</param>
        /// <returns>返回获取到的明细信息</returns>
        public IQueryable <View_S_FetchGoodsDetailBill> GetFetchGoodstDetailInfo(DateTime beginDate, DateTime endDate, SummaryMode orderMode)
        {
            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

            if (orderMode == SummaryMode.日期)
            {
                return(from r in dataContxt.View_S_FetchGoodsDetailBill
                       where r.单据日期 >= beginDate && r.单据日期 <= endDate
                       orderby r.单据日期
                       select r);
            }
            else if (orderMode == SummaryMode.图号)
            {
                return(from r in dataContxt.View_S_FetchGoodsDetailBill
                       where r.单据日期 >= beginDate && r.单据日期 <= endDate
                       orderby r.图号型号
                       select r);
            }
            else if (orderMode == SummaryMode.称)
            {
                return(from r in dataContxt.View_S_FetchGoodsDetailBill
                       where r.单据日期 >= beginDate && r.单据日期 <= endDate
                       orderby r.物品名称
                       select r);
            }
            else if (orderMode == SummaryMode.库房)
            {
                return(from r in dataContxt.View_S_FetchGoodsDetailBill
                       where r.单据日期 >= beginDate && r.单据日期 <= endDate
                       orderby r.库房名称
                       select r);
            }
            else if (orderMode == SummaryMode.材料类别)
            {
                return(from r in dataContxt.View_S_FetchGoodsDetailBill
                       where r.单据日期 >= beginDate && r.单据日期 <= endDate
                       orderby r.材料类别
                       select r);
            }
            else if (orderMode == SummaryMode.单据编号)
            {
                return(from r in dataContxt.View_S_FetchGoodsDetailBill
                       where r.单据日期 >= beginDate && r.单据日期 <= endDate
                       orderby r.单据编号
                       select r);
            }
            else
            {
                return(from r in dataContxt.View_S_FetchGoodsDetailBill
                       where r.单据日期 >= beginDate && r.单据日期 <= endDate
                       orderby r.供应商
                       select r);
            }
        }
        /// <summary>
        /// 获取指定日期的领料汇总信息
        /// </summary>
        /// <param name="beginDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <param name="orderMode">模式</param>
        /// <returns>返回获取到的汇总信息</returns>
        public IQueryable <View_S_FetchGoodsSummaryTable> GetFetchGoodsSummarInfo(DateTime beginDate, DateTime endDate, SummaryMode orderMode)
        {
            //DateTime beginDate;
            //DateTime endDate;

            //FinancingReportBasic.GetSummaryDate(date, out beginDate, out endDate);
            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;
            var result = from r in dataContxt.View_S_FetchGoodsSummaryTable
                         where r.日期 == endDate
                         orderby r.图号型号
                         select r;

            if (result.Count() == 0)
            {
                #region Modify by cjb on 2016.10.9, reason:由于LINQ无法调用存储过程AddFetchGoodsSummary,为保证操作在同一事务里,故用代码实现存储过程中的功能

                var varData = from a in dataContxt.S_FetchGoodsGatherBill
                              where a.Date >= beginDate && a.Date <= endDate
                              select a;

                dataContxt.S_FetchGoodsGatherBill.DeleteAllOnSubmit(varData);


                var varGroupBy = (from a in dataContxt.S_FetchGoodsDetailBill
                                  where a.BillTime >= beginDate && a.BillTime <= endDate
                                  group a by a.GoodsID
                                  into s
                                  select new S_FetchGoodsGatherBill
                {
                    GoodsID = s.Select(p => p.GoodsID).First(),
                    Amount = s.Sum(p => p.FetchCount),
                    UnitPrice = s.Sum(p => p.FetchCount) == 0 ? 0 : (decimal)s.Sum(p => p.Price) / (decimal)s.Sum(p => p.FetchCount),
                    Price = (decimal)s.Sum(p => p.Price),
                    Date = endDate
                }).OrderBy(s => s.GoodsID);


                dataContxt.S_FetchGoodsGatherBill.InsertAllOnSubmit(varGroupBy);
                #endregion

                //dataContxt.AddFetchGoodsSummary(beginDate, endDate);
            }

            if (orderMode == SummaryMode.称)
            {
                return(from r in dataContxt.View_S_FetchGoodsSummaryTable
                       where r.日期 == endDate
                       orderby r.物品名称
                       select r);
            }
            else if (orderMode == SummaryMode.材料类别)
            {
                return(from r in dataContxt.View_S_FetchGoodsSummaryTable
                       where r.日期 == endDate
                       orderby r.材料类别
                       select r);
            }
            else
            {
                if (result.Count() > 0)
                {
                    return(result);
                }

                return(from r in dataContxt.View_S_FetchGoodsSummaryTable
                       where r.日期 == endDate
                       orderby r.图号型号
                       select r);
            }
        }
        public static void ReportErrors(ILogger logger, string phase, OutputMode outputMode, SummaryMode summaryMode)
        {
            if (summaryMode == SummaryMode.Never)
            {
                return;
            }

            bool hasErrors = logger.GetMessages(Severity.Error).Count > 0;

            if (!hasErrors && summaryMode == SummaryMode.Error)
            {
                return;
            }

            IList <string> errors = logger.GetMessages(Severity.Error, Severity.Warning);

            if (!errors.Any())
            {
                return;
            }

            string hint = outputMode > OutputMode.Info
                ? ""
                : " (enable debug mode for more information)";
            string jointErrors = string.Join(Environment.NewLine, errors);

            string message = $"{Environment.NewLine}================{Environment.NewLine}"
                             + $"The following warnings and errors occured during {phase}{hint}:{Environment.NewLine}"
                             + jointErrors;

            if (hasErrors)
            {
                logger.LogError(message);
            }
            else
            {
                logger.LogWarning(message);
            }
        }