Exemplo n.º 1
0
 static TranslatorHelper()
 {
     TranslatorSleepTime  = Math.Max(TypeParseHelper.StrToInt32(ConfigHelper.GetAppSettingValue("TranslatorSleepTime")), 1);
     TranslatorUserMethod = Math.Max(TypeParseHelper.StrToInt32(ConfigHelper.GetAppSettingValue("TranslatorUserMethod")), 1);
     if (TranslatorSleepTime < 1)
     {
         TranslatorSleepTime = 1;
     }
     if (TranslatorUserMethod < 1)
     {
         TranslatorUserMethod = 1;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// string数组转int32数组
 /// </summary>
 /// <param name="strings"></param>
 /// <returns></returns>
 public static int[] StrsToInt32s(string[] strings)
 {
     int[] ints = null;
     if (strings != null)
     {
         int length = strings.Length;
         ints = new int[length];
         for (int i = 0; i < length; i++)
         {
             ints[i] = TypeParseHelper.StrToInt32(strings[i]);
         }
     }
     return(ints);
 }
        /// <summary>
        /// 根据服务名称获取服务状态。
        /// </summary>
        /// <param name="serviceName">服务名</param>
        /// <returns>状态</returns>
        public static int GetServiceStatus(string serviceName)
        {
            int result = 0;

            try
            {
                using (ServiceController sc = new ServiceController(serviceName))
                {
                    result = TypeParseHelper.StrToInt32(sc.Status);
                }
            }
            catch (Exception ex)
            {
                result = 0;
                throw ex;
            }
            return(result);
        }