public JsonResult getChildEquipments(string parent)
        {
            List <string> child = new List <string>();

            child = EquipmentModels.getChildEquipments(parent);
            return(Json(child, 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);
            }
        }
        public JsonResult getChildEquipment(string equipment)
        {
            var res = EquipmentModels.getChildEquipments(equipment);

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetRecipeData(string productName, string EquipID, string ID)
        {
            var result = RecipeClass.getData(productName, EquipID, ID);

            Dictionary <string, object> response = new Dictionary <string, object>();
            List <RecipeObject>         obj      = new List <RecipeObject>();

            int counter = 0;

            string type = EquipmentModels.GetEquipmentTypeByID(Convert.ToInt32(ID));

            if (type == "")
            {
                var child = EquipmentModels.getChildEquipments(EquipID);
                if (child == null)
                {
                    counter = 0;
                }
                else
                {
                    if (child.Count > 0)
                    {
                        counter = child.Count;
                    }
                    else
                    {
                        counter = 0;
                    }
                }
            }
            else
            {
                counter = 1;
            }

            try
            {
                if (result.Rows.Count > 0)
                {
                    foreach (DataRow dr in result.Rows)
                    {
                        var temp_obj = new RecipeObject();
                        temp_obj.RecipeID    = dr["RecipeID"].ToString();
                        temp_obj.RecipeName  = dr["RecipeName"].ToString();
                        temp_obj.RecipeBody  = dr["RecipeBody"].ToString();
                        temp_obj.ProductName = dr["ProductName"].ToString();
                        temp_obj.EquipID     = dr["EquipID"].ToString();
                        temp_obj.Counter     = counter;
                        DataTable dt = new DataTable();
                        dt = RecipeClass.getParams(dr["RecipeID"].ToString());
                        List <string> lstGroupName     = new List <string>();
                        List <string> lstParameterName = new List <string>();
                        List <string> lstMin           = new List <string>();
                        List <string> lstMax           = new List <string>();
                        List <string> lstValue         = new List <string>();
                        if (dt != null)
                        {
                            if (dt.Rows.Count > 0)
                            {
                                foreach (DataRow dr2 in dt.Rows)
                                {
                                    lstGroupName.Add(dr2["GroupName"].ToString());
                                    lstParameterName.Add(dr2["ParameterName"].ToString());
                                    lstMin.Add(dr2["Min"].ToString());
                                    lstMax.Add(dr2["Max"].ToString());
                                    lstValue.Add(dr2["Value"].ToString());
                                }
                            }
                        }
                        temp_obj.GroupName     = lstGroupName;
                        temp_obj.ParameterName = lstParameterName;
                        temp_obj.Min           = lstMin;
                        temp_obj.Max           = lstMax;
                        temp_obj.Value         = lstValue;
                        obj.Add(temp_obj);
                    }
                }
                else
                {
                    obj = null;
                }
            }
            catch
            {
                obj = null;
            }

            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        //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);
            }
        }