private void saveNormalMessage(ICallMessage callMessage, OperatorTimeChecker ot)
 {
     string fileName = saveFileGetNewName(callMessage);
     try
     {
         string query =
            @"INSERT INTO phone_call( id_operator,  phone,  date_start,  date_interval,  sender_mail,  file_name)
                             VALUES (@id_operator, @phone, @date_start, @date_interval, @sender_mail, @file_name)";
         ExecNonQuery(query, new SqlParameter[] { 
             new SqlParameter("@id_operator", ot.getIdOperator()),
             new SqlParameter("@phone", callMessage.Abonent()),
             new SqlParameter("@date_start", callMessage.DateTimeStart()),
             new SqlParameter("@date_interval", callMessage.DateTimeInterval()),
             new SqlParameter("@sender_mail", callMessage.Sender()),
             new SqlParameter("@file_name", fileName)
         });
     }
     catch(Exception e)
     {
         saveFailedMessage(callMessage, "Cannot save message to phone_call table: " + e.Message, fileName);
     }
 }
        public void HandleMessage(ICallMessage callMessage)
        {
            if (null == callMessage || !callMessage.isValid()) return;

            if ("".Equals(callMessage.Operator()) ||                      //   <---- these fields could be empty 
               DateTime.MinValue.Equals(callMessage.DateTimeStart()) ||   //   <---- because of incorrect mail template (regex),
               DateTime.MaxValue.Equals(callMessage.DateTimeInterval()) ||//   <---- they must be checked in the CallDataConsumer
               "".Equals(callMessage.Abonent()))                          //   <---- and mail should be saved in special table
            {
                String description = "Possibly the regex is incorrect. Check the MessageRegex element in the MessageStructure section of the config class. ";
                saveFailedMessage(callMessage, description);
                return;
            }

            OperatorTimeChecker ot;
            if (!operatorOperatorTime.TryGetValue(callMessage.Operator(), out ot))
            {
                ot = new OperatorTimeChecker(callMessage, this);
                operatorOperatorTime.Add(callMessage.Operator(), ot);
            }
            checkDateAndSave(callMessage, ot);
        }
 private void checkDateAndSave(ICallMessage callMessage, OperatorTimeChecker ot)
 {
     if (ot.isValid(callMessage))
     {
         //save to database normally
         saveNormalMessage(callMessage, ot);
     }
     else
         saveFailedMessage(callMessage, "Invalid time intervals");
 }