コード例 #1
0
ファイル: CDebug.cs プロジェクト: WesternCivilization/OUTDEV
        /// <summary>
        /// 11:01 AM Wednesday, March 16, 2016
        /// log all var to file text de debug nguyen nhan error
        /// http://stackoverflow.com/questions/6536163/how-to-list-all-variables-of-class
        /// </summary>
        /// <param name="objAny"></param>
        public static string AllFields2LogFile(string strVarName, object objAny)
        {
            try
            {
                if (objAny == null)
                {
                    return("null");
                }

                BindingFlags bindingFlags = BindingFlags.Public |
                                            BindingFlags.NonPublic |
                                            BindingFlags.Instance |
                                            BindingFlags.Static;

                StringBuilder sbBody = new StringBuilder("");
                foreach (FieldInfo field in objAny.GetType().GetFields(bindingFlags))
                {
                    string strFieldName  = field.Name;
                    string strFieldValue = GetValueOfField(objAny, field, strFieldName);

                    sbBody.Append("" + strFieldName + " = " + strFieldValue + ""
                                  + Environment.NewLine
                                  + SEPARATOR
                                  + Environment.NewLine);
                }
                string strFileName = strVarName + "___" + DateTime.Now.ToString(FORMAT_TIME) + FILE_EXT;  // "dd/MM/yyyy HH:mm";// (24/10/2012 15:36)
                CLog.LogEx(strFileName, sbBody.ToString());

                return(strFileName);
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                return("");
            }
        }
コード例 #2
0
ファイル: CBase.cs プロジェクト: WesternCivilization/OUTDEV
        public static string GetURLResponseHTTPS(string strURL)
        {
            try
            {
                WebRequest request = WebRequest.Create(strURL);
                request.Proxy       = null;
                request.Credentials = CredentialCache.DefaultCredentials;

                //allows for validation of SSL certificates
                ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate);

                HttpWebResponse response           = (HttpWebResponse)request.GetResponse();
                Stream          dataStream         = response.GetResponseStream();
                StreamReader    reader             = new StreamReader(dataStream);
                string          responseFromServer = reader.ReadToEnd();
                return(responseFromServer);
            }
            catch (System.Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                return("");
            }
        }
コード例 #3
0
ファイル: CDebug.cs プロジェクト: WesternCivilization/OUTDEV
 public static void LogFile(string strFileNameEx, string strBody)
 {
     CLog.LogEx(strFileNameEx, strBody);
 }