Esempio n. 1
0
        public string SendWhatsApp(string XAPIId, string XAPIMobile, string Message, bool isWelcomeMessage, IMyLog log, out string fileName)
        {
            fileName = "";
            try
            {
                m_TimeNow = DateTime.UtcNow;
                // 1) extract post dat
                // 2) load user file and check guid
                // 3) check time delay
                // 4) verify mobile number
                // 5) createMessageFile
                // 6) update user counters
                extractPostData(XAPIId, XAPIMobile, Message);
                bool sendFooter = true;
                loadUserFileAndCheckGUID(delegate()
                {
                    m_User.CommitOrThrow_Send(m_RequTelList, isWelcomeMessage, m_Message.Length, ref m_User.AccountStatus, out sendFooter);
                }, log);

                bool noCounterUpdate = false;
                if (Message.StartsWith("__NoSend"))
                {
                    noCounterUpdate = true;
                }
                else if (Message == "Welcome\r\n")
                {
                    noCounterUpdate = true;
                }

                int telNoId = 0;
                foreach (string tel1 in m_RequTelList)
                {
                    fileName +=
                        createMessageFile(
                            telNoId,
                            m_TimeNow,
                            log,
                            noCounterUpdate,
                            sendFooter,
                            this.m_User.DeleteOnFailed ?
                            1 : -1) + ", ";
                    // move on
                    telNoId++;
                }

                if (telNoId == 1)
                {
                    return("queued");
                }
                else
                {
                    return("queued x" + telNoId.ToString());
                }
            }
            catch (DataUnavailableException due)
            {
                return(due.Message);
            }
            catch (ArgumentException ae)
            {
                return(ae.Message);
            }
        }