Ejemplo n.º 1
0
        public static bool SendGeneralEmail(
            string toEmail,
            bool sendCopyToAdmin,
            string subject,
            string htmlBodyNoHeader,
            LogForEmailSend log)
        {
            try
            {
                string error;

                return(Send(
                           EMailCredentials.GetSupport(),
                           toEmail,
                           sendCopyToAdmin ? throw new NotImplementedException("not suitable for publication!") : (string)null,
                           subject,
                           htmlBodyNoHeader,
                           out error,
                           log,
                           subject));
            }
            catch (SystemException ex)
            {
                log.Log.Error("SystemException: " + ex.Message);
            }
            return(false);
        }
Ejemplo n.º 2
0
 public MessageProcessing_TrayFrom(NiceSystemInfo niceSystem, d_OnScreenShot onScreenshot, IMyLog trayLog, LogForEmailSend log4Email)
 {
     this.onScreenshot = onScreenshot;
     this.trayLog      = trayLog;
     this.log4Email    = log4Email;
     this.niceSystem   = niceSystem;
 }
Ejemplo n.º 3
0
        public static bool SendJustActivated(Data_AppUserFile user, LogForEmailSend log)
        {
            try
            {
                string to      = user.Email;
                string subject = "Register with NiceApi.net";

                Assembly assembly         = Assembly.GetExecutingAssembly();
                string   htmlBodyNoHeader = new StreamReader(assembly.GetManifestResourceStream("NiceApiLibrary.Embedded.JustActivated.txt")).ReadToEnd();
                htmlBodyNoHeader = htmlBodyNoHeader
                                   .Replace("{Name}", System.Web.HttpUtility.HtmlEncode(user.UserName))
                                   .Replace("{Email}", System.Web.HttpUtility.HtmlEncode(user.Email))
                                   .Replace("{Password}", System.Web.HttpUtility.HtmlEncode(user.Password))
                                   .Replace("{APIId}", System.Web.HttpUtility.HtmlEncode(user.ApiGuId))
                                   .Replace("{Mobile1}", System.Web.HttpUtility.HtmlEncode(user.MobileNumberX(0)))
                                   .Replace("{Mobile2}", System.Web.HttpUtility.HtmlEncode(user.MobileNumberX(1)))
                                   .Replace("{Mobile3}", System.Web.HttpUtility.HtmlEncode(user.MobileNumberX(2)))
                                   .Replace("{Mobile4}", System.Web.HttpUtility.HtmlEncode(user.MobileNumberX(3)))
                                   .Replace("{Mobile5}", System.Web.HttpUtility.HtmlEncode(user.MobileNumberX(4)));

                string error;

                return(Send(EMailCredentials.GetSupport(), to, subject, htmlBodyNoHeader, out error, log, "JustActivated"));
            }
            catch (SystemException)
            {
            }
            return(false);
        }
Ejemplo n.º 4
0
        public static string SendTestMail(LogForEmailSend log)
        {
            string to      = throw new NotImplementedException("not suitable for publication!");
            string subject = "Test Mail";
            string error;

            if (Send(EMailCredentials.GetSupport(), to, subject, "htmlBodyNoHeader", out error, log, "TestMail"))
            {
                return("OK");
            }
            return(error);
        }
Ejemplo n.º 5
0
 public static bool SendAdminNotification(string htmlBodyNoHeader, LogForEmailSend log)
 {
     try
     {
         string to      = throw new NotImplementedException("not suitable for publication!");
         string subject = "AdminNotification NiceApi.net";
         string error;
         return(Send(EMailCredentials.GetSupport(), to, subject, htmlBodyNoHeader, out error, log, "AdminNotification"));
     }
     catch (SystemException)
     {
     }
     return(false);
 }
Ejemplo n.º 6
0
    protected void CreateUser_Click(object sender, EventArgs e)
    {
        try
        {
            Page.Validate();
            if (Page.IsValid)
            {
                IMyLog          log       = MyLog.GetLogger("Register");
                LogForEmailSend log4Email = new LogForEmailSend(MyLog.GetLogger("Email"));

                MessageProcessing_API api = new MessageProcessing_API(null);
                bool fileArleadyUsed;
                api.Process_Registration(
                    NiceSystemInfo.DEFAULT,
                    out fileArleadyUsed,
                    true,
                    UserName.Text,
                    Tel1.Text + Tel2.Text + Tel3.Text + Tel4.Text + Tel5.Text,
                    Email.Text,
                    Password.Text,
                    GetIPAddress(),
                    WhereHeard.Text,
                    log,
                    log4Email);

                if (fileArleadyUsed)
                {
                    SessionData sd = ConstantStrings.GetSessionData(Session);
                    sd.QuickMessage     = "Your registratin failed. Please try again later.";
                    sd.QuickMessageGood = false;
                    Response.Redirect("~/Register.aspx");
                }
                else
                {
                    // ok
                    SessionData sd = ConstantStrings.GetSessionData(Session);
                    sd.QuickMessage     = "Verify your email: We sent a verification email to " + Email.Text + " .Click the link in the email to get started!";
                    sd.QuickMessageGood = true;
                    Response.Redirect("~/Login.aspx");
                }
            }
        }
        catch (DataUnavailableException)
        {
            DSSwitch.OnDataUnavailableException(this);
        }
    }
