Esempio n. 1
0
        public Dictionary <string, string> CheckDomainStatus()
        {
            Dictionary <string, string> result = new Dictionary <string, string>();

            #region agilityWebVersion
            //**** agilityWebVersion
            try
            {
                result["agilityWebVersion"] = this.GetType().Assembly.GetName().Version.ToString();
            }
            catch (Exception ex)
            {
                result["agilityWebVersion"] = "Error";
                Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString());
            }
            #endregion

            #region canWriteContentFiles

            //**** canWriteContentFiles
            try
            {
                if (!Directory.Exists(Current.Settings.ContentCacheFilePath))
                {
                    Directory.CreateDirectory(Current.Settings.ContentCacheFilePath);
                }
                string filepath = Path.Combine(Current.Settings.ContentCacheFilePath, "TestWebsiteConfiguration.tmp");
                System.IO.File.WriteAllText(filepath, DateTime.Now.ToString());

                result["canWriteContentFiles"] = true.ToString();
            }
            catch (Exception ex)
            {
                result["canWriteContentFiles"] = false.ToString();
                Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString());
            }
            #endregion

            #region canDeleteContentFiles

            //**** canDeleteContentFiles
            try
            {
                string filepath = Path.Combine(Current.Settings.ContentCacheFilePath, "TestWebsiteConfiguration.tmp");
                System.IO.File.WriteAllText(filepath, DateTime.Now.ToString());
                System.IO.File.Delete(filepath);

                result["canDeleteContentFiles"] = true.ToString();
            }
            catch (Exception ex)
            {
                result["canDeleteContentFiles"] = false.ToString();
                Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString());
            }
            #endregion

            #region dotNetVersion
            //**** dotNetVersion
            try
            {
                result["dotNetVersion"] = System.Environment.Version.ToString();
            }
            catch (Exception ex)
            {
                result["dotNetVersion"] = "Error";
                Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString());
            }
            #endregion

            //**** contentServerURL
            result["contentServerUrl"] = Current.Settings.ContentServerUrl;

            #region canContactContentServer
            //**** canContactContentServer
            try
            {
                AgilityWebsiteAuthorization auth = BaseCache.GetAgilityWebsiteAuthorization();
                try
                {
                    if (AgilityContext.Domain != null)
                    {
                        auth.WebsiteDomain = AgilityContext.Domain.DomainName;
                    }
                }
                catch { }

                using (AgilityContentServerClient client = BaseCache.GetAgilityServerClient())
                {
                    string url = client.TestConnectionAsync(auth).Result.TestConnectionResult;
                }

                result["canContactContentServer"] = true.ToString();
            }
            catch (Exception ex)
            {
                result["canContactContentServer"] = false.ToString();
                Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString());
            }
            #endregion

            //**** smtpServer
            result["smtpServer"] = Current.Settings.SmtpServer;

            #region canWriteToLog

            //**** canWriteToLog
            try
            {
                if (AgilityContext.ContentAccessor != null)
                {
                    result["canWriteToLog"] = true.ToString();
                }
                else
                {
                    string   logFile = WebTrace.GetLogFilePath();
                    FileInfo fo      = new FileInfo(logFile);
                    if (string.IsNullOrEmpty(logFile) || (fo.Exists && fo.IsReadOnly))
                    {
                        result["canWriteToLog"] = false.ToString();
                    }
                    else
                    {
                        if (!Directory.Exists(Path.GetDirectoryName(logFile)))
                        {
                            Directory.CreateDirectory(Path.GetDirectoryName(logFile));
                            if (!Directory.Exists(Path.GetDirectoryName(logFile)))
                            {
                                throw new ApplicationException("The log directory does not exist.");
                            }
                        }
                        string filepath = Path.Combine(Path.GetDirectoryName(logFile), "TestWebsiteConfiguration.tmp");
                        System.IO.File.WriteAllText(filepath, DateTime.Now.ToString());
                        result["canWriteToLog"] = true.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                result["canWriteToLog"] = false.ToString();
                Agility.Web.Tracing.WebTrace.WriteWarningLine(ex.ToString());
            }
            #endregion

            //**** logFilePath
            if (AgilityContext.ContentAccessor != null)
            {
                result["logFilePath"] = "Blob Storage";
            }
            else
            {
                result["logFilePath"] = Current.Settings.Trace.LogFilePath;
            }

            //**** traceLevel
            result["traceLevel"] = string.Format("{0}", Current.Settings.Trace.TraceLevel);

            //**** siteUsername
            result["siteUsername"] = string.Format("{0}", Environment.UserName); // System.Threading.Thread..CurrentPrincipal.Identity.Name);

            //**** isDevelopmentMode
            result["isDevelopmentMode"] = string.Format("{0}", Current.Settings.DevelopmentMode);

            //**** osVersion
            result["osVersion"] = string.Format("{0}", Environment.OSVersion);

            return(result);
        }