Example #1
0
        private void Processor(List <CurrencyInfo> items)
        {
            ServerInstrumentation.Current.Queue(1);

            int n = Environment.TickCount;

            count += items.Count;

            if (items.Count != 0)
            {
                try
                {
                    _service.BatchSave_Info(items);
                    ServerInstrumentation.Current.Process(items.Count);
                }
                catch (Exception ex)
                {
                    CurrencyStore.Common.ElibExceptionHandler.Handle(ex);
                    ServerInstrumentation.Current.Fault(items.Count);
                    BackUp(items);
                    throw;
                }

                logger.Info(string.Format("Task({0}):\tCurrent:{1}\tAll:{2}\tcost:{3}ms",
                                          index, items.Count, count, Environment.TickCount - n));
            }
            ServerInstrumentation.Current.Queue(-1);
        }
Example #2
0
        public void Insert()
        {
            for (int i = 1; i <= this.TotalBatch; i++)
            {
                currencyService.BatchSave_Info(this.Value);

                this.RealInsertCurrencyCount += this.BatchCount;

                DataCounter.AddCurrency(this.BatchCount);
            }
        }
Example #3
0
        public void Insert()
        {
            this.CurrentBatch = 1;

            for (; this.CurrentBatch <= this.TotalBatch; this.CurrentBatch += 1)
            {
                if (this.CurrentBatch == this.HourBatch * 0 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                if (this.CurrentBatch == this.HourBatch * 1 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 9, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                if (this.CurrentBatch == this.HourBatch * 2 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 10, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                if (this.CurrentBatch == this.HourBatch * 3 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 11, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                if (this.CurrentBatch == this.HourBatch * 4 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                if (this.CurrentBatch == this.HourBatch * 5 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 13, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                if (this.CurrentBatch == this.HourBatch * 6 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 14, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                if (this.CurrentBatch == this.HourBatch * 7 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 15, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                if (this.CurrentBatch == this.HourBatch * 8 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 16, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                if (this.CurrentBatch == this.HourBatch * 9 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                if (this.CurrentBatch == this.HourBatch * 10 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 18, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                if (this.CurrentBatch == this.HourBatch * 11 + 1)
                {
                    DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 19, DateTime.Now.Minute, DateTime.Now.Second);

                    this.UpdateInesrtData(nowTime);
                }

                currencyService.BatchSave_Info(this.Value);

                this.RealInsertCurrencyCount += this.BatchCount;

                DataCounter.AddCurrency(this.BatchCount);
            }
        }
Example #4
0
        private UploadResult ImportDataFile(string fileName, bool isIgnoreAlreadyUpload)
        {
            UploadResult result = new UploadResult();

            using (CurrencyFileReader fileReader = new CurrencyFileReader(fileName))
            {
                FileHeader fileHeader = fileReader.FileHeader;
                IEnumerable <CurrencyInfo> dataList = fileReader.Read(isIgnoreAlreadyUpload).ToList();

                /**/

                IDeviceService deviceService = ServiceFactory.GetService <IDeviceService>();

                bool deviceExists = deviceService.CheckExists_Info(new DeviceInfo()
                {
                    DeviceNumber = fileHeader.MachineSN
                });

                result.FileType     = fileHeader.FileType;
                result.DeviceNumber = fileHeader.MachineSN;
                result.DeviceStatus = deviceExists ? "已入库" : "未入库";

                if (!deviceExists)
                {
                    DeviceInfo deviceInfo = new DeviceInfo()
                    {
                        OrgId           = 0,
                        ModelCode       = 0,
                        KindCode        = 0,
                        DeviceNumber    = fileHeader.MachineSN,
                        SoftwareVersion = fileHeader.SoftVersion,
                        OnLineTime      = DateTime.Now,
                        DeviceStatus    = 1,
                    };

                    deviceService.Save_Info(deviceInfo);
                }

                /**/

                result.TotalCount         = fileHeader.SumRecords;
                result.AlreadyUploadCount = fileHeader.UploadRecord;

                if (isIgnoreAlreadyUpload)
                {
                    result.ShouldSaveCount = result.TotalCount - result.AlreadyUploadCount;
                }

                else
                {
                    result.ShouldSaveCount = result.TotalCount;
                }

                /**/

                ICurrencyService currencyService = ServiceFactory.GetService <ICurrencyService>();

                int bufferCount            = 500;
                int maxCount               = dataList.Count();
                List <CurrencyInfo> buffer = null;

                for (int i = 0; i <= maxCount / bufferCount; i++)
                {
                    buffer = dataList.Skip(i * bufferCount).Take(bufferCount).ToList();

                    if (buffer.Count() > 0)
                    {
                        currencyService.BatchSave_Info(buffer);
                    }
                }

                result.SuccessSaveCount = maxCount;
            }

            return(result);
        }