Ejemplo n.º 7
0
        public static bool SendRegisterActivation(Data_AppUserFile user, LogForEmailSend log)
        {
            try
            {
                string to               = user.Email;
                string subject          = "Register with NiceApi.net";
                string htmlBodyNoHeader = EMail_Data.GetRegistrationEmailBody("https://NiceApi.net/Register?ApiGuId=" + Base64_URLEncoding(user.ApiGuId));
                string error;

                bool ret = Send(EMailCredentials.GetSupport(), to, subject, htmlBodyNoHeader, out error, log, "Verify Please");
                return(ret);
            }
            catch (SystemException)
            {
            }
            return(false);
        }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // This come from an anonymous browser
        try
        {
            Page.MetaKeywords    = "Register, Send Whatsapp message, Free";
            Page.MetaDescription = "Register to use the service.";
            NiceASP.KeywordLoader.Load(this, NiceASP.KeywordLoader.Which.Register);

            string          query     = Request.QueryString["ApiGuId"];
            IMyLog          log       = MyLog.GetLogger("Register");
            LogForEmailSend log4Email = new LogForEmailSend(MyLog.GetLogger("Email"));

            if (query != null)
            {
                // email validation callback
                query = EMail.Base64_URLDecoding(query);
                MessageProcessing_API api = new MessageProcessing_API(query);
                bool good;
                api.Process_Registration_JustVerified(NiceSystemInfo.DEFAULT, out good, false, true, log, log4Email);
                if (good)
                {
                    // good,
                    SessionData sd = ConstantStrings.GetSessionData(Session);
                    sd.QuickMessage     = "Your email is now verified. Please wait 48 hour for your account to become active.";
                    sd.QuickMessageGood = true;
                    Response.Redirect("~/Login.aspx");
                }
                else
                {
                    // bad
                    SessionData sd = ConstantStrings.GetSessionData(Session);
                    sd.QuickMessage     = "This token is expired.";
                    sd.QuickMessageGood = false;
                    Response.Redirect("~/");
                }
            }
        }
        catch (DataUnavailableException)
        {
            DSSwitch.OnDataUnavailableException(this);
        }
    }
Ejemplo n.º 9
0
        public static bool SendUpgradeRequestOnHighPercent(Data_AppUserFile user, LogForEmailSend log)
        {
            try
            {
                string to      = user.Email;
                string subject = "Your account usage";

                Assembly assembly         = Assembly.GetExecutingAssembly();
                string   htmlBodyNoHeader = new StreamReader(assembly.GetManifestResourceStream("NiceApiLibrary.Embedded.UpgradeEmail.txt")).ReadToEnd();
                htmlBodyNoHeader = doFieldReplacement(htmlBodyNoHeader, user);

                string error;

                return(Send(EMailCredentials.GetSupport(), to, subject, htmlBodyNoHeader, out error, log, subject));
            }
            catch (SystemException)
            {
            }
            return(false);
        }
Ejemplo n.º 10
0
        public static bool SendUpgrade032018(Data_AppUserFile user, LogForEmailSend log)
        {
            try
            {
                string to      = user.Email;
                string subject = "Hardware upgrade";

                Assembly assembly         = Assembly.GetExecutingAssembly();
                string   htmlBodyNoHeader = new StreamReader(assembly.GetManifestResourceStream("NiceApiLibrary.Embedded.ServerMove032018EmialText.txt")).ReadToEnd();
                htmlBodyNoHeader = doFieldReplacement(htmlBodyNoHeader, user);

                string error;

                return(Send(EMailCredentials.GetSupport(), to, subject, htmlBodyNoHeader, out error, log, "Upgrade032018"));
            }
            catch (SystemException)
            {
            }
            return(false);
        }
