private HttpWebRequest GetHttpWebRequestClient() { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); if (ZCRMConfigUtil.ConfigProperties.ContainsKey("timeout")) { int?timeoutPeriod = Convert.ToInt32(ZCRMConfigUtil.GetConfigValue("timeout")); if (timeoutPeriod != null) { request.Timeout = (int)timeoutPeriod; } } request.UserAgent = APIConstants.USER_AGENT; return(request); }
internal static void Init() { Trace.AutoFlush = true; logger = new ZCRMLogger(); logSwitch = new TraceSwitch("ZCRMLogger", "ZCRMSDK Logger"); string minLoglevel = ZCRMConfigUtil.GetConfigValue(APIConstants.MIN_LOG_LEVEL); if ((minLoglevel == null) || (!APIConstants.LOGGER_LEVELS.ContainsKey(minLoglevel))) { logSwitch.Level = TraceLevel.Info; } else if (APIConstants.LOGGER_LEVELS.ContainsKey(minLoglevel)) { logSwitch.Level = APIConstants.LOGGER_LEVELS[minLoglevel]; } string logFile = ZCRMConfigUtil.GetConfigValue("logFilePath"); if (string.IsNullOrEmpty(logFile)) { logFile = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location) + Path.DirectorySeparatorChar + "LogFile.log"; } else { logFile += "LogFile.log"; } DefaultTraceListener defaultTrace = new DefaultTraceListener { LogFileName = logFile }; while (Trace.Listeners.Count > 0) { Trace.Listeners.RemoveAt(0); } Trace.Listeners.Add(defaultTrace); }