public JsonResult GetEquipmentTypeJoin(int ID) { var result = EquipmentModels.GetEquipmentTypeJoin(ID); return(Json(result, JsonRequestBehavior.AllowGet)); }
//function for Report Setup public static List <SECSGEMDefaultReplyObject> SetupReport(string Equipment) { try { int ID = EquipmentModels.GetEquipmentID(Equipment); string type = EquipmentModels.GetEquipmentTypeJoin(ID); List <SECSGEMDefaultReplyObject> obj = new List <SECSGEMDefaultReplyObject>(); SECSGEMDefaultReplyObject temp_obj = new SECSGEMDefaultReplyObject(); if (type == "") { var child = EquipmentModels.getChildEquipments(Equipment); foreach (var x in child) { string ChildEquipment = x; int ChildID = EquipmentModels.GetEquipmentID(ChildEquipment); string childtype = EquipmentModels.GetEquipmentTypeJoin(ChildID); if (childtype.ToUpper() == "DEK PRINTER") { //Product Data modified (CEID 31346) //Equipment constant change (CEID 31440) //Configuration change (CEID 31287) //Configuration Parameter modified(CEID 31345) //Adjust Parameter modified (CEID 31347) //for processed quantity temp_obj = HttpHandler.DisableCollection(ChildEquipment, 31277); //31277 Board printed obj.Add(temp_obj); temp_obj = HttpHandler.DeleteReport(ChildEquipment, 301); //301 RPTID = User Defined ID obj.Add(temp_obj); temp_obj = HttpHandler.UnlinkCollection(ChildEquipment, 31277); obj.Add(temp_obj); temp_obj = HttpHandler.AddToReport_Single(ChildEquipment, 301, 1020); //SVID = 1020 (batch_count) obj.Add(temp_obj); temp_obj = HttpHandler.LinkCollection(ChildEquipment, 31277, 301); obj.Add(temp_obj); temp_obj = HttpHandler.EnableCollection(ChildEquipment, 31277); obj.Add(temp_obj); //for multi vid sample //List<int> lstVID = new List<int>(); //lstVID.Add(456); //lstVID.Add(789); //temp_obj = HttpHandler.AddToReport_Multi(ChildEquipment, 301, lstVID); //obj.Add(temp_obj); } else if (childtype.ToUpper() == "HELLER OVEN") { //for lane 1 temp_obj = HttpHandler.DisableCollection(ChildEquipment, 1080); //1080 HellerBoardExitLane1 obj.Add(temp_obj); temp_obj = HttpHandler.DeleteReport(ChildEquipment, 401); //401 RPTID = User Defined ID obj.Add(temp_obj); temp_obj = HttpHandler.UnlinkCollection(ChildEquipment, 1080); obj.Add(temp_obj); temp_obj = HttpHandler.AddToReport_Single(ChildEquipment, 401, 13049); //SVID = 13049 (HellerPVChannel49) Boards processed Lane1 obj.Add(temp_obj); temp_obj = HttpHandler.LinkCollection(ChildEquipment, 1080, 401); obj.Add(temp_obj); temp_obj = HttpHandler.EnableCollection(ChildEquipment, 1080); obj.Add(temp_obj); //for lane 2 temp_obj = HttpHandler.DisableCollection(ChildEquipment, 1081); //1080 HellerBoardExitLane2 obj.Add(temp_obj); temp_obj = HttpHandler.DeleteReport(ChildEquipment, 402); //402 RPTID = User Defined ID obj.Add(temp_obj); temp_obj = HttpHandler.UnlinkCollection(ChildEquipment, 1081); obj.Add(temp_obj); temp_obj = HttpHandler.AddToReport_Single(ChildEquipment, 402, 13050); //SVID = 13050 (HellerPVChannel50) Boards processed Lane2 obj.Add(temp_obj); temp_obj = HttpHandler.LinkCollection(ChildEquipment, 1081, 402); obj.Add(temp_obj); temp_obj = HttpHandler.EnableCollection(ChildEquipment, 1081); obj.Add(temp_obj); } else if (childtype.ToUpper() == "PANASONIC COMPONENT ATTACH") { if (EnablePanasonic == true) { temp_obj = HttpHandler.DisableCollection(ChildEquipment, 16016); //16016 (Product1BoardEnd)?? obj.Add(temp_obj); temp_obj = HttpHandler.DeleteReport(ChildEquipment, 501); //501 RPTID = User Defined ID obj.Add(temp_obj); temp_obj = HttpHandler.UnlinkCollection(ChildEquipment, 16016); obj.Add(temp_obj); temp_obj = HttpHandler.AddToReport_Single(ChildEquipment, 501, 7003); //SVID = 7003 (Board) obj.Add(temp_obj); temp_obj = HttpHandler.LinkCollection(ChildEquipment, 16016, 501); obj.Add(temp_obj); temp_obj = HttpHandler.EnableCollection(ChildEquipment, 16016); obj.Add(temp_obj); } else { //Override //Disable Collection temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = ChildEquipment; temp_obj.EquipmentType = childtype; temp_obj.StreamFunction = "S2F37_DISABLE_COLLECTION"; temp_obj.Value = 0; obj.Add(temp_obj); //Delete Report temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = ChildEquipment; temp_obj.EquipmentType = childtype; temp_obj.StreamFunction = "S2F33_DELETE_REPORT"; temp_obj.Value = 0; obj.Add(temp_obj); //Unlink Collection temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = ChildEquipment; temp_obj.EquipmentType = childtype; temp_obj.StreamFunction = "S2F35_UNLINK_COLLECTION"; temp_obj.Value = 0; obj.Add(temp_obj); //Add Report temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = ChildEquipment; temp_obj.EquipmentType = childtype; temp_obj.StreamFunction = "S2F33_ADD_REPORT"; temp_obj.Value = 0; obj.Add(temp_obj); //Link Collection temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = ChildEquipment; temp_obj.EquipmentType = childtype; temp_obj.StreamFunction = "S2F35_LINK_COLLECTION"; temp_obj.Value = 0; obj.Add(temp_obj); //Enable Collection temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = ChildEquipment; temp_obj.EquipmentType = childtype; temp_obj.StreamFunction = "S2F37_ENABLE_COLLECTION"; temp_obj.Value = 0; obj.Add(temp_obj); } } } } else { if (type.ToUpper() == "DEK PRINTER") { temp_obj = HttpHandler.DisableCollection(Equipment, 31277); //31277 Board printed obj.Add(temp_obj); temp_obj = HttpHandler.DeleteReport(Equipment, 301); //301 RPTID = User Defined ID obj.Add(temp_obj); temp_obj = HttpHandler.UnlinkCollection(Equipment, 31277); obj.Add(temp_obj); temp_obj = HttpHandler.AddToReport_Single(Equipment, 301, 1020); //SVID = 1020 (batch_count) obj.Add(temp_obj); temp_obj = HttpHandler.LinkCollection(Equipment, 31277, 301); obj.Add(temp_obj); temp_obj = HttpHandler.EnableCollection(Equipment, 31277); obj.Add(temp_obj); //Product Data modified (CEID 31346) //Equipment constant change (CEID 31440) //Configuration change (CEID 31287) //Configuration Parameter modified(CEID 31345) //Adjust Parameter modified (CEID 31347) //testing ceids //temp_obj = HttpHandler.DisableCollection(Equipment, 31346); //obj.Add(temp_obj); //temp_obj = HttpHandler.DeleteReport(Equipment, 302); //obj.Add(temp_obj); //temp_obj = HttpHandler.UnlinkCollection(Equipment, 31346); //obj.Add(temp_obj); ////temp_obj = HttpHandler.AddToReport_Single(Equipment, 302, 2009); //SVID = 2009 (rear_print_pressure) ////obj.Add(temp_obj); //List<int> lstVID = new List<int>(); //lstVID.Add(2009); //SVID = 2009 (rear_print_pressure) //lstVID.Add(2008); //SVID = 2008 (front_print_pressure) //temp_obj = HttpHandler.AddToReport_Multi(Equipment, 302, lstVID); //obj.Add(temp_obj); //temp_obj = HttpHandler.LinkCollection(Equipment, 31346, 302); //obj.Add(temp_obj); //temp_obj = HttpHandler.EnableCollection(Equipment, 31346); //obj.Add(temp_obj); //end of testing ceid } else if (type.ToUpper() == "HELLER OVEN") { //for lane 1 temp_obj = HttpHandler.DisableCollection(Equipment, 1080); //1080 HellerBoardExitLane1 obj.Add(temp_obj); temp_obj = HttpHandler.DeleteReport(Equipment, 401); //401 RPTID = User Defined ID obj.Add(temp_obj); temp_obj = HttpHandler.UnlinkCollection(Equipment, 1080); obj.Add(temp_obj); temp_obj = HttpHandler.AddToReport_Single(Equipment, 401, 13049); //SVID = 13049 (HellerPVChannel49) Boards processed Lane1 obj.Add(temp_obj); temp_obj = HttpHandler.LinkCollection(Equipment, 1080, 401); obj.Add(temp_obj); temp_obj = HttpHandler.EnableCollection(Equipment, 1080); obj.Add(temp_obj); //for lane 2 temp_obj = HttpHandler.DisableCollection(Equipment, 1081); //1080 HellerBoardExitLane2 obj.Add(temp_obj); temp_obj = HttpHandler.DeleteReport(Equipment, 402); //402 RPTID = User Defined ID obj.Add(temp_obj); temp_obj = HttpHandler.UnlinkCollection(Equipment, 1081); obj.Add(temp_obj); temp_obj = HttpHandler.AddToReport_Single(Equipment, 402, 13050); //SVID = 13050 (HellerPVChannel50) Boards processed Lane2 obj.Add(temp_obj); temp_obj = HttpHandler.LinkCollection(Equipment, 1081, 402); obj.Add(temp_obj); temp_obj = HttpHandler.EnableCollection(Equipment, 1081); obj.Add(temp_obj); } else if (type.ToUpper() == "PANASONIC COMPONENT ATTACH") { if (EnablePanasonic == true) { temp_obj = HttpHandler.DisableCollection(Equipment, 16016); //16016 (Product1BoardEnd)?? obj.Add(temp_obj); temp_obj = HttpHandler.DeleteReport(Equipment, 501); //501 RPTID = User Defined ID obj.Add(temp_obj); temp_obj = HttpHandler.UnlinkCollection(Equipment, 16016); obj.Add(temp_obj); temp_obj = HttpHandler.AddToReport_Single(Equipment, 501, 7003); //SVID = 7003 (Board) obj.Add(temp_obj); temp_obj = HttpHandler.LinkCollection(Equipment, 16016, 501); obj.Add(temp_obj); temp_obj = HttpHandler.EnableCollection(Equipment, 16016); obj.Add(temp_obj); } else { //Override //Disable Collection temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = Equipment; temp_obj.EquipmentType = type; temp_obj.StreamFunction = "S2F37_DISABLE_COLLECTION"; temp_obj.Value = 0; obj.Add(temp_obj); //Delete Report temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = Equipment; temp_obj.EquipmentType = type; temp_obj.StreamFunction = "S2F33_DELETE_REPORT"; temp_obj.Value = 0; obj.Add(temp_obj); //Unlink Collection temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = Equipment; temp_obj.EquipmentType = type; temp_obj.StreamFunction = "S2F35_UNLINK_COLLECTION"; temp_obj.Value = 0; obj.Add(temp_obj); //Add Report temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = Equipment; temp_obj.EquipmentType = type; temp_obj.StreamFunction = "S2F33_ADD_REPORT"; temp_obj.Value = 0; obj.Add(temp_obj); //Link Collection temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = Equipment; temp_obj.EquipmentType = type; temp_obj.StreamFunction = "S2F35_LINK_COLLECTION"; temp_obj.Value = 0; obj.Add(temp_obj); //Enable Collection temp_obj = new SECSGEMDefaultReplyObject(); temp_obj.Equipment = Equipment; temp_obj.EquipmentType = type; temp_obj.StreamFunction = "S2F37_ENABLE_COLLECTION"; temp_obj.Value = 0; obj.Add(temp_obj); } } } //if any machine fail its transaction dont let continue if (obj.Contains(null)) { return(null); } else { if (obj == null) { return(null); } else { if (obj.Count == 0) { return(null); } } } return(obj); } catch { return(null); } }
//get template data public static DataTable getData(string ProductName, string EquipID, string ID) { string query = ""; bool isEffectiveDate = SettingModels.isEffectiveDate(); string type = EquipmentModels.GetEquipmentTypeJoin(Convert.ToInt32(ID)); if (type == "") { var child = EquipmentModels.getChildEquipments(EquipID); if (child != null) { if (child.Count > 0) { DataTable total_dt = new DataTable(); for (int x = 0; x < child.Count; x++) { if (isEffectiveDate == false) { query = "select top 1 a.RecipeID, a.RecipeName, a.RecipeBody, b.ProductName, c.EquipID, a.EffectiveDate, a.RecipeSize from RecipeTable a left join ProductTable b on a.ProductID=b.ProductID left join EquipRecipeTable c on a.RecipeID=c.RecipeID where b.ProductName='" + ProductName + "' and c.EquipID='" + child[x] + "' and a.EffectiveDate is not null and a.DeactivationDate is null order by a.DateApproved desc"; } else { query = "select top 1 a.RecipeID, a.RecipeName, a.RecipeBody, b.ProductName, c.EquipID, a.EffectiveDate, a.RecipeSize from RecipeTable a left join ProductTable b on a.ProductID=b.ProductID left join EquipRecipeTable c on a.RecipeID=c.RecipeID where b.ProductName='" + ProductName + "' and c.EquipID='" + child[x] + "' and a.EffectiveDate is not null and convert(datetime,a.EffectiveDate,101)<getdate() and a.DeactivationDate is null order by a.DateApproved desc"; } SqlConnection conn = new SqlConnection(connStr); SqlCommand cmd = new SqlCommand(query, conn); //cmd.CommandTimeout = 3600; DataSet ds = new DataSet(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); try { conn.Open(); da.Fill(ds); dt = ds.Tables[0]; da.Dispose(); cmd.Dispose(); conn.Close(); conn.Dispose(); SqlConnection.ClearPool(conn); } catch { conn.Close(); conn.Dispose(); SqlConnection.ClearPool(conn); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); SqlConnection.ClearPool(conn); } } total_dt.Merge(dt); } total_dt.DefaultView.Sort = "EquipID asc"; total_dt = total_dt.DefaultView.ToTable(); return(total_dt); } else { return(null); } } else { return(null); } } else { if (isEffectiveDate == false) { query = "select top 1 a.RecipeID, a.RecipeName, a.RecipeBody, b.ProductName, c.EquipID, a.EffectiveDate, a.RecipeSize from RecipeTable a left join ProductTable b on a.ProductID=b.ProductID left join EquipRecipeTable c on a.RecipeID=c.RecipeID where b.ProductName='" + ProductName + "' and c.EquipID='" + EquipID + "' and a.EffectiveDate is not null and a.DeactivationDate is null order by a.DateApproved desc"; } else { query = "select top 1 a.RecipeID, a.RecipeName, a.RecipeBody, b.ProductName, c.EquipID, a.EffectiveDate, a.RecipeSize from RecipeTable a left join ProductTable b on a.ProductID=b.ProductID left join EquipRecipeTable c on a.RecipeID=c.RecipeID where b.ProductName='" + ProductName + "' and c.EquipID='" + EquipID + "' and a.EffectiveDate is not null and convert(datetime,a.EffectiveDate,101)<getdate() and a.DeactivationDate is null order by a.DateApproved desc"; } SqlConnection conn = new SqlConnection(connStr); SqlCommand cmd = new SqlCommand(query, conn); //cmd.CommandTimeout = 3600; DataSet ds = new DataSet(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); try { conn.Open(); da.Fill(ds); dt = ds.Tables[0]; da.Dispose(); cmd.Dispose(); conn.Close(); conn.Dispose(); SqlConnection.ClearPool(conn); } catch { conn.Close(); conn.Dispose(); SqlConnection.ClearPool(conn); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); SqlConnection.ClearPool(conn); } } return(dt); } }