Ejemplo n.º 11
0
        public static bool SendWrongTelRegistered(Data_AppUserFile user, LogForEmailSend log)
        {
            try
            {
                string to      = user.Email;
                string subject = "Your registration with with NiceApi.net";

                Assembly assembly         = Assembly.GetExecutingAssembly();
                string   htmlBodyNoHeader = new StreamReader(assembly.GetManifestResourceStream("NiceApiLibrary.Embedded.Reg_TelWrong_EmailText.txt")).ReadToEnd();
                htmlBodyNoHeader = doFieldReplacement(htmlBodyNoHeader, user);

                string error;

                return(Send(EMailCredentials.GetSupport(), to, subject, htmlBodyNoHeader, out error, log, "WrongTelRegistered"));
            }
            catch (SystemException)
            {
            }
            return(false);
        }
Ejemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // This comes from the TrayApp

        IMyLog          trayLog   = MyLog.GetLogger("TrayApp");
        LogForEmailSend log4Email = new LogForEmailSend(MyLog.GetLogger("Email"));

        try
        {
            // 1) read in incoming object
            //log.Info("incoming msg");
            Data_Net_Tray2ASP fromTray  = new Data_Net_Tray2ASP();
            Stream            streamB64 = Request.InputStream;

            if (streamB64.Length == 0)
            {
                using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
                {
                    ld.GetEntry_CreateIfNotThere(NiceSystemInfo.DEFAULT_STR).debugStr = "Zero is nice at " + DateTime.UtcNow.Ticks.ToUkTime(false);
                }
                Response.ContentType = "text/plain";
                Response.Write("Zero is nice!");
                return;
            }

            BinBase64StreamHelper.Tray2ASP_FromB64Stream(ref fromTray, streamB64);
            ASPTray_ObjectList.Counters fromTrayCounter = fromTray.GetCounters();
            if (fromTrayCounter.Total_Results() != 0)
            {
                trayLog.Debug("X " + fromTrayCounter.Total_ResultsString());
            }

            //trayLog.Debug("TrayApp request from " + fromTray.TrayType);
            NiceSystemInfo subSystem = fromTray.TrayType.GetSystemInfoFromTrayType();
            if (subSystem == null)
            {
                using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
                {
                    ld.LastError = string.Format("incomming subSystem '{0}' not recognised. {1}",
                                                 fromTray.TrayType,
                                                 DateTime.UtcNow.Ticks.ToUkTime(false));
                }
                throw new SystemException("Unknown System: " + fromTray.TrayType);
            }
            //trayLog.Debug("TrayApp loaded " + subSystem.Name);

            // Update loopback file (with the data from the incoming object)
            using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
            {
                DataFile_Loopback_Entry sub = ld.GetEntry_CreateIfNotThere(subSystem.Name);
                sub.lastTrayConnection = DateTime.UtcNow;
                sub.lastTrayId         = fromTrayCounter.Total_ResultsString();
                sub.trayTypeAndIp      = fromTray.TrayType + " - " + Request.UserHostAddress + " - " + (Request.IsSecureConnection ? "https" : "httpONLY");
            }

            // 3) Process each file from the incoming object
            MessageProcessing_TrayFrom proc = new MessageProcessing_TrayFrom(subSystem, onScreenshot, trayLog, log4Email);
            proc.Process_TrayFrom(fromTray, true);

            // 5) prepare the object to be sent
            Data_Net_ASP2Tray toTray = new Data_Net_ASP2Tray();
            DateTime          dtGo   = DateTime.UtcNow.AddSeconds(3);
            while ((toTray.ObjectList.Count == 0) && (dtGo > DateTime.UtcNow))
            {
                // no data yet to send and no timeout
                toTray.ObjectList = MessageProcessing_TrayTo.GetFilesToSendToTray_ConsiderPriority(subSystem, 5, trayLog);
                if (toTray.ObjectList.Count == 0)
                {
                    Thread.Sleep(500);
                }
            }

            // 6) update the loopback file with the sent date
            ASPTray_ObjectList.Counters toTrayCounter = toTray.GetCounters();
            using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
            {
                DataFile_Loopback_Entry sub = ld.GetEntry_CreateIfNotThere(subSystem.Name);
                sub.lastToTray     = DateTime.UtcNow;
                sub.lastToTrayData = "FilesToProcess: " + toTrayCounter.Total_RequestsString();
            }

            // 7) send the object to be sent
            //            Response.ContentType = "application/octet-stream";
            Response.ContentType = "text/plain";
            BinBase64StreamHelper.ASP2Tray_ToB64Stream(ref toTray, Response.OutputStream);
        }
        catch (ThreadAbortException)
        {
            trayLog.Debug("ThreadAbortException");
        }
        catch (Exception se)
        {
            trayLog.Error("TrayApp " + se.Message + " " + se.ToString());
            Response.ContentType = "text/plain";
            Response.Write("Exception");
            Response.Write(se.Message);
            Response.Write(se.ToString());
        }
    }
