Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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 && TraceLevel.Off.Equals(APIConstants.LOGGER_LEVELS[minLoglevel]))
            {
                return;
            }

            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(APIConstants.LOG_FILE_PATH);

            if (string.IsNullOrEmpty(logFile))
            {
                logFile = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location) + Path.DirectorySeparatorChar + APIConstants.LOG_FILE_NAME;
            }
            else
            {
                logFile += APIConstants.LOG_FILE_NAME;
            }

            defaultTrace = new TextWriterTraceListener(logFile);

            Trace.Listeners.Add(defaultTrace);
        }
Ejemplo n.º 3
0
        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);
        }