Exemplo n.º 1
0
        public ActionResult Index(int?page)
        {
            DateTime            dt      = DateTime.Now;
            DateTime            endTime = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d")));
            NameValueCollection q       = new NameValueCollection();

            q.Add("CreatedAtStart", endTime.AddDays(-1).ToString("yyyy/MM/dd 10:00"));
            q.Add("CreatedAtEnd", DateTime.Now.AddHours(1).ToString("yyyy/MM/dd HH:00"));
            InspectOriginQueryModel query = new InspectOriginQueryModel(q);

            IPagedList <InspectOrigin> inspects = null;

            using (var txn = new System.Transactions.TransactionScope(TransactionScopeOption.Required,
                                                                      new TransactionOptions
            {
                IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
            }))
            {
                using (IUnitOfWork unitOfWork = new TskDataDataContext(DbUtil.ConnectionString))
                {
                    int currentPageIndex = page.HasValue ? (page.Value <= 0 ? 0 : page.Value - 1) : 0;
                    IInspectOriginRep inspectOriginRep = new InspectOriginRep(unitOfWork);
                    inspects = inspectOriginRep.Queryable(query.CreatedAtStart, query.CreatedAtEnd).ToPagedList(currentPageIndex, int.Parse(Resources.PageSize));
                }
            }
            ViewBag.Query = query;
            return(View(inspects));
        }
Exemplo n.º 2
0
        private IQueryable <InspectOrigin> GenerateQuery(IUnitOfWork unitOfWork, InspectOriginQueryModel query)
        {
            IInspectOriginRep inspectRep = new InspectOriginRep(unitOfWork);

            return(inspectRep.Queryable().Where(item =>
                                                //(string.IsNullOrEmpty(query.Text) ? true : item.Text.Contains(query.Text))&&
                                                (query.ProcessResult.HasValue ? item.ProcessResult.Equals(query.ProcessResult) : true) &&
                                                (query.CreatedAtStart.HasValue ? item.CreatedAt >= query.CreatedAtStart : true) &&
                                                (query.CreatedAtEnd.HasValue ? item.CreatedAt <= query.CreatedAtEnd : true)
                                                ));
        }
Exemplo n.º 3
0
        private List <InspectOrigin> ExportInspectOrigin(InspectOriginQueryModel query)
        {
            List <InspectOrigin> inspects = new List <InspectOrigin>();

            using (IUnitOfWork unitOfWork = new TskDataDataContext(DbUtil.ConnectionString))
            {
                IInspectOriginRep inspectRep = new InspectOriginRep(unitOfWork);
                inspects = GenerateQuery(unitOfWork, query).ToList <InspectOrigin>();
            }
            return(inspects);
        }
Exemplo n.º 4
0
        private IPagedList <InspectOrigin> QueryInspectOrigin(InspectOriginQueryModel query, int?currentPageIndex, int?pageSize)
        {
            IPagedList <InspectOrigin> inspects;

            using (IUnitOfWork unitOfWork = new TskDataDataContext(DbUtil.ConnectionString))
            {
                IInspectOriginRep inspectRep = new InspectOriginRep(unitOfWork);
                inspects = GenerateQuery(unitOfWork, query).ToPagedList(currentPageIndex.Value, pageSize.Value);
            }
            return(inspects);
        }
Exemplo n.º 5
0
        //
        // GET: /Inspect/Details/5

        public ActionResult Details(string id)
        {
            InspectOrigin inspect;

            using (IUnitOfWork unitOfWork = new TskDataDataContext(DbUtil.ConnectionString))
            {
                IInspectOriginRep inspectRep = new InspectOriginRep(unitOfWork);
                inspect = inspectRep.FindById(id);
            }
            return(View(inspect));
        }
Exemplo n.º 6
0
        public ProcessMessage CreateInspect(string text)
        {
            ProcessMessage message = new ProcessMessage();

            try
            {
                using (IUnitOfWork unitOfWork = new TskDataDataContext(MSSqlConfig.ConnectionString))
                {
                    IInspectOriginRep inspectOriginRep = new InspectOriginRep(unitOfWork);
                    InspectOrigin     inspectOrigin    = new InspectOrigin()
                    {
                        Id        = Guid.NewGuid(),
                        Text      = text,
                        CreatedAt = DateTime.Now
                    };

                    if (text == null || text.Length == 0 || text.Split(TskConfig.DataSpliter).Length != TskConfig.DataCount)
                    {
                        message.Result = false;
                        message.Messages.Add("数据为空或数据格式不存在");
                        if (!string.IsNullOrEmpty(text))
                        {
                            message.Messages.Add("数据属性长度为:" + text.Split(TskConfig.DataSpliter).Length.ToString());
                            message.Messages.Add("分隔符为:" + TskConfig.DataSpliter.ToString());
                        }
                        LogUtil.Logger.Error(message.GetMessageContent());
                    }
                    else
                    {
                        IInspectRep inspectRep = new InspectRep(unitOfWork);
                        string[]    data       = text.Split(TskConfig.DataSpliter);
                        Inspect     inspect    = new Inspect()
                        {
                            Id         = Guid.NewGuid(),
                            TskNo      = data[0],
                            LeoniNo    = data[1],
                            CusNo      = data[2],
                            ClipScanNo = data[3],
                            //  ClipScanTime1 = data[4],
                            // ClipScanTime2 = data[6],
                            TskScanNo = data[7],
                            // TskScanTime3 = data[8],
                            // Time3MinTime2 = data[9],
                            OkOrNot   = data[10],
                            CreatedAt = DateTime.Now,
                            OriginId  = inspectOrigin.Id
                        };
                        DateTime clipScanTime1 = DateTime.Now;
                        if (DateTime.TryParse(data[4], out clipScanTime1))
                        {
                            inspect.ClipScanTime1 = clipScanTime1;
                        }

                        DateTime clipScanTime2 = DateTime.Now;
                        if (DateTime.TryParse(data[6], out clipScanTime2))
                        {
                            inspect.ClipScanTime2 = clipScanTime2;
                        }

                        DateTime tskScanTime3 = DateTime.Now;
                        if (DateTime.TryParse(data[8], out tskScanTime3))
                        {
                            inspect.TskScanTime3 = tskScanTime3;
                        }

                        float time3MinTime2 = 0;
                        if (float.TryParse(data[9], out time3MinTime2))
                        {
                            inspect.Time3MinTime2 = time3MinTime2;
                        }

                        inspectRep.Create(inspect);
                        message.Messages.Add("数据处理成功");
                        message.Result = true;
                    }

                    inspectOrigin.ProcessResult  = message.Result;
                    inspectOrigin.ProcessMessage = message.GetMessageContent();
                    inspectOriginRep.Create(inspectOrigin);

                    unitOfWork.Submit();
                }
                return(message);
            }
            catch (Exception e)
            {
                LogUtil.Logger.Error(e.Message);
                throw e;
            }
        }