Ejemplo n.º 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // This comes from the Android direct

        IMyLog trayLog = MyLog.GetLogger("TrayApp");

        trayLog.Info("Incoming 17:00");
        string inBody = "notSet";

        try
        {
            LogForEmailSend log4Email = new LogForEmailSend(MyLog.GetLogger("Email"));
            Stream          inStream  = Request.InputStream;

            if (inStream.Length == 0)
            {
                Response.ContentType = "text/plain";
                Response.Write("DirectTel: Zero!");
                return;
            }

            DirectTel_InJson inJson = null;
            using (var sr = new StreamReader(inStream))
            {
                inBody = sr.ReadToEnd();
                inJson = JsonConvert.DeserializeObject <DirectTel_InJson>(inBody);
            }
            trayLog.Debug("In Json: ");
            trayLog.Debug(JsonConvert.SerializeObject(inJson));

            DirectTel_OutJson outJson = DirectTel_Processing.ProcessDirectTel(inJson, trayLog, log4Email,
                                                                              delegate(NiceSystemInfo subSystem)
            {
                //OnGet
                // Update loopback file (with the data from the incoming object)
                using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
                {
                    DataFile_Loopback_Entry sub = ld.GetEntry_CreateIfNotThere(subSystem.Name);
                    sub.lastDirectTelGet        = DateTime.UtcNow;
                }
            },
                                                                              delegate(NiceSystemInfo subSystem)
            {
                //OnAck
                // Update loopback file (with the data from the incoming object)
                using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
                {
                    DataFile_Loopback_Entry sub = ld.GetEntry_CreateIfNotThere(subSystem.Name);
                    sub.lastDirectTelAck        = DateTime.UtcNow;
                }
            });

            trayLog.Debug("Out Json: ");
            trayLog.Debug(JsonConvert.SerializeObject(outJson));
            Tx(outJson);
        }
        catch (ThreadAbortException)
        {
            trayLog.Debug("ThreadAbortException");
        }
        catch (Exception se)
        {
            trayLog.Error("DirectTel " + se.Message + " " + se.ToString());
            trayLog.Error("DirectTel " + inBody);
            Response.ContentType = "text/plain";
            Response.Write("Exception");
            Response.Write(se.Message);
            Response.Write(se.ToString());
        }
    }
Ejemplo n.º 14
0
 public OnProcessedHandler(int noOfBytes, LogForEmailSend emailLog, bool updateCounters)
 {
     this.noOfBytes      = noOfBytes;
     this.emailLog       = emailLog;
     this.updateCounters = updateCounters;
 }
