Esempio n. 1
0
        /// <summary>
        /// Changes the time format.
        /// </summary>
        /// <returns></returns>
        public static string ChgTimeFormat(string TimeString)
        {
            string strTime          = TimeString;
            string strTimeDelimiter = ":";

            try
            {
                if (TimeString.Split(Convert.ToChar(strTimeDelimiter)).Length > 1)
                {
                    //hh:mm → hhmm
                    strTime = TimeString.Replace(strTimeDelimiter, string.Empty);
                }
                else
                {
                    //hhmm → hh:mm
                    // 20141202 ZAM
                    string tempstr = ("0000" + TimeString);
                    strTime = tempstr.Substring(tempstr.Length - 4, 4);
                    strTime = strTime.Substring(0, 2) + strTimeDelimiter + strTime.Substring(2, 2);
                }
            }
            catch (Exception ex)
            {
                HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "", "ChgTimeFormat! error information : " + ex.Message + Environment.NewLine + ex.StackTrace);
                throw ex;
            }
            return(strTime);
        }
Esempio n. 2
0
        /// <summary>
        /// Changes the date format.
        /// </summary>
        /// <returns></returns>
        public static string ChgDateFormat(string DateString)
        {
            string strDate          = DateString;
            string strDateDelimiter = "/";

            try
            {
                switch (DateString.Length)
                {
                case 8:
                    //YYYYMMDD → e.g)YYYY/MM/DD
                    strDate = DateString.Substring(0, 4) + strDateDelimiter + DateString.Substring(4, 2) + strDateDelimiter + DateString.Substring(6, 2);

                    break;

                case 10:
                    //e.g)YYYY/MM/DD → YYYYMMDD
                    strDate = DateString.Replace(strDateDelimiter, string.Empty);

                    break;

                default:

                    break;
                }
            }
            catch (Exception ex)
            {
                HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "", "ChgDateFormat! error information : " + ex.Message + Environment.NewLine + ex.StackTrace);
                throw ex;
            }
            return(strDate);
        }
Esempio n. 3
0
        //数据库断开连接 ZAM 2015-5-22
        public bool DisConnect()
        {
            bool ret = false;

            try
            {
                DataConnection.count--;
                CacheConnectionObject.Close();
                ret = true;
            }
            catch (Exception ex)
            {
                HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "", "数据库断开连接失败! error information : " + ex.Message + Environment.NewLine + ex.StackTrace);
                throw ex;
            }
            return(ret);
        }