Example #1
0
        static void Main(string[] args)
        {
            string osatID = "Ardentec";

            FileInfo[] files = new DirectoryInfo(@"C:\LHD_APPLICATION\MessageCenter\Messages\" + osatID + @"\In\").GetFiles();
            int        num   = 0;

            for (int i = 0; i <= (files.Length - 1); i++)
            {
                IList <string> messages = new List <string>();
                num++;
                FileInfo info2   = files[i];
                string   str2    = FileService.ReadTextFile(info2.FullName);
                int      index   = str2.IndexOf("{\"LOT_JUDGEMENT");
                string   jsonStr = str2.Substring(index, (str2.Length - index) - 1);
                //Lot lot = LotService.ReadLotFromJson(osatID, jsonStr, messages);
                //Console.WriteLine(osatID + messages);
                //if (lot != null)
                //{
                //    LotService.SaveLotAndInformQA_AND_PE(lot);
                //    //this.lblPrompt.Text = string.Format("{0} lots loaded", i + 1);
                //}

                Lot_TransformService lts = new Lot_TransformService();
                Lot_Transformed      lt  = lts.ReadJson(jsonStr, messages);

                if (lt != null)
                {
                    lts.SaveCPJsonlot(lt);
                }


                //Application.DoEvents();
            }
            Console.WriteLine(string.Format("Import from file successed. {0} lots imported.", num));
            Console.Read();
        }
Example #2
0
        public ActionResult test()
        {
            string          jsonStr = service.GetTransformById("test1").TestStr;
            IList <string>  message = new List <string>();
            Lot_Transformed lot     = service.ReadJson(jsonStr, message);

            service.SaveCPJsonlot(lot);
            #region
            //JObject obj = (JObject)JsonConvert.DeserializeObject(jsonStr);
            //Lot_Transformed lot = new Lot_Transformed();
            //lot.ProductName = obj["product"].ToString();
            //lot.LotId = obj["lotId"].ToString();
            //string str_completiondate = obj["lotFinishTime"].ToString();
            //DateTime dt = Convert.ToDateTime(str_completiondate.Substring(0, 4) + "-" + str_completiondate.Substring(4, 2) + "-" + str_completiondate.Substring(6, 2) + " " + str_completiondate.Substring(9, 2) + ":" + str_completiondate.Substring(11, 2) + ":" + str_completiondate.Substring(13, 2) + "." + str_completiondate.Substring(16, 3));
            //lot.CompletionDate = dt;
            //lot.AutoJudeResult = obj["decision"].ToString();
            //Dictionary<string, string> dicstats = JsonConvert.DeserializeObject<Dictionary<string, string>>(obj["stats"].ToString());
            //lot.Yield = (dicstats["passPercent"] != null) ? Math.Round(Convert.ToDouble(dicstats["passPercent"].ToString()), 2, MidpointRounding.AwayFromZero) : 0.0;
            //lot.Stage = obj["stage"].ToString();
            //lot.TestProgram = obj["temperature"].ToString();
            //lot.TesterID = obj["tester"].ToString();
            //lot.Platform = obj["testerType"].ToString();
            //lot.LBNO = obj["probecard"].ToString();
            //List<LotMeteModel> metaList = JsonConvert.DeserializeObject<List<LotMeteModel>>(obj["metadata"].ToString());
            //List<string> waferList = new List<string>();
            //int waferidcount = 0;
            //List<string> allBinList = new List<string>();
            //List<string> allBinLimtList = new List<string>();
            //List<string> allBinPercentList = new List<string>();
            //foreach (LotMeteModel item in metaList)
            //{
            //    if (item.key == EnumLotMeta.osat.ToString())
            //    {
            //        lot.Vendor = item.values[0];
            //    }
            //    if (item.key == EnumLotMeta.allItem.ToString())
            //    {
            //        int index = 0;
            //        string waferid = "";
            //        foreach (string s in item.values)
            //        {
            //            index++;
            //            if (index > 1)
            //            {
            //                if (!waferid.Equals(s))
            //                {
            //                    waferList.Add(s);
            //                    waferidcount = 0;
            //                }
            //                waferidcount++;
            //            }
            //            else
            //            {
            //                lot.WaferCode = s;
            //            }
            //            waferid = s;
            //        }
            //    }
            //    if (item.key == EnumLotMeta.allBin.ToString())
            //    {
            //        allBinList = item.values;
            //        allBinList.RemoveAt(0);
            //    }
            //    if (item.key == EnumLotMeta.allBinLimit.ToString())
            //    {
            //        allBinLimtList = item.values;
            //        allBinLimtList.RemoveAt(0);
            //    }
            //    if (item.key == EnumLotMeta.allBinPercent.ToString())
            //    {
            //        allBinPercentList = item.values;
            //        allBinPercentList.RemoveAt(0);
            //    }
            //}
            //lot.WfCount = waferList.Count;
            ////  lot.UploadDate = DateTime.Now.ToLocalTime();
            //lot.Url = obj["url"].ToString();
            //int status = lot.AutoJudeResult.ToLower() == LotAutoJudgement.hold.ToString() ? (int)WaferStatus.WaitPE : (int)WaferStatus.Close;
            //lot.Status = status;
            //string lotid = Guid.NewGuid().ToString().Replace("-", "");
            //lot.ID = lotid;
            //lot.CreateDate = DateTime.Now.ToLocalTime();
            //string holdReason = "";
            //if (obj["decisionReason"] != null)
            //{
            //    holdReason = obj["decisionReason"].ToString();
            //}
            //lot.HoldReason = holdReason;
            //int suc = service.SaveLot(lot);
            //if (suc >= 0)
            //{//添加wafer
            //    Response.Write("添加lot成功");
            //    SqlWafer wafer = null;
            //    int index = 0;
            //    int waferIndex = 0;
            //    foreach (string s in waferList)
            //    {
            //        string waferid = Guid.NewGuid().ToString().Replace("-", "");
            //        wafer = new SqlWafer();
            //        wafer.ID = waferid;
            //        wafer.TransformID = lotid;
            //        wafer.WaferID = s;
            //        wafer.Status = status;
            //        wafer.HoldReason = holdReason;
            //        wafer.Yield = allBinPercentList[index * waferidcount] != null ? float.Parse(Math.Round(Convert.ToDouble(allBinPercentList[index * waferidcount].ToString()), 2, MidpointRounding.AwayFromZero).ToString()) : 0;
            //        wafer.CompletionDate = dt;
            //        wafer.PEDispose = 0;
            //        wafer.QADispose = 0;
            //        wafer.SPRDDecision = 0;
            //        wafer.CreateDate = DateTime.Now.ToLocalTime();
            //        wafer.VendorConfirm = 0;
            //        wafer.Program = obj["Program"] != null ? obj["Program"].ToString() : "";
            //        if (obj["startTime"] != null)
            //        {
            //            string str_starttime = obj["startTime"].ToString();
            //            DateTime startdt = DateTime.Parse(str_starttime.Substring(0, 4) + "-" + str_starttime.Substring(4, 2) + "-" + str_starttime.Substring(6, 2) + " " + str_starttime.Substring(9, 2) + ":" + str_starttime.Substring(11, 2) + ":" + str_starttime.Substring(13, 2) + "." + str_starttime.Substring(16, 3));
            //            wafer.StartTime = startdt;
            //        }
            //        else
            //        {
            //            wafer.StartTime = DateTime.Now.ToLocalTime();
            //        }
            //        if (waferService.SaveWafer(wafer) >= 0)//保存sbin
            //        {
            //            Response.Write("添加wafer成功");
            //            for (int i = 0; i < waferidcount; i++)
            //            {
            //                waferIndex++;
            //                if (waferIndex == 2 && i == 1)
            //                {
            //                    waferIndex = 1;
            //                }
            //                if (i > 0)
            //                {

            //                    try
            //                    {
            //                        Wafer_Sbin sbin = new Wafer_Sbin();
            //                        sbin.ID = Guid.NewGuid().ToString().Replace("-", "");
            //                        sbin.WaferID = waferid;
            //                        sbin.LotID = lotid;
            //                        sbin.SbinValue = !string.IsNullOrEmpty(allBinPercentList[waferIndex]) ? Math.Round(Convert.ToDouble(allBinPercentList[waferIndex]), 2, MidpointRounding.AwayFromZero).ToString() : "0";
            //                        sbin.IsTriggered = false;
            //                        sbin.SbinText = allBinList[i];
            //                        sbin.SbinLimit = !string.IsNullOrEmpty(allBinLimtList[i]) ? Math.Round(Convert.ToDouble(allBinLimtList[i]), 2, MidpointRounding.AwayFromZero).ToString() : "0";
            //                        sbin.Sort = i;
            //                        sbin.CreatedTime = DateTime.Now.ToLocalTime();
            //                        sbinService.SaveSBin(sbin);
            //                        Response.Write("添加sbin成功");
            //                    }
            //                    catch (Exception e)
            //                    {
            //                        throw;
            //                    }
            //                }
            //            }
            //        }

            //        index++;
            //    }
            //}
            #endregion
            return(View());
        }
Example #3
0
        public static string AdminAddress = Convert.ToString(ConfigurationManager.AppSettings["AdminAddress"]);//账号

        public void Execute(JobExecutionContext context)
        {
            Log.Instance.Info("LHD Import Service Execute Start--------------------------------------------" + DateTime.Now.ToString());
            try
            {
                SpreadtrumLHDEntities Db = new SpreadtrumLHDEntities();
                //List<LOTSImportLogs> lot = new List<LOTSImportLogs>();
                DateTime now    = DateTime.Now.AddMinutes(-2);
                var      tbList = Db.LOTSImportLogs.Where(x => x.FormatStatus == "Pending" && x.CreateTime < now).ToList();
                if (tbList.Count > 0)
                {
                    foreach (var m in tbList)
                    {
                        Lot                  lot = new Lot();
                        Lot_Transformed      lt  = new Lot_Transformed();
                        Lot_TransformService lts = new Lot_TransformService();
                        try
                        {
                            if (m.Type.ToUpper() == "FT")
                            {
                                IList <string> messages = new List <string>();
                                string         str2     = FileService.ReadTextFile(m.FilePath);
                                int            index    = str2.IndexOf("{\"LOT_JUDGEMENT");
                                string         jsonStr  = str2.Substring(index, (str2.Length - index) - 1);
                                lot      = LotService.ReadLotFromJson(m.osatID, jsonStr, messages);
                                m.LotNO  = lot.SubconLot;
                                m.Device = lot.DeviceCode + "(" + lot.DeviceName + ")";
                                m.Stage  = lot.Stage;
                            }
                            else if (m.Type.ToUpper() == "CP")
                            {
                                IList <string> messages = new List <string>();
                                string         str2     = FileService.ReadTextFile(m.FilePath);
                                int            index    = str2.IndexOf("{\"LOT_JUDGEMENT");
                                string         jsonStr  = str2.Substring(index, (str2.Length - index) - 1);
                                lt = lts.ReadJson(jsonStr, messages);
                            }
                            m.FormatStatus = "Success";
                            m.FormatTime   = DateTime.Now;
                        }
                        catch (Exception fex)
                        {
                            m.FormatStatus = "Error";
                            m.Logs        += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "--" + fex.Message + "<br/>";
                            Db.Set <LOTSImportLogs>().Attach(m);
                            Db.Entry(m).State = EntityState.Modified;

                            continue;
                        }

                        try
                        {
                            if (m.Type.ToUpper() == "FT")
                            {
                                if (lot != null)
                                {
                                    LotService.SaveLotAndInformQA_AND_PE(lot);
                                }
                            }
                            else if (m.Type.ToUpper() == "CP")
                            {
                                if (lt != null)
                                {
                                    lts.SaveCPJsonlot(lt);
                                }
                            }
                            m.ImportLHDStatus = "Success";
                            m.ImportLHDTime   = DateTime.Now;
                        }
                        catch (Exception iex)
                        {
                            m.Logs           += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "--" + iex.Message + "<br/>";
                            m.ImportLHDStatus = "Error";
                        }
                        Db.Set <LOTSImportLogs>().Attach(m);
                        Db.Entry(m).State = EntityState.Modified;
                    }
                }
                Db.SaveChanges();


                #region Template
                //    CVMSEntities Db = new CVMSEntities();

                //    List<T_Sys_MailQueue> MailsList = new List<T_Sys_MailQueue>();
                //    //Log.Instance.Info("Load Mail Data Begin-------------------------------------------" + DateTime.Now.ToString());
                //    var tbList = Db.T_Sys_MailQueue.Where(x => x.Status == "Pending").ToList();
                //    //Log.Instance.Info("Load Mail Data End-------------------------------------------" + DateTime.Now.ToString());

                //    if (tbList.Count > 0)
                //    {
                //        foreach (var m in tbList)
                //        {
                //            try
                //            {
                //                List<string> tolist = new List<string>();
                //                List<string> cclist = new List<string>();
                //                List<string> bcclist = new List<string>();
                //                //Log.Instance.Info("Load To Data Begin-------------------------------------------" + DateTime.Now.ToString());
                //                //Log.Instance.Info("Load To Data Begin-------------------------------------------" + m.To);

                //                if (!string.IsNullOrEmpty(m.To))
                //                {
                //                    string[] tos = m.To.Split(new char[1] { ';' });
                //                    foreach (var to in tos)
                //                    {
                //                        tolist.Add(to);
                //                    }

                //                }
                //                //Log.Instance.Info("Load CC Data Begin-------------------------------------------" + DateTime.Now.ToString());

                //                if (!string.IsNullOrEmpty(m.CC))
                //                {
                //                    string[] ccs = m.CC.Split(new char[1] { ';' });
                //                    foreach (var cc in ccs)
                //                    {
                //                        cclist.Add(cc);
                //                    }

                //                }
                //                //Log.Instance.Info("Load BCC Data Begin-------------------------------------------" + DateTime.Now.ToString());

                //                if (!string.IsNullOrEmpty(m.BCC))
                //                {
                //                    string[] bccs = m.BCC.Split(new char[1] { ';' });
                //                    foreach (var bcc in bccs)
                //                    {
                //                        bcclist.Add(bcc);
                //                    }
                //                }
                //                //Log.Instance.Info("Load Priority Data Begin-------------------------------------------" + DateTime.Now.ToString());

                //                MailPriority Priority;
                //                if (string.IsNullOrEmpty(m.Priority))
                //                {
                //                    Priority = MailPriority.Normal;
                //                }
                //                else
                //                {
                //                    Priority = (MailPriority)Enum.Parse(typeof(MailPriority), m.Priority);
                //                }


                //                //Log.Instance.Info("Send Mail Begin--------------------------------------------" + DateTime.Now.ToString());
                //                MailHelp.SendMail(tolist, cclist, bcclist, m.Subject, m.Boday, Priority);
                //                m.Status = "Sent";
                //                m.SendTime = DateTime.Now;
                //                //Log.Instance.Info("Send Mail End--------------------------------------------" + DateTime.Now.ToString());
                //            }
                //            catch (Exception ex)
                //            {
                //                Log.Instance.Error(ex);
                //                List<string> tolist = new List<string>();
                //                tolist.Add(AdminAddress);
                //                MailHelp.SendMail(tolist, null, null, "CVMS Mail Send Error", ex.Message, MailPriority.High);
                //                m.Status = "Error";
                //            }
                //            Db.Set<T_Sys_MailQueue>().Attach(m);
                //            Db.Entry(m).State = EntityState.Modified;

                //        }
                //        Db.SaveChanges();
                //    }
                #endregion
            }
            catch (Exception e)
            {
                Log.Instance.Error(e);
            }
            Log.Instance.Info("LHD Import Service Execute End--------------------------------------------" + DateTime.Now.ToString());
        }