示例#1
0
        } //end of this method

        /// <summary>
        /// This method return the drive path
        /// </summary>
        /// <param name="driveLetter"></param>
        /// <param name="configFile"></param>
        /// <returns></returns>
        public static string getDrivePath(string driveLetter, string configFile)
        {
            string drivepath = "";

            try
            {
                if (!driveLetter.Trim().EndsWith(":"))
                {
                    driveLetter = driveLetter.Trim() + ":";
                }
                //string FilePath = System.Environment.GetEnvironmentVariable("FINANCECONFIG");  //Read from Env variable
                //if (FilePath == null) { FilePath = "C:\\Finance\\"; }

                string FilePath = ConfigurationManager.AppSettings["FINANCECONFIG"];
                if (FilePath == null)
                {
                    FilePath = "D:\\financeconfig\\";
                }
                if (!FilePath.EndsWith("\\"))
                {
                    FilePath += "\\";
                }
                FilePath += configFile.Trim();
                DSPATH myDataSet = new DSPATH();
                myDataSet.ReadXml(FilePath.Trim());
                if (myDataSet.NetworkMappings.Rows.Count > 0)
                {
                    DataRow[] rowsFound = myDataSet.NetworkMappings.Select("DriveLetter ='" + driveLetter.Trim().ToUpper() + "' OR DriveLetter ='" + driveLetter.Trim().ToLower() + "'");
                    if (rowsFound.Length > 0)
                    {
                        drivepath = rowsFound[0]["DrivePath"].ToString().Trim();
                    }
                    else
                    {
                        drivepath = "ERROR: Path not found for '" + driveLetter + "'";
                        EventLog.AddWebErrors("GSA.R7BD.Utility", "Utilities", "getDrivePath", drivepath);
                    }
                }
            }
            catch (Exception exp)
            {
                drivepath = "ERROR:" + exp.Message;
                EventLog.AddWebErrors("GGSA.R7BD.Utility", "Utilities", "getDrivePath", exp.Message);
            }
            return(drivepath);
        }//end of method
示例#2
0
        public static string GetUrl(string driveLetter, string appName)
        {
            string drivepath = "";

            try
            {
                if (!driveLetter.Trim().EndsWith(":"))
                {
                    driveLetter = driveLetter.Trim() + ":";
                }


                string configFilePath = ConfigurationManager.AppSettings["FINANCECONFIG"].ToString();
                if (configFilePath == null)
                {
                    configFilePath = "D:\\financeconfig\\";
                }
                if (!configFilePath.EndsWith("\\"))
                {
                    configFilePath += "\\";
                }
                configFilePath = configFilePath.Trim() + "urls.xml";

                DSPATH myDataSet = new DSPATH();
                myDataSet.ReadXml(configFilePath.Trim());
                if (myDataSet.NetworkMappings.Rows.Count > 0)
                {
                    DataRow[] rowsFound = myDataSet.NetworkMappings.Select("DriveLetter ='" + driveLetter.Trim().ToUpper() + "' OR DriveLetter ='" + driveLetter.Trim().ToLower() + "'");
                    if (rowsFound.Length > 0)
                    {
                        drivepath = rowsFound[0]["DrivePath"].ToString().Trim();
                    }
                    else
                    {
                        EventLog.AddWebErrors("GSA.R7BD.Utility", "Utilities", "GetUrl", " AppName:" + appName + "  DriveLetter:" + driveLetter);
                    }
                }
            }
            catch (Exception exp)
            {
                EventLog.AddWebErrors("GSA.R7BD.Utility", "Utilities", "GetUrl", exp.Message + " AppName:" + appName + "  DriveLetter:" + driveLetter);
            }
            return(drivepath);
        }