Exemplo n.º 1
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        ///     Parses the string value from the given object - particularly useful for dates and uses the pretty date format used elsewhere
        /// </summary>
        public static string ParseRawVal(object rawObj)
        {
            string val = "";

            try {
                if (rawObj == null)
                {
                    val = "";
                }
                else
                {
                    // check to see if it is a date ....
                    if (rawObj.GetType() == (new DateTime().GetType()))
                    {
                        DateTime tempDT = new DateTime();
                        DateTime.TryParse(rawObj.ToString(), out tempDT);
                        val = DateTimeInformation.PrettyDateFormat(tempDT);
                    }
                    else
                    {
                        // integer or string ...
                        val = rawObj.ToString();
                    }
                }
            } catch (Exception ex) {
                //
                Logger.LogError(7, "Couldn't parse the raw value from the given object in GetFieldValue: " + ex.ToString());
            }

            return(val);
        }
        //---------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>The dates should be in the pretty format 1 Jan 2006</summary>
        public static string DateQueryGetPseudoCode(DateTime fromDate, DateTime toDate)
        {
            string fromDateStr = null;

            if (IsNullDate(fromDate) == false)
            {
                fromDateStr = DateTimeInformation.PrettyDateFormat(fromDate);
            }

            string toDateStr = null;

            if (IsNullDate(toDate) == false)
            {
                toDateStr = DateTimeInformation.PrettyDateFormat(toDate);
            }

            return(DateQueryGetPseudoCode(fromDateStr, toDateStr));
        }