Exemplo n.º 1
0
        //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();
            }
        }
Exemplo n.º 2
0
 //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);
     }
 }
Exemplo n.º 3
0
 /*Get Current TimeZone*/
 public static string GetCurrentTimeZone()
 {
     try
     {
         TimeZone LocalZone = TimeZone.CurrentTimeZone;
         return(LocalZone.StandardName.ToString());
     }
     catch (Exception ex)
     {
         GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => GetCurrentTimeZone :", ex);
         throw new BLException("GlobalSysInfo => GetCurrentTimeZone : " + ex.Message);
     }
 }
Exemplo n.º 4
0
 /*Get Windows Login User Details*/
 public static string GetWindowsLoginUserName()
 {
     try
     {
         WindowsIdentity wi     = WindowsIdentity.GetCurrent();
         string          Result = wi.Name;
         return(Result);
     }
     catch (Exception ex)
     {
         GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => GetWindowsLoginUserName : "******"GlobalSysInfo => GetWindowsLoginUserName : " + ex.Message);
     }
 }
Exemplo n.º 5
0
 private static bool IsHostAccessible(string hostNameOrAddress)
 {
     try
     {
         Ping      ping  = new Ping();
         PingReply reply = ping.Send(hostNameOrAddress, PING_TIMEOUT);
         return(reply.Status == IPStatus.Success);
     }
     catch (Exception ex)
     {
         GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => IsHostAccessible : ", ex);
         throw new BLException("GlobalSysInfo => IsHostAccessible : " + ex.Message);
     }
 }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
 /*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);
     }
 }
Exemplo n.º 8
0
 /*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);
     }
 }
Exemplo n.º 9
0
 public static bool ValidateSpecialCharacter(string Value)
 {
     try
     {
         foreach (Char character in Value)
         {
             if (!Char.IsLetterOrDigit(character) && !Char.IsWhiteSpace(character))
             {
                 Value = Convert.ToString(Value).Replace(Convert.ToString(character), "");
                 return(false);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => ValidateSpecialCharacter : ", ex);
         throw new BLException("GlobalSysInfo => ValidateSpecialCharacter : " + ex.Message);
     }
 }
Exemplo n.º 10
0
        /*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);
            }
        }
Exemplo n.º 11
0
        private static IDictionary <string, object> GetParametersFromPreviousMethodCall()
        {
            try
            {
                var StackTrace = new StackTrace();
                var Frame      = StackTrace.GetFrame(2);
                var Method     = Frame.GetMethod();

                var Dictionary = new Dictionary <string, object>();
                foreach (var ParameterInfo in Method.GetParameters())
                {
                    Dictionary.Add(ParameterInfo.Name, ParameterInfo.DefaultValue);
                }
                return(Dictionary);
            }
            catch (Exception ex)
            {
                GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => IDictionary : ", ex);
                throw new BLException("GlobalSysInfo => IDictionary : " + ex.Message);
            }
        }
Exemplo n.º 12
0
 public void ExecSysAuditLogProc()
 {
     try
     {
         foreach (var dbInfo in Dbctx.ExecuteStoreQuery <BusinessObject>("Stcl_CIFMIS_GetDBAuditInfo"))
         {
             MacAddrDb    = dbInfo.MacAddress.ToString();
             IPAddrDb     = !string.IsNullOrEmpty(dbInfo.ClientNetAddress) ? dbInfo.ClientNetAddress.ToString() : "";
             TimeZoneDb   = dbInfo.TimeZone.ToString();
             CurrDTDb     = dbInfo.CurrDateTime;
             DBUserNameDb = dbInfo.DBUserName.ToString();
             DBNameDb     = dbInfo.DataBaseName.ToString();
             HostNameDb   = dbInfo.HostName.ToString();
         }
     }
     catch (Exception ex)
     {
         GlobalSysFunctions.ShowCallerInfo("GlobalSysInfo => ExecSysAuditLogProc : ", ex);
         throw new BLException("GlobalSysInfo => ExecSysAuditLogProc : " + ex.Message);
     }
 }
Exemplo n.º 13
0
 /*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);
     }
 }
Exemplo n.º 14
0
        /*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);
        }