Ejemplo n.º 15
0
        public string Process_Registration_JustVerified(NiceSystemInfo niceSystem, out bool ok, bool sendAdminNotification, bool sendAdminNotificationToWhatsapp, IMyLog log, LogForEmailSend log4Email)
        {
            StringBuilder sbInfo     = new StringBuilder();
            string        telToCheck = null;

            ok = false;
            string friendlyEmail = null;
            bool   okIntern      = false;

            try
            {
                timeNow = DateTime.UtcNow;
                // 1 extract (check) input data
                if (string.IsNullOrEmpty(APIId))
                {
                    throw new ArgumentException("X-APIId missing");
                }

                // 2 load user file and check guid
                string email = Data_AppUserFile.API_IdToEmail(APIId);
                if (email == null)
                {
                    throw new ArgumentException("X-APIId unknown");
                }
                DSSwitch.appUser().Update_General(email, delegate(Data_AppUserFile user, Object args)
                {
                    if (user == null)
                    {
                        throw new ArgumentException("X-APIId unknown");
                    }
                    if (user.ApiGuId != APIId)
                    {
                        throw new ArgumentException("X-APIId unknown");
                    }
                    if (user.AccountStatus != Data_AppUserFile.eUserStatus.email_sent_for_verification)
                    {
                        throw new ArgumentException("AccountStatus is wrong");
                    }

                    // 3 action, produce telCheck file and update AccountStatus
                    user.AccountStatus = Data_AppUserFile.eUserStatus.verified_checkingTelNumbers;
                    telToCheck         = user.MobileNumbers_AllConfirmed__.getVal + user.MobileNumbers_AllUnConfirmed__.getVal;
                    friendlyEmail      = user.Email;
                    okIntern           = true;
                }, null, delegate(Object args)
                {
                    // post process
                    if (log != null)
                    {
                        log.Info(friendlyEmail + " just verified his email");
                    }
                    if (sendAdminNotification)
                    {
                        EMail.SendAdminNotification(friendlyEmail + " just verified his email", log4Email);
                    }
                    if (sendAdminNotificationToWhatsapp)
                    {
                        NotificationInfo notificationInfo = DSSwitch.full().GetNotificationInfo();
                        NiceSystemInfo notifyToUse        = DSSwitch.full().GetSystems(false).FirstOrDefault(s => s.Name == notificationInfo.Name);
                        if (notifyToUse != null)
                        {
                            Data_Net__00NormalMessage msg = new Data_Net__00NormalMessage(
                                Data_AppUserFile.API_IdToEmail(notifyToUse.APIId),
                                "zapi_" + notificationInfo.RxTel,
                                DateTime.UtcNow.Ticks,
                                friendlyEmail + " just verified his email",
                                0, 10, true);
                            DSSwitch.msgFile00().Store(notifyToUse, msg, Data_Net__00NormalMessage.eLocation.Queued, log);
                        }
                    }
                    Data_Net__04CheckTelNumbers _04 = new Data_Net__04CheckTelNumbers(friendlyEmail, timeNow.Ticks, telToCheck, "");
                    DSSwitch.msgFile04().Store(niceSystem, _04, log);
                }, log);
            }
            catch (ArgumentException ae)
            {
                sbInfo.Append(ae.Message);
            }
            catch (Exception)
            {
                sbInfo.Append("ERROR");
            }
            ok = okIntern;
            return(sbInfo.ToString());
        }
Ejemplo n.º 16
0
        public string Process_Registration(NiceSystemInfo niceSystem, out bool fileArleadyUsed, bool sendActivationEmail, string UserName, string MoblieAllNumbers, string Email, string Password, string CreationIp, string WhereHeardText, IMyLog log, LogForEmailSend log4Email)
        {
            StringBuilder sbInfo = new StringBuilder();

            fileArleadyUsed = true;
            try
            {
                timeNow = DateTime.UtcNow;
                Data_AppUserFile ud = Data_AppUserFile.Create(
                    UserName, true, MoblieAllNumbers, Email, Password, CreationIp);
                sbInfo.Append(ud.ApiGuId);
                DSSwitch.appUser().StoreNew(ud, out fileArleadyUsed, log);
                if (!fileArleadyUsed)
                {
                    if (sendActivationEmail)
                    {
                        EMail.SendRegisterActivation(ud, log4Email);
                    }
                    if (log != null)
                    {
                        log.Info(ud.Email + " account created");
                    }
                    if (log != null)
                    {
                        log.Info("WhereHeard " + WhereHeardText);
                    }
                }
            }
            catch (ArgumentException ae)
            {
                sbInfo.Append(ae.Message);
            }
            catch (Exception)
            {
                sbInfo.Append("ERROR");
            }
            return(sbInfo.ToString());
        }
