public bool CheckExistCheckItemTypeRule(CheckItemTypeRuleDef item) { try { IBOMRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>(); return itemRepository.CheckExistCheckItemTypeRule(item); } catch (Exception) { throw; } }
void cacheTagDataValue(CheckItemTypeRuleDef chkRule, TagData tagData) { foreach (KeyValuePair<string, bool> keyValue in chkRule.MatchRuleGroupNames) { if (keyValue.Value) { if (!tagData.GroupValueList.ContainsKey(keyValue.Key)) { tagData.GroupValueList.Add(keyValue.Key, ResolveValue.GetValueWithoutError(tagData.Product, tagData.PCB, tagData.DN, null, keyValue.Key, GlobalConstName.UnderScoreChar)); } } } #region disable code //if (!string.IsNullOrEmpty(chkRule.Descr)) //{ // string[] nameList = chkRule.Descr.Split(','); // foreach (string name in nameList) // { // if (name.Contains(".")) // { // string groupName= name.Replace(".", "_"); // chkRule.MatchRule = chkRule.MatchRule.Replace(name, groupName); // if (!tagData.GroupValueList.ContainsKey(groupName)) // { // tagData.GroupValueList.Add(groupName, // ResolveValue.GetValueWithoutError(tagData.Product, tagData.PCB, tagData.DN, null, name, '.')); // } // } // else //no object format type // { // //throw new Exception(string.Format(wrongDescrError, chkRule.CheckItemType)); // } // } // chkRule.Descr=chkRule.Descr.Replace(".", "_"); //} #endregion }
private FlatBOMItem getNextBom(string checkItemType, string bomNodeTypeLink, IList<IBOMNode> bomNodes, UtilityCommonImpl utl, CheckItemTypeRuleDef chkRule, TagData tagdata, IProduct product) { int index = bomNodeTypeLink.IndexOf(GlobalConstName.ArrowStr); string bomNodeType = index < 0 ? bomNodeTypeLink : bomNodeTypeLink.Substring(0, index); string nextBomNodeType = index <= 0 ?null : bomNodeTypeLink.Substring(index + 2); var filterMatchRule = utl.FilterMatchRule; if (string.IsNullOrEmpty(nextBomNodeType)) { var matchBomNodeList = bomNodes.Where(x => filterMatchRule.MatchCheckItemTypeRule(product, x.Part, chkRule, bomNodeType.Trim())).ToList(); if (matchBomNodeList.Count > 0) { if (string.IsNullOrEmpty(chkRule.MatchRule)) { throw new Exception(string.Format(emptyMatchRuleError, chkRule.CheckItemType)); } var partList = matchBomNodeList.Select(x => x.Part).ToList(); //Qty 不一致報錯 int qty = matchBomNodeList[0].Qty; if (matchBomNodeList.Count > 1) { if (matchBomNodeList.Any(x => x.Qty != qty)) { throw new Exception(string.Format(differentQtyError, string.Join(GlobalConstName.CommaStr,partList.Select(x=>x.PN).ToArray()))); } } //replace matchRule '.' to '_' cacheTagDataValue(chkRule, tagdata); var kp_flat_bom_item = new FlatBOMItem(qty, checkItemType, partList); kp_flat_bom_item.PartNoItem = string.Join(GlobalConstName.CommaStr, partList.Select(x => x.PN).ToArray()); kp_flat_bom_item.Descr = partList[0].Descr + (string.IsNullOrEmpty(chkRule.Descr)?string.Empty: GlobalConstName.SlashStr + chkRule.Descr); kp_flat_bom_item.CheckItemTypeRuleList = new List<CheckItemTypeRuleDef> { chkRule }; return kp_flat_bom_item; } return null; } else // have next bomNode { foreach( IBOMNode node in bomNodes) { if (filterMatchRule.CheckBomNodeType(node.Part.BOMNodeType, bomNodeType)) { FlatBOMItem bomItem= getNextBom(checkItemType,nextBomNodeType,node.Children,utl,chkRule,tagdata,product); if (bomItem != null) { return bomItem; } } } return null; } }
private FlatBOMItem createFlatBOMItem(string virtualPN, string descr, string checkItemType, string valueType, CheckItemTypeRuleDef ruleDefine) { DateTime now = DateTime.Now; IPart part = new Part() { PN = virtualPN, //PN要跟 flat_bom_item.PartNoItem值一樣 CustPn = string.Empty, Remark = string.Empty, Descr = descr, Descr2 = string.Empty, Type = checkItemType, Udt = now, Cdt = now }; FlatBOMItem flat_bom_item = new FlatBOMItem(qty, checkItemType, new List<IPart>() { part }); flat_bom_item.PartNoItem = part.PN; flat_bom_item.Tp = checkItemType; flat_bom_item.Descr = descr; flat_bom_item.ValueType = valueType; //存放Part match時檢查的值 if (ruleDefine != null) { flat_bom_item.CheckItemTypeRuleList = new List<CheckItemTypeRuleDef> { ruleDefine }; } return flat_bom_item; }
/// <summary> /// /// </summary> /// <param name="itemType"></param> public void UpdateCheckItemTypeRule(CheckItemTypeRuleDef itemType) { try { MethodBase mthObj = MethodBase.GetCurrentMethod(); int tk = mthObj.MetadataToken; SQLContextNew sqlCtx = null; CheckItemTypeRuleDef condition = new CheckItemTypeRuleDef { ID = itemType.ID }; lock (mthObj) { if (!SQLCache.PeerTheSQL(tk, out sqlCtx)) { CheckItemTypeRule cond = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(condition); CheckItemTypeRule setv = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(itemType, CheckItemTypeRule.fn_id); sqlCtx = FuncNew.GetConditionedUpdate<CheckItemTypeRule>(new SetValueCollection<CheckItemTypeRule>(new CommonSetValue<CheckItemTypeRule>(setv)), new ConditionCollection<CheckItemTypeRule>(new EqualCondition<CheckItemTypeRule>(cond))); // sqlCtx = new SQLContextNew(); // sqlCtx.Sentence = @"update CheckItemTypeRule // set CheckItemType=@CheckItemType, // Line=@Line, // Station=@Station, // Family=@Family, // BomNodeType=@BomNodeType, // PartDescr=@PartDescr, // PartType=@PartType, // MatchRule=@MatchRule, // CheckRule=@CheckRule, // SaveRule=@SaveRule, // Descr=@Descr, // Editor=@Editor, // Udt=GETDATE(), // NeedUniqueCheck=@NeedUniqueCheck, // NeedCommonSave=@NeedCommonSave, // CheckTestKPCount=@CheckTestKPCount, // NeedSave=@NeedSave // where ID=@ID "; // sqlCtx.AddParam("ID", new SqlParameter("@ID", SqlDbType.Int)); // sqlCtx.AddParam("CheckItemType", new SqlParameter("@CheckItemType", SqlDbType.VarChar)); // sqlCtx.AddParam("Line", new SqlParameter("@Line", SqlDbType.VarChar)); // sqlCtx.AddParam("Station", new SqlParameter("@Station", SqlDbType.VarChar)); // sqlCtx.AddParam("Family", new SqlParameter("@Family", SqlDbType.VarChar)); // sqlCtx.AddParam("BomNodeType", new SqlParameter("@BomNodeType", SqlDbType.VarChar)); // sqlCtx.AddParam("PartDescr", new SqlParameter("@PartDescr", SqlDbType.VarChar)); // sqlCtx.AddParam("PartType", new SqlParameter("@PartType", SqlDbType.VarChar)); // sqlCtx.AddParam("MatchRule", new SqlParameter("@MatchRule", SqlDbType.VarChar)); // sqlCtx.AddParam("CheckRule", new SqlParameter("@CheckRule", SqlDbType.VarChar)); // sqlCtx.AddParam("SaveRule", new SqlParameter("@SaveRule", SqlDbType.VarChar)); // sqlCtx.AddParam("Descr", new SqlParameter("@Descr", SqlDbType.VarChar)); // sqlCtx.AddParam("Editor", new SqlParameter("@Editor", SqlDbType.VarChar)); // sqlCtx.AddParam("NeedUniqueCheck", new SqlParameter("@NeedUniqueCheck", SqlDbType.VarChar)); // sqlCtx.AddParam("NeedCommonSave", new SqlParameter("@NeedCommonSave", SqlDbType.VarChar)); // sqlCtx.AddParam("CheckTestKPCount", new SqlParameter("@CheckTestKPCount", SqlDbType.VarChar)); // sqlCtx.AddParam("NeedSave", new SqlParameter("@NeedSave", SqlDbType.VarChar)); // SQLCache.InsertIntoCache(tk, sqlCtx); } } //sqlCtx.Param("ID").Value = itemType.ID; //sqlCtx.Param("CheckItemType").Value = itemType.CheckItemType; //sqlCtx.Param("Line").Value = string.IsNullOrEmpty(itemType.Line) ? "" : itemType.Line; //sqlCtx.Param("Station").Value = string.IsNullOrEmpty(itemType.Station) ? "" : itemType.Station; //sqlCtx.Param("Family").Value = string.IsNullOrEmpty(itemType.Family) ? "" : itemType.Family; //sqlCtx.Param("BomNodeType").Value = string.IsNullOrEmpty(itemType.BomNodeType) ? "" : itemType.BomNodeType; //sqlCtx.Param("PartDescr").Value = string.IsNullOrEmpty(itemType.PartDescr) ? "" : itemType.PartDescr; //sqlCtx.Param("PartType").Value = string.IsNullOrEmpty(itemType.PartType) ? "" : itemType.PartType; //sqlCtx.Param("MatchRule").Value = string.IsNullOrEmpty(itemType.MatchRule) ? "" : itemType.MatchRule; //sqlCtx.Param("CheckRule").Value = string.IsNullOrEmpty(itemType.CheckRule) ? "" : itemType.CheckRule; //sqlCtx.Param("SaveRule").Value = string.IsNullOrEmpty(itemType.SaveRule) ? "" : itemType.SaveRule; //sqlCtx.Param("Descr").Value = string.IsNullOrEmpty(itemType.Descr) ? "" : itemType.Descr; //sqlCtx.Param("Editor").Value = itemType.Editor; //sqlCtx.Param("NeedUniqueCheck").Value = itemType.NeedUniqueCheck; //sqlCtx.Param("NeedCommonSave").Value = itemType.NeedCommonSave; //sqlCtx.Param("NeedSave").Value = itemType.NeedSave; //sqlCtx.Param("CheckTestKPCount").Value = itemType.CheckTestKPCount; sqlCtx = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(sqlCtx, condition); sqlCtx = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(sqlCtx, itemType, true); string udtName = g.DecSV(CheckItemTypeRule.fn_udt); if (sqlCtx.ParamKeys.Contains(udtName)) { DateTime cmDt = _Schema.SqlHelper.GetDateTime(); sqlCtx.Param(g.DecSV(CheckItemTypeRule.fn_udt)).Value = cmDt; } _Schema.SqlHelper.ExecuteNonQuery(_Schema.SqlHelper.ConnectionString_BOM, CommandType.Text, sqlCtx.Sentence, sqlCtx.Params); } catch (Exception) { throw; } }
/// <summary> /// /// </summary> /// <param name="id"></param> public void DeleteCheckItemTypeRule(int id) { try { MethodBase mthObj = MethodBase.GetCurrentMethod(); int tk = mthObj.MetadataToken; SQLContextNew sqlCtx = null; CheckItemTypeRuleDef condition = new CheckItemTypeRuleDef { ID = id }; lock (mthObj) { if (!SQLCache.PeerTheSQL(tk, out sqlCtx)) { CheckItemTypeRule cond = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(condition); sqlCtx = FuncNew.GetConditionedDelete<CheckItemTypeRule>(new ConditionCollection<CheckItemTypeRule>(new EqualCondition<CheckItemTypeRule>(cond))); // sqlCtx = new SQLContextNew(); // sqlCtx.Sentence = @"delete CheckItemTypeRule // where ID=@ID "; // sqlCtx.AddParam("ID", new SqlParameter("@ID", SqlDbType.Int)); // SQLCache.InsertIntoCache(tk, sqlCtx); } } //sqlCtx.Param("ID").Value = id; sqlCtx = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(sqlCtx, condition); _Schema.SqlHelper.ExecuteNonQuery(_Schema.SqlHelper.ConnectionString_BOM, CommandType.Text, sqlCtx.Sentence, sqlCtx.Params); } catch (Exception) { throw; } }
/// <summary> /// /// </summary> /// <param name="itemType"></param> public void AddCheckItemTypeRule(CheckItemTypeRuleDef itemType) { try { MethodBase mthObj = MethodBase.GetCurrentMethod(); int tk = mthObj.MetadataToken; SQLContextNew sqlCtx = null; DateTime now = DateTime.Now; if (itemType.Cdt == DateTime.MinValue) { itemType.Cdt = now; } if (itemType.Udt == DateTime.MinValue) { itemType.Udt = now; } lock (mthObj) { if (!SQLCache.PeerTheSQL(tk, out sqlCtx)) { sqlCtx = FuncNew.GetAquireIdInsert<CheckItemTypeRule>(tk); // sqlCtx = new SQLContextNew(); // sqlCtx.Sentence = @"insert into CheckItemTypeRule (CheckItemType, Line, Station, Family, // BomNodeType,PartDescr,PartType, // MatchRule, CheckRule, SaveRule, Descr, // Editor, Cdt, Udt,NeedUniqueCheck,NeedCommonSave, // NeedSave,CheckTestKPCount) // Values( @CheckItemType, @Line, @Station, @Family, // @BomNodeType,@PartDescr,@PartType, // @MatchRule, @CheckRule, @SaveRule, @Descr, // @Editor, GETDATE(), GETDATE(), // @NeedUniqueCheck,@NeedCommonSave, // @NeedSave,@CheckTestKPCount) "; // sqlCtx.AddParam("CheckItemType", new SqlParameter("@CheckItemType", SqlDbType.VarChar)); // sqlCtx.AddParam("Line", new SqlParameter("@Line", SqlDbType.VarChar)); // sqlCtx.AddParam("Station", new SqlParameter("@Station", SqlDbType.VarChar)); // sqlCtx.AddParam("Family", new SqlParameter("@Family", SqlDbType.VarChar)); // sqlCtx.AddParam("BomNodeType", new SqlParameter("@BomNodeType", SqlDbType.VarChar)); // sqlCtx.AddParam("PartDescr", new SqlParameter("@PartDescr", SqlDbType.VarChar)); // sqlCtx.AddParam("PartType", new SqlParameter("@PartType", SqlDbType.VarChar)); // sqlCtx.AddParam("MatchRule", new SqlParameter("@MatchRule", SqlDbType.VarChar)); // sqlCtx.AddParam("CheckRule", new SqlParameter("@CheckRule", SqlDbType.VarChar)); // sqlCtx.AddParam("SaveRule", new SqlParameter("@SaveRule", SqlDbType.VarChar)); // sqlCtx.AddParam("Descr", new SqlParameter("@Descr", SqlDbType.VarChar)); // sqlCtx.AddParam("Editor", new SqlParameter("@Editor", SqlDbType.VarChar)); // sqlCtx.AddParam("NeedUniqueCheck", new SqlParameter("@NeedUniqueCheck", SqlDbType.VarChar)); // sqlCtx.AddParam("NeedCommonSave", new SqlParameter("@NeedCommonSave", SqlDbType.VarChar)); // sqlCtx.AddParam("CheckTestKPCount", new SqlParameter("@CheckTestKPCount", SqlDbType.VarChar)); // sqlCtx.AddParam("NeedSave", new SqlParameter("@NeedSave", SqlDbType.VarChar)); // SQLCache.InsertIntoCache(tk, sqlCtx); } } //sqlCtx.Param("CheckItemType").Value = itemType.CheckItemType; //sqlCtx.Param("Line").Value = string.IsNullOrEmpty(itemType.Line) ? "" : itemType.Line; //sqlCtx.Param("Station").Value = string.IsNullOrEmpty(itemType.Station) ? "" : itemType.Station; //sqlCtx.Param("Family").Value = string.IsNullOrEmpty(itemType.Family) ? "" : itemType.Family; //sqlCtx.Param("BomNodeType").Value = string.IsNullOrEmpty(itemType.BomNodeType) ? "" : itemType.BomNodeType; //sqlCtx.Param("PartDescr").Value = string.IsNullOrEmpty(itemType.PartDescr) ? "" : itemType.PartDescr; //sqlCtx.Param("PartType").Value = string.IsNullOrEmpty(itemType.PartType) ? "" : itemType.PartType; //sqlCtx.Param("MatchRule").Value = string.IsNullOrEmpty(itemType.MatchRule) ? "" : itemType.MatchRule; //sqlCtx.Param("CheckRule").Value = string.IsNullOrEmpty(itemType.CheckRule) ? "" : itemType.CheckRule; //sqlCtx.Param("SaveRule").Value = string.IsNullOrEmpty(itemType.SaveRule) ? "" : itemType.SaveRule; //sqlCtx.Param("Descr").Value = string.IsNullOrEmpty(itemType.Descr) ? "" : itemType.Descr; //sqlCtx.Param("Editor").Value = itemType.Editor; //sqlCtx.Param("NeedUniqueCheck").Value = itemType.NeedUniqueCheck; //sqlCtx.Param("NeedCommonSave").Value = itemType.NeedCommonSave; //sqlCtx.Param("NeedSave").Value = itemType.NeedSave; //sqlCtx.Param("CheckTestKPCount").Value = itemType.CheckTestKPCount; sqlCtx = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(sqlCtx, itemType); _Schema.SqlHelper.ExecuteNonQuery(_Schema.SqlHelper.ConnectionString_BOM, CommandType.Text, sqlCtx.Sentence, sqlCtx.Params); } catch (Exception) { throw; } }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <returns></returns> public bool CheckExistCheckItemTypeRule(CheckItemTypeRuleDef item) { try { bool ret = false; MethodBase mthObj = MethodBase.GetCurrentMethod(); int tk = mthObj.MetadataToken; SQLContextNew sqlCtx = null; string checkItemType = item.CheckItemType; string editor = item.Editor; DateTime cdt = item.Cdt; DateTime udt = item.Udt; item.CheckItemType = null; item.Editor = null; item.Udt = DateTime.MinValue; item.Cdt = DateTime.MinValue; lock (mthObj) { if (!SQLCache.PeerTheSQL(tk, out sqlCtx)) { CheckItemTypeRule cond = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(item); sqlCtx = FuncNew.GetConditionedSelect<CheckItemTypeRule>(tk, "TOP 1", new string[] { CheckItemTypeRule.fn_id }, new ConditionCollection<CheckItemTypeRule>(new EqualCondition<CheckItemTypeRule>(cond))); // sqlCtx = new SQLContextNew(); // sqlCtx.Sentence = @"select top 1 ID // from CheckItemTypeRule // where --CheckItemType=@CheckItemType and // Line=@Line and // Station=@Station and // Family=@Family and // BomNodeType = @BomNodeType and // PartDescr = @PartDescr and // PartType =@PartType and // MatchRule = @MatchRule and // // CheckRule = @CheckRule and // SaveRule = @SaveRule and // Descr = @Descr and // NeedUniqueCheck = @NeedUniqueCheck and // NeedCommonSave = @NeedCommonSave and // NeedSave = @NeedSave and // CheckTestKPCount = @CheckTestKPCount "; // //sqlCtx.AddParam("CheckItemType", new SqlParameter("@CheckItemType", SqlDbType.VarChar)); // sqlCtx.AddParam("Line", new SqlParameter("@Line", SqlDbType.VarChar)); // sqlCtx.AddParam("Station", new SqlParameter("@Station", SqlDbType.VarChar)); // sqlCtx.AddParam("Family", new SqlParameter("@Family", SqlDbType.VarChar)); // sqlCtx.AddParam("BomNodeType", new SqlParameter("@BomNodeType", SqlDbType.VarChar)); // sqlCtx.AddParam("PartDescr", new SqlParameter("@PartDescr", SqlDbType.VarChar)); // sqlCtx.AddParam("PartType", new SqlParameter("@PartType", SqlDbType.VarChar)); // sqlCtx.AddParam("MatchRule", new SqlParameter("@MatchRule", SqlDbType.VarChar)); // sqlCtx.AddParam("CheckRule", new SqlParameter("@CheckRule", SqlDbType.VarChar)); // sqlCtx.AddParam("SaveRule", new SqlParameter("@SaveRule", SqlDbType.VarChar)); // sqlCtx.AddParam("Descr", new SqlParameter("@Descr", SqlDbType.VarChar)); // sqlCtx.AddParam("NeedUniqueCheck", new SqlParameter("@NeedUniqueCheck", SqlDbType.VarChar)); // sqlCtx.AddParam("NeedCommonSave", new SqlParameter("@NeedCommonSave", SqlDbType.VarChar)); // sqlCtx.AddParam("NeedSave", new SqlParameter("@NeedSave", SqlDbType.VarChar)); // sqlCtx.AddParam("CheckTestKPCount", new SqlParameter("@CheckTestKPCount", SqlDbType.VarChar)); // SQLCache.InsertIntoCache(tk, sqlCtx); } } //sqlCtx.Param("CheckItemType").Value = item.CheckItemType; //sqlCtx.Param("Line").Value = item.Line; //sqlCtx.Param("Station").Value = item.Station; //sqlCtx.Param("Family").Value = item.Family; //sqlCtx.Param("BomNodeType").Value = item.BomNodeType; //sqlCtx.Param("PartDescr").Value = item.PartDescr; //sqlCtx.Param("PartType").Value = item.PartType; //sqlCtx.Param("MatchRule").Value = item.MatchRule; //sqlCtx.Param("CheckRule").Value = item.CheckRule; //sqlCtx.Param("SaveRule").Value = item.SaveRule; //sqlCtx.Param("Descr").Value = item.Descr; //sqlCtx.Param("NeedUniqueCheck").Value = item.NeedUniqueCheck; //sqlCtx.Param("NeedCommonSave").Value = item.NeedCommonSave; //sqlCtx.Param("NeedSave").Value = item.NeedSave; //sqlCtx.Param("CheckTestKPCount").Value = item.CheckTestKPCount; sqlCtx = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(sqlCtx, item); using (SqlDataReader sqlR = _Schema.SqlHelper.ExecuteReader(_Schema.SqlHelper.ConnectionString_BOM, CommandType.Text, sqlCtx.Sentence, sqlCtx.Params)) { if (sqlR != null && sqlR.HasRows) { ret = true; } } item.CheckItemType = checkItemType; item.Editor = editor; item.Cdt = cdt; item.Udt = udt; return ret; } catch (Exception) { throw; } }
/// <summary> /// /// </summary> /// <param name="itemType"></param> /// <param name="line"></param> /// <param name="station"></param> /// <param name="family"></param> /// <returns></returns> public bool CheckExistCheckItemTypeRule(string itemType, string line, string station, string family) { try { bool ret = false; MethodBase mthObj = MethodBase.GetCurrentMethod(); int tk = mthObj.MetadataToken; SQLContextNew sqlCtx = null; CheckItemTypeRuleDef condition = new CheckItemTypeRuleDef { CheckItemType = itemType, Line = line, Station = station, Family = family }; lock (mthObj) { if (!SQLCache.PeerTheSQL(tk, out sqlCtx)) { CheckItemTypeRule cond = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(condition); sqlCtx = FuncNew.GetConditionedSelect<CheckItemTypeRule>(tk, "TOP 1", new string[] { CheckItemTypeRule.fn_id }, new ConditionCollection<CheckItemTypeRule>(new EqualCondition<CheckItemTypeRule>(cond))); // sqlCtx = new SQLContextNew(); // sqlCtx.Sentence = @"select top 1 ID // from CheckItemTypeRule // where CheckItemType=@CheckItemType and // Line=@Line and // Station=@Station and // Family=@Family "; // sqlCtx.AddParam("CheckItemType", new SqlParameter("@CheckItemType", SqlDbType.VarChar)); // sqlCtx.AddParam("Line", new SqlParameter("@Line", SqlDbType.VarChar)); // sqlCtx.AddParam("Station", new SqlParameter("@Station", SqlDbType.VarChar)); // sqlCtx.AddParam("Family", new SqlParameter("@Family", SqlDbType.VarChar)); // SQLCache.InsertIntoCache(tk, sqlCtx); } } //sqlCtx.Param("CheckItemType").Value = itemType; //sqlCtx.Param("Line").Value = line; //sqlCtx.Param("Station").Value = station; //sqlCtx.Param("Family").Value = family; sqlCtx = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(sqlCtx, condition); using (SqlDataReader sqlR = _Schema.SqlHelper.ExecuteReader(_Schema.SqlHelper.ConnectionString_BOM, CommandType.Text, sqlCtx.Sentence, sqlCtx.Params)) { if (sqlR != null && sqlR.HasRows) { ret = true; } } return ret; } catch (Exception) { throw; } }
/// <summary> /// /// </summary> /// <param name="itemType"></param> /// <returns></returns> public IList<CheckItemTypeRuleDef> GetCheckItemTypeRuleByItemType(string itemType) { try { IList<CheckItemTypeRuleDef> ret = new List<CheckItemTypeRuleDef>(); MethodBase mthObj = MethodBase.GetCurrentMethod(); int tk = mthObj.MetadataToken; SQLContextNew sqlCtx = null; CheckItemTypeRuleDef condition = new CheckItemTypeRuleDef { CheckItemType = itemType }; lock (mthObj) { if (!SQLCache.PeerTheSQL(tk, out sqlCtx)) { //sqlCtx = new SQLContextNew(); CheckItemTypeRule cond = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(condition); sqlCtx = FuncNew.GetConditionedSelect<CheckItemTypeRule>(tk, null, null, new ConditionCollection<CheckItemTypeRule>(new EqualCondition<CheckItemTypeRule>(cond)), CheckItemTypeRule.fn_line, CheckItemTypeRule.fn_station, CheckItemTypeRule.fn_family); //} // sqlCtx = FuncNew.SetColumnFromField<T, R>(sqlCtx, condition); // sqlCtx.Sentence = @"select ID, CheckItemType, Line, Station, Family, // BomNodeType,PartDescr,PartType, // MatchRule, CheckRule, SaveRule, Descr, // Editor, Cdt, Udt,NeedUniqueCheck,NeedCommonSave, // NeedSave,CheckTestKPCount,FilterExpression // from CheckItemTypeRule // where CheckItemType=@CheckItemType // order by Line,Station,Family"; // sqlCtx.AddParam("CheckItemType", new SqlParameter("@CheckItemType", SqlDbType.VarChar)); // SQLCache.InsertIntoCache(tk, sqlCtx); } } //sqlCtx.Param("CheckItemType").Value = itemType; sqlCtx = FuncNew.SetColumnFromField<CheckItemTypeRule, CheckItemTypeRuleDef>(sqlCtx, condition); using (SqlDataReader sqlR = _Schema.SqlHelper.ExecuteReader(_Schema.SqlHelper.ConnectionString_BOM, CommandType.Text, sqlCtx.Sentence, sqlCtx.Params)) { ret = FuncNew.SetFieldFromColumn<CheckItemTypeRule, CheckItemTypeRuleDef, CheckItemTypeRuleDef>(ret, sqlR, sqlCtx); //while (sqlR != null && sqlR.Read()) //{ // CheckItemTypeRuleDef item = IMES.Infrastructure.Repository._Schema.SQLData.ToObject<CheckItemTypeRuleDef>(sqlR); // ret.Add(item); //} } return ret; } catch (Exception) { throw; } }
private bool getCheckItemTypeRulePriorityByRegex(CheckItemTypeRuleDef rule, string line, string station, string family) { bool isLine = !string.IsNullOrEmpty(rule.Line); bool isStation = !string.IsNullOrEmpty(rule.Station); bool isFamily = !string.IsNullOrEmpty(rule.Family); bool matchFamily = (isFamily ? Regex.IsMatch(family, rule.Family) : family == rule.Family); if (rule.Line == line && rule.Station == station && matchFamily) { rule.Priority = 1; return true; } if (!isFamily && rule.Line == line && rule.Station == station) { rule.Priority = 2; return true; } if (!isStation && rule.Line == line && matchFamily) { rule.Priority = 3; return true; } if (!isLine && rule.Station == station && matchFamily) { rule.Priority = 4; return true; } if (!isStation && !isFamily && rule.Line == line) { rule.Priority = 5; return true; } if (!isLine && !isFamily && rule.Station == station) { rule.Priority = 6; return true; } if (!isLine && !isStation && matchFamily) { rule.Priority = 7; return true; } if (!isLine && !isStation && !isFamily) { rule.Priority = 8; return true; } return false; }
public void AddCheckItemTypeRule(CheckItemTypeRuleDef itemType) { try { IBOMRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>(); itemRepository.AddCheckItemTypeRule(itemType); } catch (Exception) { throw; } }
protected void btnSave_ServerClick(Object sender, EventArgs e) { CheckItemTypeRuleDef item = new CheckItemTypeRuleDef(); CheckItemTypeRuleDef checkitem = new CheckItemTypeRuleDef(); item.CheckItemType = this.cmbCheckItemTypeList.InnerDropDownList.SelectedValue.Trim(); item.Line = this.cmbLine.InnerDropDownList.SelectedValue.Trim(); item.Station = this.cmbStation.InnerDropDownList.SelectedValue.Trim(); item.Family = this.cmbFamily.InnerDropDownList.SelectedValue.Trim(); item.BomNodeType = this.txtBomNodeType.Value.Trim(); item.PartDescr = this.txtPartDescr.Value.Trim(); item.PartType = this.txtPartType.Value.Trim(); item.FilterExpression = this.txtFilterExpression.Value.Trim(); item.MatchRule = this.txtMatchRule.Value.Trim(); item.CheckRule = this.txtCheckRule.Value.Trim(); item.SaveRule = this.txtSaveRule.Value.Trim(); item.NeedUniqueCheck = this.cmbNeedUniqueCheck.SelectedItem.Value; item.NeedCommonSave = this.cmbNeedCommonSave.SelectedItem.Value; item.NeedSave = this.cmbNeedSave.SelectedItem.Value; item.CheckTestKPCount = this.cmbCheckTestKPCount.SelectedItem.Value; item.Descr = this.txtDescr.Value.Trim(); item.Editor = this.HiddenUserName.Value; item.ID = Convert.ToInt32(this.hidID.Value != "" ? this.hidID.Value : "-1"); checkitem.Line = this.cmbLine.InnerDropDownList.SelectedValue.Trim(); checkitem.Station = this.cmbStation.InnerDropDownList.SelectedValue.Trim(); checkitem.Family = this.cmbFamily.InnerDropDownList.SelectedValue.Trim(); checkitem.BomNodeType = this.txtBomNodeType.Value.Trim(); checkitem.PartDescr = this.txtPartDescr.Value.Trim(); checkitem.PartType = this.txtPartType.Value.Trim(); checkitem.FilterExpression = this.txtFilterExpression.Value.Trim(); checkitem.MatchRule = this.txtMatchRule.Value.Trim(); checkitem.CheckRule = this.txtCheckRule.Value.Trim(); checkitem.SaveRule = this.txtSaveRule.Value.Trim(); checkitem.NeedUniqueCheck = this.cmbNeedUniqueCheck.SelectedItem.Value; checkitem.NeedCommonSave = this.cmbNeedCommonSave.SelectedItem.Value; checkitem.NeedSave = this.cmbNeedSave.SelectedItem.Value; checkitem.CheckTestKPCount = this.cmbCheckTestKPCount.SelectedItem.Value; checkitem.Descr = this.txtDescr.Value.Trim(); try { if (iCheckItemTypeListMaintain.CheckExistCheckItemTypeRule(checkitem)) { showErrorMessage("Is exist"); return; } if (item.ID != -1) { iCheckItemTypeListMaintain.UpdateCheckItemTypeRule(item); } else { iCheckItemTypeListMaintain.AddCheckItemTypeRule(item); } } catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { showErrorMessage(ex.Message); return; } string itemId = Convert.ToString(item.ID); ShowListByCustomAndStage(); this.updatePanel.Update(); ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "AddUpdateComplete('" + itemId + "');DealHideWait();", true); }