public JsonResult UpdateNGWafer()
        {
            var           wafer_list = Request.Form["wafer_list"];
            List <string> wafelist   = (List <string>)Newtonsoft.Json.JsonConvert.DeserializeObject(wafer_list, (new List <string>()).GetType());

            WaferPackVM.UpdateNGWafer(wafelist);
            var ret = new JsonResult();

            ret.Data = new { sucess = true };
            return(ret);
        }
        private List <WaferTableItem> RetrieveWaferData()
        {
            var           marks        = Request.Form["marks"];
            List <string> SNList       = (List <string>)Newtonsoft.Json.JsonConvert.DeserializeObject(marks, (new List <string>()).GetType());
            var           DateCodeList = new List <string>();

            foreach (var item in SNList)
            {
                var sn = item.Replace("'", "").Trim().ToUpper();
                if (sn.Length > 7)
                {
                    DateCodeList.Add(sn);
                }
            }

            var appendinfodict = new Dictionary <string, string>();

            var sndict     = new Dictionary <string, bool>();
            var wafertable = new List <WaferTableItem>();

            if (DateCodeList.Count > 0)
            {
                var datesnlist = WaferPackVM.RetrieveSNByDateCode(DateCodeList, appendinfodict);
                foreach (var item in datesnlist)
                {
                    var sn = item.SN.Replace("'", "").Trim().ToUpper();
                    if (!sndict.ContainsKey(sn))
                    {
                        sndict.Add(sn, true);
                        wafertable.Add(item);
                    }
                }
            }

            foreach (var item in SNList)
            {
                var sn = item.Replace("'", "").Trim().ToUpper();
                if (sn.Length <= 7 && !sndict.ContainsKey(sn))
                {
                    sndict.Add(sn, true);
                    var tempvm = new WaferTableItem();
                    tempvm.SN = sn;
                    wafertable.Add(tempvm);
                }
            }

            var cablesndict = new Dictionary <string, bool>();
            var fwafertable = WaferPackVM.SolveCableSN(wafertable, cablesndict);

            WaferPackVM.RetrieveWaferBySN(fwafertable);
            var ngwaferdict = WaferPackVM.RetrieveNGWaferDict();

            foreach (var item in fwafertable)
            {
                if (ngwaferdict.ContainsKey(item.WaferNum))
                {
                    item.Status = WAFERSTATUS.NG;
                    //set NG for cable SN
                    if (!string.IsNullOrEmpty(item.DateCode) &&
                        cablesndict.ContainsKey(item.DateCode))
                    {
                        cablesndict[item.DateCode] = false;
                    }
                }
                else if (string.IsNullOrEmpty(item.WaferNum))
                {
                    item.Status = WAFERSTATUS.NA;
                }
                else
                {
                    item.Status = WAFERSTATUS.GOOD;
                }
            }

            //smame cable sn ,if one sub module is NG, whole module is NG
            foreach (var item in fwafertable)
            {
                if (!string.IsNullOrEmpty(item.DateCode) &&
                    cablesndict.ContainsKey(item.DateCode) &&
                    !cablesndict[item.DateCode])
                {
                    item.Status = WAFERSTATUS.NG;
                }

                if (!string.IsNullOrEmpty(item.SN) &&
                    appendinfodict.ContainsKey(item.SN))
                {
                    item.AppendInfo = appendinfodict[item.SN];
                }

                if (!string.IsNullOrEmpty(item.DateCode) &&
                    appendinfodict.ContainsKey(item.DateCode))
                {
                    item.AppendInfo = appendinfodict[item.DateCode];
                }
            }

            return(fwafertable);
        }
 // GET: WaferPack
 public ActionResult Index()
 {
     ViewBag.NG_Wafer_List = WaferPackVM.RetrieveNGWafer();
     return(View());
 }