Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //if (AppUpdatesAvailableInternal())
            //{
            //    MessageBox.Show("New version of Inferno available.",
            //        "New version!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //}

            //Splasher.Show(typeof(frmSplash));

            mDanteFilePath = string.Empty;
            mLogFilePath = string.Empty;

            try
            {
                var objParseCommandLine = new clsParseCommandLine();
                var success = false;

                if (objParseCommandLine.ParseCommandLine())
                {
                    if (SetOptionsUsingCommandLineParameters(objParseCommandLine))
                        success = true;
                }

                if (!success ||
                    objParseCommandLine.NeedToShowHelp ||
                    objParseCommandLine.ParameterCount + objParseCommandLine.NonSwitchParameterCount == 0)
                {

                    var syntaxMessage = "Supported command line switches are /F and /L \n" +
                                        "Use '/F FilePath.dnt' to load a data file \n" +
                                        "Use '/L LogFilePath' to specify a custom log file path";

                    MessageBox.Show(syntaxMessage, "InfernoRDN Syntax", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception parsing the command line arguments: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            var mfrmDAnTEmdi = new frmDAnTEmdi(mDanteFilePath, mLogFilePath);

            if (!mfrmDAnTEmdi.IsDisposed)
                Application.Run(mfrmDAnTEmdi);
        }
Exemplo n.º 2
0
 private static bool ParseParameter(
     clsParseCommandLine objParseCommandLine,
     string parameterName,
     string description,
     ref string targetVariable)
 {
     string value;
     if (objParseCommandLine.RetrieveValueForParameter(parameterName, out value))
     {
         if (string.IsNullOrWhiteSpace(value))
         {
             ShowErrorMessage("/" + parameterName + " does not have " + description);
             return false;
         }
         targetVariable = string.Copy(value);
     }
     return true;
 }
Exemplo n.º 3
0
        private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine objParseCommandLine)
        {
            // Returns True if no problems; otherwise, returns false
            var lstValidParameters = new List<string> { "F", "L" };

            try
            {
                // Make sure no invalid parameters are present
                if (objParseCommandLine.InvalidParametersPresent(lstValidParameters))
                {
                    var badArguments = new List<string>();
                    foreach (var item in objParseCommandLine.InvalidParameters(lstValidParameters))
                    {
                        badArguments.Add("/" + item);
                    }

                    ShowErrorMessage("Invalid commmand line parameters", badArguments);

                    return false;
                }

                // Query objParseCommandLine to see if various parameters are present

                if (objParseCommandLine.NonSwitchParameterCount > 0)
                    mDanteFilePath = objParseCommandLine.RetrieveNonSwitchParameter(0);

                if (!ParseParameter(objParseCommandLine, "F", "a session file path", ref mDanteFilePath)) return false;

                if (!ParseParameter(objParseCommandLine, "L", "a log file path", ref mLogFilePath)) return false;

                return true;
            }
            catch (Exception ex)
            {
                ShowErrorMessage("Error parsing the command line parameters: " + Environment.NewLine + ex.Message);
            }

            return false;
        }
        public static void Main()
        {
            var commandLineParser = new clsParseCommandLine();
            commandLineParser.ParseCommandLine();

            if (commandLineParser.NeedToShowHelp) {
                ShowProgramHelp();
                return;
            }

            var extractScanFilters = commandLineParser.IsParameterPresent("GetFilters");
            if (extractScanFilters)
            {
                var workingDirectory = ".";

                if (commandLineParser.NonSwitchParameterCount > 0)
                {
                    workingDirectory = commandLineParser.RetrieveNonSwitchParameter(0);
                }
                ExtractScanFilters(workingDirectory);
                return;
            }

            var sourceFilePath = DEFAULT_FILE_PATH;

            if (commandLineParser.NonSwitchParameterCount > 0) {
                sourceFilePath = commandLineParser.RetrieveNonSwitchParameter(0);
            }

            var fiSourceFile = new FileInfo(sourceFilePath);

            if (!fiSourceFile.Exists) {
                Console.WriteLine("File not found: " + fiSourceFile.FullName);
                return;
            }

            var centroid = commandLineParser.IsParameterPresent("centroid");
            var testSumming = commandLineParser.IsParameterPresent("sum");

            var startScan = 0;
            var endScan = 0;

            string strValue;
            int intValue;

            if (commandLineParser.RetrieveValueForParameter("Start", out strValue)) {
                if (int.TryParse(strValue, out intValue))
                {
                    startScan = intValue;
                }
            }

            if (commandLineParser.RetrieveValueForParameter("End", out strValue))
            {
                if (int.TryParse(strValue, out intValue))
                {
                    endScan = intValue;
                }
            }

            TestScanFilterParsing();

            TestReader(fiSourceFile.FullName, centroid, testSumming, startScan, endScan);

            if (centroid) {
                // Also process the file with centroiding off
                TestReader(fiSourceFile.FullName, false, testSumming, startScan, endScan);
            }

            // Uncomment the following to test the GetCollisionEnergy() function
            //TestReader("..\EDRN_ERG_Spop_ETV1_50fmolHeavy_0p5ugB53A_Frac48_3Oct12_Gandalf_W33A1_16a.raw")

            Console.WriteLine("Done");
        }
Exemplo n.º 5
0
        static int Main(string[] args)
        {
            var objParseCommandLine = new FileProcessor.clsParseCommandLine();

            mInputFilePath    = string.Empty;
            mOutputFolderPath = string.Empty;

            mReverseSort    = false;
            mIgnoreCase     = false;
            mHasHeaderLine  = false;
            mKeepEmptyLines = false;

            mSortColumn          = 0;
            mColumnDelimiter     = string.Empty;
            mSortColumnIsNumeric = false;

            mMaxFileSizeMBForInMemorySort = TextFileSorter.DEFAULT_IN_MEMORY_SORT_MAX_FILE_SIZE_MB;
            mChunkSizeMB          = TextFileSorter.DEFAULT_CHUNK_SIZE_MB;
            mWorkingDirectoryPath = UtilityMethods.GetTempFolderPath();

            mUseLogFile  = false;
            mLogFilePath = string.Empty;

            mLastProgressStatus = DateTime.UtcNow;

            try
            {
                if (objParseCommandLine.ParseCommandLine())
                {
                    SetOptionsUsingCommandLineParameters(objParseCommandLine);
                }

                if (objParseCommandLine.NeedToShowHelp ||
                    (objParseCommandLine.ParameterCount + objParseCommandLine.NonSwitchParameterCount) == 0 ||
                    string.IsNullOrWhiteSpace(mInputFilePath))
                {
                    ShowProgramHelp();
                    return(-1);
                }

                var sortUtility = new TextFileSorter
                {
                    ShowMessagesAtConsole        = false,
                    ReverseSort                  = mReverseSort,
                    IgnoreCase                   = mIgnoreCase,
                    HasHeaderLine                = mHasHeaderLine,
                    KeepEmptyLines               = mKeepEmptyLines,
                    SortColumn                   = mSortColumn,
                    SortColumnIsNumeric          = mSortColumnIsNumeric,
                    ColumnDelimiter              = mColumnDelimiter,
                    MaxFileSizeMBForInMemorySort = mMaxFileSizeMBForInMemorySort,
                    ChunkSizeMB                  = mChunkSizeMB,
                    WorkingDirectoryPath         = mWorkingDirectoryPath,
                    LogMessagesToFile            = mUseLogFile,
                    LogFilePath                  = mLogFilePath
                };

                // Attach events
                sortUtility.MessageEvent    += sortUtility_MessageEvent;
                sortUtility.ErrorEvent      += sortUtility_ErrorEvent;
                sortUtility.WarningEvent    += sortUtility_WarningEvent;
                sortUtility.ProgressChanged += sortUtility_ProgressChanged;

                var success = sortUtility.ProcessFile(mInputFilePath, mOutputFolderPath);

                if (!success)
                {
                    return(-2);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error occurred in Program->Main: " + Environment.NewLine + ex.Message);
                Console.WriteLine(ex.StackTrace);
                return(-1);
            }

            return(0);
        }
Exemplo n.º 6
0
        private static bool SetOptionsUsingCommandLineParameters(FileProcessor.clsParseCommandLine objParseCommandLine)
        {
            // Returns True if no problems; otherwise, returns false

            var lstValidParameters = new List <string> {
                "I", "O", "R", "Reverse",
                "IgnoreCase", "Header", "KeepEmpty",
                "Col", "Delim", "IsNumeric",
                "MaxInMemory", "ChunkSize",
                "Work", "L", "Log"
            };

            try
            {
                // Make sure no invalid parameters are present
                if (objParseCommandLine.InvalidParametersPresent(lstValidParameters))
                {
                    var badArguments = new List <string>();
                    foreach (string item in objParseCommandLine.InvalidParameters(lstValidParameters))
                    {
                        badArguments.Add("/" + item);
                    }

                    ShowErrorMessage("Invalid commmand line parameters", badArguments);

                    return(false);
                }

                if (objParseCommandLine.NonSwitchParameterCount > 0)
                {
                    mInputFilePath = objParseCommandLine.RetrieveNonSwitchParameter(0);
                }

                if (!ParseParameter(objParseCommandLine, "I", "an input file name", ref mInputFilePath))
                {
                    return(false);
                }
                if (!ParseParameter(objParseCommandLine, "O", "an output folder name", ref mOutputFolderPath))
                {
                    return(false);
                }

                if (objParseCommandLine.IsParameterPresent("R") ||
                    objParseCommandLine.IsParameterPresent("Reverse"))
                {
                    mReverseSort = true;
                }

                if (objParseCommandLine.IsParameterPresent("IgnoreCase"))
                {
                    mIgnoreCase = true;
                }

                if (objParseCommandLine.IsParameterPresent("Header"))
                {
                    mHasHeaderLine = true;
                }

                if (objParseCommandLine.IsParameterPresent("KeepEmpty"))
                {
                    mKeepEmptyLines = true;
                }


                if (!ParseParameterInt(objParseCommandLine, "Col", "a column number (the first column is column 1)", ref mSortColumn))
                {
                    return(false);
                }

                var strValue = string.Empty;
                if (!ParseParameter(objParseCommandLine, "Delim", "a delimiter", ref strValue))
                {
                    return(false);
                }
                if (!string.IsNullOrWhiteSpace(strValue))
                {
                    mColumnDelimiter = string.Copy(strValue);
                }

                if (objParseCommandLine.IsParameterPresent("IsNumeric"))
                {
                    mSortColumnIsNumeric = true;
                }

                if (!ParseParameterInt(objParseCommandLine, "MaxInMemory", "a file size, in MB", ref mMaxFileSizeMBForInMemorySort))
                {
                    return(false);
                }

                if (!ParseParameterInt(objParseCommandLine, "ChunkSize", "a memory size, in MB", ref mChunkSizeMB))
                {
                    return(false);
                }

                if (!ParseParameter(objParseCommandLine, "Work", "a folder path", ref mWorkingDirectoryPath))
                {
                    return(false);
                }

                if (objParseCommandLine.IsParameterPresent("L") || objParseCommandLine.IsParameterPresent("Log"))
                {
                    mUseLogFile = true;

                    if (objParseCommandLine.RetrieveValueForParameter("L", out strValue))
                    {
                        mLogFilePath = string.Copy(strValue);
                    }
                    else if (objParseCommandLine.RetrieveValueForParameter("Log", out strValue))
                    {
                        mLogFilePath = string.Copy(strValue);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error parsing the command line parameters: " + Environment.NewLine + ex.Message);
            }

            return(false);
        }
        public static int Main(string[] args)
        {
            var objParseCommandLine = new FileProcessor.clsParseCommandLine();

            mLogLevel = clsLogTools.LogLevels.INFO;

            mMTSServer = string.Empty;
            mLogDBConnectionString = clsMyEMSLMTSFileCacher.LOG_DB_CONNECTION_STRING;
            mMinimumCacheFreeSpaceGB = clsMyEMSLMTSFileCacher.DEFAULT_MINIMUM_CACHE_FREE_SPACE_GB;
            mLocalServerMode = false;
            mPreviewMode = false;

            try
            {
                var success = false;

                if (objParseCommandLine.ParseCommandLine())
                {
                    if (SetOptionsUsingCommandLineParameters(objParseCommandLine))
                        success = true;
                }

                if (!success ||
                    objParseCommandLine.NeedToShowHelp ||
                    objParseCommandLine.ParameterCount + objParseCommandLine.NonSwitchParameterCount == 0 ||
                    mMTSServer.Length == 0 && !mLocalServerMode)
                {
                    ShowProgramHelp();
                    return -1;

                }

                if (mLocalServerMode)
                {
                    mMTSServer = string.Empty;
                }
                else
                {
                    string pendingWindowsUpdateMessage;
                    var updatesArePending = clsWindowsUpdateStatus.UpdatesArePending(out pendingWindowsUpdateMessage);

                    if (updatesArePending)
                    {
                        Console.WriteLine(pendingWindowsUpdateMessage);
                        Console.WriteLine("Will not contact the MTS server to process cache requests");
                        return 0;
                    }
                }

                var downloader = new clsMyEMSLMTSFileCacher(mMTSServer, mLogLevel, mLogDBConnectionString)
                {
                    MinimumCacheFreeSpaceGB = mMinimumCacheFreeSpaceGB
                };

                // Attach the events
                downloader.ErrorEvent += downloader_ErrorEvent;
                downloader.MessageEvent += downloader_MessageEvent;

                // Initiate processing, which will contact the MTS Server to see if any files need to be cached
                success = downloader.Start(mPreviewMode);

                if (!success)
                {
                    ShowErrorMessage("Error processing cache requests for MTS server " + mMTSServer + ": " + downloader.ErrorMessage);
                    return -3;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error occurred in Program->Main: " + Environment.NewLine + ex.Message);
                Console.WriteLine(ex.StackTrace);
                Thread.Sleep(1500);
                return -1;
            }

            return 0;
        }
        private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine objParseCommandLine)
        {
            // Returns True if no problems; otherwise, returns false
            var lstValidParameters = new List<string> { "Local", "Preview", "LogDB", "FS" };

            try
            {
                // Make sure no invalid parameters are present
                if (objParseCommandLine.InvalidParametersPresent(lstValidParameters))
                {
                    var badArguments = new List<string>();
                    foreach (var item in objParseCommandLine.InvalidParameters(lstValidParameters))
                    {
                        badArguments.Add("/" + item);
                    }

                    ShowErrorMessage("Invalid commmand line parameters", badArguments);

                    return false;
                }

                // Query objParseCommandLine to see if various parameters are present
                if (objParseCommandLine.NonSwitchParameterCount > 0)
                {
                    mMTSServer = objParseCommandLine.RetrieveNonSwitchParameter(0);
                }

                if (objParseCommandLine.IsParameterPresent("Local"))
                {
                    mLocalServerMode = true;
                }

                if (objParseCommandLine.IsParameterPresent("Preview"))
                {
                    mPreviewMode = true;
                }

                string strValue;
                if (objParseCommandLine.RetrieveValueForParameter("LogDB", out strValue))
                {
                    if (string.IsNullOrWhiteSpace(strValue))
                        ShowErrorMessage("/LogDB does not have a value; not overriding the logging connection string");
                    else
                        mLogDBConnectionString = strValue;
                }

                if (objParseCommandLine.RetrieveValueForParameter("FS", out strValue))
                {
                    if (string.IsNullOrWhiteSpace(strValue))
                        ShowErrorMessage("/FS does not have a value; not overriding the minimum free space");
                    else
                    {
                        if (!int.TryParse(strValue, out mMinimumCacheFreeSpaceGB))
                            ShowErrorMessage("Error converting " + strValue + " to an integer for parameter /FS");
                    }
                }

                return true;
            }
            catch (Exception ex)
            {
                ShowErrorMessage("Error parsing the command line parameters: " + Environment.NewLine + ex.Message);
            }

            return false;
        }