Ejemplo n.º 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // This comes from the Admin User (protected)

        NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true);

        if (!IsPostBack)
        {
            IMyLog          logInTest = MyLog.GetLogger("Test");
            LogForEmailSend log4Email = new LogForEmailSend(MyLog.GetLogger("Email"));

            string           user  = null;
            Data_AppUserFile userF = null;

            string sVal = Request.QueryString["Id"];
            switch (sVal)
            {
            case "ShowRecentMessages":
                Response.ContentType = "text/plain";
                Response.Write("ShowRecentMessages:\r\n");
                int Days = 5;
                if (Request.QueryString["Days"] != null)
                {
                    Days = Int32.Parse(Request.QueryString["Days"]);
                }
                DateTime pivTime = DateTime.UtcNow;
                pivTime = pivTime.AddDays(-1 * Days);
                DSSwitch.msgFile00().ForEach(
                    NiceASP.SessionData.SessionsSystem_Get(Session), pivTime, null, Data_Net__00NormalMessage.eLocation.Processed, logInTest,
                    delegate(Data_Net__00NormalMessage _00)
                {
                    if (!_00.NoCounterUpdate)
                    {
                        Response.Write(_00.DestMobile + "\r\n".PadLeft(40, '*'));
                        Response.Write(_00.UserId + "\r\n");
                        Response.Write(_00.MsgTicks.ToUkTime(true) + "\r\n");
                        if (_00.FailedCounter != 0)
                        {
                            Response.Write(String.Format("FailedCounter: {0} / {1}\r\n", _00.FailedCounter, _00.DisposeAfterNFailed));
                        }
                        Response.Write(_00.Msg + "\r\n\r\n");
                    }
                });
                break;

            case "ShowSentMessages":
                Response.ContentType = "text/plain";
                Response.Write("ShowSentMessages:\r\n");
                user = Request.QueryString["u"];
                Response.Write(user + ":\r\n");
                DSSwitch.msgFile00().ForEach(NiceASP.SessionData.SessionsSystem_Get(Session), DateTime.MinValue, user, Data_Net__00NormalMessage.eLocation.Processed, logInTest,
                                             delegate(Data_Net__00NormalMessage _00)
                {
                    Response.Write(_00.DestMobile + "\r\n");
                    Response.Write(_00.MsgTicks.ToUkTime(true) + "\r\n");
                    Response.Write(String.Format("FailedCounter: {0} / {1}\r\n", _00.FailedCounter, _00.DisposeAfterNFailed));
                    Response.Write("NoCounterUpdate: " + _00.NoCounterUpdate.ToString() + "\r\n");
                    Response.Write(_00.Msg + "\r\n\r\n");
                });
                break;

            case "ShowUsers":
                bool filterOut_email_sent_for_verification = false;
                bool filterOut_verified_welcome_No_sent    = false;
                bool filterOut_verified_welcome_queued     = false;
                bool filterOut_verified_checkingTelNumbers = false;
                bool filterOut_blocked                      = false;
                bool filterOut_free_account                 = false;
                bool filterOut_commercial_monthly           = false;
                bool filterOut_commercial_payassent         = false;
                bool filterOut_commercial_systemDuplication = false;
                switch (Request.QueryString["Filter"])
                {
                case "OnlyInteresting":
                    filterOut_email_sent_for_verification = true;
                    filterOut_blocked = true;
                    break;

                case "OnlyCommercial":
                    filterOut_verified_checkingTelNumbers = true;
                    filterOut_verified_welcome_No_sent    = true;
                    filterOut_verified_welcome_queued     = true;
                    filterOut_email_sent_for_verification = true;
                    filterOut_blocked      = true;
                    filterOut_free_account = true;
                    break;
                }

                Data_AppUserFile.SortType sortType = Data_AppUserFile.SortType.State;
                switch (Request.QueryString["Sort"])
                {
                case "Date":
                    sortType = Data_AppUserFile.SortType.Date;
                    break;

                case "State":
                    sortType = Data_AppUserFile.SortType.State;
                    break;

                case "Email":
                    sortType = Data_AppUserFile.SortType.Email;
                    break;

                case "Usage":
                    sortType = Data_AppUserFile.SortType.Usage;
                    break;
                }

                showUsers_tableHeader(DSSwitch.appUser().GetInfo());
                int count = 0;
                DSSwitch.appUser().RetrieveAll(sortType,
                                               delegate(Data_AppUserFile d)
                {
                    if (count++ > 1000)
                    {
                        // limit to 1000 results
                        return;
                    }

                    switch (d.AccountStatus)
                    {
                    case Data_AppUserFile.eUserStatus.email_sent_for_verification:
                        if (!filterOut_email_sent_for_verification)
                        {
                            showUsers_tableEntry(d, Data_AppUserFile.EmailSaveChars(d.Email));
                        }
                        break;

                    case Data_AppUserFile.eUserStatus.verified_welcome_No_sent:
                        if (!filterOut_verified_welcome_No_sent)
                        {
                            showUsers_tableEntry(d, Data_AppUserFile.EmailSaveChars(d.Email));
                        }
                        break;

                    case Data_AppUserFile.eUserStatus.verified_welcome_queued:
                        if (!filterOut_verified_welcome_queued)
                        {
                            showUsers_tableEntry(d, Data_AppUserFile.EmailSaveChars(d.Email));
                        }
                        break;

                    case Data_AppUserFile.eUserStatus.verified_checkingTelNumbers:
                        if (!filterOut_verified_checkingTelNumbers)
                        {
                            showUsers_tableEntry(d, Data_AppUserFile.EmailSaveChars(d.Email));
                        }
                        break;

                    case Data_AppUserFile.eUserStatus.blocked:
                        if (!filterOut_blocked)
                        {
                            showUsers_tableEntry(d, Data_AppUserFile.EmailSaveChars(d.Email));
                        }
                        break;

                    case Data_AppUserFile.eUserStatus.free_account:
                        if (!filterOut_free_account)
                        {
                            showUsers_tableEntry(d, Data_AppUserFile.EmailSaveChars(d.Email));
                        }
                        break;

                    case Data_AppUserFile.eUserStatus.commercial_monthly:
                    case Data_AppUserFile.eUserStatus.commercial_monthlyDifPrice:
                        if (!filterOut_commercial_monthly)
                        {
                            showUsers_tableEntry(d, Data_AppUserFile.EmailSaveChars(d.Email));
                        }
                        break;

                    case Data_AppUserFile.eUserStatus.commercial_payassent:
                        if (!filterOut_commercial_payassent)
                        {
                            showUsers_tableEntry(d, Data_AppUserFile.EmailSaveChars(d.Email));
                        }
                        break;

                    case Data_AppUserFile.eUserStatus.commercial_systemDuplication:
                        if (!filterOut_commercial_systemDuplication)
                        {
                            showUsers_tableEntry(d, Data_AppUserFile.EmailSaveChars(d.Email));
                        }
                        break;
                    }
                },
                                               logInTest);
                showUsers_tableFooter();
                break;

            //case "CopyAppUsersToDB":
            //    int count = 0;
            //    DSSwitch.appUser().RetrieveAll(
            //        Data_AppUserFile.SortType.State,
            //        delegate(Data_AppUserFile d)
            //        {
            //            bool fileArleadyUsed;
            //            DSSwitch.appUser_DB().StoreNew(d, out fileArleadyUsed, logInTest);
            //            count++;
            //        },
            //        logInTest);
            //    Response.ContentType = "text/plain";
            //    Response.Write("Done " + count.ToString());
            //    break;


            case "SendWelcomeSMS":
                Response.ContentType = "text/plain";
                user  = Request.QueryString["u"];
                userF = DSSwitch.appUser().RetrieveOne(user, logInTest);
                Response.ContentType = "text/plain";
                foreach (string tel1 in userF.MobileNumberArray())
                {
                    string additionalInfo;
                    Response.Write(tel1 + " " +
                                   (new APIActualSending(NiceASP.SessionData.SessionsSystem_Get(Session)).SendWhatsApp(
                                        userF.ApiGuId,
                                        tel1,
                                        "Welcome to NiceApi.net\r\n",
                                        true,
                                        logInTest,
                                        out additionalInfo)));
                    Response.Write(" " + additionalInfo);
                    System.Threading.Thread.Sleep(200);
                    Response.Write(" slept\r\n");
                }
                break;

            case "SendJustActivated":
                user  = Request.QueryString["u"];
                userF = DSSwitch.appUser().RetrieveOne(user, logInTest);
                Response.ContentType = "text/plain";
                Response.Write(sVal + (
                                   EMail.SendJustActivated(userF, log4Email) ?
                                   " ok" : " failed"));
                break;

            case "ResendVerifyMail":
                user  = Request.QueryString["u"];
                userF = DSSwitch.appUser().RetrieveOne(user, logInTest);
                Response.ContentType = "text/plain";
                Response.Write(sVal + (
                                   EMail.SendRegisterActivation(userF, log4Email) ?
                                   " ok" : " failed"));
                break;

            case "Queue":
                doQueue(logInTest);
                break;

            case "Log":
                logInTest.Info("A test msg from Test.Log");
                Response.ContentType = "text/plain";
                Response.Write("Log done");
                break;

            case "null":
                userF = null;
                user  = userF.UserName;    // simulate bad code
                break;

            default:
                throw new ArgumentNullException("only a test");
            }
        }
    }
