void importSourceFileBrowser_OnFileSelectedTryParse(object sender, ImportSourcePathInfo e) {
			//if (this.dataSnapshot.FileSelectedAbsname == e.FSI.FullName) return;
			this.dataSnapshot.PathCsv = Path.GetDirectoryName(e.FSI.FullName);
			this.dataSnapshot.FileSelected = e.FSI.Name;
			this.dataSnapshotSerializer.Serialize();
			bool success = this.stepsAllparseFromDataSnapshot();
			e.ParsingFailedHightlightRed = !success;
		}
Esempio n. 2
0
        void importSourceFileBrowser_OnFileSelectedTryParse(object sender, ImportSourcePathInfo e)
        {
            //if (this.dataSnapshot.FileSelectedAbsname == e.FSI.FullName) return;
            this.dataSnapshot.PathCsv      = Path.GetDirectoryName(e.FSI.FullName);
            this.dataSnapshot.FileSelected = e.FSI.Name;
            this.dataSnapshotSerializer.Serialize();
            bool success = this.stepsAllparseFromDataSnapshot();

            e.ParsingFailedHightlightRed = !success;
        }
Esempio n. 3
0
 object olvColumnFileName_imageGetter(object rowObject)
 {
     try {
         ImportSourcePathInfo ispi = rowObject as ImportSourcePathInfo;
         var    fsi   = ispi.FSI;
         string full  = fsi.FullName;
         int    index = sysImgHelper.GetImageIndex(full);
         return(index);
     } catch (Exception ex) {
         Assembler.PopupException("olvColumnFileName_imageGetter()", ex);
         return(null);
     }
 }
Esempio n. 4
0
        public void PopulateListFromCsvPath(string pathCsv)
        {
            if (pathCsv == null)
            {
                Assembler.PopupException("didn't populate: pathCsv can't be null PopulateListFromCsvPath(pathCsv[null])");
                return;
            }
            DirectoryInfo pathInfo = new DirectoryInfo(pathCsv);

            if (!pathInfo.Exists)
            {
                return;
            }
            this.txtFolder.Text = pathCsv;
            if (this.OnDirectoryChanged != null)
            {
                this.OnDirectoryChanged(this, new DirectoryInfoEventArgs(pathInfo));
            }
            Cursor.Current = Cursors.WaitCursor;
            var fsis = pathInfo.GetFileSystemInfos();
            var fsisExtendedFolders = new List <ImportSourcePathInfo>();
            var fsisExtendedFiles   = new List <ImportSourcePathInfo>();

            foreach (var fsi in fsis)
            {
                if (fsi is DirectoryInfo)
                {
                    fsisExtendedFolders.Add(new ImportSourcePathInfo(fsi));
                }
                else
                {
                    fsisExtendedFiles.Add(new ImportSourcePathInfo(fsi));
                }
            }
            List <ImportSourcePathInfo> foldersThenFiles = new List <ImportSourcePathInfo>(fsisExtendedFolders);

            foldersThenFiles.AddRange(fsisExtendedFiles);
            DirectoryInfo di = Directory.GetParent(pathCsv);

            if (di != null)
            {
                ImportSourcePathInfo parentFolder = new ImportSourcePathInfo(new DirectoryInfo(Path.Combine(pathCsv, "..")));
                parentFolder.Name = "..";
                foldersThenFiles.Insert(0, parentFolder);
            }
            this.olvFiles.SetObjects(foldersThenFiles);
            this.olvFiles.EnsureVisible(0);
            //this.olvFiles.SelectedIndex = 0;
            this.olvFiles.SelectObject("..", true);             // weird but no focus on ".."
            Cursor.Current = Cursors.Default;
        }
