示例#1
0
        public static void AddErrorInLog(string NameError, string DescrError)
        {
            try
            {
                using (AvtoritetEntities entities = new AvtoritetEntities())
                {
                    LogErrorsSet entity   = new LogErrorsSet();
                    string       hostName = Dns.GetHostName();
                    string       str2     = "";
                    for (int i = 0; i < Dns.GetHostEntry(hostName).AddressList.Length; i++)
                    {
                        if (!Dns.GetHostEntry(hostName).AddressList[i].IsIPv6LinkLocal)
                        {
                            if (str2 != "")
                            {
                                str2 = str2 + ", ";
                            }
                            str2 = str2 + Dns.GetHostEntry(hostName).AddressList[i].ToString();
                        }
                    }
                    string userName    = Environment.UserName;
                    string machineName = Environment.MachineName;
                    entity.Computer   = hostName + ", " + str2 + ", " + userName + ", " + machineName;
                    entity.DateError  = new DateTime?(DateTime.Now);
                    entity.ExeName    = "Лаунчер";
                    entity.NameError  = NameError;
                    entity.DescrError = DescrError;

                    entities.LogErrorsSet.Add(entity);
                    entities.SaveChanges();
                }
            }
            catch (Exception e)
            {
                MainWindow.Logging(e);

                if (!(Application.Current == null))
                {
                    Application.Current.Shutdown(-1);
                }
                else
                {
                    ;
                }
            }
        }
示例#2
0
        public static void AddErrorInLog(string NameError, string DescrError)
        {
            try
            {
                using (AvtoritetEntities ae = new AvtoritetEntities())
                {
                    LogErrorsSet log    = new LogErrorsSet();
                    string       myHost = Dns.GetHostName();
                    string       compIP = "";
                    for (int i = 0; i < Dns.GetHostEntry(myHost).AddressList.Length; i++)
                    {
                        if (!Dns.GetHostEntry(myHost).AddressList[i].IsIPv6LinkLocal)
                        {
                            if (compIP != "")
                            {
                                compIP += ", ";
                            }
                            compIP += Dns.GetHostEntry(myHost).AddressList[i].ToString();
                        }
                    }
                    string userNameWin = System.Environment.UserName;
                    string compName    = System.Environment.MachineName;
                    log.Computer = string.Concat(new string[]
                    {
                        myHost, ", ",
                        compIP, ", ",
                        userNameWin, ", ",
                        compName
                    });
                    log.DateError  = new System.DateTime?(System.DateTime.Now);
                    log.ExeName    = "Прокси сервер";
                    log.NameError  = NameError;
                    log.DescrError = DescrError;

                    ae.LogErrorsSet.Add(log);
                    ae.SaveChanges();
                }
            }
            catch
            {
            }
        }