Beispiel #1
0
        public static List <UserRemindInfo> GetUserRemindInfo()
        {
            try
            {
                LogManager.GetCurrentClassLogger().Trace("start request planned dates from" + ConfigurationManager.AppSettings["dbConnectionSctring"]);
            }
            catch (System.Exception ex)
            {
                LogManager.GetCurrentClassLogger().Error("cant read connection string message: " + ex.Message);
            }

            List <UserRemindInfo> result = new List <UserRemindInfo>();
            string query = "select * from InfoAboutClientsForTomorrow";

            // create connection and command
            using (SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["dbConnectionSctring"]))
                using (SqlCommand cmd = new SqlCommand(query, cn))
                {
                    cn.Open();
                    SqlDataReader dr = cmd.ExecuteReader();
                    try
                    {
                        while (dr.Read())
                        {
                            UserRemindInfo info = new UserRemindInfo();
                            info.Name        = (string)dr["ClientName"];
                            info.PhoneNumber = (string)dr["ClientPhone"];
                            info.Time        = ((DateTime)dr["StartTime"]).ToString("HH:mm");
                            result.Add(info);
                        }
                        //   dates = NailDate.Parse(dr);
                    }
                    catch (System.Exception ex)
                    {
                        var log = LogManager.GetCurrentClassLogger();
                        log.Error("Can not get data from DB reason:" + ex.Message);
                    }
                    finally
                    {
                        cn.Close();
                    }
                    return(result);
                }
        }
Beispiel #2
0
        private static void SendSms(UserRemindInfo info)
        {
            var log = LogManager.GetCurrentClassLogger();

            log.Trace("send sms start for info: " + info.ToString());
            try
            {
                Console.WriteLine("send sms to " + info.Name);
                ProcessStartInfo inf = new ProcessStartInfo(@"C:\platform-tools\sendremind.bat", string.Format("{0} \"{1}\" \"{2}\"", info.PhoneNumber, "Напоминаем завтра у вас запись на", info.Time));
                inf.CreateNoWindow = true;
                inf.WindowStyle    = ProcessWindowStyle.Hidden;
                var proc = System.Diagnostics.Process.Start(inf);
                proc.WaitForExit();
                proc.Close();
                Thread.Sleep(500);
            }
            catch (System.Exception ex)
            {
                log.Error("call bat file throw exception: " + ex.Message);
            }
            log.Trace("send sms exit");
        }