Esempio n. 5
0
        bool stepsAllparseFromDataSnapshot()
        {
            Cursor.Current = Cursors.WaitCursor;
            try {
                var fsi = new FileInfo(this.dataSnapshot.FileSelectedAbsname);
                var pi  = new ImportSourcePathInfo(fsi);
                this.step1parseFileInfo(pi);
            } catch (Exception ex) {
                this.olvCsvParsedRaw.Reset();
                this.olvCsvParsedRaw.EmptyListMsg = "step1parseFileInfo\r\n[" + ex.Message + "]"
                                                    + "\r\nin new ImportSourcePathInfo(new FileInfo(" + this.dataSnapshot.FileSelected + "))";
                Assembler.PopupException("step1parseFileInfo()", ex);
                this.olvParsedByFormat.SetObjects(null);
                this.olvParsedByFormat.EmptyListMsg = "";
                this.disableRangeBarAndBtnImport();
                Cursor.Current = Cursors.Default;
                return(false);
            }

            try {
                this.step2syncCsvRawToFieldSetup();
            } catch (Exception ex) {
                this.olvParsedByFormat.SetObjects(null);
                this.olvParsedByFormat.EmptyListMsg = "step2syncCsvRawToFieldSetup\r\n[" + ex.Message + "]"
                                                      + "\r\nfor [" + this.dataSnapshot.FileSelected + "]";
                Assembler.PopupException("step2syncCsvRawToFieldSetup()", ex);
                this.disableRangeBarAndBtnImport();
                Cursor.Current = Cursors.Default;
                return(false);
            }

            bool step3success = this.step3safe();

            if (step3success == false)
            {
                return(false);
            }

            Cursor.Current = Cursors.Default;
            return(true);
        }
		bool stepsAllparseFromDataSnapshot() {
			Cursor.Current = Cursors.WaitCursor;
			try {
				var fsi = new FileInfo(this.dataSnapshot.FileSelectedAbsname);
				var pi = new ImportSourcePathInfo(fsi);
				this.step1parseFileInfo(pi);
			} catch (Exception ex) {
				this.olvCsvParsedRaw.Reset();
				this.olvCsvParsedRaw.EmptyListMsg = "step1parseFileInfo\r\n[" + ex.Message + "]"
					+ "\r\nin new ImportSourcePathInfo(new FileInfo(" + this.dataSnapshot.FileSelected + "))";
				Assembler.PopupException("step1parseFileInfo()", ex);
				this.olvParsedByFormat.SetObjects(null);
				this.olvParsedByFormat.EmptyListMsg = "";
				this.disableRangeBarAndBtnImport();
				Cursor.Current = Cursors.Default;
				return false;
			}

			try {
				this.step2syncCsvRawToFieldSetup();
			} catch (Exception ex) {
				this.olvParsedByFormat.SetObjects(null);
				this.olvParsedByFormat.EmptyListMsg = "step2syncCsvRawToFieldSetup\r\n[" + ex.Message + "]"
					+ "\r\nfor [" + this.dataSnapshot.FileSelected + "]";
				Assembler.PopupException("step2syncCsvRawToFieldSetup()", ex);
				this.disableRangeBarAndBtnImport();
				Cursor.Current = Cursors.Default;
				return false;
			}

			bool step3success = this.step3safe();
			if (step3success == false) return false;
			
			Cursor.Current = Cursors.Default;
			return true;
		}
		public void PopulateListFromCsvPath(string pathCsv) {
			if (pathCsv == null) {
				Assembler.PopupException("didn't populate: pathCsv can't be null PopulateListFromCsvPath(pathCsv[null])");
				return;
			}
            DirectoryInfo pathInfo = new DirectoryInfo(pathCsv);
			if (!pathInfo.Exists) return;
			this.txtFolder.Text = pathCsv;
			if (this.OnDirectoryChanged != null) {
				this.OnDirectoryChanged(this, new DirectoryInfoEventArgs(pathInfo));
			}
            Cursor.Current = Cursors.WaitCursor;
			var fsis = pathInfo.GetFileSystemInfos();
			var fsisExtendedFolders = new List<ImportSourcePathInfo>();
			var fsisExtendedFiles = new List<ImportSourcePathInfo>();
			foreach (var fsi in fsis) {
				if (fsi is DirectoryInfo) {
					fsisExtendedFolders.Add(new ImportSourcePathInfo(fsi));
				} else {
					fsisExtendedFiles.Add(new ImportSourcePathInfo(fsi));
				}
			}
			List<ImportSourcePathInfo> foldersThenFiles = new List<ImportSourcePathInfo>(fsisExtendedFolders);
			foldersThenFiles.AddRange(fsisExtendedFiles);
			DirectoryInfo di = Directory.GetParent(pathCsv);
            if (di != null) {
				ImportSourcePathInfo parentFolder = new ImportSourcePathInfo(new DirectoryInfo(Path.Combine(pathCsv, "..")));
				parentFolder.Name = "..";
				foldersThenFiles.Insert(0, parentFolder);
            }
			this.olvFiles.SetObjects(foldersThenFiles);
			this.olvFiles.EnsureVisible(0);
			//this.olvFiles.SelectedIndex = 0;
			this.olvFiles.SelectObject("..", true);	// weird but no focus on ".."
            Cursor.Current = Cursors.Default;
        }
		void step1parseFileInfo(ImportSourcePathInfo e) {
			this.dataSnapshot.FileSelected = e.FSI.Name;
			this.csvUnnamed = readCsvToMatrix(e.FSI.FullName);
			string status = " Rows[" + this.csvUnnamed.Count + "]";
			if (this.csvUnnamed.Count == 0) {
				string msg = "File [" + e.FSI.Name + "] isn't a CSV file;\r\nDouble Click here to open and adjust your settings";
				throw new Exception(msg);
			}
			int maxColumns = 0;
			foreach (var row in this.csvUnnamed) {
				if (row.Count > maxColumns) maxColumns = row.Count;
			}
			if (maxColumns == 0) {
				string msg = "File [" + e.FSI.Name + "] is CSV with ZERO columns (???);\r\nDouble Click here to open and adjust your settings";
				throw new Exception(msg);
			}
			status += " Columns[" + maxColumns + "] found in File[" + e.FSI.Name + "]";
			
			string statusOld = this.grpPreviewParsedRaw.Text;
			int posToAppend = statusOld.IndexOf('|');
			//if (posToAppend < 0) posToAppend = 0;
			string prefix = statusOld.Substring(0, posToAppend+1); // no exception thrown even if posToAppend=-1 (not found)
			this.grpPreviewParsedRaw.Text = prefix + status;
			

			//this.csvPreviewParsedRaw.Columns.Clear();
			//this.csvPreviewParsedRaw.AllColumns.Clear();
			//this.csvPreviewParsedRaw.Clear();
			this.olvCsvParsedRaw.Reset();
			this.olvColGenParsedRaw.Clear();
			//RELIES_ON_CLASS_PROPERTIES_WHICH_LIST<LIST<STRING>>_DOESNT_HAVE Generator.GenerateColumns(this.csvPreviewParsedRaw, csvUnnamed);

			//int width = this.csvPreviewParsedRaw.Width / maxColumns;
			for (int i = 0; i < maxColumns; i++) {
				var olvColumn = new OLVColumn();
				olvColumn.Name = "AnonymousColumn_" + (i+1);
				olvColumn.Text = "Anonymous " + (i + 1);
				//olvColumn.Width = width;
				//if (i == maxColumns-1) olvColumn.FillsFreeSpace = true;
				ColumnCatcher iCatcher;
				if (this.dataSnapshot.FieldSetupCurrent.Count >= i+1) {
					iCatcher = this.dataSnapshot.FieldSetupCurrent[i];
				} else {
					iCatcher = new ColumnCatcher(i, this.dataSnapshot);
					this.dataSnapshot.FieldSetupCurrent.Add(iCatcher);
				}
				olvColumn.AspectGetter = iCatcher.AspectGetterParsedRaw;
				this.olvCsvParsedRaw.Columns.Add(olvColumn);
				//this.csvPreviewParsedRaw.AllColumns.Add(olvColumn);
				this.olvColGenParsedRaw.Add(olvColumn, iCatcher);
			}
			//MAKES_THE_TABLE_EMPTY_EVEN_WITHOUT_HEADERS_this.csvPreviewParsedRaw.RebuildColumns();
			this.olvCsvParsedRaw.SetObjects(this.csvUnnamed);
			this.olvCsvParsedRaw.AutoResizeColumns();
		}
