protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { try { IProduct product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); var CurrentProductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IList<ProductInfo> infos = null; IProduct CurrentForceEOQC = CurrentProductRepository.FindOneProductWithProductIDOrCustSN(this.Key); infos = CurrentForceEOQC.ProductInfoes; ProductInfo prin = null; foreach (ProductInfo info in infos) { if (info.InfoType == "ForceEOQC" && info.InfoValue == "0") { prin = info; break; } } if (prin != null) { prin.InfoValue = "1"; //CurrentForceEOQC.UpdateStatus(prin); // Update } else { prin = new ProductInfo(); prin.InfoValue = "11"; //CurrentForceEOQC.AddQCStatus(prin); //Add } return base.DoExecute(executionContext); } catch (FisException ex) { throw; } catch (Exception ex) { throw; } }
private void UpdateFAIModel(string model, string editor) { IUnitOfWork uow = new UnitOfWork(); IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IList<IProduct> lstPrds = prodRep.GetProductListByModel(model); if (null != lstPrds && lstPrds.Count > 0) { lstPrds = lstPrds.Where(x => x.ProductInfoes.Any(y => (y.InfoType == "FAIinFA" || y.InfoType == "FAIinPAK") && y.InfoValue == "Y")).ToList(); foreach (IProduct p in lstPrds) { prodRep.BackUpProductInfoDefered(uow, p.ProId, editor, "FAIinFA"); prodRep.BackUpProductInfoDefered(uow, p.ProId, editor, "FAIinPAK"); IMES.FisObject.FA.Product.ProductInfo item = new IMES.FisObject.FA.Product.ProductInfo(); item.ProductID = p.ProId; item.InfoType = "FAIinFA"; item.InfoValue = ""; item.Editor = editor; IMES.FisObject.FA.Product.ProductInfo cond = new IMES.FisObject.FA.Product.ProductInfo(); cond.ProductID = p.ProId; cond.InfoType = "FAIinFA"; prodRep.UpdateProductInfoDefered(uow, item, cond); // item = new IMES.FisObject.FA.Product.ProductInfo(); item.ProductID = p.ProId; item.InfoType = "FAIinPAK"; item.InfoValue = ""; item.Editor = editor; cond = new IMES.FisObject.FA.Product.ProductInfo(); cond.ProductID = p.ProId; cond.InfoType = "FAIinPAK"; prodRep.UpdateProductInfoDefered(uow, item, cond); } } string OnlyNeedOQCApprove = CommonImpl.GetInstance().GetValueFromSysSetting("OnlyNeedOQCApprove"); string FAIFAQty = CommonImpl.GetInstance().GetValueFromSysSetting("FAIFAQty"); string FAIPAKQty = CommonImpl.GetInstance().GetValueFromSysSetting("FAIPAKQty"); // 刪除 ApprovalStatusInfo condApprovalStatus = new ApprovalStatusInfo(); condApprovalStatus.ModuleKeyValue = model; IList<ApprovalStatusInfo> lstApprovalStatus = iModelRepository.GetApprovalStatus(condApprovalStatus); if (null != lstApprovalStatus && lstApprovalStatus.Count > 0) { foreach (ApprovalStatusInfo approvalStatusInfo in lstApprovalStatus) { UploadFilesInfo condUploadFiles = new UploadFilesInfo(); condUploadFiles.ApprovalStatusID = approvalStatusInfo.ID; IList<UploadFilesInfo> lstUploadFilesInfo = iModelRepository.GetUploadFiles(condUploadFiles); if (null != lstUploadFilesInfo && lstUploadFilesInfo.Count > 0) { foreach (UploadFilesInfo uploadFilesInfo in lstUploadFilesInfo) iModelRepository.DeleteUploadFiles(uploadFilesInfo.ID); } iModelRepository.DeleteApprovalStatus(approvalStatusInfo.ID); } } string FAState = ""; // 新增ApprovalStatus if ("Y" == OnlyNeedOQCApprove) { string strSQL = @"insert into ApprovalStatus( ApprovalItemID, ModuleKeyValue, Status, Editor, Cdt, Udt) select a.ID, b.Model as ModuleKeyValue, case when IsNeedApprove='Y' then 'Waiting' else 'Option' end as [Status], @CurrentUser, GETDATE() as Cdt, GETDATE() as Udt from ApprovalItem a , FAIModel b where b.Model=@OpenModel and a.Module= 'FAI'+b.ModelType and a.Department = 'OQC'"; SqlParameter[] paramsArray = new SqlParameter[2]; paramsArray[0] = new SqlParameter("@CurrentUser", SqlDbType.VarChar); paramsArray[0].Value = editor; paramsArray[1] = new SqlParameter("@OpenModel", SqlDbType.VarChar); paramsArray[1].Value = model; SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString_FA, System.Data.CommandType.Text, strSQL, paramsArray); FAState = "Approval"; } else if (string.IsNullOrEmpty(OnlyNeedOQCApprove) || "N" == OnlyNeedOQCApprove) { string strSQL = @"insert into ApprovalStatus( ApprovalItemID, ModuleKeyValue, Status, Editor, Cdt, Udt) select a.ID, b.Model as ModuleKeyValue, case when IsNeedApprove='Y' then 'Waiting' else 'Option' end as [Status], @CurrentUser, GETDATE() as Cdt, GETDATE() as Udt from ApprovalItem a , FAIModel b where b.Model=@OpenModel and a.Module= 'FAI'+b.ModelType "; SqlParameter[] paramsArray = new SqlParameter[2]; paramsArray[0] = new SqlParameter("@CurrentUser", SqlDbType.VarChar); paramsArray[0].Value = editor; paramsArray[1] = new SqlParameter("@OpenModel", SqlDbType.VarChar); paramsArray[1].Value = model; SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString_FA, System.Data.CommandType.Text, strSQL, paramsArray); FAState = "Waiting"; } DateTime now = DateTime.Now; FAIModelInfo itemFai = iModelRepository.GetFAIModelByModel(model); itemFai.Model = model; itemFai.PlanInputDate = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0, 0); itemFai.FAQty = int.Parse(FAIFAQty); itemFai.inFAQty = 0; itemFai.PAKQty = int.Parse(FAIPAKQty); itemFai.inPAKQty = 0; itemFai.FAState = FAState; itemFai.PAKState = "Hold"; itemFai.Remark = "Reopen"; itemFai.Editor = editor; itemFai.Cdt = now; itemFai.Udt = now; iModelRepository.UpdateFAIModelDefered(uow, itemFai); uow.Commit(); }
/// <summary> /// 更新RecordCKK /// </summary> /// <param name="editor">editor</param> /// <param name="prod">prod</param> /// <param name="CKK">CKK</param> /// <returns></returns> public void RecordCKK(string editor, string prod, string CKK) { try { bool have = productRepository.CheckExistProductInfo(prod, "CKK"); if (have) { IMES.FisObject.FA.Product.ProductInfo setValue = new IMES.FisObject.FA.Product.ProductInfo(); IMES.FisObject.FA.Product.ProductInfo condition = new IMES.FisObject.FA.Product.ProductInfo(); setValue.InfoValue = CKK; setValue.Editor = editor; setValue.Udt = DateTime.Now; condition.ProductID = prod; condition.InfoType = "CKK"; productRepository.UpdateProductInfo(setValue, condition); } else { IMES.FisObject.FA.Product.ProductInfo newValue = new IMES.FisObject.FA.Product.ProductInfo(); newValue.ProductID = prod; newValue.InfoType = "CKK"; newValue.InfoValue = CKK; newValue.Editor = editor; newValue.Udt = DateTime.Now; newValue.Cdt = DateTime.Now; productRepository.InsertProductInfo(newValue); } } catch (Exception ee) { throw ee; } }
/// <summary> /// 检查Product是否有未修护的记录 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var currentProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product); var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); //1 Insert UnpackProduct productRepository.BackUpProduct(this.Editor, new Product(currentProduct.ProId),null); //2Insert UnpackProduct_Part ProductInfo eqCondition = new ProductInfo(); ProductInfo neqCondition= new ProductInfo(); eqCondition.ProductID = currentProduct.ProId; neqCondition.InfoType = "ECR"; productRepository.BackUpProductInfo(this.Editor, eqCondition, neqCondition); productRepository.DeleteProductInfo( eqCondition, neqCondition); ProductPart eqPartCondition = new ProductPart(); ProductPart neqPartCondition= new ProductPart(); eqPartCondition.ProductID = currentProduct.ProId; neqPartCondition.Station = "40"; productRepository.BackUpProductPart(this.Editor, eqPartCondition, neqPartCondition); productRepository.DeleteProductPart(eqPartCondition, neqPartCondition); currentProduct.CartonWeight = 0; currentProduct.DeliveryNo = string.Empty; currentProduct.PalletNo = string.Empty; productRepository.Update(currentProduct,CurrentSession.UnitOfWork); return base.DoExecute(executionContext); }
/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { IProduct curProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); string ctno = (string)CurrentSession.GetValue("CTNO"); IList<string> defectList = (IList<string>)CurrentSession.GetValue(Session.SessionKeys.DefectList); IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); //Insert UnpackProduct_Part select *, @editor, @Udt from Product_Part //where ProductID=@ProductID and CheckItemType<>’LCM’ ProductPart cond = new ProductPart(); cond.PartID = curProduct.ProId; ProductPart ncond = new ProductPart(); ncond.CheckItemType = "LCM"; productRep.BackUpProductPartByDn(Editor, cond, ncond); //Delete Product_Part where ProductID=@ProductID and CheckItemType<>’LCM’ productRep.DeleteProductPart(cond, ncond); //Insert UnpackProductInfo select *, @editor, @Udt from ProductInfo where ProductID=@ProductID IMES.FisObject.FA.Product.ProductInfo infoconf = new IMES.FisObject.FA.Product.ProductInfo(); infoconf.ProductID = curProduct.ProId; ; productRep.BackUpProductInfo(Editor, infoconf, null); //Delete ProductInfo where ProductID=@ProductID productRep.DeleteProductInfo(infoconf, null); //if exists(select * from IqcCause1(nolock) where CtLabel=@CTNo and MpDefect=@Defect) //update IqcCause1 set Udt = GETDATE() where CtLabel=@CTNo and MpDefect=@Defect //else //insert into IqcCause1(CtLabel,MpDefect) values(@CTNo,@Defect) IDefectRepository defectRep = RepositoryFactory.GetInstance().GetRepository<IDefectRepository, Defect>(); foreach (string code in defectList) { IqcCause1Info qconf = new IqcCause1Info(); qconf.ctLabel = ctno; qconf.mpDefect = code; IList<IqcCause1Info> infoList = defectRep.GetIqcCause1InfoList(qconf); if (infoList.Count == 0) { defectRep.AddIqcCause(qconf); } else { IqcCause1Info item = new IqcCause1Info(); item.udt = DateTime.Now; defectRep.UpdateUDTofIqcCause(item, qconf); } } return base.DoExecute(executionContext); }
private bool CheckOA3Key(IHierarchicalBOM bom, IProduct p, string fkiPath, CredentialCache FKICredentialCache, string editor, UnitOfWork uow) { bool bWIN8 = false; IList<IBOMNode> P1BomNodeList = bom.GetFirstLevelNodesByNodeType("P1"); //foreach (IBOMNode bomNode in P1BomNodeList) //{ // if (bomNode.Part.Descr.StartsWith("ECOA")) // { // bWIN8 = true; // break; // } //} CommonImpl2 cm2 = new CommonImpl2(); bWIN8 = cm2.CheckIsWIN8(bom); if (!bWIN8) return true; if (fkiPath == "") return true; //Switch off checking by FKIServer. string thisURI = ""; if (fkiPath.EndsWith("/")) { thisURI = fkiPath + "UnitStatus"; } else { thisURI = fkiPath + "/UnitStatus"; } HttpWebRequest req = (HttpWebRequest)WebRequest.Create(thisURI); req.AllowAutoRedirect = true; req.CookieContainer = new CookieContainer(); req.ContentType = "application/plain; charset=utf-8"; req.Accept = "*/*"; req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; req.KeepAlive = true; req.Method = "POST"; req.Credentials = FKICredentialCache.GetCredential(new Uri(fkiPath), "NTLM"); string XMLInputData = "<?xml version='1.0' encoding='utf-8' ?>"; XMLInputData += "<UnitStatusRequest xmlns='http://HP.ITTS.OA30/digitaldistribution/2011/08'>"; XMLInputData += "<HPSerialNumber>"; XMLInputData += p.CUSTSN; XMLInputData += "</HPSerialNumber>"; XMLInputData += "<ProductKeyID>"; XMLInputData += ""; XMLInputData += "</ProductKeyID>"; XMLInputData += "</UnitStatusRequest>"; Encoding encoding = Encoding.Default; byte[] buffer = encoding.GetBytes(XMLInputData); req.ContentLength = buffer.Length; req.GetRequestStream().Write(buffer, 0, buffer.Length); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); XmlTextReader xmlr = new XmlTextReader(res.GetResponseStream()); string status = ""; string rc = ""; bool bError = false; bool bFound = false; StringBuilder str = new StringBuilder("Formatted Response:\n"); while (xmlr.Read()) { switch (xmlr.NodeType) { case XmlNodeType.Element: if (xmlr.IsEmptyElement) str.AppendFormat("<{0}/>", xmlr.Name); else str.AppendFormat("<{0}>", xmlr.Name); break; case XmlNodeType.Text: str.Append(xmlr.Value); break; case XmlNodeType.CDATA: str.AppendFormat("<![CDATA[{0}]]>", xmlr.Value); break; case XmlNodeType.ProcessingInstruction: str.AppendFormat("<?{0} {1}?>", xmlr.Name, xmlr.Value); break; case XmlNodeType.Comment: str.AppendFormat("<!--{0}-->", xmlr.Value); break; case XmlNodeType.XmlDeclaration: str.AppendFormat("<?xml version='1.0'?>"); break; case XmlNodeType.DocumentType: str.AppendFormat("<!DOCTYPE{0} [{1}]>", xmlr.Name, xmlr.Value); break; case XmlNodeType.EntityReference: str.Append(xmlr.Name); break; case XmlNodeType.EndElement: str.AppendFormat("</{0}>", xmlr.Name); break; case XmlNodeType.Whitespace: str.Append("\n"); break; } if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ReturnCode")) { xmlr.Read(); str.Append(xmlr.Value); rc = xmlr.Value.Trim(); if (rc != "000") bError = true; continue; } if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ReturnMessage")) { if (bError) { xmlr.Read(); str.Append(xmlr.Value); string msg = xmlr.Value; xmlr.Close(); throw new Exception("[" + rc + "]:" + msg); } } if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ProductKeyStateName")) { xmlr.Read(); str.Append(xmlr.Value); status = xmlr.Value; // Marked this by Benson at 2013/3/8 // if (status == "NotifiedBound") if (status == "NotifiedBound" || status == "FKIErrorBound") { //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound" --OLD //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound/FKIErrorBound" --NEW add by Benson at 2013/3/8 if (bFound) { xmlr.Close(); return false; } bFound = true; continue; } if (status == "Bound" || status == "PendingBound") { //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound" if (bFound) { xmlr.Close(); return false; } bFound = true; //对于状态为Bound/PendingBound的Product需要记录到ProductInfo中 IMES.FisObject.FA.Product.ProductInfo item = new IMES.FisObject.FA.Product.ProductInfo(); item.ProductID = p.ProId; item.InfoType = "Win8KeyState"; item.InfoValue = status; item.Editor = editor; if (productRepository.CheckExistProductInfo(p.ProId, "Win8KeyState")) { IMES.FisObject.FA.Product.ProductInfo cond = new IMES.FisObject.FA.Product.ProductInfo(); cond.ProductID = p.ProId; cond.InfoType = "Win8KeyState"; productRepository.UpdateProductInfoDefered(uow, item, cond); } else { productRepository.InsertProductInfoDefered(uow, item); } continue; } //Returned 或PendingReturn或NotifiedReturned或FKIErrorReturn --Mantis0001691 // Marked this by Benson at 2013/3/8 // if (status != "Returned" && status != "NotifiedReturned" && status != "PendingReturn") if (status != "Returned" && status != "NotifiedReturned" && status != "PendingReturn" && status != "FKIErrorReturn") { xmlr.Close(); return false; } } } xmlr.Close(); Console.Write(str.ToString()); return bFound; }
/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override System.Workflow.ComponentModel.ActivityExecutionStatus DoExecute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext) { IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IDeliveryRepository currentRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); string DN = (string)CurrentSession.GetValue(Session.SessionKeys.DeliveryNo); string customerSn = (string)CurrentSession.GetValue(Session.SessionKeys.CustSN); string prod = (string)CurrentSession.GetValue(Session.SessionKeys.ProductIDOrCustSN); IProduct currentProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); ; /* if (customerSn != "") { currentProduct = productRepository.GetProductByCustomSn(customerSn); } else if (prod != "") { currentProduct = productRepository.Find(prod); } if (null == currentProduct) { List<string> errpara = new List<string>(); if (customerSn != "") { errpara.Add(customerSn); } else if (prod != "") { errpara.Add(prod); } throw new FisException("SFC002", errpara); } IMES.FisObject.FA.Product.ProductStatus newStatus = new IMES.FisObject.FA.Product.ProductStatus(); newStatus.Status = "1"; newStatus.StationId = this.Station; newStatus.Udt = DateTime.Now; string[] prodIds = new string[1]; prodIds[0] = prod; productRepository.UpdateProductStatusesDefered(CurrentSession.UnitOfWork, newStatus, prodIds); ProductStatusInfo statusIfo = productRepository.GetProductStatusInfo(prod); var productLog = new ProductLog { ProductID = prod, Model = currentProduct.Model, Station = this.Station, Status = StationStatus.Pass, Line = statusIfo.pdLine, Editor = this.Editor, Cdt = DateTime.Now }; ProductLog[] logs = { productLog }; productRepository.InsertProductLogsDefered(CurrentSession.UnitOfWork, logs);*/ if ("96" == this.Station) { } else { string ckk = ""; bool retJapan = modelRep.CheckExistModelInfo("PN", currentProduct.Model, "#ABJ"); if (retJapan == true) { ckk = "1"; } else { ckk = "0"; } bool have = productRepository.CheckExistProductInfo(prod, "CKK"); if (have) { IMES.FisObject.FA.Product.ProductInfo setValue = new IMES.FisObject.FA.Product.ProductInfo(); IMES.FisObject.FA.Product.ProductInfo condition = new IMES.FisObject.FA.Product.ProductInfo(); setValue.InfoValue = ckk; setValue.Editor = this.Editor; setValue.Udt = DateTime.Now; condition.ProductID = prod; condition.InfoType = "CKK"; productRepository.UpdateProductInfoDefered(CurrentSession.UnitOfWork, setValue, condition); } else { IMES.FisObject.FA.Product.ProductInfo newValue = new IMES.FisObject.FA.Product.ProductInfo(); newValue.ProductID = prod; newValue.InfoType = "CKK"; newValue.InfoValue = ckk; newValue.Editor = this.Editor; newValue.Udt = DateTime.Now; newValue.Cdt = DateTime.Now; productRepository.InsertProductInfoDefered(CurrentSession.UnitOfWork, newValue); } } CurrentSession.AddValue(Session.SessionKeys.Product, currentProduct); return base.DoExecute(executionContext); }