Пример #1
0
        //#region Validation IsDate

        ////(yyyy/MM/dd)
        //private static readonly string isDate_PATTERN = @"((19|20|30|40|50)\d\d)\/(0[1-9]|1[0-9])\/((0|1)[0-9]|2[0-9]|3[0-1])$";

        ////private static readonly string isDate_PATTERN = @"^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))|^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d+$";

        //public static bool IsValidDate(string date)
        //{
        //  //try
        //  //{
        //  //  if (IsValidEmpty(date) == false)
        //  //  {
        //  //    Convert.ToDateTime(date);
        //  //    return true;
        //  //  }
        //  //}
        //  //catch
        //  //{
        //  //  //MethodesClass.ErrorLogAsync("date is " + date + MethodesClass.GetMethodName());
        //  //  return false;
        //  //}
        //  if (date != null && date != string.Empty)
        //    return Regex.IsMatch(date, isDate_PATTERN) & date.Trim().Length > 0;
        //  else
        //  {
        //    return false;
        //  }
        //}

        //#endregion Validation IsDate

        #region Validation DateTime

        public static bool IsValiDateTime(string date, string dateFormat)
        {
            try
            {
                DateTime dt = default;
                //bool isValid = DateTime.TryParseExact(date, dateFormat, null, 0, out dt);
                bool isValid = DateTime.TryParseExact(date, dateFormat, null, 0, out dt);
                if (!isValid)
                {
                    return(false);
                }
                DateTime min = new DateTime(1967, 1, 1);
                DateTime max = new DateTime(3000, 1, 1);
                if (dt < min || dt > max)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception e1)
            {
                MethodesClass.ErrorLogAsync("date is " + date + "\n" + " Exception Is " + e1.Message + MethodesClass.GetMethodName());
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// Executes the gives SQL query
        /// </summary>
        /// <param name="query">The SQL query to be executed</param>
        /// <param name="Parameters">Query parameters and their values</param>
        /// <returns>Number of rows affected</returns>
        public int ExecuteNonQuery(string query, Dictionary <string, object> Parameters = null)
        {
            int x = ExecuteCommand(connString, providerName, query, Parameters);

            if (x <= 0)
            {
                MethodesClass.ErrorLogAsync(query + MethodesClass.GetMethodName());
            }
            return(x);
        }
        public static void ErrorLogAsync(string Message)
        {
            StreamWriter sw = null;

            try
            {
                string sLogFormat = Convert.ToDateTime(MethodesClass.DateTimeNow()).ToString(ConstansValuesClass.formatDate) + " " + Convert.ToDateTime(MethodesClass.DateTimeNow()).ToLongTimeString() + " ==> ";
                string sPathName  = System.Web.HttpContext.Current.Server.MapPath("~/_Log");
                //string sPathName = @"C:\Users\Dell\Desktop\Refit v 1.0\_Log";
                CeartFolder(sPathName);
                string sYear      = Convert.ToDateTime(MethodesClass.DateTimeNow()).Year.ToString();
                string sMonth     = Convert.ToDateTime(MethodesClass.DateTimeNow()).Month.ToString();
                string sDay       = Convert.ToDateTime(MethodesClass.DateTimeNow()).Day.ToString();
                string sErrorTime = sDay + " - " + sMonth + "-" + sYear;
                sw = new StreamWriter(sPathName + "\\" + sErrorTime + ".txt", true);
                sw.WriteLine(sLogFormat + Message);
                sw.Flush();

                #region Send mail by Erorr

                string projectName = GetProjectName();
                //Ahmed Mail
                //await SendingAlertMessages.sendMail(ConstansValuesClass.sendFrom, ConstansValuesClass.password, ConstansValuesClass.stmpServer, ConstansValuesClass.portNumber, "*****@*****.**", "Error Project : " + projectName, (sLogFormat + Message), "");
                ////Ahmed Omer Mail
                //await SendingAlertMessages.sendMail(ConstansValuesClass.sendFrom, ConstansValuesClass.password, ConstansValuesClass.stmpServer, ConstansValuesClass.portNumber, "*****@*****.**", "Error Project : " + projectName, (sLogFormat + Message), "");

                #endregion Send mail by Erorr
            }
            catch (Exception)
            {
                //ErrorLog(ex.ToString());
            }
            finally
            {
                if (sw != null)
                {
                    sw.Dispose();
                    sw.Close();
                }
            }
        }
        public static bool DistanceMeasurement(string empoloyeLatitude, string empoLongitude, string palceLatitude, string placeLongitude, string placeArea)
        {
            try
            {
                double destance = MethodesClass.GetDistanceBetweenPoints(
                    Convert.ToDouble(empoloyeLatitude),
                    Convert.ToDouble(empoLongitude),
                    Convert.ToDouble(palceLatitude),
                    Convert.ToDouble(placeLongitude));

                if (Math.Abs(destance) <= Math.Abs(Convert.ToDouble(placeArea)))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception) { }
            return(false);
        }