Ejemplo n.º 18
0
        public static DirectTel_OutJson ProcessDirectTel(DirectTel_InJson inJson, IMyLog trayLog, LogForEmailSend log4Email, dOnAction onGet, dOnAction onAck)
        {
            trayLog.Debug("DirectTel: Loading " + inJson.SubSystem);
            NiceSystemInfo subSystem = inJson.SubSystem.GetSystemInfoFromTrayType();

            if (subSystem == null)
            {
                throw new Exception("subSystem == null");
            }

            switch (inJson.Inst)
            {
            case "Get":
            {
                // Update loopback file (with the data from the incoming object)
                if (onGet != null)
                {
                    onGet(subSystem);
                }

                // Prepare the object to be sent
                ASPTrayBase trayBase = MessageProcessing_TrayTo.GetFilesToSendToTray_ConsiderPriority(subSystem, 1, trayLog).FirstOrDefault();
                if (trayBase == null)
                {
                    // nothing, so just wait
                    return(new DirectTel_OutJson()
                        {
                            WaitSec = 10,
                        });
                }
                if (trayBase is Data_Net__00NormalMessage)
                {
                    Data_Net__00NormalMessage _00 = trayBase as Data_Net__00NormalMessage;
                    return(new DirectTel_OutJson()
                        {
                            Id = "00" + _00.GetFileName(),
                            Zapi = _00.DestMobile.Replace("+", ""),
                            Text = _00.Msg,
                            IsAddTelOnly = false,
                            WaitSec = 1,
                        });
                }
                if (trayBase is Data_Net__04CheckTelNumbers)
                {
                    Data_Net__04CheckTelNumbers _04 = trayBase as Data_Net__04CheckTelNumbers;
                    MobileNoHandler             h   = new MobileNoHandler(_04.TelList);
                    string firstTel = h.MobileNumberX_AsZapi(0);
                    return(new DirectTel_OutJson()
                        {
                            Id = "04" + _04.GetFileName(),
                            Zapi = firstTel,
                            Text = null,
                            IsAddTelOnly = true,
                            WaitSec = 1,
                        });
                }
            }
            break;

            case "Ack":
                // Update loopback file (with the data from the incoming object)
                if (onAck != null)
                {
                    onAck(subSystem);
                }

                MessageProcessing_TrayFrom proc   = new MessageProcessing_TrayFrom(subSystem, null, trayLog, log4Email);
                Data_Net_Tray2ASP          helper = new Data_Net_Tray2ASP();
                if (inJson.Id.StartsWith("00"))
                {
                    inJson.Id = inJson.Id.Substring(2);
                    Data_Net__01NormalMessageResult _01 = new Data_Net__01NormalMessageResult(inJson.Id, true);
                    helper.ObjectList.Add(_01);
                    proc.Process_TrayFrom(helper, true);
                    return(new DirectTel_OutJson());
                }
                else if (inJson.Id.StartsWith("04"))
                {
                    inJson.Id = inJson.Id.Substring(2);
                    Data_Net__05CheckTelNumbersResult _05 = new Data_Net__05CheckTelNumbersResult(inJson.Id, null, null, null);
                    helper.ObjectList.Add(_05);
                    proc.Process_TrayFrom(helper, true);
                    return(new DirectTel_OutJson());
                }
                else
                {
                }


                break;

            default:
                throw new Exception("Unknown inst");
            }

            return(null);
        }
