private void frmMold_Load(object sender, EventArgs e) { _moldRepository = new MoldRepository(_projectDataContext); LanguageTranslate.ChangeLanguageForm(this); LanguageTranslate.ChangeLanguageGridView(viewDuLieu); Search(); }
private void frmScanBarcode_Load(object sender, EventArgs e) { _projectDataContext = new ProjectDataContext(); _scanBarcodeRepository = new ScanBarcodeRepository(_projectDataContext); _registBarcodeRepository = new RegistBarcodeRepository(_projectDataContext); _partNumberRepository = new PartNumberRepository(_projectDataContext); _machineRepository = new MachineRepository(_projectDataContext); _moldRepository = new MoldRepository(_projectDataContext); _shiftRepository = new ShiftRepository(_projectDataContext); LanguageTranslate.ChangeLanguageForm(this); LoadCount(); LoadPartNumberData(); LoadMachineData(); LoadMoldData(); _serialPort = new SerialPort(); _serialPort.DataReceived += new SerialDataReceivedEventHandler(this.serialPort_DataReceived); Control.CheckForIllegalCrossThreadCalls = false; ClosePortCOM(GlobalConstants.portCOM); OpenPortCOM(GlobalConstants.portCOM, 9600); timer.Enabled = true; txtBarcode.Focus(); }
private void Search() { _projectDataContext = new ProjectDataContext(); _moldRepository = new MoldRepository(_projectDataContext); dgvDuLieu.DataSource = _moldRepository.GetAll().OrderBy(_ => _.MoldNo); Control(); }
/// <summary> /// obtains a detail of mold /// </summary> /// <param name="id">identifier of mold</param> /// <returns>returns the result to action</returns> public ActionResult Detail(int?id) { MoldRepository objMold = new MoldRepository(SessionCustom); Mold mold = null; XmlDocument xmlDoc = null; if (id != null) { objMold.Entity.MoldId = id; objMold.Load(); mold = objMold.Entity; ViewBag.id = id; xmlDoc = new XmlDocument(); xmlDoc.LoadXml(objMold.Entity.Xmlcontent); } return(this.View(new Molde() { UserPrincipal = CustomUser, Module = this.Module, Mold = mold, ColModul = CustomMemberShipProvider.GetModuls(CustomUser.UserId, SessionCustom, HttpContext), CurrentLanguage = CurrentLanguage, Xmldocument = xmlDoc })); }
/// <summary> /// 根据模具警报类型获得模具警报信息 /// </summary> /// <param name="type">模具警报类型</param> /// <returns>模具警报信息列表</returns> public List <MoldWarnInfo> GetMoldWarnInfo(MoldWarnType type) { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IMoldRepository moldRepostitory = new MoldRepository(unitwork); List <MoldView> molds = moldRepostitory.GetByWarnType(type); List <MoldWarnInfo> moldWarnInfos = new List <MoldWarnInfo>(); foreach (MoldView m in molds) { MoldWarnInfo moldWarnInfo = new MoldWarnInfo() { MoldNR = m.MoldNR, Type = m.TypeName, ProjectName = m.ProjectName, MaxLendHour = (double)m.MaxLendHour, LendTime = (DateTime)m.LastRecordDate, CurrentPosition = m.StorageRecordNR.HasValue ? moldRepostitory.GetMoldCurrPosiByRecordNR((Guid)m.StorageRecordNR) : string.Empty }; moldWarnInfos.Add(moldWarnInfo); } return(moldWarnInfos); } }
/// <summary> /// set mold cut /// </summary> /// <param name="moldNr"></param> /// <param name="currentCut"></param> /// <param name="totalCut"></param> /// <returns></returns> public string SetMoldCut(string moldNr, string currentCut, string totalCut) { Mold mold = null; try { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IMoldRepository moldRep = new MoldRepository(unitwork); mold = moldRep.GetById(moldNr); if (mold != null) { // update mold state mold.CurrentCuttimes = int.Parse(currentCut); mold.Cuttedtimes = int.Parse(totalCut); } unitwork.Submit(); } } catch (Exception ex) { LogUtil.log.Error(ex.ToString()); } return(moldNr); }
/// <summary> /// 根据搜索条件获得模具基本信息 /// </summary> /// <param name="conditions">搜索条件</param> /// <returns>模具基本信息列表</returns> public List <MoldBaseInfo> GetMoldByMutiConditions(MoldSearchCondition conditions) { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IMoldRepository moldRepostitory = new MoldRepository(unitwork); List <MoldView> molds = moldRepostitory.GetByMutiConditions(conditions); List <MoldBaseInfo> moldBaseInfos = new List <MoldBaseInfo>(); foreach (MoldView m in molds) { MoldBaseInfo moldBaseInfo = new MoldBaseInfo() { MoldNR = m.MoldNR, Name = m.Name, Type = m.TypeName, State = m.State, StateCN = m.StateCN, ProjectId = m.ProjectID, ProjectName = m.ProjectName, CurrentPosition = m.StorageRecordNR.HasValue ? moldRepostitory.GetMoldCurrPosiByRecordNR((Guid)m.StorageRecordNR) : string.Empty }; moldBaseInfos.Add(moldBaseInfo); } return(moldBaseInfos); } }
/// <summary> /// 根据模具号获得模具基本信息 /// </summary> /// <param name="moldNR">模具号</param> /// <returns>模具基本信息</returns> public MoldBaseInfo GetMoldBaseInfoByNR(string moldNR) { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IMoldRepository moldRepostitory = new MoldRepository(unitwork); IAttachmentRepository attachRep = new AttachmentRepository(unitwork); IPositionRepository posiRep = new PositionRepository(unitwork); MoldView m = moldRepostitory.GetMoldViewByMoldNR(moldNR); if (m != null) { MoldBaseInfo mb = new MoldBaseInfo() { MoldNR = m.MoldNR, Name = m.Name, Type = m.TypeName, Position = posiRep.GetByFacilictyNR(moldNR).PositionNR, Producer = m.Producer, Material = m.Material, Weight = m.Weight == null ? string.Empty : m.Weight.ToString(), State = m.State, StateCN = m.StateCN, ProjectId = m.ProjectID, ProjectName = m.ProjectName, Attach = attachRep.GetByMasterNR(moldNR) }; return(mb); } return(null); } }
/// <summary> /// 根据模具号获得库位号 /// </summary> /// <param name="posiNr">库位号</param> /// <returns>模具号</returns> public string GetMoldNrByPosiNr(string posiNr) { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IMoldRepository moldRep = new MoldRepository(unitwork); return(moldRep.GetMoldNrByPosiNr(posiNr)); } }
/// <summary> /// 根据模具号判断模具是否存在 /// </summary> /// <param name="moldNR">模具号</param> /// <returns>判断结果</returns> public bool MoldExist(string moldNR) { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IMoldRepository moldRep = new MoldRepository(unitwork); return moldRep.MoldExsit(moldNR); } }
/// <summary> /// 根据模具号获得库位号 /// </summary> /// <param name="moldNR">模具号</param> /// <returns>库位号</returns> public string GetMoldCurrentPosition(string moldNR) { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IMoldRepository moldRepostitory = new MoldRepository(unitwork); MoldView moldview = moldRepostitory.GetMoldViewByMoldNR(moldNR); return(moldview.StorageRecordNR == null ? string.Empty : moldRepostitory.GetMoldCurrPosiByRecordNR((Guid)moldview.StorageRecordNR)); } }
/// <summary> /// 模具测试 /// </summary> /// <param name="moldNR">模具号</param> /// <param name="operatorNR">操作员工号</param> /// <param name="files">文件列表</param> /// <returns>测试信息</returns> public Message MoldTest(string moldNR, string operatorNR, FileUP[] files, int currentCutTimes, bool moldNormal) { try { using (TransactionScope ts = new TransactionScope()) { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IReportRepository reportRep = new ReportRepository(unitwork); Report report = new Report(); report.ReportId = GuidUtil.GenerateGUID(); report.MoldID = moldNR; report.ReportType = ReportType.TestReport; report.OperatorID = operatorNR; report.Date = DateTime.Now; //upload files FileUpLoad(files, report.ReportId.ToString()); reportRep.Add(report); // update the last released date IMoldRepository moldRep = new MoldRepository(unitwork); Mold mold = moldRep.GetById(moldNR); mold.LastReleasedDate = report.Date; mold.Cuttedtimes += mold.CurrentCuttimes; mold.CurrentCuttimes = 0; if (moldNormal) { mold.State = MoldStateType.Normal; } unitwork.Submit(); ts.Complete(); return(new Message() { MsgType = MsgType.OK, Content = "实验报告上传成功!" }); } } } catch (Exception ex) { LogUtil.log.Error(ex.ToString()); return(new Message() { MsgType = MsgType.Error, Content = ex.Message }); } }
/// <summary> /// gets the home of mold module /// </summary> /// <returns>returns the result to action</returns> public ActionResult Index() { MoldRepository objMold = new MoldRepository(SessionCustom); return(this.View(new Molde() { UserPrincipal = CustomUser, Module = this.Module, CollMold = objMold.GetAll(), ColModul = CustomMemberShipProvider.GetModuls(CustomUser.UserId, SessionCustom, HttpContext), CurrentLanguage = CurrentLanguage })); }
private void frmMoldAddEdit_Load(object sender, EventArgs e) { _moldRepository = new MoldRepository(_projectDataContext); LanguageTranslate.ChangeLanguageForm(this); if (String.IsNullOrEmpty(_id)) { Clear(); } else { GetData(); } }
public ContentResult GetMold(int id) { MoldRepository objMoldRepository = new MoldRepository(SessionCustom); objMoldRepository.Entity.MoldId = id; objMoldRepository.LoadByKey(); XmlDocument objDoc = new XmlDocument(); objDoc.LoadXml(objMoldRepository.Entity.Xmlcontent); string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(objDoc.ChildNodes[1]); return(new ContentResult() { Content = json, ContentType = "application/json" }); }
/// <summary> /// gets the home of news module /// </summary> /// <param name="mod">identifier of module</param> /// <param name="sectionId">identifier of section</param> /// <returns>returns the result to action</returns> public ActionResult Index(int mod, int?sectionId) { ContentManagement objcontentman = new ContentManagement(this.SessionCustom, HttpContext); SectionRepository objsection = new SectionRepository(this.SessionCustom); TemplateRepository objtemplate = new TemplateRepository(this.SessionCustom); ContentRepository objcontent = new ContentRepository(this.SessionCustom); TagFacade tagFacade = new TagFacade(); objtemplate.Entity.Type = 0; MoldRepository objMold = new MoldRepository(this.SessionCustom); List <Domain.Entities.Mold> collMold = objMold.GetAll(); collMold.Insert( 0, new Domain.Entities.Mold() { Name = Resources.Global.Messages.SELECT }); return(this.View(new NewsModel() { UserPrincipal = this.CustomUser, Module = this.Module, ColModul = CustomMemberShipProvider.GetModuls(this.CustomUser.UserId, this.SessionCustom, HttpContext), Templates = objtemplate.GetAll().Select(t => t.TemplateId), DeepFollower = sectionId != null ? Business.Utils.GetDeepFollower(objsection.GetAll(), sectionId.Value) : null, IContent = new Domain.Entities.Content() { ModulId = mod, SectionId = sectionId }, CurrentLanguage = this.CurrentLanguage, CollMold = collMold, Categories = objcontent.Categories(), Tags = tagFacade.GetAll().Select(t => new SelectListItem { Text = t.Name, Value = t.TagId.ToString() }) })); }
public ActionResult Detail(int?id, Molde model, FormCollection values) { MoldRepository objMold = new MoldRepository(SessionCustom); objMold.Entity = model.Mold; objMold.Entity.Xmlcontent = this.GetXmlDocument(values).InnerXml; if (id != null) { objMold.Entity.MoldId = id; objMold.Update(); this.InsertAudit("Update", this.Module.Name + " -> " + objMold.Entity.Name); } else { objMold.Insert(); this.InsertAudit("Insert", this.Module.Name + " -> " + objMold.Entity.Name); } return(this.RedirectToAction("Index")); }
private void frmRegistBarcodeAddEdit_Load(object sender, EventArgs e) { _registBarcodeRepository = new RegistBarcodeRepository(_projectDataContext); _partNumberRepository = new PartNumberRepository(_projectDataContext); _machineRepository = new MachineRepository(_projectDataContext); _moldRepository = new MoldRepository(_projectDataContext); _shiftRepository = new ShiftRepository(_projectDataContext); LanguageTranslate.ChangeLanguageForm(this); LoadPartNumberData(); LoadMachineData(); LoadShiftData(); LoadMoldData(); if (String.IsNullOrEmpty(_id)) { Clear(); } else { Close(); } }
/// <summary> /// 根据模具号获得模具动态信息 /// </summary> /// <param name="moldNR">模具号</param> /// <returns>模具基本信息</returns> public MoldDynamicInfo GetMoldDynamicInfoByMoldNR(string moldNR) { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IMoldRepository moldRepostitory = new MoldRepository(unitwork); MoldView moldview = moldRepostitory.GetMoldViewByMoldNR(moldNR); if (moldview == null) { return(null); } IStorageRecordRepository storageRep = new StorageRecordRepository(unitwork); StorageRecord storageRecord = null; if (moldview.StorageRecordNR != null) { storageRecord = storageRep.GetByStorageNR((Guid)moldview.StorageRecordNR); } MoldDynamicInfo moldDynamicInfo = new MoldDynamicInfo() { CurrentPosition = moldview.StorageRecordNR == null ? string.Empty : moldRepostitory.GetMoldCurrPosiByRecordNR((Guid)moldview.StorageRecordNR), Operator = storageRecord == null ? string.Empty : storageRecord.OperatorId, OperateTime = storageRecord == null ? string.Empty : storageRecord.Date.ToString(), AllowedCuttedTime = moldview.MaxCuttimes, CurrentCuttedTime = moldview.CurrentCuttimes, ReleaseCycle = moldview.ReleaseCycle, LastReleasedTime = moldview.LastReleasedDate.ToString(), MantainCycle = moldview.MaintainCycle, LastMantainTime = moldview.LastMainedDate.ToString(), State = moldview.State, StateCN = EnumUtil.GetEnumDescriptionByEnumValue(moldview.State), ProjectId = moldview.ProjectID, ProjectName = moldview.ProjectName }; return(moldDynamicInfo); } }
//Motor de la aplicación Estaciones, Bandejas, Moldes, Operaciones, Ordenes de fabricación y piezas private void TimerComunicationStatus_Tick(object sender, EventArgs e) { TimerS7ComunicationStatus.Stop(); foreach (var station in AppGlobal.Stations) { if (station.Bussy) { continue; } if (!S7.GetBitAt(AppGlobal.Snap7Server.Read(station.StatusChangeS7), 0, 0)) { continue; } var data = AppGlobal.Snap7Server.Read(station.DataAddressS7); station.DataContent = Common.GetDataContent(data); var pallet = PalletController.GetByCode(station.DataContent.PalletCode); var operation = OperationController.GetByCode(station.DataContent.OperationCode); var mold = MoldRepository.GetByCode(station.DataContent.MoldCode); station.ActiveOperation = operation; if (operation.InitPart || operation.EndPart) { station.Bussy = true; Thread AskForReferencePartThread = new Thread(new ThreadStart(() => AskForReferencePart(station, pallet, operation, mold))); AskForReferencePartThread.Start(); } else { OperationRegisterController.Register(station, pallet, operation, mold, "Pieza 1"); AppGlobal.Snap7Server.WriteWord(station.StatusChangeS7Ack, (ushort)operation.Code); } } TimerS7ComunicationStatus.Start(); }
/// <summary> /// 归还模具 /// </summary> /// <param name="moldNR">模具号</param> /// <param name="applicantNR">申请员工工号</param> /// <param name="operatorNR">操作员工工号</param> /// <param name="remark">备注</param> /// <param name="moldState">模具状态</param> /// <returns>归还信息</returns> public Message ReturnMold(string moldNR, string applicantNR, string operatorNR, string remark, MoldReturnStateType moldState) { try { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IMoldRepository moldRep = new MoldRepository(unitwork); Mold mold = moldRep.GetById(moldNR); if (mold.State != MoldStateType.NotReturned) { return new Message() { MsgType = MsgType.Warn, Content = "模具已归还!" } } ; StorageRecord storageRecord = new StorageRecord(); //set value of storage record IPositionRepository positionRep = new PositionRepository(unitwork); //Position position = positionRep.GetByFacilictyNR(moldNR); Position position = positionRep.GetPartPoolPosition(Settings.Default.MoldPoolPosiNr); storageRecord.PositionId = position.PositionID; storageRecord.StorageRecordNR = GuidUtil.GenerateGUID(); storageRecord.Source = moldRep.GetMoldCurrPosiByMoldNR(moldNR); storageRecord.Destination = position.PositionNR; storageRecord.OperatorId = operatorNR; storageRecord.ApplicantId = applicantNR; storageRecord.Date = DateTime.Now; storageRecord.Quantity = 1; storageRecord.TargetNR = moldNR; storageRecord.Remark = remark; storageRecord.RecordType = StorageRecordType.Return; // add new storage record IStorageRecordRepository recordRep = new StorageRecordRepository(unitwork); recordRep.Add(storageRecord); // update mold last apply storage record nr IMoldLastRecordRepository lastRecordRep = new MoldLastRecordRepository(unitwork); MoldLastRecord lastRecord = lastRecordRep.GetByMoldNR(moldNR); lastRecord.StorageRecordNR = storageRecord.StorageRecordNR; // update mold state mold = moldRep.GetById(storageRecord.TargetNR); mold.State = (MoldStateType)moldState; // update workstation mold count IWorkstationRepository workstationRep = new WorkstationRepository(unitwork); Workstation workstation = workstationRep.GetById(storageRecord.Source); if (workstation != null) { workstation.CurrentMoldCount--; } unitwork.Submit(); return(new Message() { MsgType = MsgType.OK, Content = "归还成功" }); } } catch (Exception ex) { LogUtil.log.Error(ex.ToString()); return(new Message() { MsgType = MsgType.Error, Content = ex.Message }); } }
/// <summary> /// obtains the news detail /// </summary> /// <param name="mod">identifier of module</param> /// <param name="id">identifier of section</param> /// <returns>returns the result to action</returns> public ActionResult Detail(int mod, int id) { ContentManagement objcontentman = new ContentManagement(SessionCustom, HttpContext); ContentRepository objcontent = new ContentRepository(SessionCustom); NewsRepository objnews = new NewsRepository(SessionCustom); FileattachRepository objfiles = new FileattachRepository(SessionCustom); TagRepository objtag = new TagRepository(SessionCustom); SectionRepository objsection = new SectionRepository(SessionCustom); TemplateRepository objtemplate = new TemplateRepository(SessionCustom); MoldRepository objMold = new MoldRepository(SessionCustom); XmlNodeList collXmlNode = null; TagFacade tagFacade = new TagFacade(); List <Domain.Entities.Mold> collMold = objMold.GetAll(); collMold.Insert( 0, new Domain.Entities.Mold() { Name = Resources.Global.Messages.SELECT }); objtemplate.Entity.Type = 0; objnews.Entity.ContentId = objfiles.Entity.ContentId = objcontent.Entity.ContentId = id; objnews.LoadByKey(); objcontent.LoadByKey(); if (objnews.Entity.MoldId != null) { XmlDocument objXmlDocument = new XmlDocument(); objXmlDocument.LoadXml(objnews.Entity.Xmlcontent); collXmlNode = objXmlDocument.GetElementsByTagName("node"); } IEnumerable <Tag> SelectedTags = objtag.GetTagbycontent(id); this.ViewBag.SelectedTags = string.Join("|", SelectedTags.Select(t => t.TagId)); this.ViewBag.NewsTags = string.Empty; return(this.View( "Index", new NewsModel() { UserPrincipal = this.CustomUser, ColModul = CustomMemberShipProvider.GetModuls(this.CustomUser.UserId, this.SessionCustom, HttpContext), Module = this.Module, ListFiles = objfiles.GetAllReadOnly(), News = objnews.Entity, IContent = objcontent.Entity, Templates = objtemplate.GetAll().Select(t => t.TemplateId), ListContent = objcontent.GetContentRelation(CurrentLanguage.LanguageId.Value), ListTags = SelectedTags, DeepFollower = Business.Utils.GetDeepFollower(objsection.GetAll(), objcontent.Entity.SectionId.Value), CurrentLanguage = this.CurrentLanguage, CollMold = collMold, CollXmlNode = collXmlNode, Categories = objcontent.Categories(), Tags = tagFacade.GetAll().Select(t => new SelectListItem { Text = t.Name, Value = t.TagId.ToString() }) })); }
/// <summary> /// 将模具从缓冲区移到库位 /// </summary> /// <param name="moldNR">模具号</param> /// <param name="operatorNR">操作员工号</param> /// <param name="remark">备注</param> /// <returns>操作信息</returns> public Message ReturnMoldInPosition(string moldNR, string operatorNR, string remark) { try { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IMoldRepository moldRep = new MoldRepository(unitwork); Mold mold = moldRep.GetById(moldNR); if (mold.State == MoldStateType.NotReturned) { return new Message() { MsgType = MsgType.Warn, Content = "模具还未归还,请归还后再入库!" } } ; string currentPosi = moldRep.GetMoldCurrPosiByMoldNR(moldNR); if (!currentPosi.Equals(GetPartPoolPosiNr())) { return new Message() { MsgType = MsgType.Warn, Content = "模具已经入库!" } } ; StorageRecord storageRecord = new StorageRecord(); //set value of storage record IPositionRepository positionRep = new PositionRepository(unitwork); Position position = positionRep.GetByFacilictyNR(moldNR); storageRecord.PositionId = position.PositionID; storageRecord.StorageRecordNR = GuidUtil.GenerateGUID(); storageRecord.Source = currentPosi; storageRecord.Destination = position.PositionNR; storageRecord.OperatorId = operatorNR == null?string.Empty: operatorNR.ToString(); storageRecord.Date = DateTime.Now; storageRecord.Quantity = 1; storageRecord.TargetNR = moldNR; storageRecord.Remark = remark == null?string.Empty:remark.ToString(); storageRecord.RecordType = StorageRecordType.MoveStore; // add new storage record IStorageRecordRepository recordRep = new StorageRecordRepository(unitwork); recordRep.Add(storageRecord); // update mold last apply storage record nr IMoldLastRecordRepository lastRecordRep = new MoldLastRecordRepository(unitwork); MoldLastRecord lastRecord = lastRecordRep.GetByMoldNR(moldNR); lastRecord.StorageRecordNR = storageRecord.StorageRecordNR; unitwork.Submit(); return(new Message() { MsgType = MsgType.OK, Content = "入库成功" }); } } catch (Exception ex) { LogUtil.log.Error(ex.ToString()); return(new Message() { MsgType = MsgType.Error, Content = ex.Message }); } }
/// <summary> /// 模具移库 /// </summary> /// <param name="moldNR">模具号</param> /// <param name="sourcePosiNr">源位置号</param> /// <param name="desiPosiNr">目标位置号</param> /// <returns>移库信息</returns> public Message MoldMoveStore(string moldNR, string warehouseNR, string sourcePosiNr, string desiPosiNr) { try { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IPositionRepository posiRep = new PositionRepository(unitwork); if (!posiRep.PositionExsit(desiPosiNr)) { return new Message() { MsgType = MsgType.Warn, Content = "目标库位不存在,请核实!" } } ; IMoldRepository moldRep = new MoldRepository(unitwork); if (moldRep.GetMoldNrByPosiNr(desiPosiNr).Length == 0) { // there is no mold in desitination position // add new uniqstorage Position position = posiRep.GetByWarehouseNRAndPositionNR(warehouseNR, desiPosiNr); // add new uniqstorage IUniqStorageRepository uniqStroageRep = new UniqStorageRepository(unitwork); uniqStroageRep.DeleteByMoldNr(moldNR); UniqStorage uniqStorage = new UniqStorage() { UniqStorageId = GuidUtil.GenerateGUID(), UniqNR = moldNR, PositionId = position.PositionID, Quantity = 1 }; uniqStroageRep.Add(uniqStorage); //set value of storage record StorageRecord storageRecord = new StorageRecord(); storageRecord.PositionId = position.PositionID; storageRecord.StorageRecordNR = GuidUtil.GenerateGUID(); storageRecord.Source = sourcePosiNr; storageRecord.Destination = desiPosiNr; storageRecord.Date = DateTime.Now; storageRecord.Quantity = 1; storageRecord.TargetNR = moldNR; storageRecord.RecordType = StorageRecordType.MoveStore; // add new storage record IStorageRecordRepository recordRep = new StorageRecordRepository(unitwork); recordRep.Add(storageRecord); IMoldLastRecordRepository moldLastRecord = new MoldLastRecordRepository(unitwork); moldLastRecord.GetByMoldNR(moldNR).StorageRecordNR = storageRecord.StorageRecordNR; } else { Position sourcePosi = posiRep.GetByWarehouseNRAndPositionNR(warehouseNR, sourcePosiNr); Position desiPosi = posiRep.GetByWarehouseNRAndPositionNR(warehouseNR, desiPosiNr); UniqStorage sourceU = sourcePosi.UniqStorage.First(); UniqStorage desiU = desiPosi.UniqStorage.First(); string desiMoldNr = desiU.UniqNR; sourceU.UniqNR = desiMoldNr; desiU.UniqNR = moldNR; // add new storage record IStorageRecordRepository recordRep = new StorageRecordRepository(unitwork); StorageRecord sourcestorageRecord = new StorageRecord(); sourcestorageRecord.PositionId = sourcePosi.PositionID; sourcestorageRecord.StorageRecordNR = GuidUtil.GenerateGUID(); sourcestorageRecord.Source = sourcePosiNr; sourcestorageRecord.Destination = desiPosiNr; sourcestorageRecord.Date = DateTime.Now; sourcestorageRecord.Quantity = 1; sourcestorageRecord.TargetNR = moldNR; sourcestorageRecord.RecordType = StorageRecordType.MoveStore; recordRep.Add(sourcestorageRecord); StorageRecord desistorageRecord = new StorageRecord(); desistorageRecord.PositionId = desiPosi.PositionID; desistorageRecord.StorageRecordNR = GuidUtil.GenerateGUID(); desistorageRecord.Source = desiPosiNr; desistorageRecord.Destination = sourcePosiNr; desistorageRecord.Date = DateTime.Now; desistorageRecord.Quantity = 1; desistorageRecord.TargetNR = desiMoldNr; desistorageRecord.RecordType = StorageRecordType.MoveStore; recordRep.Add(desistorageRecord); IMoldLastRecordRepository moldLastRecord = new MoldLastRecordRepository(unitwork); moldLastRecord.GetByMoldNR(moldNR).StorageRecordNR = sourcestorageRecord.StorageRecordNR; moldLastRecord.GetByMoldNR(desiMoldNr).StorageRecordNR = desistorageRecord.StorageRecordNR; } unitwork.Submit(); return(new Message() { MsgType = MsgType.OK, Content = "移库成功" }); } } catch (Exception ex) { LogUtil.log.Error(ex.ToString()); return(new Message() { MsgType = MsgType.Error, Content = ex.Message }); } }
/// <summary> /// 申领模具 /// </summary> /// <param name="moldUseType">模具使用类型</param> /// <param name="moldNR">模具号</param> /// <param name="applicantNR">申请员工工号</param> /// <param name="operatorNR">操作员工工号</param> /// <param name="workstationNR">操作台号</param> /// <returns>申请信息</returns> public Message ApplyMold(MoldUseType moldUseType, string moldNR, string applicantNR, string operatorNR, string workstationNR) { try { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IWorkstationRepository workstationRep = new WorkstationRepository(unitwork); IMoldRepository moldRep = new MoldRepository(unitwork); Mold mold = moldRep.GetById(moldNR); // check mold is available for apply if (mold.State == MoldStateType.NotReturned) { return new Message() { MsgType = MsgType.Warn, Content = "模具处于不可借状态!" } } ; // check workstaition reach the max mold apply number if (workstationRep.OverAppliedMold(workstationNR) == false && Settings.Default.AllowOverApply == false) { return new Message() { MsgType = MsgType.Warn, Content = "申领已到达上限!" } } ; if (mold.CurrentCuttimes != null && mold.MaxCuttimes != null) { if (mold.CurrentCuttimes.Value > mold.MaxCuttimes.Value) { return(new Message() { MsgType = MsgType.Warn, Content = "模具压接次数超过上限!" }); } } IPositionRepository positionRep = new PositionRepository(unitwork); Position position = positionRep.GetByFacilictyNR(moldNR); //set value of storage record IStorageRecordRepository recordRep = new StorageRecordRepository(unitwork); StorageRecord storageRecord = new StorageRecord(); storageRecord.StorageRecordNR = GuidUtil.GenerateGUID(); storageRecord.PositionId = position.PositionID; storageRecord.Source = position.PositionNR; storageRecord.Destination = workstationNR; storageRecord.OperatorId = operatorNR; storageRecord.ApplicantId = applicantNR; storageRecord.Quantity = 1; storageRecord.Date = DateTime.Now; storageRecord.TargetNR = moldNR; storageRecord.RecordType = (StorageRecordType)moldUseType; // add new storage record recordRep.Add(storageRecord); // update mold last apply storage record nr IMoldLastRecordRepository lastRecordRep = new MoldLastRecordRepository(unitwork); MoldLastRecord lastRecord = lastRecordRep.GetByMoldNR(moldNR); lastRecord.StorageRecordNR = storageRecord.StorageRecordNR; // update mold state mold = moldRep.GetById(storageRecord.TargetNR); mold.State = MoldStateType.NotReturned; // update the workstation current mold count Workstation workstation = workstationRep.GetById(storageRecord.Destination); workstation.CurrentMoldCount++; unitwork.Submit(); return(new Message() { MsgType = MsgType.OK, Content = "申领成功" }); } } catch (Exception ex) { LogUtil.log.Error(ex.ToString()); return(new Message() { MsgType = MsgType.Error, Content = "请核实所填数据的准确性" }); } }
/// <summary> /// 模具移动工作台 /// </summary> /// <param name="moldNR">模具号</param> /// <param name="operatorNR">操作员工号</param> /// <param name="targetWStationNR">目标工作台号</param> /// <returns>移动信息</returns> public Message MoldMoveWorkStation(string moldNR, string operatorNR, string targetWStationNR) { try { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IWorkstationRepository workstationRep = new WorkstationRepository(unitwork); IMoldRepository moldRep = new MoldRepository(unitwork); IEmployeeRepository empRep = new EmployeeRepository(unitwork); Mold mold = moldRep.GetById(moldNR); if (!empRep.Exist(operatorNR)) { return new Message() { MsgType = MsgType.Warn, Content = "操作员不存在!" } } ; if (mold == null) { return new Message() { MsgType = MsgType.Warn, Content = "模具不存在!" } } ; Workstation tworkstation = workstationRep.GetById(targetWStationNR); if (tworkstation == null) { return new Message() { MsgType = MsgType.Warn, Content = "目标工作台不存在!" } } ; // check mold is available for move if (mold.State != MoldStateType.NotReturned) { return new Message() { MsgType = MsgType.Warn, Content = "模具未被借用,请先借用!" } } ; MoldView moldview = moldRep.GetMoldViewByMoldNR(moldNR); string currentWorkPosi = moldview.StorageRecordNR == null ? string.Empty : moldRep.GetMoldCurrPosiByRecordNR((Guid)moldview.StorageRecordNR); // if(workstationRep.GetById(currentWorkPosi)==null) // return new Message() { MsgType = MsgType.Warn, Content = "模具正在使用的工作台号已经被修改,请先归还此模具再做后续操作!" }; if (currentWorkPosi.Equals(targetWStationNR)) { return new Message() { MsgType = MsgType.Warn, Content = "模具已经在此工作台,不可重复移动!" } } ; // check workstaition reach the max mold apply number if (workstationRep.OverAppliedMold(targetWStationNR) == false && Settings.Default.AllowOverApply == false) { return new Message() { MsgType = MsgType.Warn, Content = "目标工作台已经到达模具使用上限!" } } ; IPositionRepository positionRep = new PositionRepository(unitwork); Position position = positionRep.GetByFacilictyNR(moldNR); //set value of storage record IStorageRecordRepository recordRep = new StorageRecordRepository(unitwork); StorageRecord storageRecord = new StorageRecord(); storageRecord.StorageRecordNR = GuidUtil.GenerateGUID(); storageRecord.PositionId = position.PositionID; storageRecord.Source = currentWorkPosi; storageRecord.Destination = targetWStationNR; storageRecord.OperatorId = operatorNR; storageRecord.Quantity = 1; storageRecord.Date = DateTime.Now; storageRecord.TargetNR = moldNR; storageRecord.RecordType = StorageRecordType.MoveWStation; // add new storage record recordRep.Add(storageRecord); // update mold last apply storage record nr IMoldLastRecordRepository lastRecordRep = new MoldLastRecordRepository(unitwork); MoldLastRecord lastRecord = lastRecordRep.GetByMoldNR(moldNR); lastRecord.StorageRecordNR = storageRecord.StorageRecordNR; // update the workstation current mold count //Workstation tworkstation = workstationRep.GetById(storageRecord.Destination); //if(tworkstation!=null) tworkstation.CurrentMoldCount++; Workstation sworkstation = workstationRep.GetById(storageRecord.Source); if (sworkstation != null) { sworkstation.CurrentMoldCount--; } unitwork.Submit(); return(new Message() { MsgType = MsgType.OK, Content = "移动工作台成功!" }); } } catch (Exception ex) { LogUtil.log.Error(ex.ToString()); return(new Message() { MsgType = MsgType.Error, Content = "请核实所填数据的准确性" }); } }
public ActionResult Create(NewsModel model, HttpPostedFileBase contentImage, List <string> videoyoutube, string existingTags, string newTags) { NewsRepository objnews = new NewsRepository(this.SessionCustom); ContentManagement objcontent = new ContentManagement(this.SessionCustom, HttpContext); try { objcontent.ContentImage = contentImage; objcontent.CollVideos = videoyoutube; this.SessionCustom.Begin(); model.IContent.LanguageId = CurrentLanguage.LanguageId; objcontent.ContentInsert(model.IContent); objnews.Entity = model.News; objnews.Entity.ExistingTags = !string.Empty.Equals(existingTags) ? existingTags : null; objnews.Entity.NewTags = !string.Empty.Equals(newTags) ? newTags : null; if (objnews.Entity.ContentId != null) { if (model.News.MoldId != null) { MoldRepository objMoldRepository = new MoldRepository(this.SessionCustom); objMoldRepository.Entity.MoldId = model.News.MoldId; objMoldRepository.LoadByKey(); XmlDocument objDoc = this.GetXmlInformation(objMoldRepository.Entity.Xmlcontent, objnews.Entity.ContentId.Value); model.News.Xmlcontent = objDoc.InnerXml; } objnews.Update(); this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name); } else { if (model.News.MoldId != null) { MoldRepository objMoldRepository = new MoldRepository(SessionCustom); objMoldRepository.Entity.MoldId = model.News.MoldId; objMoldRepository.LoadByKey(); XmlDocument objDoc = this.GetXmlInformation(objMoldRepository.Entity.Xmlcontent, objcontent.ObjContent.ContentId.Value); model.News.Xmlcontent = objDoc.InnerXml; } if (!string.IsNullOrEmpty(Request.Form["TempFiles"])) { string[] files = Request.Form["TempFiles"].Split(','); if (files.Length > 0) { if (!Directory.Exists(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\")); } } foreach (var item in files) { string filep = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); if (System.IO.File.Exists(filep)) { string filedestin = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); System.IO.File.Move(filep, Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item))); } if (!string.IsNullOrEmpty(objnews.Entity.Xmlcontent)) { objnews.Entity.Xmlcontent = objnews.Entity.Xmlcontent.Replace(item, "/Files/" + objcontent.ObjContent.ContentId + "/" + Path.GetFileName(item)); } } } objnews.Entity.ContentId = objcontent.ObjContent.ContentId; objnews.Insert(); this.InsertAudit("Insert", this.Module.Name + " -> " + model.IContent.Name); } this.SessionCustom.Commit(); } catch (Exception ex) { SessionCustom.RollBack(); Utils.InsertLog( this.SessionCustom, "Error" + this.Module.Name, ex.Message + " " + ex.StackTrace); } if (Request.Form["GetOut"] == "0") { return(this.RedirectToAction("Index", "Content", new { mod = Module.ModulId })); } else { return(this.RedirectToAction("Detail", "News", new { mod = Module.ModulId, id = objnews.Entity.ContentId })); } }