public static List <ProjectYieldViewModule> GetYieldByDay(string pjkey, string starttime, string endtime, Cache mycache)
        {
            var ret = new List <ProjectYieldViewModule>();
            var pvm = ProjectViewModels.RetrieveOneProject(pjkey);

            var stime = DateTime.Parse(starttime);
            var etime = DateTime.Parse(endtime);

            var ldate = new List <DateTime>();

            for (var item = stime; item < etime;)
            {
                ldate.Add(item);
                item = item.AddDays(1);
            }

            var startidx = 0;

            if (ldate.Count > 30)
            {
                startidx = ldate.Count - 30;
            }

            for (int idx = startidx; idx < ldate.Count - 1; idx++)
            {
                var temp = GetYieldByDateRange(pjkey, ldate[idx].ToString(), ldate[idx + 1].ToString(), pvm, mycache);
                if (temp.RealTimeYields.Count > 0)
                {
                    ret.Add(temp);
                }
            }
            return(ret);
        }
Example #2
0
        public static void PrePareLatestData(Controller ctrl, string projectkey)
        {
            if (UpdatePJLockUsing(projectkey))
            {
                return;
            }

            try
            {
                var vm = ProjectViewModels.RetrieveOneProject(projectkey);
                if (vm.PNList.Count > 0)
                {
                    string lastupdatetime = BITestData.RetrieveLatestTimeOfLocalBI(projectkey);
                    if (!string.IsNullOrEmpty(lastupdatetime))
                    {
                        var vlast = DateTime.Parse(lastupdatetime);
                        vlast = vlast.AddMinutes(18);
                        if (vlast < DateTime.Now)
                        {
                            BIDataUtility.UpdateProjectData(ctrl, vm);
                        }
                    }
                    else
                    {
                        BIDataUtility.UpdateProjectData(ctrl, vm);
                    }
                }

                ResetUpdatePJLock(projectkey);
            }
            catch (Exception ex)
            {
                ResetUpdatePJLock(projectkey);
            }
        }
        public static ProjectViewModels RetrieveOneProject(string key)
        {
            var sql = "select ProjectKey,ProjectName,StartDate,FinishRate,Description,APVal1,APVal2,ProjectType from Project where ProjectKey = '<ProjectKey>' and validate = 1";

            sql = sql.Replace("<ProjectKey>", key);
            var dbret = DBUtility.ExeLocalSqlWithRes(sql, null);

            if (dbret.Count > 0)
            {
                var ret = new ProjectViewModels(Convert.ToString(dbret[0][0])
                                                , Convert.ToString(dbret[0][1]), Convert.ToString(dbret[0][2])
                                                , Convert.ToDouble(dbret[0][3]), Convert.ToString(dbret[0][4])
                                                , Convert.ToString(dbret[0][5]), Convert.ToString(dbret[0][6])
                                                , Convert.ToString(dbret[0][7]));

                ret.MemberList     = RetrieveProjectMembers(key);
                ret.TabList        = RetrieveProjectMesTable(key);
                ret.PNList         = RetrieveProjectPn(key);
                ret.StationList    = RetrieveProjectStation(key);
                ret.MDIDList       = RetrieveProjectModelID(key);
                ret.SumDatasetList = RetrieveProjectSumDataSet(key);
                return(ret);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        public static void RetrieveWaferDataFromMes(Controller ctrl, string projectkey)
        {
            if (UpdatePJLockUsing(projectkey))
            {
                return;
            }

            try
            {
                var vm = ProjectViewModels.RetrieveOneProject(projectkey);
                BIDataUtility.RetrievePjWaferAllData(ctrl, vm);
                ResetUpdatePJLock(projectkey);
            }
            catch (Exception ex)
            {
                ResetUpdatePJLock(projectkey);
            }
        }
Example #5
0
        private static Dictionary <string, string> RetrieveSqlFromProjectModel(ProjectViewModels projectmodel)
        {
            var tables = new Dictionary <string, string>();

            foreach (var s in projectmodel.StationList)
            {
                foreach (var m in projectmodel.TabList)
                {
                    if (string.Compare(s.Station.ToUpper(), m.Station.ToUpper()) == 0)
                    {
                        if (!tables.ContainsKey(s.Station))
                        {
                            tables.Add(s.Station, m.TableName);
                        }
                        break;
                    }
                }
            }

            string pncond = PNCondition(projectmodel.PNList);

            var joinstr = " LEFT JOIN Insite.Container b WITH (NOLOCK) ON b.containername = a.ModuleSerialNum LEFT JOIN Insite.MfgOrder d WITH(NOLOCK) ON d.MfgOrderId = b.MfgOrderId ";
            var sql     = "select a.dc_<DCTABLE>HistoryId,a.ModuleSerialNum, a.WhichTest, a.ModuleType, a.ErrAbbr, a.TestTimeStamp, a.TestStation,a.assemblypartnum ,d.MfgOrderName from "
                          + " insite.dc_<DCTABLE> a (nolock) " + joinstr + " where assemblypartnum in  (<PNCOND>)  <TIMECOND>  order by  moduleserialnum,testtimestamp DESC";

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

            foreach (var tb in tables)
            {
                if (string.IsNullOrEmpty(pncond))
                {
                    ret.Add(tb.Key, string.Empty);
                }
                else
                {
                    ret.Add(tb.Key, sql.Replace("<DCTABLE>", tb.Value).Replace("<PNCOND>", pncond));
                }
            }
            return(ret);
        }
Example #6
0
        private static void CreateSystemIssues(List <ProjectTestData> failurelist)
        {
            if (failurelist.Count > 0)
            {
                var pj            = ProjectViewModels.RetrieveOneProject(failurelist[0].ProjectKey);
                var firstengineer = "";
                foreach (var m in pj.MemberList)
                {
                    if (string.Compare(m.Role, ProjectViewModels.ENGROLE) == 0)
                    {
                        firstengineer = m.Name;
                        break;
                    }
                }

                foreach (var item in failurelist)
                {
                    var vm = new IssueViewModels();
                    vm.ProjectKey   = item.ProjectKey;
                    vm.IssueKey     = item.DataID;
                    vm.IssueType    = ISSUETP.Bug;
                    vm.Summary      = "Module " + item.ModuleSerialNum + " failed for " + item.ErrAbbr + " @ " + item.WhichTest;
                    vm.Priority     = ISSUEPR.Major;
                    vm.DueDate      = DateTime.Now.AddDays(7);
                    vm.ReportDate   = item.TestTimeStamp;
                    vm.Assignee     = firstengineer;
                    vm.Reporter     = "System";
                    vm.Resolution   = Resolute.Pending;
                    vm.ResolvedDate = DateTime.Parse("1982-05-06 01:01:01");
                    vm.Description  = "Module " + item.ModuleSerialNum + " failed for " + item.ErrAbbr + " @ " + item.WhichTest + " on tester " + item.TestStation + " " + item.TestTimeStamp.ToString("yyyy-MM-dd hh:mm:ss");
                    vm.CommentType  = COMMENTTYPE.Description;
                    vm.ModuleSN     = item.ModuleSerialNum;
                    vm.ErrAbbr      = item.ErrAbbr;
                    vm.DataID       = item.DataID;
                    //ProjectEvent.CreateIssueEvent(vm.ProjectKey, "System", vm.Assignee, vm.Summary, vm.IssueKey);
                    vm.StoreIssue();
                }
            }
        }
Example #7
0
        public static void PrePareMESLatestData(string projectkey)
        {
            if (UpdatePJLockUsing(projectkey))
            {
                return;
            }

            try
            {
                var vm = ProjectViewModels.RetrieveOneProject(projectkey);
                if (vm.TabList.Count > 0 &&
                    vm.PNList.Count > 0 &&
                    vm.StationList.Count > 0)
                {
                    string lastupdatetime = ProjectTestData.RetrieveLatestTimeOfLocalProject(projectkey);
                    if (!string.IsNullOrEmpty(lastupdatetime))
                    {
                        //var vlast = DateTime.Parse(lastupdatetime);
                        //vlast = vlast.AddMinutes(18);
                        //if (vlast < DateTime.Now)
                        //{
                        MESUtility.UpdateProjectData(vm, lastupdatetime, DateTime.Now.ToString());
                        //}
                    }
                    else
                    {
                        MESUtility.UpdateProjectData(vm, vm.StartDate.ToString(), DateTime.Now.ToString());
                    }
                }

                ResetUpdatePJLock(projectkey);
            }
            catch (Exception ex)
            {
                ResetUpdatePJLock(projectkey);
            }
        }
        public static List <ProjectYieldViewModule> GetYieldByMonth(string pjkey, Cache mycache, int Months)
        {
            var ret = new List <ProjectYieldViewModule>();

            var pvm   = ProjectViewModels.RetrieveOneProject(pjkey);
            var ldate = RetrieveDateSpanByMonth(pvm.StartDate.ToString(), DateTime.Now.ToString());

            var startidx = 0;

            if (ldate.Count > Months)
            {
                startidx = ldate.Count - Months - 1;
            }

            for (int idx = startidx; idx < ldate.Count - 1; idx++)
            {
                var temp = GetYieldByDateRange(pjkey, ldate[idx].ToString(), ldate[idx + 1].ToString(), pvm, mycache);
                if (temp.RealTimeYields.Count > 0)
                {
                    ret.Add(temp);
                }
            }
            return(ret);
        }
Example #9
0
        public static List <ProjectBIYieldViewModule> GetYieldByWeeks(string pjkey, int Weeks)
        {
            var ret = new List <ProjectBIYieldViewModule>();

            var pvm   = ProjectViewModels.RetrieveOneProject(pjkey);
            var ldate = RetrieveDateSpanByWeek(pvm.StartDate.ToString(), DateTime.Now.ToString());

            var startidx = 0;

            if (ldate.Count > Weeks)
            {
                startidx = ldate.Count - Weeks - 1;
            }

            for (int idx = startidx; idx < ldate.Count - 1; idx++)
            {
                var temp = GetYieldByDateRange(pjkey, ldate[idx].ToString(), ldate[idx + 1].ToString(), pvm);
                if (temp.LastYields.Count > 0)
                {
                    ret.Add(temp);
                }
            }
            return(ret);
        }
        public static List <ProjectYieldViewModule> GetYieldByBRNum(string pjkey, string BRNUM, ProjectViewModels pvm, Cache mycache, string yieldtype)
        {
            var retlist = new List <ProjectYieldViewModule>();

            var brs = BRNUM.Split(new string[] { ";", ",", " " }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var br in brs)
            {
                var ret = new ProjectYieldViewModule();
                ret.ProjectKey = pjkey;

                var plist = ProjectTestData.RetrieveProjectTestDataByBR(pjkey, br, yieldtype, false, mycache);

                var tplist    = new List <ProjectTestData>();
                var datacount = plist.Count - 1;
                for (int idx = datacount; idx >= 0; idx--)
                {
                    tplist.Add(plist[idx]);
                }

                RetrieveFirstYield(ret, tplist, pvm);

                RetrieveCummYield(ret, plist, pvm);

                if (ret.FirstYields.Count > 0)
                {
                    ret.XKey = br;
                    retlist.Add(ret);
                }
            }

            return(retlist);
        }
        public static ProjectYieldViewModule GetYieldByDateRange(string pjkey, string sdate, string edate, ProjectViewModels pvm, Cache mycache)
        {
            var ret = new ProjectYieldViewModule();

            ret.ProjectKey = pjkey;
            ret.StartDate  = DateTime.Parse(sdate);
            ret.EndDate    = DateTime.Parse(edate);

            var startdate = DateTime.Parse(DateTime.Parse(sdate).ToString("yyyy-MM-dd") + " 07:30:00").ToString();
            var enddate   = DateTime.Parse(DateTime.Parse(edate).ToString("yyyy-MM-dd") + " 07:30:00").ToString();

            if (startdate == enddate)
            {
                return(ret);
            }

            var plist = ProjectTestData.RetrieveProjectTestData(pjkey, startdate, DateTime.Parse(enddate).AddYears(5).ToString(), false, mycache);

            if (plist.Count == 0)
            {
                return(ret);
            }


            var fdatalist = new List <ProjectTestData>();
            var enddatet  = DateTime.Parse(enddate);

            foreach (var item in plist)
            {
                if (enddatet >= item.TestTimeStamp)
                {
                    fdatalist.Add(item);
                }
            }

            //var fdatalist = ProjectTestData.RetrieveProjectTestData(pjkey, startdate, enddate, false);
            RetrieveRealTimeYield(ret, fdatalist, pvm);

            var tplist    = new List <ProjectTestData>();
            var datacount = fdatalist.Count - 1;

            for (int idx = datacount; idx >= 0; idx--)
            {
                tplist.Add(fdatalist[idx]);
            }

            //var tplist = ProjectTestData.RetrieveProjectTestData(pjkey, startdate, enddate, true);

            var snstationdict = ProjectTestData.RetrieveSNBeforeDateWithStation(pjkey, startdate, mycache);
            var sndict        = new Dictionary <string, bool>();

            foreach (var kvpair in snstationdict)
            {
                var endindex = kvpair.Key.LastIndexOf('-');
                var sn       = kvpair.Key.Substring(0, endindex);
                if (!sndict.ContainsKey(sn))
                {
                    sndict.Add(sn, true);
                }
            }


            //var sndict = ProjectTestData.RetrieveSNBeforeDate(pjkey, startdate);
            var validatedict = new Dictionary <string, bool>();

            foreach (var item in tplist)
            {
                if (!sndict.ContainsKey(item.ModuleSerialNum))
                {
                    if (!validatedict.ContainsKey(item.ModuleSerialNum))
                    {
                        validatedict.Add(item.ModuleSerialNum, true);
                    }
                }
            }

            //var plist = ProjectTestData.RetrieveProjectTestData(pjkey, startdate,DateTime.Parse(enddate).AddYears(5).ToString(), false);
            var filteredPjData2 = new List <ProjectTestData>();

            foreach (var item in plist)
            {
                if (validatedict.ContainsKey(item.ModuleSerialNum))
                {
                    filteredPjData2.Add(item);
                }
            }
            RetrieveSNYield(ret, filteredPjData2, pvm);


            //plist = ProjectTestData.RetrieveProjectTestData(pjkey, startdate, enddate, true);
            //snlist = ProjectTestData.RetrieveSNBeforeDateWithStation(pjkey, startdate);
            validatedict = new Dictionary <string, bool>();
            var filteredPjData = new List <ProjectTestData>();

            foreach (var item in tplist)
            {
                if (!snstationdict.ContainsKey(item.ModuleSerialNum + "-" + item.WhichTest))
                {
                    filteredPjData.Add(item);
                    if (!validatedict.ContainsKey(item.ModuleSerialNum))
                    {
                        validatedict.Add(item.ModuleSerialNum, true);
                    }
                }
            }

            RetrieveFirstYield(ret, filteredPjData, pvm);


            //plist = ProjectTestData.RetrieveProjectTestData(pjkey, startdate, enddate, false);
            filteredPjData2 = new List <ProjectTestData>();
            foreach (var item in fdatalist)
            {
                if (validatedict.ContainsKey(item.ModuleSerialNum))
                {
                    filteredPjData2.Add(item);
                }
            }

            RetrieveCummYield(ret, filteredPjData2, pvm);

            plist.Clear();
            snstationdict.Clear();
            sndict.Clear();
            validatedict.Clear();
            GC.Collect();
            GC.WaitForPendingFinalizers();

            return(ret);
        }
        private static void RetrieveCummYield(ProjectYieldViewModule pyvm, List <ProjectTestData> plist, ProjectViewModels pvm)
        {
            var yielddict = new Dictionary <string, TestYield>();
            var sndict    = new Dictionary <string, bool>();

            foreach (var p in plist)
            {
                if (!sndict.ContainsKey(p.WhichTest + ":" + p.ModuleSerialNum))
                {
                    sndict.Add(p.WhichTest + ":" + p.ModuleSerialNum, true);
                    if (yielddict.ContainsKey(p.WhichTest))
                    {
                        yielddict[p.WhichTest].InputCount = yielddict[p.WhichTest].InputCount + 1;
                        if (string.Compare(p.ErrAbbr, "PASS", true) == 0)
                        {
                            yielddict[p.WhichTest].OutputCount = yielddict[p.WhichTest].OutputCount + 1;
                        }
                        RegisterError(p.ErrAbbr, p.WhichTest, pyvm.LErrorMap);
                    }
                    else
                    {
                        var tempyield = new TestYield();
                        tempyield.InputCount = 1;
                        if (string.Compare(p.ErrAbbr, "PASS", true) == 0)
                        {
                            tempyield.OutputCount = 1;
                        }
                        else
                        {
                            tempyield.OutputCount = 0;
                        }
                        tempyield.WhichTest = p.WhichTest;

                        RegisterError(p.ErrAbbr, p.WhichTest, pyvm.LErrorMap);
                        yielddict.Add(p.WhichTest, tempyield);
                    }
                }
            }

            if (pvm.SumDatasetList.Count > 0)
            {
                foreach (var s in pvm.SumDatasetList)
                {
                    if (yielddict.ContainsKey(s.Station))
                    {
                        pyvm.LastYields.Add(yielddict[s.Station]);
                    }
                }
            }
            else if (pvm.StationList.Count > 0)
            {
                foreach (var s in pvm.StationList)
                {
                    if (yielddict.ContainsKey(s.Station))
                    {
                        pyvm.LastYields.Add(yielddict[s.Station]);
                    }
                }
            }
        }
Example #13
0
        public static ProjectBIYieldViewModule GetYieldByDateRange(string pjkey, string sdate, string edate, ProjectViewModels pvm)
        {
            var ret = new ProjectBIYieldViewModule();

            ret.ProjectKey = pjkey;
            ret.StartDate  = DateTime.Parse(sdate);
            ret.EndDate    = DateTime.Parse(edate);

            var startdate = DateTime.Parse(DateTime.Parse(sdate).ToString("yyyy-MM-dd") + " 07:30:00").ToString();
            var enddate   = DateTime.Parse(DateTime.Parse(edate).ToString("yyyy-MM-dd") + " 07:30:00").ToString();

            if (startdate == enddate)
            {
                return(ret);
            }

            var plist        = BITestData.RetrieveProjectTestData(pjkey, startdate, enddate, true);
            var snlist       = BITestData.RetrieveSNBeforeDate(pjkey, startdate);
            var validatedict = new Dictionary <string, bool>();

            foreach (var item in plist)
            {
                if (!snlist.ContainsKey(item.ModuleSerialNum + "-" + item.WhichTest))
                {
                    if (!validatedict.ContainsKey(item.ModuleSerialNum))
                    {
                        validatedict.Add(item.ModuleSerialNum, true);
                    }
                }
            }

            plist = BITestData.RetrieveProjectTestData(pjkey, startdate, DateTime.Parse(enddate).AddYears(5).ToString(), false);
            var filteredPjData2 = new List <BITestData>();

            foreach (var item in plist)
            {
                if (validatedict.ContainsKey(item.ModuleSerialNum))
                {
                    filteredPjData2.Add(item);
                }
            }

            RetrieveCummYield(ret, filteredPjData2);

            return(ret);
        }
Example #14
0
        public static void UpdateProjectData(ProjectViewModels vm, string starttime, string endtime)
        {
            try
            {
                if (vm.StationList.Count > 0 &&
                    vm.TabList.Count > 0 &&
                    vm.PNList.Count > 0)
                {
                    var failurelist = new List <ProjectTestData>();
                    var passlist    = new List <ProjectTestData>();

                    bool bondinged = false;
                    if (ProjectTestData.RetrieveLatestTimeOfLocalProject(vm.ProjectKey) != null)
                    {
                        bondinged = true;
                    }

                    var bondingeddatadict = new Dictionary <string, bool>();
                    if (bondinged)
                    {
                        bondingeddatadict = ProjectTestData.RetrieveAllDataID(vm.ProjectKey);
                    }

                    var sqls = RetrieveSqlFromProjectModel(vm);
                    foreach (var s in sqls)
                    {
                        if (string.IsNullOrEmpty(s.Value))
                        {
                            continue;
                        }

                        var sndict = new Dictionary <string, bool>();
                        var sql    = s.Value.Replace("<TIMECOND>", "and TestTimeStamp > '" + starttime + "' and TestTimeStamp < '" + endtime + "'");
                        var dbret  = DBUtility.ExeMESSqlWithRes(sql);
                        foreach (var item in dbret)
                        {
                            try
                            {
                                var tempdata = new ProjectTestData(vm.ProjectKey, Convert.ToString(item[0]), Convert.ToString(item[1])
                                                                   , s.Key, Convert.ToString(item[3]), Convert.ToString(item[4])
                                                                   , Convert.ToString(item[5]), Convert.ToString(item[6]), Convert.ToString(item[7]));
                                tempdata.JO = Convert.ToString(item[8]);

                                if (!bondinged)
                                {
                                    tempdata.StoreProjectTestData();

                                    if (!sndict.ContainsKey(tempdata.ModuleSerialNum))
                                    {
                                        sndict.Add(tempdata.ModuleSerialNum, true);
                                        if (string.Compare(tempdata.ErrAbbr, "PASS", true) != 0)
                                        {
                                            var ekey    = ProjectErrorViewModels.GetUniqKey();
                                            var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, tempdata.ErrAbbr, "", 1);
                                            pjerror.Reporter    = "System";
                                            pjerror.Description = "";
                                            pjerror.AddandUpdateProjectError();

                                            failurelist.Add(tempdata);
                                        }
                                        else
                                        {
                                            passlist.Add(tempdata);
                                        }
                                    }
                                }
                                else
                                {
                                    if (!bondingeddatadict.ContainsKey(tempdata.DataID))
                                    {
                                        bondingeddatadict.Add(tempdata.DataID, true);

                                        tempdata.StoreProjectTestData();

                                        if (!sndict.ContainsKey(tempdata.ModuleSerialNum))
                                        {
                                            sndict.Add(tempdata.ModuleSerialNum, true);
                                            if (string.Compare(tempdata.ErrAbbr, "PASS", true) != 0)
                                            {
                                                var ekey    = ProjectErrorViewModels.GetUniqKey();
                                                var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, tempdata.ErrAbbr, "", 1);
                                                pjerror.Reporter    = "System";
                                                pjerror.Description = "";
                                                pjerror.AddandUpdateProjectError();

                                                failurelist.Add(tempdata);
                                            }
                                            else
                                            {
                                                passlist.Add(tempdata);
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            { }
                        }
                    }

                    if (vm.FinishRating < 90 && DateTime.Parse(starttime) != vm.StartDate)
                    {
                        //use latest failure cover previous failure
                        foreach (var item in failurelist)
                        {
                            IssueViewModels.CloseIssueAutomaticllyWithFailedSN(item.ProjectKey, item.ModuleSerialNum, item.WhichTest, item.TestStation, item.TestTimeStamp.ToString("yyyy-MM-dd hh:mm:ss"));
                        }

                        CreateSystemIssues(failurelist);
                    }

                    if (vm.FinishRating < 90 && DateTime.Parse(starttime) != vm.StartDate)
                    {
                        //use pass sn cover previous failure
                        foreach (var item in passlist)
                        {
                            IssueViewModels.CloseIssueAutomaticlly(item.ProjectKey, item.ModuleSerialNum, item.WhichTest, item.TestStation, item.TestTimeStamp.ToString("yyyy-MM-dd hh:mm:ss"));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #15
0
        public static void StartProjectBonding(ProjectViewModels vm)
        {
            try
            {
                if (ProjectTestData.UpdatePJLockUsing(vm.ProjectKey))
                {
                    return;
                }


                if (vm.StationList.Count > 0 &&
                    vm.TabList.Count > 0 &&
                    vm.PNList.Count > 0)
                {
                    var failurelist = new List <ProjectTestData>();


                    bool bondinged = false;
                    if (ProjectTestData.RetrieveLatestTimeOfLocalProject(vm.ProjectKey) != null)
                    {
                        bondinged = true;
                    }

                    var bondingeddatadict = new Dictionary <string, bool>();
                    if (bondinged)
                    {
                        bondingeddatadict = ProjectTestData.RetrieveAllDataID(vm.ProjectKey);
                    }

                    var sqls = RetrieveSqlFromProjectModel(vm);
                    foreach (var s in sqls)
                    {
                        if (string.IsNullOrEmpty(s.Value))
                        {
                            continue;
                        }

                        var sndict = new Dictionary <string, bool>();
                        var sql    = s.Value.Replace("<TIMECOND>", "and TestTimeStamp > '" + vm.StartDate.ToString() + "' and TestTimeStamp < '" + DateTime.Now.ToString() + "'");
                        var dbret  = DBUtility.ExeMESSqlWithRes(sql);
                        foreach (var item in dbret)
                        {
                            try
                            {
                                var tempdata = new ProjectTestData(vm.ProjectKey, Convert.ToString(item[0]), Convert.ToString(item[1])
                                                                   , s.Key, Convert.ToString(item[3]), Convert.ToString(item[4])
                                                                   , Convert.ToString(item[5]), Convert.ToString(item[6]), Convert.ToString(item[7]));
                                tempdata.JO = Convert.ToString(item[8]);

                                if (!bondinged)
                                {
                                    tempdata.StoreProjectTestData();

                                    if (!sndict.ContainsKey(tempdata.ModuleSerialNum))
                                    {
                                        sndict.Add(tempdata.ModuleSerialNum, true);
                                        if (string.Compare(tempdata.ErrAbbr, "PASS", true) != 0)
                                        {
                                            var ekey    = ProjectErrorViewModels.GetUniqKey();
                                            var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, tempdata.ErrAbbr, "", 1);
                                            pjerror.Reporter    = "System";
                                            pjerror.Description = "";
                                            pjerror.AddandUpdateProjectError();

                                            failurelist.Add(tempdata);
                                        }
                                    }
                                }
                                else
                                {
                                    if (!bondingeddatadict.ContainsKey(tempdata.DataID))
                                    {
                                        bondingeddatadict.Add(tempdata.DataID, true);
                                        tempdata.StoreProjectTestData();

                                        if (!sndict.ContainsKey(tempdata.ModuleSerialNum))
                                        {
                                            sndict.Add(tempdata.ModuleSerialNum, true);
                                            if (string.Compare(tempdata.ErrAbbr, "PASS", true) != 0)
                                            {
                                                var ekey    = ProjectErrorViewModels.GetUniqKey();
                                                var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, tempdata.ErrAbbr, "", 1);
                                                pjerror.Reporter    = "System";
                                                pjerror.Description = "";
                                                pjerror.AddandUpdateProjectError();

                                                failurelist.Add(tempdata);
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            { }
                        }
                    }

                    //if (vm.FinishRating < 90)
                    //{
                    //    CreateSystemIssues(failurelist);
                    //}
                }

                ProjectTestData.ResetUpdatePJLock(vm.ProjectKey);
            }
            catch (Exception ex)
            {
                ProjectTestData.ResetUpdatePJLock(vm.ProjectKey);
            }
        }
Example #16
0
        public static void StartProjectBonding(Controller ctrl, ProjectViewModels vm)
        {
            var vtab = new List <string>();

            vtab.Add("dbo.PRLL_VcselInfoSummary_2016");
            vtab.Add("dbo.PRLL_VcselInfoSummary_2017");
            foreach (var vt in vtab)
            {
                try
                {
                    if (BITestData.UpdatePJLockUsing(vm.ProjectKey))
                    {
                        return;
                    }

                    if (vm.PNList.Count > 0)
                    {
                        var bondeddatadict = BITestData.RetrieveAllDataID(vm.ProjectKey);

                        //var failurelist = new List<BITestData>();
                        var sql    = "select ModuleSerialNum,Step,ModuleType,ErrAbbr,TestTimeStamp,TestStation,ModulePartNum,wafer,waferpn from  " + vt + "(nolock) where wafer <> 'NULL' and waferpn  <> 'NULL' and ErrAbbr  <> 'NULL' and ModulePartNum in <PNCOND> and TestTimeStamp > '<TIMECOND>'  and TestTimeStamp < '" + DateTime.Now.ToString() + "' order by TestTimeStamp Desc,ModuleSerialNum";
                        var pncond = PNCondition(vm.PNList);

                        if (string.IsNullOrEmpty(pncond))
                        {
                            BITestData.ResetUpdatePJLock(vm.ProjectKey);
                            return;
                        }

                        sql = sql.Replace("<PNCOND>", pncond).Replace("<TIMECOND>", vm.StartDate.ToString());

                        var tempdataiddict = new Dictionary <string, BITestData>();
                        var dbret          = DBUtility.ExePRLSqlWithRes(ctrl, sql);
                        foreach (var line in dbret)
                        {
                            var tempid = ConvertString(line[0]) + "_" + ConvertString(line[1]);

                            if (bondeddatadict.ContainsKey(tempid))
                            {
                                if (DateTime.Parse(ConvertString(line[4])) <= bondeddatadict[tempid])
                                {
                                    continue;
                                }
                            }

                            if (tempdataiddict.ContainsKey(tempid))
                            {
                                if (DateTime.Parse(ConvertString(line[4])) == tempdataiddict[tempid].TestTimeStamp)
                                {
                                    if (string.Compare(ConvertString(line[3]), "Pass", true) != 0)
                                    {
                                        tempdataiddict[tempid].ErrAbbr = ConvertString(line[3]);

                                        var ekey    = ProjectErrorViewModels.GetUniqKey();
                                        var pjerror = new ProjectErrorViewModels(ProjectErrorViewModels.BURNIN, ekey, ConvertString(line[3]), "", 1);
                                        pjerror.Reporter    = "System";
                                        pjerror.Description = "";
                                        pjerror.AddandUpdateProjectError();
                                    }
                                }    //same time
                            }
                            else
                            {
                                var tempdata = new BITestData();
                                tempdata.DataID          = GetUniqKey();
                                tempdata.ProjectKey      = vm.ProjectKey;
                                tempdata.ModuleSerialNum = ConvertString(line[0]);
                                tempdata.WhichTest       = ConvertString(line[1]);
                                tempdata.ModuleType      = ConvertString(line[2]);
                                tempdata.ErrAbbr         = ConvertString(line[3]);
                                tempdata.TestTimeStamp   = DateTime.Parse(ConvertString(line[4]));
                                tempdata.TestStation     = ConvertString(line[5]);
                                tempdata.PN      = ConvertString(line[6]);
                                tempdata.Wafer   = ConvertString(line[7]);
                                tempdata.Waferpn = ConvertString(line[8]);

                                tempdataiddict.Add(tempid, tempdata);
                            }
                        }    //end foreach

                        foreach (var kv in tempdataiddict)
                        {
                            kv.Value.StoreBIData();
                        }    //end foreach
                    }

                    BITestData.ResetUpdatePJLock(vm.ProjectKey);
                }
                catch (Exception ex)
                {
                    BITestData.ResetUpdatePJLock(vm.ProjectKey);
                }
            }
        }
Example #17
0
        public static void RetrievePjWaferAllData(Controller ctrl, ProjectViewModels vm)
        {
            var vtab = new List <string>();

            vtab.Add("dbo.PRLL_VcselInfoSummary_2016");
            vtab.Add("dbo.PRLL_VcselInfoSummary_2017");
            foreach (var vt in vtab)
            {
                try
                {
                    var wafers = BITestData.RetrieveAllWafer(vm.ProjectKey);
                    if (vm.PNList.Count > 0 && wafers.Count > 0)
                    {
                        var failurelist = new List <BITestData>();
                        var failuredict = new Dictionary <string, bool>();
                        var passlist    = new List <BITestData>();

                        var starttime = vm.StartDate.ToString();

                        var sql    = "select ModuleSerialNum,Step,ModuleType,ErrAbbr,TestTimeStamp,TestStation,ModulePartNum,wafer,waferpn from  " + vt + "(nolock) where wafer in <WAFERCOND> and waferpn  <> 'NULL' and ErrAbbr  <> 'NULL' and ModulePartNum in <PNCOND> and TestTimeStamp <= '<TIMECOND>' order by TestTimeStamp Desc,ModuleSerialNum";
                        var pncond = PNCondition(vm.PNList);
                        if (string.IsNullOrEmpty(pncond))
                        {
                            return;
                        }
                        var wafercond = "('";
                        foreach (var w in wafers)
                        {
                            wafercond = wafercond + w + "','";
                        }
                        wafercond = wafercond.Substring(0, wafercond.Length - 2) + ")";

                        sql = sql.Replace("<PNCOND>", pncond).Replace("<TIMECOND>", starttime).Replace("<WAFERCOND>", wafercond);

                        var dbret = DBUtility.ExePRLSqlWithRes(ctrl, sql);
                        if (dbret.Count > 0)
                        {
                            var bondeddatadict = BITestData.RetrieveAllDataIDASC(vm.ProjectKey);
                            var tempdataiddict = new Dictionary <string, BITestData>();

                            foreach (var line in dbret)
                            {
                                var tempid = ConvertString(line[0]) + "_" + ConvertString(line[1]);

                                if (!bondeddatadict.ContainsKey(tempid))
                                {
                                    if (tempdataiddict.ContainsKey(tempid))
                                    {
                                        if (DateTime.Parse(ConvertString(line[4])) == tempdataiddict[tempid].TestTimeStamp)
                                        {
                                            if (string.Compare(ConvertString(line[3]), "Pass", true) != 0)
                                            {
                                                tempdataiddict[tempid].ErrAbbr = ConvertString(line[3]);

                                                if (!failuredict.ContainsKey(tempdataiddict[tempid].ModuleSerialNum))
                                                {
                                                    failuredict.Add(tempdataiddict[tempid].ModuleSerialNum, true);
                                                    failurelist.Add(tempdataiddict[tempid]);

                                                    var ekey    = ProjectErrorViewModels.GetUniqKey();
                                                    var pjerror = new ProjectErrorViewModels(ProjectErrorViewModels.BURNIN, ekey, ConvertString(line[3]), "", 1);
                                                    pjerror.Reporter    = "System";
                                                    pjerror.Description = "";
                                                    pjerror.AddandUpdateProjectError();
                                                }
                                            }
                                        }    //same time
                                    }
                                    else
                                    {
                                        var tempdata = new BITestData();
                                        tempdata.DataID          = GetUniqKey();
                                        tempdata.ProjectKey      = vm.ProjectKey;
                                        tempdata.ModuleSerialNum = ConvertString(line[0]);
                                        tempdata.WhichTest       = ConvertString(line[1]);
                                        tempdata.ModuleType      = ConvertString(line[2]);
                                        tempdata.ErrAbbr         = ConvertString(line[3]);
                                        tempdata.TestTimeStamp   = DateTime.Parse(ConvertString(line[4]));
                                        tempdata.TestStation     = ConvertString(line[5]);
                                        tempdata.PN      = ConvertString(line[6]);
                                        tempdata.Wafer   = ConvertString(line[7]);
                                        tempdata.Waferpn = ConvertString(line[8]);

                                        tempdataiddict.Add(tempid, tempdata);
                                    }
                                } //end if (!bondeddatadict.ContainsKey(tempid))
                            }     //end foreach

                            foreach (var kv in tempdataiddict)
                            {
                                kv.Value.StoreBIData();
                            } //end foreach
                        }     //end if (dbret.Count > 0)
                    }         //end if pn > 0
                }
                catch (Exception ex)
                {
                }
            }
        }
Example #18
0
        public static void StartProjectBonding(ProjectViewModels vm)
        {
            try
            {
                if (ProjectTestData.UpdatePJLockUsing(vm.ProjectKey))
                {
                    return;
                }


                if (vm.MDIDList.Count > 0 &&
                    vm.SumDatasetList.Count > 0)
                {
                    var dsdict = new Dictionary <string, bool>();
                    foreach (var item in vm.SumDatasetList)
                    {
                        dsdict.Add(item.Station, true);
                    }

                    var failurelist = new List <ProjectTestData>();


                    //(c.MODEL_ID like 'FTLX6871%' or c.MODEL_ID like 'FTLX6872%' or c.MODEL_ID like 'FTLX6672%')
                    var mdcond = "(";
                    foreach (var w in vm.MDIDList)
                    {
                        mdcond = mdcond + "c.MODEL_ID like '" + w.Pn.Trim() + "%' or ";
                    }
                    mdcond = mdcond.Substring(0, mdcond.Length - 4) + ")";


                    var s      = "SELECT a.MFR_SN,d.DATASET_NAME,c.FAMILY,d.STATUS,d.END_TIME,d.STATION,a.MFR_PN,d.ROUTE_ID FROM PARTS a INNER JOIN ROUTES b ON a.OPT_INDEX = b.PART_INDEX INNER JOIN BOM_CONTEXT_ID c ON c.BOM_CONTEXT_ID = b.BOM_CONTEXT_ID INNER JOIN DATASETS d ON b.ROUTE_ID = d.ROUTE_ID WHERE <mdcond> and d.END_TIME > '<TIMECOND>'  ORDER BY d.ROUTE_ID,d.END_TIME DESC";
                    var sndict = new Dictionary <string, bool>();
                    var sql    = s.Replace("<TIMECOND>", vm.StartDate.ToString("yyyyMMddhhmmss")).Replace("<mdcond>", mdcond);


                    var currentroutid       = "";
                    var currentroutedsnames = new List <ProjectStation>();
                    var pjdatalist          = new List <ProjectTestData>();

                    var dbret = DBUtility.ExeATESqlWithRes(sql);

                    foreach (var item in dbret)
                    {
                        try
                        {
                            var status      = Convert.ToString(item[3]);
                            var ds          = Convert.ToString(item[1]);
                            var temprouteid = Convert.ToString(item[7]);

                            if (string.Compare(currentroutid, temprouteid) != 0)
                            {
                                currentroutid = temprouteid;

                                if (pjdatalist.Count > 0)
                                {
                                    FindErrAbbr(pjdatalist, currentroutedsnames, dsdict);

                                    foreach (var pjdata in pjdatalist)
                                    {
                                        pjdata.StoreProjectTestData();
                                    }

                                    if (string.Compare(pjdatalist[0].ErrAbbr, "PASS", true) != 0)
                                    {
                                        if (!sndict.ContainsKey(pjdatalist[0].ModuleSerialNum))
                                        {
                                            sndict.Add(pjdatalist[0].ModuleSerialNum, true);

                                            failurelist.Add(pjdatalist[0]);

                                            var ekey    = ProjectErrorViewModels.GetUniqKey();
                                            var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, pjdatalist[0].ErrAbbr, "", 1);
                                            pjerror.Reporter    = "System";
                                            pjerror.Description = "";
                                            pjerror.AddandUpdateProjectError();
                                        }
                                    }
                                    else
                                    {
                                        if (!sndict.ContainsKey(pjdatalist[0].ModuleSerialNum))
                                        {
                                            sndict.Add(pjdatalist[0].ModuleSerialNum, true);
                                        }
                                    }
                                }//end if (tempdata != null)

                                pjdatalist.Clear();
                                currentroutedsnames.Clear();
                                currentroutedsnames.Add(new ProjectStation(ds, status));
                            }
                            else //if (tempdata != null)
                            {
                                currentroutedsnames.Add(new ProjectStation(ds, status));
                            }

                            if (dsdict.ContainsKey(ds))
                            {
                                var spdatetime = Convert.ToString(item[4]);
                                var stdtime    = spdatetime.Substring(0, 4) + "-" + spdatetime.Substring(4, 2) + "-" + spdatetime.Substring(6, 2) + " "
                                                 + spdatetime.Substring(8, 2) + ":" + spdatetime.Substring(10, 2) + ":" + spdatetime.Substring(12, 2);

                                //(string pk, string did, string sn, string wtest, string mt, string err, string testtime, string station, string p)
                                var tempdata = new ProjectTestData(vm.ProjectKey, GetUniqKey(), Convert.ToString(item[0])
                                                                   , Convert.ToString(item[1]), Convert.ToString(item[2]), Convert.ToString(item[3]).ToUpper()
                                                                   , stdtime, Convert.ToString(item[5]), Convert.ToString(item[6]));

                                pjdatalist.Add(tempdata);
                            }
                        }
                        catch (Exception ex)
                        { }
                    }    //end for each

                    if (pjdatalist.Count > 0)
                    {
                        FindErrAbbr(pjdatalist, currentroutedsnames, dsdict);

                        foreach (var pjdata in pjdatalist)
                        {
                            pjdata.StoreProjectTestData();
                        }

                        if (string.Compare(pjdatalist[0].ErrAbbr, "PASS", true) != 0)
                        {
                            if (!sndict.ContainsKey(pjdatalist[0].ModuleSerialNum))
                            {
                                sndict.Add(pjdatalist[0].ModuleSerialNum, true);

                                failurelist.Add(pjdatalist[0]);

                                var ekey    = ProjectErrorViewModels.GetUniqKey();
                                var pjerror = new ProjectErrorViewModels(vm.ProjectKey, ekey, pjdatalist[0].ErrAbbr, "", 1);
                                pjerror.Reporter    = "System";
                                pjerror.Description = "";
                                pjerror.AddandUpdateProjectError();
                            }
                        }
                        else
                        {
                            if (!sndict.ContainsKey(pjdatalist[0].ModuleSerialNum))
                            {
                                sndict.Add(pjdatalist[0].ModuleSerialNum, true);
                            }
                        }
                    } //end if (tempdata != null)
                }     // if model list > 0

                ProjectTestData.ResetUpdatePJLock(vm.ProjectKey);
            }
            catch (Exception ex)
            {
                ProjectTestData.ResetUpdatePJLock(vm.ProjectKey);
            }
        }