static public async Task <ObservableCollection <ClassSob> > OpenP() { ObservableCollection <ClassSob> classSobsC = new ObservableCollection <ClassSob>(); try { var picker = new Windows.Storage.Pickers.FileOpenPicker(); picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail; picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".uranprog"); picker.FileTypeFilter.Add(".xml"); Windows.Storage.StorageFile file = await picker.PickSingleFileAsync(); if (file != null) { // Application now has read/write access to the picked file // this.textBlock.Text = "Picked photo: " + file.Name; // } // else // { // this.textBlock.Text = "Operation cancelled."; // } // var folderPicker = new Windows.Storage.Pickers.FolderPicker(); // folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop; // folderPicker.FileTypeFilter.Add("*"); // Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync(); // if (folder != null) // { // Application now has read/write access to all contents in the picked folder // (including other sub-folder contents) // Windows.Storage.AccessCache.StorageApplicationPermissions. // FutureAccessList.AddOrReplace("PickedFolderToken", folder); // StorageFolder storageFolder = ApplicationData.Current.LocalFolder; using (StreamReader writer = new StreamReader(await file.OpenStreamForReadAsync())) { DataSet ds = new DataSet(); ds.ReadXml(writer); // выбираем первую таблицу DataTable SobT = ds.Tables[0]; // перебор всех строк таблицы foreach (DataRow row in SobT.Rows) { Debug.WriteLine(row.ItemArray[0].ToString()); List <ClassSobNeutron> cll = new List <ClassSobNeutron>(); var cells = row.ItemArray; string[] strTime = row.ItemArray[3].ToString().Split('.'); // Debug.WriteLine(time1); DataTimeUR dataTimeUR = new DataTimeUR(0, 0, Convert.ToInt16(strTime[0]), Convert.ToInt16(strTime[1]), Convert.ToInt16(strTime[2]), Convert.ToInt16(strTime[3]), Convert.ToInt16(strTime[4]), Convert.ToInt16(strTime[5]), Convert.ToInt16(strTime[6])); if (row.ItemArray[1].ToString().Contains("Test")) { string[] vs = row.ItemArray[1].ToString().Split("_"); string gg = vs[0] + "_" + vs[2]; dataTimeUR.corectTime(gg); } else { dataTimeUR.corectTime(row.ItemArray[1].ToString()); } int[] mA = new int[12]; for (int i = 0; i < 12; i++) { mA[i] = Convert.ToInt32(row.ItemArray[i + 6]); } int[] mT = new int[12]; for (int i = 0; i < 12; i++) { mT[i] = Convert.ToInt32(row.ItemArray[i + 54]); } double[] sT = new double[12]; for (int i = 0; i < 12; i++) { // MessageDialog messageDialog4 = new MessageDialog(row.ItemArray[i+30].ToString()+"\t"+i.ToString()); // await messageDialog4.ShowAsync(); sT[i] = Convert.ToDouble((row.ItemArray[i + 30].ToString().Replace(".", ","))); } if (Convert.ToInt32(row.ItemArray[5]) > 0) { DataTable dNeutron = ds.Tables[1]; foreach (DataRow rowN in dNeutron.Rows) { var cellsN = rowN.ItemArray; if ((row.ItemArray[1].ToString() == rowN.ItemArray[1].ToString()) && (dataTimeUR.TimeString() == rowN.ItemArray[4].ToString())) { cll.Add(new ClassSobNeutron() { D = Convert.ToInt32(rowN.ItemArray[2]), Amp = Convert.ToInt32(rowN.ItemArray[3]), TimeAmp = Convert.ToInt32(rowN.ItemArray[7]), TimeEnd = Convert.ToInt32(rowN.ItemArray[8]), TimeEnd3 = Convert.ToInt32(rowN.ItemArray[9]), TimeFirst = Convert.ToInt32(rowN.ItemArray[5]), TimeFirst3 = Convert.ToInt32(rowN.ItemArray[6]) }); } } } try { classSobsC.Add(new ClassSob() { nameFile = row.ItemArray[1].ToString(), nameklaster = row.ItemArray[2].ToString(), nameBAAK = "У1", time = dataTimeUR.TimeString(), mAmp = mA, dateUR = dataTimeUR, TimeS0 = Convert.ToString(row.ItemArray[54]), TimeS1 = Convert.ToString(row.ItemArray[55]), TimeS2 = Convert.ToString(row.ItemArray[56]), TimeS3 = Convert.ToString(row.ItemArray[57]), TimeS4 = Convert.ToString(row.ItemArray[58]), TimeS5 = Convert.ToString(row.ItemArray[59]), TimeS6 = Convert.ToString(row.ItemArray[60]), TimeS7 = Convert.ToString(row.ItemArray[61]), TimeS8 = Convert.ToString(row.ItemArray[62]), TimeS9 = Convert.ToString(row.ItemArray[63]), TimeS10 = Convert.ToString(row.ItemArray[64]), TimeS11 = Convert.ToString(row.ItemArray[65]), mTimeD = mT, sig0 = Convert.ToDouble((row.ItemArray[30].ToString().Replace(".", ","))), sig1 = Convert.ToDouble((row.ItemArray[31].ToString().Replace(".", ","))), sig2 = Convert.ToDouble((row.ItemArray[32].ToString().Replace(".", ","))), sig3 = Convert.ToDouble((row.ItemArray[33].ToString().Replace(".", ","))), sig4 = Convert.ToDouble((row.ItemArray[34].ToString().Replace(".", ","))), sig5 = Convert.ToDouble((row.ItemArray[35].ToString().Replace(".", ","))), sig6 = Convert.ToDouble((row.ItemArray[36].ToString().Replace(".", ","))), sig7 = Convert.ToDouble((row.ItemArray[37].ToString().Replace(".", ","))), sig8 = Convert.ToDouble((row.ItemArray[38].ToString().Replace(".", ","))), sig9 = Convert.ToDouble((row.ItemArray[39].ToString().Replace(".", ","))), sig10 = Convert.ToDouble((row.ItemArray[40].ToString().Replace(".", ","))), sig11 = Convert.ToDouble((row.ItemArray[41].ToString().Replace(".", ","))), Nnull0 = Convert.ToInt16(row.ItemArray[42]), Nnull1 = Convert.ToInt16(row.ItemArray[43]), Nnull2 = Convert.ToInt16(row.ItemArray[44]), Nnull3 = Convert.ToInt16(row.ItemArray[45]), Nnull4 = Convert.ToInt16(row.ItemArray[46]), Nnull5 = Convert.ToInt16(row.ItemArray[47]), Nnull6 = Convert.ToInt16(row.ItemArray[48]), Nnull7 = Convert.ToInt16(row.ItemArray[49]), Nnull8 = Convert.ToInt16(row.ItemArray[50]), Nnull9 = Convert.ToInt16(row.ItemArray[51]), Nnull10 = Convert.ToInt16(row.ItemArray[52]), Nnull11 = Convert.ToInt16(row.ItemArray[53]), classSobNeutronsList = cll }); } catch (Exception ex) { MessageDialog messageDialogf1 = new MessageDialog("dfsfs" + ex.ToString()); await messageDialogf1.ShowAsync(); } //booksTable.Columns.Add(idColumn); // booksTable.Columns.Add(FileColumn); //booksTable.Columns.Add(klColumn); // booksTable.Columns.Add(TimeColumn); // booksTable.Columns.Add(SAColumn); // booksTable.Columns.Add(SNColumn); /* booksTable.Columns.Add(AD1Column); * booksTable.Columns.Add(AD2Column); * booksTable.Columns.Add(AD3Column); * booksTable.Columns.Add(AD4Column); * booksTable.Columns.Add(AD5Column); * booksTable.Columns.Add(AD6Column); * booksTable.Columns.Add(AD7Column); * booksTable.Columns.Add(AD8Column); * booksTable.Columns.Add(AD9Column); * booksTable.Columns.Add(AD10Column); * booksTable.Columns.Add(AD11Column); * booksTable.Columns.Add(AD12Column); * * booksTable.Columns.Add(ND1Column); * booksTable.Columns.Add(ND2Column); * booksTable.Columns.Add(ND3Column); * booksTable.Columns.Add(ND4Column); * booksTable.Columns.Add(ND5Column); * booksTable.Columns.Add(ND6Column); * booksTable.Columns.Add(ND7Column); * booksTable.Columns.Add(ND8Column); * booksTable.Columns.Add(ND9Column); * booksTable.Columns.Add(ND10Column); * booksTable.Columns.Add(ND11Column); * booksTable.Columns.Add(ND12Column); * * booksTable.Columns.Add(Sig1Column); * booksTable.Columns.Add(Sig2Column); * booksTable.Columns.Add(Sig3Column); * booksTable.Columns.Add(Sig4Column); * booksTable.Columns.Add(Sig5Column); * booksTable.Columns.Add(Sig6Column); * booksTable.Columns.Add(Sig7Column); * booksTable.Columns.Add(Sig8Column); * booksTable.Columns.Add(Sig9Column); * booksTable.Columns.Add(Sig10Column); * booksTable.Columns.Add(Sig11Column); * booksTable.Columns.Add(Sig12Column); * * booksTable.Columns.Add(NullD1Column); * booksTable.Columns.Add(NullD2Column); * booksTable.Columns.Add(NullD3Column); * booksTable.Columns.Add(NullD4Column); * booksTable.Columns.Add(NullD5Column); * booksTable.Columns.Add(NullD6Column); * booksTable.Columns.Add(NullD7Column); * booksTable.Columns.Add(NullD8Column); * booksTable.Columns.Add(NullD9Column); * booksTable.Columns.Add(NullD10Column); * booksTable.Columns.Add(NullD11Column); * booksTable.Columns.Add(NullD12Column); * * booksTable.Columns.Add(TD1Column); * booksTable.Columns.Add(TD2Column); * booksTable.Columns.Add(TD3Column); * booksTable.Columns.Add(TD4Column); * booksTable.Columns.Add(TD5Column); * booksTable.Columns.Add(TD6Column); * booksTable.Columns.Add(TD7Column); * booksTable.Columns.Add(TD8Column); * booksTable.Columns.Add(TD9Column); * booksTable.Columns.Add(TD10Column); * booksTable.Columns.Add(TD11Column); * booksTable.Columns.Add(TD12Column); */ } } } else { } } catch (Exception ex) { MessageDialog messageDialogf = new MessageDialog(ex.ToString()); await messageDialogf.ShowAsync(); } return(classSobsC); }
static public async Task <ObservableCollection <ClassSob> > OpenP() { ObservableCollection <ClassSob> classSobsC = new ObservableCollection <ClassSob>(); try { var picker = new Windows.Storage.Pickers.FileOpenPicker(); picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail; picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".uranprog"); picker.FileTypeFilter.Add(".xml"); Windows.Storage.StorageFile file = await picker.PickSingleFileAsync(); if (file != null) { using (StreamReader writer = new StreamReader(await file.OpenStreamForReadAsync())) { DataSet ds = new DataSet(); int x = 0; using (XmlTextReader reader = new XmlTextReader(await file.OpenStreamForReadAsync())) { Debug.WriteLine("Start"); while (reader.Read()) { if (reader.IsStartElement("Sob") && !reader.IsEmptyElement) { while (reader.Read()) { if (reader.IsStartElement("Time") && !reader.IsEmptyElement) { Debug.WriteLine(x.ToString() + "\t" + reader.ReadString()); x++; } } } if (reader.IsStartElement("Project")) { Debug.WriteLine("ff" + x.ToString()); x++; } } } Debug.WriteLine("End"); ds.ReadXml(writer); // выбираем первую таблицу DataTable SobT = ds.Tables[0]; SobT.ReadXml(writer); MessageDialog messageDialogf11 = new MessageDialog("Rows" + SobT.Rows.Count.ToString()); await messageDialogf11.ShowAsync(); // перебор всех строк таблицы foreach (DataRow row in SobT.Rows) { Debug.WriteLine(row.ItemArray[0].ToString()); List <ClassSobNeutron> cll = new List <ClassSobNeutron>(); var cells = row.ItemArray; string[] strTime = row.ItemArray[3].ToString().Split('.'); // Debug.WriteLine(time1); DataTimeUR dataTimeUR = new DataTimeUR(0, 0, Convert.ToInt16(strTime[0]), Convert.ToInt16(strTime[1]), Convert.ToInt16(strTime[2]), Convert.ToInt16(strTime[3]), Convert.ToInt16(strTime[4]), Convert.ToInt16(strTime[5]), Convert.ToInt16(strTime[6])); if (row.ItemArray[1].ToString().Contains("Test")) { string[] vs = row.ItemArray[1].ToString().Split("_"); string gg = vs[0] + "_" + vs[2]; dataTimeUR.corectTime(gg); } else { dataTimeUR.corectTime(row.ItemArray[1].ToString()); } int[] mA = new int[12]; for (int i = 0; i < 12; i++) { mA[i] = Convert.ToInt32(row.ItemArray[i + 6]); } int[] mT = new int[12]; for (int i = 0; i < 12; i++) { mT[i] = Convert.ToInt32(row.ItemArray[i + 54]); } double[] sT = new double[12]; for (int i = 0; i < 12; i++) { sT[i] = Convert.ToDouble((row.ItemArray[i + 30].ToString().Replace(".", ","))); } /* if (Convert.ToInt32(row.ItemArray[5]) > 0) * { * * DataTable dNeutron = ds.Tables[1]; * foreach (DataRow rowN in dNeutron.Rows) * { * var cellsN = rowN.ItemArray; * if ((row.ItemArray[1].ToString() == rowN.ItemArray[1].ToString()) && (dataTimeUR.TimeString() == rowN.ItemArray[4].ToString())) * { * cll.Add(new ClassSobNeutron() * { * D = Convert.ToInt32(rowN.ItemArray[2]), * Amp = Convert.ToInt32(rowN.ItemArray[3]), * TimeAmp = Convert.ToInt32(rowN.ItemArray[7]), * TimeEnd = Convert.ToInt32(rowN.ItemArray[8]), * TimeEnd3 = Convert.ToInt32(rowN.ItemArray[9]), * TimeFirst = Convert.ToInt32(rowN.ItemArray[5]), * TimeFirst3 = Convert.ToInt32(rowN.ItemArray[6]) * }); * } * } * * } * */ try { Debug.WriteLine(dataTimeUR.TimeString()); classSobsC.Add(new ClassSob() { nameFile = row.ItemArray[1].ToString(), nameklaster = row.ItemArray[2].ToString(), nameBAAK = "У1", time = dataTimeUR.TimeString(), mAmp = mA, dateUR = dataTimeUR, TimeS0 = Convert.ToString(row.ItemArray[54]), TimeS1 = Convert.ToString(row.ItemArray[55]), TimeS2 = Convert.ToString(row.ItemArray[56]), TimeS3 = Convert.ToString(row.ItemArray[57]), TimeS4 = Convert.ToString(row.ItemArray[58]), TimeS5 = Convert.ToString(row.ItemArray[59]), TimeS6 = Convert.ToString(row.ItemArray[60]), TimeS7 = Convert.ToString(row.ItemArray[61]), TimeS8 = Convert.ToString(row.ItemArray[62]), TimeS9 = Convert.ToString(row.ItemArray[63]), TimeS10 = Convert.ToString(row.ItemArray[64]), TimeS11 = Convert.ToString(row.ItemArray[65]), mTimeD = mT, sig0 = Convert.ToDouble((row.ItemArray[30].ToString().Replace(".", ","))), sig1 = Convert.ToDouble((row.ItemArray[31].ToString().Replace(".", ","))), sig2 = Convert.ToDouble((row.ItemArray[32].ToString().Replace(".", ","))), sig3 = Convert.ToDouble((row.ItemArray[33].ToString().Replace(".", ","))), sig4 = Convert.ToDouble((row.ItemArray[34].ToString().Replace(".", ","))), sig5 = Convert.ToDouble((row.ItemArray[35].ToString().Replace(".", ","))), sig6 = Convert.ToDouble((row.ItemArray[36].ToString().Replace(".", ","))), sig7 = Convert.ToDouble((row.ItemArray[37].ToString().Replace(".", ","))), sig8 = Convert.ToDouble((row.ItemArray[38].ToString().Replace(".", ","))), sig9 = Convert.ToDouble((row.ItemArray[39].ToString().Replace(".", ","))), sig10 = Convert.ToDouble((row.ItemArray[40].ToString().Replace(".", ","))), sig11 = Convert.ToDouble((row.ItemArray[41].ToString().Replace(".", ","))), Nnull0 = Convert.ToInt16(row.ItemArray[42]), Nnull1 = Convert.ToInt16(row.ItemArray[43]), Nnull2 = Convert.ToInt16(row.ItemArray[44]), Nnull3 = Convert.ToInt16(row.ItemArray[45]), Nnull4 = Convert.ToInt16(row.ItemArray[46]), Nnull5 = Convert.ToInt16(row.ItemArray[47]), Nnull6 = Convert.ToInt16(row.ItemArray[48]), Nnull7 = Convert.ToInt16(row.ItemArray[49]), Nnull8 = Convert.ToInt16(row.ItemArray[50]), Nnull9 = Convert.ToInt16(row.ItemArray[51]), Nnull10 = Convert.ToInt16(row.ItemArray[52]), Nnull11 = Convert.ToInt16(row.ItemArray[53]), classSobNeutronsList = cll }); } catch (Exception ex) { MessageDialog messageDialogf1 = new MessageDialog("dfsfs" + ex.ToString()); await messageDialogf1.ShowAsync(); } } } } else { } } catch (Exception ex) { MessageDialog messageDialogf = new MessageDialog(ex.ToString()); await messageDialogf.ShowAsync(); } return(classSobsC); }