Beispiel #1
0
        public virtual INCCTransferBase Restore()
        { // current file
            INCCTransferBase result = null;

            switch (mft)
            {
            case eFileType.eInitialDataDetector:
            {
                INCCInitialDataDetectorFile idd = new INCCInitialDataDetectorFile(mlogger, mpath);
                bool good = idd.Restore(mpath);
                if (good)
                {
                    result = idd;         // this now has the structs ready
                }
            }
            break;

            case eFileType.eInitialDataCalibration:
            {
                INCCInitialDataCalibrationFile idcal = new INCCInitialDataCalibrationFile(mlogger, mpath);
                bool good = idcal.Restore(mpath);
                if (good)
                {
                    result = idcal;         // this now has the structs ready
                }
            }
            break;

            case eFileType.eTransfer:
            {
                INCCTransferFile idt  = new INCCTransferFile(mlogger, mpath);
                bool             good = idt.Restore(mpath);
                if (good)
                {
                    result = idt;         // this now has the structs ready
                }
            }
            break;

            case eFileType.eNCC:
            {
                INCCReviewFile irf  = new INCCReviewFile(mlogger, mpath);
                bool           good = irf.Restore(mpath);
                if (good)
                {
                    result = irf;         // this now has the structs ready
                }
            }
            break;

            case eFileType.eUnknown:
                mlogger.TraceEvent(LogLevels.Info, 34007, "Skipping {0}", mpath);
                break;

            default:      // for future expansion
                // dev note: NOP and COP files are just CSV or Tab-delimited text files, so no binary matching is needed, so I am moving the handling of these to another class (OPfiles)
                mlogger.TraceEvent(LogLevels.Info, 34008, "Not processing the unsupported file {0}", mpath);
                break;
            }
            ;

            return(result);
        }
Beispiel #2
0
        public new virtual List <INCCTransferBase> Restore()
        { // folder and file(s)
            List <INCCTransferBase> results = new List <INCCTransferBase>();

            if (IsZip() || IsFolder())
            {
                // do the folder or zip extract, then individual restore
                mlogger.TraceEvent(LogLevels.Info, 33020, "Use the folder content");
                if (IsFolder())
                {
                    IEnumerable <string> effs = null;
                    try
                    {
                        effs = from f in
                               (string.IsNullOrEmpty(searchPattern) ? Directory.EnumerateFiles(fpath) : Directory.EnumerateFiles(fpath, searchPattern))
                               select f;
                    }
                    catch (Exception e)
                    {
                        mlogger.TraceEvent(LogLevels.Warning, 33021, e.Message);
                    }
                    finally
                    {
                        if (effs == null || (effs.Count() <= 0))
                        {
                            mlogger.TraceEvent(LogLevels.Info, 33021, "No files found in {0}, see ya . . .", fpath);
                        }
                        else
                        {
                            mlogger.TraceEvent(LogLevels.Info, 33022, "Examining {0} files in {1} for INCC review and transfer file processing", effs.Count(), fpath);
                        }
                    }
                    if (effs == null)
                    {
                        return(results);
                    }

                    int fcount = effs.Count(), j = 0;
                    // Show files and build list
                    foreach (var f in effs)
                    {
                        j++;
                        string p = f.Substring(f.LastIndexOf("\\") + 1);
                        mlogger.TraceEvent(LogLevels.Verbose, 33023, "  {0}", p);// Remove path information from string.
                        eh(this, new TransferEventArgs((int)(100.0 * (j / (float)fcount)), "Scanning " + p));
                        if (mct != null && mct.IsCancellationRequested)
                        {
                            break;
                        }
                        base.SetFilePath(f);
                        INCCTransferBase itf = base.Restore();
                        if (itf == null)
                        {
                            mlogger.TraceEvent(LogLevels.Verbose, 33024, "Unable to restore file {0}", f);
                        }
                        else
                        {
                            results.Add(itf);//mlogger.TraceInformation("  R file %.256s", fullfilepath);
                        }
                    }
                    return(results);
                }
                else if (IsZip())
                {
                    mlogger.TraceEvent(LogLevels.Warning, 33025, "Unable to restore compressed file {0}", fpath);
                }
                return(results);
            }
            else if (mft == eFileType.eFileList)
            {
                mlogger.TraceEvent(LogLevels.Info, 33022, "Examining {0} files for INCC review and transfer file processing", paths.Count());
                int j = 0;
                // Show files and build list
                foreach (var f in paths)
                {
                    j++;
                    string p = f.Substring(f.LastIndexOf("\\") + 1);
                    mlogger.TraceEvent(LogLevels.Verbose, 33023, "  {0}", p);// Remove path information from string.
                    eh(this, new TransferEventArgs((int)(100.0 * (j / (float)paths.Count)), "Scanning " + p));
                    if (mct != null && mct.IsCancellationRequested)
                    {
                        break;
                    }
                    base.SetFilePath(f);
                    INCCTransferBase itf = base.Restore();
                    if (itf == null)
                    {
                        mlogger.TraceEvent(LogLevels.Verbose, 33024, "Unable to restore file {0}", f);
                    }
                    else
                    {
                        results.Add(itf);
                    }
                }
            }
            else  // 1 lonely file
            {
                INCCTransferBase itf = base.Restore();
                if (itf == null)
                {
                    mlogger.TraceEvent(LogLevels.Verbose, 33026, "Unable to restore file {0}", base.GetFilePath());
                }
                else
                {
                    results.Add(itf);
                }
            }
            return(results);
        }
