private ResPackage[] RefreshPackages( List <PathPackageTuple> ppts, ResPackage[] rps, string name) { if (ppts == null) { return(null); } if (rps == null) { return(this.LoadPackages(ppts, name)); } int i, count = rps.Length; bool flag; ResPackage rp; List <IResourceIndexEntry> rieList; List <ResPackage> results = new List <ResPackage>(); foreach (PathPackageTuple ppt in ppts) { if (ppt != null && ppt.Package != null) { flag = true; for (i = count - 1; i >= 0 && flag; i--) { rp = rps[i]; if (string.Equals(rp.Path, ppt.Path)) { flag = false; results.Add(rp); count--; if (i < count) { Array.Copy(rps, i + 1, rps, i, count - i); } rps[count] = null; } } if (flag) { rieList = ppt.Package.FindAll(this.mIsValid); if (rieList != null && rieList.Count > 0) { i = 0; rp = new ResPackage(ppt.Path, rieList.Count); foreach (IResourceIndexEntry rie in rieList) { rp.Entries[i++] = new ResEntry( rie.ResourceGroup, rie.Instance); } results.Add(rp); } } } } return(results.ToArray()); }
private ResPackage[] LoadPackages( List <PathPackageTuple> ppts, string name) { if (ppts == null) { return(null); } int i; ResPackage rp; List <IResourceIndexEntry> rieList; List <ResPackage> results = new List <ResPackage>(); string status = null; if (StatusMessage != null) { status = "Searching for " + this.mExt[0] + "(0x" + this.mTID.ToString("X8") + ") in " + name + " Package:\n"; } foreach (PathPackageTuple ppt in ppts) { if (ppt != null && ppt.Package != null) { if (StatusMessage != null) { StatusMessage(status + ppt.Path); } rieList = ppt.Package.FindAll(this.mIsValid); if (rieList != null && rieList.Count > 0) { i = 0; rp = new ResPackage(ppt.Path, rieList.Count); foreach (IResourceIndexEntry rie in rieList) { rp.Entries[i++] = new ResEntry( rie.ResourceGroup, rie.Instance); } results.Add(rp); } } } return(results.ToArray()); }
// Read and Handle the csv-Result File (Multi-Line) public static void HandleCSV_multiLine(object param) { HandleCSVParam hcsv_param = (HandleCSVParam)param; MetroTunnelDB database = new MetroTunnelDB(); int record_id = hcsv_param.record_id; string filepath = hcsv_param.filepath; MainWindow mw = hcsv_param.mw; FileStream fs = new FileStream(filepath, FileMode.Open, System.IO.FileAccess.Read); StreamReader sr = new StreamReader(fs); // Record the Line once string strline; string[] arrline = null; string[] tablehead = null; int columncount = 0; bool isfirst = true; int linecount = 0; // Multi-Line Param const int line_query_once = 50; List <ResPackage> LinePackList = new List <ResPackage>(); while ((strline = sr.ReadLine()) != null) { //Handle one line each time ResPackage LinePack = new ResPackage(); LinePack.x = new float[DataRows]; LinePack.y = new float[DataRows]; //CalResPackage LineCalPack = new CalResPackage(); //LineCalPack.s = new float[DataRows]; //LineCalPack.a = new float[DataRows]; arrline = strline.Split(','); if (isfirst) { columncount = arrline.Length; isfirst = false; } for (int i = 0; i < columncount; i++) { try { //SerialNum if (i == 0) { LinePack.SerialNum = arrline[0].ToCharArray(); } //Timestamp else if (i == 1) { LinePack.Timestamp = Convert.ToInt32(arrline[1]); } else { int count = i / 2 - 1; //x if (i % 2 == 0) { LinePack.x[count] = Convert.ToSingle(arrline[i]); } //y else { // LinePack.y[count] = Convert.ToSingle(arrline[i]); LinePack.y[count] = Convert.ToSingle(count); } } } catch (System.NullReferenceException) { //SerialNum if (i == 0) { continue; } //Timestamp else if (i == 1) { continue; } else { int count = i / 2 - 1; //x if (i % 2 == 0) { LinePack.x[count] = 0; } //y else { LinePack.y[count] = 0; } } } catch (System.IndexOutOfRangeException) { //SerialNum if (i == 0) { continue; } //Timestamp else if (i == 1) { continue; } else { int count = i / 2 - 1; //x if (i % 2 == 0) { LinePack.x[count] = 0; } //y else { LinePack.y[count] = 0; } } } } LinePackList.Add(LinePack); //Convert to s-a //bool ret = false; //ret = ModelHandler.ConvertRes(LinePack, ref LineCalPack); //if (!ret) //{ // Console.WriteLine("Covertion Failed ! ! !\n"); //} if (LinePackList.Count % line_query_once == 0) { DataRaw[] dataRaws = new DataRaw[LinePackList.Count]; for (int l = 0; l < LinePackList.Count; l++) { //Get DataRaw dataRaws[l] = new DataRaw(record_id, LinePackList[l].Timestamp, ConfigHandler.GetCameraNum(LinePackList[l].SerialNum), LinePackList[l].x, LinePackList[l].y); mw.line_counter++; } //Send to MySQL int retm = 0; try { retm = database.InsertIntoDataRaw(dataRaws); } catch (System.Exception) { mw.DebugWriteLine("截面数据库插入异常"); } if (!Convert.ToBoolean(retm)) { mw.DebugWriteLine("截面数据库插入异常"); } linecount = 0; LinePackList.Clear(); } // mw.SubProcessReport(mw.line_counter++); } if (LinePackList.Count > 0) { DataRaw[] dataRaws = new DataRaw[LinePackList.Count]; for (int l = 0; l < LinePackList.Count; l++) { //Get DataRaw dataRaws[l] = new DataRaw(record_id, LinePackList[l].Timestamp, ConfigHandler.GetCameraNum(LinePackList[l].SerialNum), LinePackList[l].x, LinePackList[l].y); mw.line_counter++; } //Send to MySQL int retm = 0; try { retm = database.InsertIntoDataRaw(dataRaws); } catch (System.Exception) { mw.DebugWriteLine("截面数据库插入异常"); } if (!Convert.ToBoolean(retm)) { mw.DebugWriteLine("截面数据库插入异常"); } } DataAnalyze.threadControlCounter += 1; }
private ResPackage[] RefreshPackages( List<PathPackageTuple> ppts, ResPackage[] rps, string name) { if (ppts == null) { return null; } if (rps == null) { return this.LoadPackages(ppts, name); } int i, count = rps.Length; bool flag; ResPackage rp; List<IResourceIndexEntry> rieList; List<ResPackage> results = new List<ResPackage>(); foreach (PathPackageTuple ppt in ppts) { if (ppt != null && ppt.Package != null) { flag = true; for (i = count - 1; i >= 0 && flag; i--) { rp = rps[i]; if (string.Equals(rp.Path, ppt.Path)) { flag = false; results.Add(rp); count--; if (i < count) Array.Copy(rps, i + 1, rps, i, count - i); rps[count] = null; } } if (flag) { rieList = ppt.Package.FindAll(this.mIsValid); if (rieList != null && rieList.Count > 0) { i = 0; rp = new ResPackage(ppt.Path, rieList.Count); foreach (IResourceIndexEntry rie in rieList) { rp.Entries[i++] = new ResEntry( rie.ResourceGroup, rie.Instance); } results.Add(rp); } } } } return results.ToArray(); }
private ResPackage[] LoadPackages( List<PathPackageTuple> ppts, string name) { if (ppts == null) { return null; } int i; ResPackage rp; List<IResourceIndexEntry> rieList; List<ResPackage> results = new List<ResPackage>(); string status = null; if (StatusMessage != null) { status = "Searching for " + this.mExt[0] + "(0x" + this.mTID.ToString("X8") + ") in " + name + " Package:\n"; } foreach (PathPackageTuple ppt in ppts) { if (ppt != null && ppt.Package != null) { if (StatusMessage != null) { StatusMessage(status + ppt.Path); } rieList = ppt.Package.FindAll(this.mIsValid); if (rieList != null && rieList.Count > 0) { i = 0; rp = new ResPackage(ppt.Path, rieList.Count); foreach (IResourceIndexEntry rie in rieList) { rp.Entries[i++] = new ResEntry( rie.ResourceGroup, rie.Instance); } results.Add(rp); } } } return results.ToArray(); }