Ejemplo n.º 19
0
        public static bool Send(EMailCredentials from, string to, string bcc, string subject, string htmlBodyNoHeader, out string errorText, LogForEmailSend log, string logId)
        {
            EMailCredentials cred = from;

            errorText = "";

            if ((to == null) && (bcc != null))
            {
                // no to set but a bcc, so swap
                to  = bcc;
                bcc = null;
            }

            MailMessage mail = new MailMessage();

            mail.To.Add(to);
            if (bcc != null)
            {
                mail.Bcc.Add(bcc);
            }
            mail.From            = cred.From;
            mail.Subject         = subject;
            mail.SubjectEncoding = System.Text.Encoding.UTF8;
            mail.Body            = EMail_Data.GetHeaderHtml() + htmlBodyNoHeader + EMail_Data.GetFooterHtml();
            mail.BodyEncoding    = System.Text.Encoding.UTF8;
            mail.IsBodyHtml      = true;
            mail.Priority        = MailPriority.High;

            if ("SendEmailToDataport".IsAppSettingsTrue())
            {
                using (MemoryStream ms = mail.RawMessage())
                {
                    CSC.DataLoggerAccess.Send(ms.ToArray());
                }
                return(true);
            }
            else
            {
                SmtpClient client = new SmtpClient();
                client.Credentials = cred.NetCredential;
                client.Port        = cred.Port;
                client.Host        = cred.Host;
                client.EnableSsl   = cred.EnableSsl;
                try
                {
                    client.Send(mail);
                    log.Log.Info(logId + " to " + to);
                    return(true);
                }
                catch (Exception ex)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine(ex.ToString());
                    sb.AppendLine(ex.Message);
                    Exception ex2 = ex;
                    while (ex2 != null)
                    {
                        sb.AppendLine(ex2.ToString());
                        ex2 = ex2.InnerException;
                    }
                    errorText = sb.ToString();
                    log.Log.Error(logId + " to " + to + " " + errorText);
                }
            }
            return(false);
        }
Ejemplo n.º 20
0
 public static bool Send(EMailCredentials from, string to, string subject, string htmlBodyNoHeader, out string errorText, LogForEmailSend log, string logId)
 {
     return(Send(from, to, null, subject, htmlBodyNoHeader, out errorText, log, logId));
 }