//below function will used to get channel/EndPointBinding value from specified web config file path
        public static string GetChannel(string configFile)
        {
            DirectoryInfo di = new DirectoryInfo(configFile.Remove(configFile.Length - 10));

            FileInfo[]     rgFiles         = di.GetFiles("web.config");
            SqlCommand     CmdXMLFileData  = new SqlCommand();
            SqlDataAdapter DaXmlFileData   = new SqlDataAdapter(CmdXMLFileData);
            DataSet        DsXMLFileData   = new DataSet();
            DataView       dv              = new DataView();
            string         EndpointBinding = string.Empty;

            try
            {
                foreach (FileInfo fi in rgFiles)
                {
                    DsXMLFileData.ReadXml(fi.FullName);
                    if (DsXMLFileData.Tables.Count > 0)
                    {
                        if (DsXMLFileData.Tables.Contains("Add"))
                        {
                            DsXMLFileData.Tables["Add"].DefaultView.RowFilter = "BindingConfiguration <> '' AND scheme = 'net.tcp' AND binding='customBinding' ";
                            DataTable dt = (DsXMLFileData.Tables["Add"].DefaultView).ToTable();
                            if (dt.Rows.Count > 0)
                            {
                                if (Convert.ToString(dt.Rows[0]["bindingconfiguration"]) == "TcpCompressedUsernameWindowsChannel")
                                {
                                    EndpointBinding = "UsernameWindowsChannel";
                                }
                                else if (Convert.ToString(dt.Rows[0]["bindingconfiguration"]) == "TcpCompressedWindows")
                                {
                                    EndpointBinding = "Windows";
                                }
                                else
                                {
                                    ShowCallerInfo("Known bindingconfiguration not found, Please contact Administrator");
                                }
                            }
                            else
                            {
                                ShowCallerInfo("BindingConfiguration section not found, Please contact Administrator");
                            }
                        }
                    }
                }
                return(EndpointBinding);
            }
            catch (Exception ex)
            {
                GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => GetChannel : ", ex);
                throw new BLException("GlobalSysInfo => GetChannel : " + ex.Message);
            }
            finally
            {
                DsXMLFileData.Dispose();
                dv.Dispose();
            }
        }
 //below function will used to get all specified sysParam values in dataset format
 public static DataSet GetAllSysParamValues(string ErpConStr, string code)
 {
     try
     {
         SqlConnection Con = new SqlConnection(ErpConStr);
         SqlCommand    Cmd = new SqlCommand();
         if (Con.State == ConnectionState.Closed)
         {
             Con.Open();
         }
         Cmd.CommandText = "Stcl_CIFMIS_Global_GetSysParamData";
         Cmd.CommandType = CommandType.StoredProcedure;
         Cmd.Connection  = Con;
         Cmd.Parameters.AddWithValue("@code", code);
         SqlDataAdapter Da = new SqlDataAdapter(Cmd);
         DataSet        Ds = new DataSet();
         Da.Fill(Ds);
         if (Con.State == ConnectionState.Open)
         {
             Con.Close();
         }
         if (Ds != null)
         {
             if (Ds.Tables.Count > 0)
             {
                 if (Ds.Tables[0].Rows.Count > 0)
                 {
                     return(Ds);
                 }
                 else
                 {
                     GlobalSysFunctions.ShowCallerInfo("Stcl.Global.GlobalProcedures => GetAllSysParamValues(): Ds.Table[0].Rows.Count = 0");
                     return(Ds);
                 }
             }
             else
             {
                 GlobalSysFunctions.ShowCallerInfo("Stcl.Global.GlobalProcedures => GetAllSysParamValues(): Ds.Tables.Count = 0 (might be sp or table objects not there)");
                 return(Ds);
             }
         }
         else
         {
             GlobalSysFunctions.ShowCallerInfo("Stcl.Global.GlobalProcedures => GetAllSysParamValues(): Ds = null (might be sp or table objects not there)");
             return(Ds);
         }
     }
     catch (Exception ex)
     {
         GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => GetAllSysParamValues : ", ex);
         throw new BLException("GlobalSysInfo => GetAllSysParamValues : " + ex.Message);
     }
 }
        public static DataTable GetSysAuditInfo()
        {
            try
            {
                DataTable DtSysInfo = new DataTable();
                DtSysInfo.Columns.Add("ApplicationDateTime_c", System.Type.GetType("System.DateTime"));
                DtSysInfo.Columns.Add("ApplicationIPAddress_c", System.Type.GetType("System.String"));
                DtSysInfo.Columns.Add("ApplicationMACAddress_c", System.Type.GetType("System.String"));
                DtSysInfo.Columns.Add("ApplicationTimeZone_c", System.Type.GetType("System.String"));
                DtSysInfo.Columns.Add("ApplicationMotherBoardId_c", System.Type.GetType("System.String"));
                DtSysInfo.Columns.Add("DatabaseDateTime_c", System.Type.GetType("System.DateTime"));
                DtSysInfo.Columns.Add("DatabaseIPAddress_c", System.Type.GetType("System.String"));
                DtSysInfo.Columns.Add("DatabaseMACAddress_c", System.Type.GetType("System.String"));
                DtSysInfo.Columns.Add("DatabaseTimeZone_c", System.Type.GetType("System.String"));
                DtSysInfo.Columns.Add("DatabaseUserName_c", System.Type.GetType("System.String"));
                DtSysInfo.Columns.Add("DatabaseName_c", System.Type.GetType("System.String"));
                DtSysInfo.Columns.Add("DatabaseHostName_c", System.Type.GetType("System.String"));
                GlobalSysFunctions ObjSys = new GlobalSysFunctions(EContext);

                //Keep below commented code as per discussion of Mahesh Deore 01-June-2017.
                ////ObjSys.ExecSysAuditLogProc();
                ////DtSysInfo.Rows.Add(
                ////    GlobalSysFunctions.GetApplicationDateTime(),                // ApplicationDateTime_c

                ////    GlobalSysFunctions.GetIPAddress(),                          // ApplicationIPAddress_c
                ////    Convert.ToString(GlobalSysFunctions.GetMacAddress()),       // ApplicationMACAddress_c
                ////    GlobalSysFunctions.GetCurrentTimeZone(),                    // ApplicationTimeZone_c
                ////    Convert.ToString(GlobalSysFunctions.GetMotherBoardID()),    // ApplicationMotherBoardId_c
                ////    Convert.ToDateTime(CurrDTDb),                                                  // DatabaseDateTime_c
                ////    IPAddrDb,                                                  // DatabaseIPAddress_c
                ////    //GlobalSysFunctions.GetMacAddressFromIP(IPAddrDb).Replace("MAC Address = ", ""),
                ////    //Update By Shweta Parashar on 12-Jan-2016 ,given Error while  Mac Address is blank
                ////    string.IsNullOrEmpty(GlobalSysFunctions.GetMacAddressFromIP(IPAddrDb)) ? "" : GlobalSysFunctions.GetMacAddressFromIP(IPAddrDb).Replace("MAC Address = ", ""), // DatabaseMACAddress_c
                ////    TimeZoneDb,
                ////    DBUserNameDb,
                ////    DBNameDb,
                ////    HostNameDb
                ////    );
                DtSysInfo.Rows.Add(DateTime.Now.ToString(), "localhost", "-", "-", "-", DateTime.Now, "-", "-", "-", "-", "-", "-");

                return(DtSysInfo);
            }
            catch (Exception ex)
            {
                GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => GetSysAuditInfo : ", ex);
                throw new BLException("GlobalSysInfo => GetSysAuditInfo : " + ex.Message);
            }
        }
 /*Get MotherBoardId */
 public static string GetMotherBoardID()
 {
     try
     {
         ////ManagementObjectCollection mbCol = new ManagementClass("Win32_BaseBoard").GetInstances();
         ManagementObjectCollection mbCol = new ManagementClass("Win32_BIOS").GetInstances();
         //Enumerating the list
         ManagementObjectCollection.ManagementObjectEnumerator mbEnum = mbCol.GetEnumerator();
         //Move the cursor to the first element of the list (and most probably the only one)
         mbEnum.MoveNext();
         //Getting the serial number of that specific motherboard
         return(((ManagementObject)(mbEnum.Current)).Properties["SerialNumber"].Value.ToString());
     }
     catch (Exception ex)
     {
         GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => GetMotherBoardID : ", ex);
         throw new BLException("GlobalSysInfo => GetMotherBoardID : " + ex.Message);
     }
 }
 /*Get MAC Address*/
 public static PhysicalAddress GetMacAddress()
 {
     try
     {
         foreach (NetworkInterface NetInt in NetworkInterface.GetAllNetworkInterfaces())
         {
             if (NetInt.NetworkInterfaceType == NetworkInterfaceType.Ethernet && NetInt.OperationalStatus == OperationalStatus.Up)
             {
                 return(NetInt.GetPhysicalAddress());
             }
         }
         return(null);
     }
     catch (Exception ex)
     {
         GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => GetMacAddress : ", ex);
         throw new BLException("GlobalSysInfo => GetMacAddress : " + ex.Message);
     }
 }
        /*Get CPU ID*/
        public static string GetCPUID()
        {
            try
            {
                string CpuId = string.Empty;
                ManagementObjectSearcher   ObjMos     = new ManagementObjectSearcher("Select ProcessorID From Win32_processor");
                ManagementObjectCollection ObjMocList = ObjMos.Get();

                foreach (ManagementObject ObjMo in ObjMocList)
                {
                    CpuId = ObjMo["ProcessorID"].ToString();
                }
                return(CpuId);
            }
            catch (Exception ex)
            {
                GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => GetCPUID : ", ex);
                throw new BLException("GlobalSysInfo => GetCPUID : " + ex.Message);
            }
        }
 /*Get IP Address*/
 public static string GetIPAddress()
 {
     try
     {
         string      HostName = Dns.GetHostName();
         IPHostEntry IPEntry  = Dns.GetHostEntry(HostName);
         foreach (IPAddress IPAdd in IPEntry.AddressList)
         {
             if (IPAdd.AddressFamily.ToString() == "InterNetwork")
             {
                 return(IPAdd.ToString());
             }
         }
         return("-");
     }
     catch (Exception ex)
     {
         GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => GetIPAddress : ", ex);
         throw new BLException("GlobalSysInfo => GetIPAddress : " + ex.Message);
     }
 }
        /*Get MAC Address added by IP Address [Mahesh]*/
        public static string GetMacAddressFromIP(string ipAddress)
        {
            string macAddress = string.Empty;

            if (!IsHostAccessible(ipAddress))
            {
                return(null);
            }
            try
            {
                ProcessStartInfo processStartInfo = new ProcessStartInfo();
                Process          process          = new Process();
                processStartInfo.FileName = "nbtstat";
                processStartInfo.RedirectStandardInput  = false;
                processStartInfo.RedirectStandardOutput = true;
                processStartInfo.Arguments       = "-a " + ipAddress;
                processStartInfo.UseShellExecute = false;
                process = Process.Start(processStartInfo);

                int Counter = -1;

                while (Counter <= -1)
                {
                    Counter = macAddress.Trim().ToLower().IndexOf("mac address", 0);
                    if (Counter > -1)
                    {
                        break;
                    }
                    macAddress = process.StandardOutput.ReadLine();
                }
                process.WaitForExit();
                macAddress = macAddress.Trim();
            }
            catch (Exception e)
            {
                GlobalSysFunctions.ShowCallerInfo("GetMacAddressFromIP > Failed because : ", e);
                Console.WriteLine("GetMacAddressFromIP > Failed because : " + e.ToString());
            }
            return(macAddress);
        }