// private void SendMails(string model) // { // string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; // logger.DebugFormat("BEGIN: {0}()", methodName); // try // { // string strSQL = @"select distinct c.OwnerEmail, c.CCEmail // from ApprovalStatus a // inner join FAIModel b on a.ModuleKeyValue = b.Model // inner join ApprovalItem c on a.ApprovalItemID=c.ID and // c.Module = (Case when b.ModelType='BTO' // then 'FAIBTO' // ELSE 'FAIBTF' END) and // c.ActionName='ReleaseFA' and // c.Department='OQC' // where a.ModuleKeyValue=@Model"; // SqlParameter paraNameModel = new SqlParameter("@Model", SqlDbType.VarChar, 20); // paraNameModel.Direction = ParameterDirection.Input; // paraNameModel.Value = model; // DataTable dt = SqlHelper.ExecuteDataFill(SqlHelper.ConnectionString_GetData, CommandType.Text, strSQL, paraNameModel); // if (dt.Rows.Count == 0) // { // return; // } // string FromAddress = ConfigurationManager.AppSettings["FromAddress"]; // string[] ToAddress = dt.Rows[0]["OwnerEmail"].ToString().Trim().Split(','); // string[] CcAddress = dt.Rows[0]["CCEmail"].ToString().Trim().Split(','); // string MailSubject = ConfigurationManager.AppSettings["MailSubject"]; // string EmailServer = ConfigurationManager.AppSettings["MailServer"]; // string content = string.Format(@"Dear QC: // IMG,DMI,SIE,PA 四個部門已對已下機型確認OK,請貴部儘快確認! // MODEL:{0}",model); // SendMail.Send(FromAddress, // ToAddress, // CcAddress, // MailSubject, // content, // EmailServer); // } // catch (FisException e) // { // logger.Error(e.mErrmsg, e); // throw new Exception(e.mErrmsg); // } // catch (Exception e) // { // logger.Error(e.Message, e); // throw; // } // finally // { // logger.DebugFormat("END: {0}()", methodName); // } // } public void ReleaseStatus(string model, string approvalID, string editor) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; logger.DebugFormat("BEGIN: {0}()", methodName); try { ApprovalStatusInfo approvalstatusItem = new ApprovalStatusInfo(); approvalstatusItem.ID = Convert.ToInt32(approvalID); approvalstatusItem.Status = "Approved"; approvalstatusItem.Editor = editor; approvalstatusItem.Udt = DateTime.Now; iModelRepository.UpdateApprovalStatus(approvalstatusItem); FAIModelInfo faiModelItem = new FAIModelInfo(); faiModelItem.Model = model; faiModelItem.PAKState = "Release"; faiModelItem.Editor = editor; faiModelItem.Udt = DateTime.Now; iModelRepository.UpdateFAIModel(faiModelItem); } catch (FisException e) { logger.Error(e.mErrmsg, e); throw new Exception(e.mErrmsg); } catch (Exception e) { logger.Error(e.Message, e); throw; } finally { logger.DebugFormat("END: {0}()", methodName); } }
public void RemoveStatus(string model, string approvalID, string comment, string editor) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; logger.DebugFormat("BEGIN: {0}()", methodName); try { ApprovalStatusInfo approvalstatusItem = new ApprovalStatusInfo(); approvalstatusItem.ID = Convert.ToInt32(approvalID); approvalstatusItem.Status = "Waiting"; approvalstatusItem.Comment = comment; approvalstatusItem.Editor = editor; approvalstatusItem.Udt = DateTime.Now; iModelRepository.UpdateApprovalStatus(approvalstatusItem); string strSQL = @"select a.Status,COUNT(1)as Qty from ApprovalStatus a inner join ApprovalItem b on a.ApprovalItemID = b.ID and b.IsNeedApprove = 'Y' inner join FAIModel c on a.ModuleKeyValue = c.Model where a.ModuleKeyValue =@Model and b.Module = 'FAI'+ rtrim(c.ModelType) and b.ActionName='ReleaseFA' group by a.Status"; SqlParameter paraNameModel = new SqlParameter("@Model", SqlDbType.VarChar, 20); paraNameModel.Direction = ParameterDirection.Input; paraNameModel.Value = model; DataTable dt = SqlHelper.ExecuteDataFill(SqlHelper.ConnectionString_GetData, CommandType.Text, strSQL, paraNameModel); int approvedQty = 0; string faStatus = ""; foreach (DataRow dr in dt.Rows) { if (dr["Status"].ToString() == "Approved") { approvedQty = Convert.ToInt32(dr["Qty"].ToString()); } } if (approvedQty == 0) { faStatus = "Waiting"; } else { faStatus = "InApproval"; } FAIModelInfo faiModelItem = new FAIModelInfo(); faiModelItem.Model = model; faiModelItem.FAState = faStatus; faiModelItem.Editor = editor; faiModelItem.Udt = DateTime.Now; iModelRepository.UpdateFAIModel(faiModelItem); } catch (FisException e) { logger.Error(e.mErrmsg, e); throw new Exception(e.mErrmsg); } catch (Exception e) { logger.Error(e.Message, e); throw; } finally { logger.DebugFormat("END: {0}()", methodName); } }
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(); }
public void CheckApprovalStatusAndChengeStatus(string model, string approvalStatusID, string approvalItemID, string comment, string editor, string family, string department, string isNeedUploadFile, string filename) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; logger.DebugFormat("BEGIN: {0}()", methodName); try { string strSQL = ""; if (isNeedUploadFile == "Y" && string.IsNullOrEmpty(filename)) { strSQL = @"select * from ApprovalItemAttr where ApprovalItemID =@approvalID and AttrName = 'FamilyNeedUploadFile' and AttrValue in ('ALL', @family) "; SqlParameter paraNameApprovalID = new SqlParameter("@approvalID", SqlDbType.VarChar, 20); paraNameApprovalID.Direction = ParameterDirection.Input; paraNameApprovalID.Value = approvalItemID; SqlParameter paraNameFamily = new SqlParameter("@family", SqlDbType.VarChar, 20); paraNameFamily.Direction = ParameterDirection.Input; paraNameFamily.Value = family; DataTable dt = SqlHelper.ExecuteDataFill(SqlHelper.ConnectionString_GetData, CommandType.Text, strSQL, paraNameApprovalID, paraNameFamily); if (dt.Rows.Count > 0) { throw new FisException("CQCHK50112", new string[] { }); } } ApprovalStatusInfo approvalstatusItem = new ApprovalStatusInfo(); approvalstatusItem.ID = Convert.ToInt32(approvalStatusID); approvalstatusItem.Status = "Approved"; approvalstatusItem.Comment = comment; approvalstatusItem.Editor = editor; approvalstatusItem.Udt = DateTime.Now; iModelRepository.UpdateApprovalStatus(approvalstatusItem); if (department == "OQC") { strSQL = @" select a.Status,COUNT(1)as Qty from ApprovalStatus a inner join ApprovalItem b on a.ApprovalItemID = b.ID inner join FAIModel c on a.ModuleKeyValue = c.Model where b.Module = 'FAI'+ rtrim(c.ModelType) and b.ActionName = 'ReleaseFA' and b.IsNeedApprove = 'Y' and a.ModuleKeyValue=@Model group by a.Status"; SqlParameter paraNameModel = new SqlParameter("@Model", SqlDbType.VarChar, 20); paraNameModel.Direction = ParameterDirection.Input; paraNameModel.Value = model; DataTable dt = SqlHelper.ExecuteDataFill(SqlHelper.ConnectionString_GetData, CommandType.Text, strSQL, paraNameModel); int waitingQty = 0; int approvedQty = 0; string faStatus = ""; foreach (DataRow dr in dt.Rows) { if (dr["Status"].ToString() == "Waiting") { waitingQty = Convert.ToInt32(dr["Qty"].ToString()); } if (dr["Status"].ToString() == "Approved") { approvedQty = Convert.ToInt32(dr["Qty"].ToString()); } } if (waitingQty > 0) { throw new FisException("CQCHK50113", new string[] { }); } if (waitingQty == 0) { faStatus = "Release"; SendMails(model); } FAIModelInfo faiModelItem = new FAIModelInfo(); faiModelItem.Model = model; faiModelItem.FAState = faStatus; faiModelItem.Editor = editor; faiModelItem.Udt = DateTime.Now; iModelRepository.UpdateFAIModel(faiModelItem); } else { strSQL = @"select a.Status,COUNT(1)as Qty from ApprovalStatus a inner join ApprovalItem b on a.ApprovalItemID = b.ID and b.Department <> 'OQC' inner join FAIModel c on a.ModuleKeyValue = c.Model and b.Module = 'FAI'+ rtrim(c.ModelType) and b.IsNeedApprove = 'Y' and b.ActionName='ReleaseFA' where a.ModuleKeyValue =@Model group by a.Status"; SqlParameter paraNameModel = new SqlParameter("@Model", SqlDbType.VarChar, 20); paraNameModel.Direction = ParameterDirection.Input; paraNameModel.Value = model; DataTable dt = SqlHelper.ExecuteDataFill(SqlHelper.ConnectionString_GetData, CommandType.Text, strSQL, paraNameModel); int waitingQty = 0; int approvedQty = 0; string faStatus = "Waiting"; foreach (DataRow dr in dt.Rows) { if (dr["Status"].ToString() == "Waiting") { waitingQty = Convert.ToInt32(dr["Qty"].ToString()); } if (dr["Status"].ToString() == "Approved") { approvedQty = Convert.ToInt32(dr["Qty"].ToString()); } } if (waitingQty == 0) { faStatus = "Approval"; SendMails(model); } else if (approvedQty == 1) { faStatus = "InApproval"; } FAIModelInfo faiModelItem = new FAIModelInfo(); faiModelItem.Model = model; faiModelItem.FAState = faStatus; faiModelItem.Editor = editor; faiModelItem.Udt = DateTime.Now; iModelRepository.UpdateFAIModel(faiModelItem); } } catch (FisException e) { logger.Error(e.mErrmsg, e); throw new Exception(e.mErrmsg); } catch (Exception e) { logger.Error(e.Message, e); throw; } finally { logger.DebugFormat("END: {0}()", methodName); } }