Esempio n. 9
0
        void step1parseFileInfo(ImportSourcePathInfo e)
        {
            this.dataSnapshot.FileSelected = e.FSI.Name;
            this.csvUnnamed = readCsvToMatrix(e.FSI.FullName);
            string status = " Rows[" + this.csvUnnamed.Count + "]";

            if (this.csvUnnamed.Count == 0)
            {
                string msg = "File [" + e.FSI.Name + "] isn't a CSV file;\r\nDouble Click here to open and adjust your settings";
                throw new Exception(msg);
            }
            int maxColumns = 0;

            foreach (var row in this.csvUnnamed)
            {
                if (row.Count > maxColumns)
                {
                    maxColumns = row.Count;
                }
            }
            if (maxColumns == 0)
            {
                string msg = "File [" + e.FSI.Name + "] is CSV with ZERO columns (???);\r\nDouble Click here to open and adjust your settings";
                throw new Exception(msg);
            }
            status += " Columns[" + maxColumns + "] found in File[" + e.FSI.Name + "]";

            string statusOld   = this.grpPreviewParsedRaw.Text;
            int    posToAppend = statusOld.IndexOf('|');
            //if (posToAppend < 0) posToAppend = 0;
            string prefix = statusOld.Substring(0, posToAppend + 1);           // no exception thrown even if posToAppend=-1 (not found)

            this.grpPreviewParsedRaw.Text = prefix + status;


            //this.csvPreviewParsedRaw.Columns.Clear();
            //this.csvPreviewParsedRaw.AllColumns.Clear();
            //this.csvPreviewParsedRaw.Clear();
            this.olvCsvParsedRaw.Reset();
            this.olvColGenParsedRaw.Clear();
            //RELIES_ON_CLASS_PROPERTIES_WHICH_LIST<LIST<STRING>>_DOESNT_HAVE Generator.GenerateColumns(this.csvPreviewParsedRaw, csvUnnamed);

            //int width = this.csvPreviewParsedRaw.Width / maxColumns;
            for (int i = 0; i < maxColumns; i++)
            {
                var olvColumn = new OLVColumn();
                olvColumn.Name = "AnonymousColumn_" + (i + 1);
                olvColumn.Text = "Anonymous " + (i + 1);
                //olvColumn.Width = width;
                //if (i == maxColumns-1) olvColumn.FillsFreeSpace = true;
                ColumnCatcher iCatcher;
                if (this.dataSnapshot.FieldSetupCurrent.Count >= i + 1)
                {
                    iCatcher = this.dataSnapshot.FieldSetupCurrent[i];
                }
                else
                {
                    iCatcher = new ColumnCatcher(i, this.dataSnapshot);
                    this.dataSnapshot.FieldSetupCurrent.Add(iCatcher);
                }
                olvColumn.AspectGetter = iCatcher.AspectGetterParsedRaw;
                this.olvCsvParsedRaw.Columns.Add(olvColumn);
                //this.csvPreviewParsedRaw.AllColumns.Add(olvColumn);
                this.olvColGenParsedRaw.Add(olvColumn, iCatcher);
            }
            //MAKES_THE_TABLE_EMPTY_EVEN_WITHOUT_HEADERS_this.csvPreviewParsedRaw.RebuildColumns();
            this.olvCsvParsedRaw.SetObjects(this.csvUnnamed);
            this.olvCsvParsedRaw.AutoResizeColumns();
        }