Esempio n. 1
0
            //[ScriptIgnore]
            //[Newtonsoft.Json.JsonIgnore]
            //public string CompleteFile
            //{
            //    get
            //    {
            //        return File.Contains(":") ? File : Cliver.Log.AppDir + "\\" + File;
            //    }
            //}

            override protected void Loaded()
            {
                if (!File.Contains(":"))
                {
                    File = Cliver.Log.AppCompanyUserDataDir + "\\" + File;
                }
                if (!System.IO.File.Exists(File))
                {
                    string file0 = Cliver.Log.AppDir + "\\" + PathRoutines.GetFileName(File);
                    if (!System.IO.File.Exists(file0))
                    {
                        throw new Exception("Cannot find the original Input file: " + file0);
                    }
                    string d = PathRoutines.GetFileDir(File);
                    if (!Directory.Exists(d))
                    {
                        throw new Exception("Input file directory '" + d + "' does not exist. Modify its path in the settings file.");
                    }
                    System.IO.File.Copy(file0, File);
                    Save();
                }

                if (FileFormat == FileFormatEnum.NULL)
                {
                    switch (PathRoutines.GetFileExtension(File).ToLower())
                    {
                    case "csv":
                        FileFormat = FileFormatEnum.CSV;
                        break;

                    case "txt":
                    case "tsv":
                    case "tab":
                        FileFormat = FileFormatEnum.TSV;
                        break;

                    default:
                        throw new Exception("Unknown option: " + PathRoutines.GetFileExtension(File).ToLower());
                    }
                }
            }
Esempio n. 2
0
            override protected void Loaded()
            {
                if (FileName == null)
                {
                    if (FileFormat == FileFormatEnum.NULL)
                    {
                        FileFormat = FileFormatEnum.TSV;
                    }
                    string file_name = ProgramRoutines.GetAppName();
                    switch (FileFormat)
                    {
                    case FileFormatEnum.CSV:
                        FileName = file_name + ".csv";
                        break;

                    case FileFormatEnum.TSV:
                        FileName = file_name + ".tsv";
                        break;

                    case FileFormatEnum.XLS:
                        throw new Exception("XLS format not implemented.");

                    default:
                        throw new Exception("Unknown option: " + FileFormat);
                    }
                }
                else
                {
                    if (FileFormat == FileFormatEnum.NULL)
                    {
                        switch (PathRoutines.GetFileExtension(FileName).ToLower())
                        {
                        case "csv":
                            FileFormat = FileFormatEnum.CSV;
                            break;

                        case "txt":
                        case "tsv":
                        case "tab":
                            FileFormat = FileFormatEnum.TSV;
                            break;

                        default:
                            throw new Exception("Unknown option: " + PathRoutines.GetFileExtension(FileName).ToLower());
                        }
                    }
                }
                switch (FileFormat)
                {
                case FileFormatEnum.CSV:
                    FieldSeparator = Cliver.FieldPreparation.FieldSeparator.COMMA;
                    break;

                case FileFormatEnum.TSV:
                    FieldSeparator = Cliver.FieldPreparation.FieldSeparator.TAB;
                    break;

                case FileFormatEnum.XLS:
                    throw new Exception("XLS format not implemented.");

                case FileFormatEnum.NULL:
                    throw new Exception("File format not defined.");

                default:
                    throw new Exception("Unknown option: " + FileFormat);
                }
            }