public static void CreateEagleFile(LotEntity lotEntity, string localdir, string infofile) { string date = System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); string filename = localdir + "\\" + infofile; string cmd = "shellnt program " + lotEntity.RecipeName + " -at -b"; try { StreamWriter sw = File.CreateText(filename); sw.WriteLine("Time=" + date + "\n"); sw.WriteLine("Product=" + lotEntity.DeviceId + "\n"); sw.WriteLine("RecipeName =" + lotEntity.RecipeName + "\n"); sw.WriteLine("LotNo =" + lotEntity.LotNo + "\n"); sw.WriteLine("SubLotNo = 1" + "\n"); sw.WriteLine("LotSize = " + lotEntity.LotQty + "\n"); sw.Flush(); sw.Close(); StartCommand(cmd); date = System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); System.Text.StringBuilder strMsg = new System.Text.StringBuilder("Time=" + date + "\r\n"); strMsg.Append("Product=" + lotEntity.DeviceId + "\r\n"); strMsg.Append("shellnt program " + lotEntity.RecipeName + " -at -b"); } catch (Exception ex) { UtilLog.Error(ex); } }
public static void CreateStatecFile(LotEntity lotEntity, string localdir, string infofile, string station) { UtilLog.Info("starting Create statec file:"); string date = System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); string filename = localdir + "\\" + infofile; string cmd = "shellnt program " + lotEntity.RecipeName + " -at -b"; try { DeleteFile(localdir, infofile.Substring(infofile.Length - 4, 4)); StreamWriter sw = File.CreateText(filename); sw.WriteLine("STATION:" + station); sw.WriteLine("DEVICE_NAME:" + lotEntity.DeviceId); sw.WriteLine("PROGRAM_NAME:" + lotEntity.RecipeName); sw.WriteLine("LOT_NUMBER:" + lotEntity.LotNo); sw.WriteLine("LOT_QUANTITY:" + lotEntity.LotQty); sw.WriteLine("GDCAL:" + lotEntity.SpmGdcal); sw.Flush(); sw.Close(); } catch (Exception ex) { UtilLog.Error(ex); } }
private void ProcessLot(LotEntity lot) { try { lot.IsActive = false; lotService.Update(lot); Debug.Print("Update lot"); if (lot.Bids.Count > 0) { var seller = userService.GetOneByPredicate(u => u.ProfileId == lot.ProfileId); int max = lot.Bids.Max(b => b.Price); var winnerProfileId = lot.Bids.First(b => b.Price == max).ProfileId; var winner = userService.GetOneByPredicate(u => u.ProfileId == winnerProfileId); if ((winner != null) && (seller != null)) { SendAsync(winner.Email, "Action: You are winner!", "Seller is " + seller.Email); SendAsync(seller.Email, "Auction: Your item is sold out", "Winner is " + winner.Email); Debug.Print("Email"); log.Info(string.Format("Auction (LotId: {0}, Name: {1}): Emails were sended successfully!", lot.Id, lot.Name)); } } } catch (ArgumentException ae) { log.Error("Error (mail sending iteration): wrong parameters " + ae.ToString()); } catch (FormatException fe) { log.Error("Error (mail sending iteration): wrong string of address " + fe.ToString()); } catch (Exception e) { log.Error("Error (mail sending iteration): " + e.ToString()); } }
public bool TryCreateBid(BidEntity bid, LotEntity lot) { if (lot.UserId == bid.UserId || DateTime.Now >= (lot.StartDate + new TimeSpan(lot.Duration, 0, 0, 0))) { return(false); } CreateBid(bid); return(true); }
public void DeleteLot(LotEntity entity) { try { _lotRepository.Delete(entity.ToDalLot()); _unitOfWork.Commit(); } catch (Exception exception) { Log.LogError(exception); } }
public bool TryUpdateLot(LotEntity lot) { if (GetLotEntity(lot.Id).State == LotStateEntity.Unsold) { UpdateLot(lot); return(true); } else { return(false); } }
public FileContentResult GetImage(int id) { LotEntity lot = _lotService.GetLotEntity(id); if (lot.ImageData != null) { return(File(lot.ImageData, lot.ImageType)); } else { return(null); } }
public void CreateLot(LotEntity entity) { try { var dalLot = entity.ToDalLot(); _lotRepository.Create(dalLot); _unitOfWork.Commit(); } catch (Exception exception) { Log.LogError(exception); } }
public static LotRowViewModel ToLotRowViewModel(this LotEntity lotEntity) { return(new LotRowViewModel() { Id = lotEntity.Id, Name = lotEntity.LotName, EndDate = lotEntity.EndDate, StartingBid = lotEntity.StartingBid, SettedCategoryName = lotEntity.CategoryName, SellerLogin = lotEntity.SellerLogin, StartDate = lotEntity.StartDate, IsSold = lotEntity.IsSold }); }
public static DalLot ToDalLot(this LotEntity lot) { return(new DalLot { BuyOutBet = lot.BuyOutBet, CreatedByUserId = lot.CreatedByUserId, EndDate = lot.EndDate, Id = lot.Id, LotClosed = lot.LotClosed, LotDescription = lot.LotDescription, LotPicture = lot.LotPicture, LotPicturePreview = lot.LotPicturePreview, MinimalBet = lot.MinimalBet, Name = lot.Name, LotEnded = lot.LotEnded }); }
public static LotViewModel ToLotViewModel(this LotEntity lot) { return(new LotViewModel { BuyOutBid = lot.BuyOutBet, CreatedByUser = lot.CreatedByUser.ToUserViewModel(), CreatedByUserId = lot.CreatedByUserId, EndDate = lot.EndDate, Id = lot.Id, LotClosed = lot.LotClosed, LotEnded = lot.LotEnded, LotDescription = lot.LotDescription, LotPicture = lot.LotPicture, LotPicturePreview = lot.LotPicturePreview, Name = lot.Name, MinimalBid = lot.MinimalBet }); }
public ActionResult GetBidsList(BidListViewModel model) { LotEntity currentLot = _lotService.GetLotEntity((int)model.LotId); string currentUserEmail = currentLot.User.Email; decimal currentPrice = currentLot.LastPrice ?? currentLot.StartPrice; if (currentUserEmail == User.Identity.Name) { ModelState.AddModelError("", "You can not add bid for your own lot"); } else if ((model.Price <= currentPrice)) { ModelState.AddModelError("", string.Format("Your bid must be higher than the last bet {0} byn ", currentPrice)); } else if (ModelState.IsValid) { BidEntity newBid = new BidEntity { Price = model.Price, LotId = model.LotId, UserId = _userService.GetUserByEmail(User.Identity.Name).Id, Date = DateTime.Now }; if (_bidService.TryCreateBid(newBid, currentLot)) { currentLot.LastPrice = newBid.Price; _lotService.UpdateLot(currentLot); } if (!Request.IsAjaxRequest()) { return(RedirectToAction("LotDetails", new { id = model.LotId })); } else { model.Bids = _bidService.GetAllBidEntitiesByLotId(model.LotId).Select(b => b.ToMvcBid()).OrderByDescending(b => b.Price); return(PartialView(model)); } } if (!Request.IsAjaxRequest()) { return(RedirectToAction("LotDetails", new { id = model.LotId })); } else { model.Bids = _bidService.GetAllBidEntitiesByLotId(model.LotId).Select(b => b.ToMvcBid()).OrderByDescending(b => b.Price); return(PartialView(model)); } }
public static LotViewModel ToMvcLot(this LotEntity lotEntity) { return(new LotViewModel() { Id = lotEntity.Id, Name = lotEntity.Name, StartPrice = lotEntity.StartPrice, Description = lotEntity.Description, StartDate = lotEntity.StartDate, Duration = lotEntity.Duration, LastPrice = lotEntity.LastPrice, ImageData = lotEntity.ImageData, ImageType = lotEntity.ImageType, State = lotEntity.State.ToMvcLotState(), CategoryId = lotEntity.CategoryId, UserId = lotEntity.UserId, OwnerName = lotEntity.User.Name }); }
public static DalLot ToDalLot(this LotEntity lotEntity) { DalLot newLot = new DalLot { Id = lotEntity.Id, Name = lotEntity.Name, StartPrice = lotEntity.StartPrice, LastPrice = lotEntity.LastPrice, Description = lotEntity.Description, StartDate = lotEntity.StartDate, Duration = lotEntity.Duration, ImageData = lotEntity.ImageData, ImageType = lotEntity.ImageType, State = lotEntity.State.ToDalLotState(), UserId = lotEntity.UserId, CategoryId = lotEntity.CategoryId }; return(newLot); }
private bool CheckBidPossibility(UserEntity user, LotEntity lot) { bool result = true; if ((lot.IsActive == false) || (lot.IsChecked == false)) { result = false; } else { if (user != null) { if (user.ProfileId == lot.ProfileId) { result = false; } } } return(result); }
public static DalLot ToDalLot(this LotEntity lotEntity) { return(new DalLot() { Id = lotEntity.Id, IsBlocked = lotEntity.IsBlocked, CategoryName = lotEntity.CategoryName, CategoryRefId = lotEntity.CategoryRefId, IsConfirm = lotEntity.IsConfirm, Discription = lotEntity.Discription, BlockReason = lotEntity.BlockReason, LotName = lotEntity.LotName, SellerRefId = lotEntity.SellerRefId, EndDate = lotEntity.EndDate, IsSold = lotEntity.IsSold, SellerEmail = lotEntity.SellerEmail, SellerLogin = lotEntity.SellerLogin, StartDate = lotEntity.StartDate, StartingBid = lotEntity.StartingBid }); }
public static LotDetailsViewModel ToLotDetailsViewModel(this LotEntity lotEntity) { return(new LotDetailsViewModel() { Id = lotEntity.Id, BlockReason = lotEntity.BlockReason, CategoryRefId = lotEntity.CategoryRefId, Discription = lotEntity.Discription, EndDate = lotEntity.EndDate, IsBlocked = lotEntity.IsBlocked, IsConfirm = lotEntity.IsConfirm, IsSold = lotEntity.IsSold, Name = lotEntity.LotName, SellerEmail = lotEntity.SellerEmail, SellerLogin = lotEntity.SellerLogin, SellerRefId = lotEntity.SellerRefId, SettedCategoryName = lotEntity.CategoryName, StartDate = lotEntity.StartDate, StartingBid = lotEntity.StartingBid }); }
public static LotViewModel ToLotViewModel(this LotEntity model) { if (model == null) { return(null); } var result = new LotViewModel { Id = model.Id, Description = model.Description, IsChecked = model.IsChecked, IsActive = model.IsActive, Name = model.Name, EndDate = model.EndDate, StartDate = model.StartDate, Picture = model.Picture, ProfileId = model.ProfileId, Tags = model.Tags.Select(t => t.ToTagViewModel()).ToList() }; return(result); }
public static DalLot ToDalLot(this LotEntity lotEntity) { if (lotEntity == null) { return(null); } var lot = new DalLot { Id = lotEntity.Id, Name = lotEntity.Name, StartDate = lotEntity.StartDate, EndDate = lotEntity.EndDate, IsActive = lotEntity.IsActive, IsChecked = lotEntity.IsChecked, Picture = lotEntity.Picture, ProfileId = lotEntity.ProfileId, Description = lotEntity.Description, Tags = lotEntity.Tags.Select(tag => new DalTag { Id = tag.Id, Name = tag.Name } ).ToList(), Bids = lotEntity.Bids.Select(bid => new DalBid { Id = bid.Id, ProfileId = bid.ProfileId, Date = bid.Date, Price = bid.Price, LotId = bid.LotId } ).ToList() }; return(lot); }
public static LotEntity ToBllLot(this DalLot dalLot) { if (dalLot == null) { return(null); } var lot = new LotEntity { Id = dalLot.Id, Name = dalLot.Name, StartDate = dalLot.StartDate, EndDate = dalLot.EndDate, IsActive = dalLot.IsActive, IsChecked = dalLot.IsChecked, Picture = dalLot.Picture, ProfileId = dalLot.ProfileId, Description = dalLot.Description, Tags = dalLot.Tags.Select(tag => new TagEntity { Id = tag.Id, Name = tag.Name } ).ToList(), Bids = dalLot.Bids.Select(bid => new BidEntity { Id = bid.Id, ProfileId = bid.ProfileId, Date = bid.Date, Price = bid.Price, LotId = bid.LotId } ).ToList() }; return(lot); }
public ListBidViewModel GetBidsList(LotEntity lot) { ListBidViewModel model = new ListBidViewModel(); model.List = new List <BidViewModel>(); if (lot != null) { foreach (BidEntity bidEntity in lot.Bids) { BidViewModel bidViewModel = bidEntity.ToBidViewModel(); var profile = profileService.GetOneByPredicate(p => p.Id == bidEntity.ProfileId); if (profile != null) { bidViewModel.Name = profile.Name; } else { bidViewModel.Name = "Unknown"; } model.List.Add(bidViewModel); } } return(model); }
/// <summary> /// 打印条码。 /// </summary> /// <param name="batch">是否批量打印。</param> private void Print(bool batch) { try { ComputerEntity computerEntity = new ComputerEntity(); if (computerEntity.GetComputerPrinterInfo(PropertyService.Get(PROPERTY_FIELDS.COMPUTER_NAME))) { if (computerEntity.PrinterType.Length < 1 || computerEntity.BarcodeModule.Length < 1) { MessageService.ShowError("请配置打印机类型或标签模板"); return; } else { if (Convert.ToInt32(computerEntity.PrinterType) == (int)PortType.Local) { if (computerEntity.PrinterName.Length == 0) { MessageService.ShowMessage("请配置打印机名称"); return; } } else { if (computerEntity.PrinterPort.Length == 0) { MessageService.ShowMessage("请配置打印机端口"); return; } if (Convert.ToInt32(computerEntity.PrinterType) == (int)PortType.Network && computerEntity.PrinterIP.Length == 0) { MessageService.ShowError("请配置打印机Ip地址"); return; } } } if (rowHandle > -1) { //组织要打印的数据。 List <BarCode> barcodeList = new List <BarCode>(); if (batch)//如果要批量打印。 { foreach (int i in gvLotInfo.GetSelectedRows()) { string lotNumber = gvLotInfo.GetRowCellValue(i, POR_LOT_FIELDS.FIELD_LOT_NUMBER).ToString(); BarCode barcode = new BarCode(lotNumber); barcodeList.Add(barcode); } } else { BarCode barcode = new BarCode(_lotNumber); barcodeList.Add(barcode); } //打印 int printNumber = 0; try { printNumber = CodePrint.BarCodePrint(barcodeList, computerEntity.BarcodeModule, computerEntity.PrinterName, computerEntity.PrinterIP, computerEntity.PrinterPort, (PortType)(Convert.ToInt32(computerEntity.PrinterType))); } catch (Exception ex) { MessageService.ShowWarning("打印失败:" + ex.Message); return; } //更新批次状态。 LotEntity entity = new LotEntity(); List <string> lotNumbers = new List <string>(); for (int i = 0; i < printNumber; i++) { lotNumbers.Add(barcodeList[i].BatteryCellCode); } if (!entity.UpdatePrintFlag(lotNumbers)) { MessageService.ShowError("更新批次号打印机状态失败。"); return; } else { if (batch)//如果要批量打印。 { foreach (int i in gvLotInfo.GetSelectedRows()) { gvLotInfo.SetRowCellValue(i, POR_LOT_FIELDS.FIELD_IS_PRINT, (Convert.ToInt32(_printFlag) + 1).ToString()); } } else { gvLotInfo.SetRowCellValue(rowHandle, POR_LOT_FIELDS.FIELD_IS_PRINT, (Convert.ToInt32(_printFlag) + 1).ToString()); } } if (printNumber == barcodeList.Count)//打印成功 { MessageService.ShowMessage("${res:FanHai.Hemera.Addins.Sorting.Message.PrintFinished}", "提示"); } else { MessageService.ShowMessage("部分条码打印未成功。", "提示"); } } } } catch (Exception ex) { MessageService.ShowError(ex.Message); } }
public UserEntity GetMaxBidOwner(LotEntity lot) { return(lot.Bids.LastOrDefault(b => b.Date <= (lot.StartDate + new TimeSpan(lot.Duration, 0, 0, 0))).User); }
public void Delete(LotEntity lot) { lotRepository.Delete(lot.ToDalLot()); uow.Commit(); }
public void Update(LotEntity lot) { lotRepository.Update(lot.ToDalLot()); uow.Commit(); }
public async Task <Lot> GetLotAsync(int lotId) { LotEntity lot = await UoW.Lots.GetAsync(lotId) ?? throw new WrongIdException("Lot"); return(mapper.Map <Lot>(lot)); }
public Lot GetLot(int lotId) { LotEntity lot = UoW.Lots.Get(lotId) ?? throw new WrongIdException("Lot"); return(mapper.Map <Lot>(lot)); }
public void CreateLot(LotEntity lot) { lotRepository.Create(lot.ToDalLot()); uow.Commit(); }
public void CloseLot(LotEntity lot) { _lotRepository.CloseLot(lot.ToDalLot()); _uow.Commit(); }
public bool ValidateBidPrice(BidEntity bid, LotEntity lot) { return(bid.Price > lot.LastPrice); }