Example #1
0
        /// <summary>
        /// Modified by: Akshay Pisal
        /// Last Modified: 2/1/2019
        /// Description: Based on user inputs function returns version or size of file specified in command.
        /// </summary>
        ///
        public string FileOperator(string strInput)
        {
            try
            {
                string[] strData = strInput.Split(' ');
                ThirdPartyTools.FileDetails objFileDetails = new ThirdPartyTools.FileDetails();

                string[] VersionFormats = ConfigurationManager.AppSettings["VersionArray"].Split(',');
                string[] SizeFormats    = ConfigurationManager.AppSettings["SizeArray"].Split(',');
                if (strData.Length != 2)
                {
                    return("Input is invalid. Please specify only two parameters.");
                }

                if (VersionFormats.Contains(strData[0].Trim()))
                {
                    return("File Version : " + objFileDetails.Version(strData[1].Trim()));
                }

                if (SizeFormats.Contains(strData[0].Trim()))
                {
                    return("File Size : " + Convert.ToString(objFileDetails.Size(strData[1].Trim())));
                }

                return("Command does not exists. Please verify command and try again.");
            }
            catch (IndexOutOfRangeException ex)
            {
                adapter.Log(ex);
                return("Application Exception has occured. Please Contact System Admin.");
            }
            catch (NullReferenceException exRef)
            {
                adapter.Log(exRef);
                return("Application error has occured.Please try after sometime.");
            }
            catch (System.IO.IOException exIo)
            {
                adapter.Log(exIo);
                return("File operation failed. Please confirm file path.");
            }
            catch (Exception ex)
            {
                adapter.Log(ex);
                return("Application error has occured.Please try after sometime.");
            }
        }
Example #2
0
        public object Run(string[] args)
        {
            if (!FileCheckerHelper.ValidateArguments(args))
            {
                throw new ArgumentException("Provided arguments are null or not valid, please contact with System Admin!");
            }

            var functionalityToPerform = args[0];
            var filepath = args[1];

            if (FileCheckerHelper.IsInstructedToCheckVersionOrSize(functionalityToPerform))
            {
                Logger.Trace($"Checking Version for {filepath}");
                return(_fileDetailsTool.Version(filepath.Trim()));
            }

            if (FileCheckerHelper.IsInstructedToCheckVersionOrSize(functionalityToPerform, checkIfSize: true))
            {
                Logger.Trace($"Checking Size for {filepath}");
                return(_fileDetailsTool.Size(filepath.Trim()));
            }

            throw new ArgumentException($"Provided arguments are not valid: {functionalityToPerform}");
        }
Example #3
0
 public string Version(string filePath)
 {
     return(_fileDetails.Version(filePath));
 }
        /// <summary>
        /// this function returns version of file based on input
        /// value for cmdVersion
        /// </summary>

        public string FileVersion(string cmdVersion)
        {
            var result = fileDetails.Version(cmdVersion);

            return(result);
        }