Beispiel #3
0
        public new virtual List <INCCTransferBase> Restore()
        { // folder and file(s)
            List <INCCTransferBase> results = new List <INCCTransferBase>();

            if (IsZip() || IsFolder())
            {
                // do the folder or zip extract, then individual restore
                mlogger.TraceEvent(LogLevels.Info, 33020, "Use the folder content");
                if (IsFolder())
                {
                    IEnumerable <string> effs = null;
                    effs = from f in
                           (String.IsNullOrEmpty(searchPattern) ? Directory.EnumerateFiles(fpath) : Directory.EnumerateFiles(fpath, searchPattern))
                           select f;

                    if (effs == null || (effs.Count() <= 0))
                    {
                        mlogger.TraceEvent(LogLevels.Info, 33021, "No files found in {0}, see ya . . .", fpath);
                    }

                    mlogger.TraceEvent(LogLevels.Info, 33022, "Examining {0} files in {1} for INCC file processing", effs.Count(), fpath);

                    // Show files and build list
                    foreach (var f in effs)
                    {
                        mlogger.TraceEvent(LogLevels.Verbose, 33023, "  {0}", f.Substring(f.LastIndexOf("\\") + 1));// Remove path information from string.

                        base.SetFilePath(f);
                        INCCTransferBase itf = base.Restore();
                        if (itf == null)
                        {
                            mlogger.TraceEvent(LogLevels.Verbose, 33024, "Unable to restore file {0}", f);
                        }
                        else
                        {
                            results.Add(itf);//mlogger.TraceInformation("  R file %.256s", fullfilepath);
                        }
                    }
                    return(results);
                }
                else if (IsZip())
                {
                    mlogger.TraceEvent(LogLevels.Warning, 33025, "Unable to restore compressed file {0}", fpath);
                }
                return(results);
            }
            else if (mft == eFileType.eFileList)
            {
                mlogger.TraceEvent(LogLevels.Info, 33022, "Examining {0} files for INCC file processing", paths.Count());

                // Show files and build list
                foreach (var f in paths)
                {
                    mlogger.TraceEvent(LogLevels.Verbose, 33023, "  {0}", f.Substring(f.LastIndexOf("\\") + 1));// Remove path information from string.

                    base.SetFilePath(f);
                    INCCTransferBase itf = base.Restore();
                    if (itf == null)
                    {
                        mlogger.TraceEvent(LogLevels.Verbose, 33024, "Unable to restore file {0}", f);
                    }
                    else
                    {
                        results.Add(itf);
                    }
                }
            }
            else  // 1 lonely file
            {
                INCCTransferBase itf = base.Restore();
                if (itf == null)
                {
                    mlogger.TraceEvent(LogLevels.Verbose, 33026, "Unable to restore file {0}", base.GetFilePath());
                }
                else
                {
                    results.Add(itf);
                }
            }
            return(results);
        }