Example #1
0
 public void Search(string str)
 {
     FileterFileList.Clear();
     if (!string.IsNullOrWhiteSpace(str))
     {
         foreach (var sf in CurrentFileList)
         {
             if (sf.Name.ToLower().Contains(str.ToLower()))
             {
                 FileterFileList.Add(sf);
             }
         }
     }
     else
     {
         foreach (var sf in CurrentFileList)
         {
             FileterFileList.Add(sf);
         }
     }
 }
Example #2
0
        //连接数据库
        public void  getCurrentFileData()
        {
            if (CurrentFileList != null)
            {
                CurrentFileList.Clear();
                FileterFileList.Clear();
            }
            else
            {
                CurrentFileList = new ObservableCollection <StateFileModel>();
                FileterFileList = new ObservableCollection <StateFileModel>();
            }
            if (DataUtils.StaticInfo.MesMode.ToLower() == "true")
            {
                string ateKind   = DataUtils.StaticInfo.ATEKind;
                string terminal  = (new ViewModelLocator()).MainWindow.StatusInfo.Terminal;
                string material  = (new ViewModelLocator()).MainWindow.StatusInfo.Material;
                string processid = (new ViewModelLocator()).MainWindow.StatusInfo.Process;
                if (DataUtils.StaticInfo.ATEStatusFile.ToUpper() == "TRUE")
                {
                    if ((new ViewModelLocator()).MainWindow.StatusInfo.IsAdmin)
                    {
                        GetAllFileData();
                    }
                    else
                    {
                        string strSql      = @"select PROCESSName from SYS_PROCESS where PROCESSID='{0}'";
                        string processName = DataUtils.DB.GetSingleValueFromSQL(string.Format(strSql, processid)).ToString();

                        string    sql    = @"select * from (SELECT 类型,产品,ISNULL(B.PROCESSNAME,'') 工序,文件名,更新时间,更新人员,审核人员,审核时间,是否审核 FROM (
                                   SELECT A.ATEKIND 类型,A.MATERIALHANDLE 产品,A.PROCESS,A.MATERIALHANDLE+'-'+A.PROCESS 文件名,CONVERT(VARCHAR(100), A.UPDATETIME, 120) 更新时间,A.UPDATEUSER 更新人员,A.CONFIRMUSER 审核人员,
                                   CONVERT(VARCHAR(100), A.CONFIRMTIME, 120) 审核时间,ISNULL(A.CONFIRMSTATUS,'N') 是否审核 
                                   FROM ATE_STATUS_FILE A 
                                   UNION
                                   SELECT 'ATES' 类型,
                                   CASE WHEN CHARINDEX(C.PROCESSID,B.FILENAME)>0 THEN LEFT(B.FILENAME,LEN(B.FILENAME)-LEN(C.PROCESSID )-1) ELSE B.FILENAME END 产品, 
                                   C.PROCESSID ,B.FILENAME 文件名,CONVERT(VARCHAR(100), B.UPDATETIME, 120) 更新时间,B.UPDATEUSER 更新人员,B.CONFIRMUSER 审核人员,
                                   CONVERT(VARCHAR(100), B.CONFIRMTIME, 120) 审核时间,ISNULL(B.CONFIRMSTATUS,'N') 是否审核 
                                   FROM  G_TEST_STATUS B,(SELECT DISTINCT SHOPORDER,PROCESSID,STATUSID FROM G_ASSIGN_SHOPORDER_TEST_STATUS WHERE PROCESSID IS NOT NULL AND STATUSID<>'') C WHERE B.FILENAME=C.STATUSID
                                   ) A LEFT JOIN SYS_PROCESS B ON A.PROCESS=B.PROCESSID) A
                                   where A.类型='{0}' and A.工序='{1}' and A.是否审核='Y'   ORDER BY 审核时间 DESC,更新时间 DESC";
                        DataTable dtFile = DataUtils.DB.GetDataSetFromSQL(string.Format(sql, ateKind, processName)).Tables[0];
                        if (dtFile.Rows.Count <= 0)
                        {
                            CurrentFileList = null; FileterFileList = null; return;
                        }
                        else
                        {
                            foreach (DataRow dr in dtFile.Rows)
                            {
                                string    SQLFile = @"select A.FileID, A.Material,A.IsFolder, A.PROCESS, datalength(StateData)/1024 SIZE,A.UpDateTime from SYS_TEST_PLAN A WHERE a.Material='{0}'  and  PROCESS='{1}'";
                                DataTable dtData  = DataUtils.DB.GetDataSetFromSQL(string.Format(SQLFile, Convert.ToString(dr["产品"]), processid)).Tables[0];
                                foreach (DataRow dRow in dtData.Rows)
                                {
                                    if (Convert.IsDBNull(dRow["SIZE"]))
                                    {
                                        dRow["SIZE"] = "0";
                                    }
                                    StateFileModel sf = new StateFileModel()
                                    {
                                        ID             = Convert.ToInt32(dRow["FileID"]),
                                        IsFolder       = Convert.ToChar(dRow["IsFolder"]) == 'Y' ? true : false,
                                        Name           = Convert.ToString(dRow["Material"]),
                                        UpdateDateTime = Convert.ToString(dRow["UpdateTime"]),
                                        FileProcess    = Convert.ToString(dRow["Process"]),
                                        FileSize       = Convert.ToString(dRow["SIZE"]) + "KB"
                                    };
                                    CurrentFileList.Add(sf);
                                    FileterFileList.Add(sf);
                                }
                            }
                        }
                    }
                }
                else
                {
                    GetAllFileData();
                }
            }
            else
            {
                GetATEModeFileData();
            }
        }