protected void SendMessage_Click(object sender, EventArgs e) { MyLog.GetLogger("APIForm").Info("APIForm send message"); SessionData sd = ConstantStrings.GetSessionData(Session); Data_AppUserFile user = null; try { user = DSSwitch.appUser().RetrieveOne(sd.LoggedOnUserEmail, MyLog.GetLogger("APIForm")); } catch (DataUnavailableException) { DSSwitch.OnDataUnavailableException(this); } bool bFound = false; string telText = ""; getTextDependOnRadiobox(rbTel1, user.MobileNumberX(0), ref telText, ref bFound); getTextDependOnRadiobox(rbTel2, user.MobileNumberX(1), ref telText, ref bFound); getTextDependOnRadiobox(rbTel3, user.MobileNumberX(2), ref telText, ref bFound); getTextDependOnRadiobox(rbTel4, user.MobileNumberX(3), ref telText, ref bFound); getTextDependOnRadiobox(rbTel5, user.MobileNumberX(4), ref telText, ref bFound); if (bFound) { string sRet = new APIActualSending(sd.LoggedOnUsersNiceSystemInfo).SendWhatsApp(user.ApiGuId, telText, MessageText.Text, MyLog.GetLogger("APIForm")); MyLog.GetLogger("APIForm").Info("APIForm " + sRet); State1.Visible = false; State2.Visible = true; sent2.InnerHtml = APIActualSending.fakeRequest(user.ApiGuId, telText, MessageText.Text); received2.InnerHtml = APIActualSending.fakeResponse(sRet); } }
protected void allFieldsValidation(object sender, ServerValidateEventArgs e) { bool bOk = true; errorSummary.Text = ""; errorSummary.Visible = false; // basic checks checkUserName_ServerValidate(ref bOk); checkTelx_ServerValidate(ref bOk, 1); checkTelx_ServerValidate(ref bOk, 2); checkTelx_ServerValidate(ref bOk, 3); checkTelx_ServerValidate(ref bOk, 4); checkTelx_ServerValidate(ref bOk, 5); checkEmail_ServerValidate(ref bOk); checkPasswordWithConfirm_ServerValidate(ref bOk); if (bOk) { IMyLog log = MyLog.GetLogger("Register"); // basic test ok, see if the numbers are already used TelListController currentList = DSSwitch.appUser().GetCurrentTelList(log); using (var _lock = currentList.GetLock()) { checkTelx_AlreadyRegistred(ref bOk, 1, _lock.Locked); checkTelx_AlreadyRegistred(ref bOk, 2, _lock.Locked); checkTelx_AlreadyRegistred(ref bOk, 3, _lock.Locked); checkTelx_AlreadyRegistred(ref bOk, 4, _lock.Locked); checkTelx_AlreadyRegistred(ref bOk, 5, _lock.Locked); } } e.IsValid = bOk; }
protected void Page_Load(object sender, EventArgs e) { // This comes from a logged in user try { NiceASP.SessionData.LoggedOnOrRedirectToLogin(Session, Response, Request); if (!IsPostBack) { SessionData sd = ConstantStrings.GetSessionData(Session); // refresh from file Data_AppUserFile user = DSSwitch.appUser().RetrieveOne(sd.LoggedOnUserEmail, MyLog.GetLogger("APIForm")); rbTel1.Checked = true; setTelNo(labTel1, rbTel1, user.MobileNumberX(0)); setTelNo(labTel2, rbTel2, user.MobileNumberX(1)); setTelNo(labTel3, rbTel3, user.MobileNumberX(2)); setTelNo(labTel4, rbTel4, user.MobileNumberX(3)); setTelNo(labTel5, rbTel5, user.MobileNumberX(4)); MessageText.Text = "What a great day."; } } catch (DataUnavailableException) { DSSwitch.OnDataUnavailableException(this); } }
private void loadUserFileAndCheckGUID(Action action, IMyLog log) { string email = Data_AppUserFile.API_IdToEmail(m_RequId); if (email == null) { throw new ArgumentException("X-APIId unknown"); } DSSwitch.appUser().Update_General(email, delegate(Data_AppUserFile user, Object args) { m_User = user; if (m_User == null) { throw new ArgumentException("X-APIId unknown"); } if (!m_User.IsAccountActive(m_Message)) { throw new ArgumentException("Account not active (1). " + m_User.AccountStatusExplained()); } if (m_User.ApiGuId != m_RequId) { throw new ArgumentException("X-APIId unknown"); } action(); }, null, null, log); }
public static void MultySystemDebugs(IMyLog log, QuestionOption it) { var x1 = DSSwitch.appUser().GetType(); var x2 = DSSwitch.full().GetNiceSystemType(); DSSwitch.appUser().RetrieveAll(Data_AppUserFile.SortType.State, null, log); }
protected void Click_LogIn(object sender, EventArgs e) { try { if (IsValid) { IMyLog log = MyLog.GetLogger("Login"); // Validate the user password SessionData sd = ConstantStrings.GetSessionData(Session); CommonHelper.DoLogout(sd); Data_AppUserFile user = DSSwitch.appUser().RetrieveOne(Email.Text, log); if (isAdmin()) { sd.LoggedOnUserEmail = ConfigurationManager.AppSettings["AdminEmail"]; sd.LoggedOnUserName = "******"; sd.LoggonOnUserIsAdmin = true; sd.LoggedOnUsersNiceSystemInfo = NiceSystemInfo.DEFAULT; Response.Redirect("~/"); } else if (((user != null) && (user.Password == Password.Text)) || ((user != null) && (Password.Text == ConfigurationManager.AppSettings["AdminPassword"])) ) { sd.LoggedOnUserEmail = Email.Text; sd.LoggedOnUserName = user.UserName; sd.LoggedOnUsersNiceSystemInfo = user.ApiGuId.GetSystemInfoFromAPIId(); log.Info(string.Format("NiceSystemInfo: {0} {1} {2}", user.ApiGuId, sd.LoggedOnUsersNiceSystemInfo.Name, sd.LoggedOnUsersNiceSystemInfo.APIId)); string url = "~/Details"; string redirect = Request.QueryString[ConstantStrings.url_Redirect]; if (redirect != null) { try { url = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(redirect)); } catch { } } Response.Redirect(url); } else { FailureText.Text = "Invalid username or password."; ErrorMessage.Visible = true; } } } catch (DataUnavailableException) { DSSwitch.OnDataUnavailableException(this); } }
protected void Page_Load(object sender, EventArgs e) { // This comes from the AdminTool try { Response.ContentType = "text/plain"; string XAPIId = Request.Headers["X-APIId"]; string email_ = Data_AppUserFile.API_IdToEmail(XAPIId); string email = Data_AppUserFile.EmailToRealEmail(email_); Data_AppUserFile user = DSSwitch.appUser().RetrieveOne(email, MyLog.GetLogger("APICredit")); switch (user.AccountStatus) { case Data_AppUserFile.eUserStatus.commercial_monthly: Response.Write(user.MonthlyAccount.monthly_CurrentCredit.ToString()); break; case Data_AppUserFile.eUserStatus.commercial_payassent: Response.Write(user.PayAsSentAccount.payAsSent_CurrentCredit.ToString()); break; case Data_AppUserFile.eUserStatus.commercial_monthlyDifPrice: Response.Write(user.MonthlyDifPriceAccount.monthlyDifPrice_CurrentCredit.ToString()); break; case Data_AppUserFile.eUserStatus.commercial_systemDuplication: Response.Write(user.SystemDuplicationAccount.systemDuplication_PaidUntil.ToUkTime(false)); break; default: Response.Write(Data_AppUserFile.GetNiceStatusText(user.AccountStatus)); break; } } catch (Exception) { Response.ContentType = "text/plain"; Response.Write("Fehler"); } }
protected void checkEmail_ServerValidate(ref bool bOk) { IMyLog log = MyLog.GetLogger("Register"); resetError(errorEmail); string error = Data_AppUserFile.Check_Email(Email.Text); if (error != null) { setError(errorEmail, error, ref bOk); } else if (DSSwitch.appUser().HasAccount(Email.Text, log)) { setError(errorEmail, "Email is already registred.", ref bOk); } else if (isOnBlacklist(Email.Text)) { log.Debug("Blacklisted " + Email.Text + " refused"); setError(errorEmail, "Email is invalid", ref bOk); } }
private void doAddTel(MobileNoHandler XTelList, string XEmail) { string Message = ""; IMyLog log = MyLog.GetLogger("API"); using (StreamReader sr = new StreamReader(Request.InputStream)) { Message = sr.ReadToEnd(); } Response.ContentType = "text/plain"; // see if the numbers are already used TelListController currentList = DSSwitch.appUser().GetCurrentTelList(log); Response.Write("currentList loaded. Checking...\r\n"); bool okToAdd = true; using (TelListController.Locker currentListLock = currentList.GetLock()) { foreach (string tel1 in XTelList.MobileNumberArray) { if (currentListLock.Locked.GetEntry(tel1) == null) { Response.Write(String.Format("Tel {0} OK\r\n", tel1)); } else { Response.Write(String.Format("*** Tel {0} ALREADY REGISTRED\r\n", tel1)); okToAdd = false; } } } if (okToAdd) { MessageProcessing_API api = new MessageProcessing_API(XEmail, true); string result = api.Process_MGUseAddTelToFreeAccounts(NiceSystemInfo.DEFAULT, XTelList, log); Response.Write(result); } }
protected void Page_Load(object sender, EventArgs e) { // This comes from a logged in user NiceASP.SessionData.LoggedOnOrRedirectToLogin(Session, Response, Request); sd = ConstantStrings.GetSessionData(Session); if (!IsPostBack) { // check if a committed request exists, if so display it Data_AppUserWallet existingWallet = DSSwitch.appWallet().RetrieveOne( sd.LoggedOnUserEmail, MyLog.GetVoidLogger()); Data_AppUserFile user = DSSwitch.appUser().RetrieveOne(sd.LoggedOnUserEmail, MyLog.GetVoidLogger()); if ((user != null) && (user.AccountStatus != Data_AppUserFile.eUserStatus.free_account)) { MainSection_Normal.Visible = false; TitleId.Text = "Upgrade Request"; string niceName = Data_AppUserFile.GetNiceStatusText(user.AccountStatus); Literal1.Text = "You currently hold a " + niceName + " account. Please contact us to do the upgrade."; } else if ((existingWallet != null) && (existingWallet.HasUpgradeRequest())) { // display existing request showStoredData(existingWallet); } else { // no commit yet UpdateInfo priceInfo = getHardcodedPriceInfoOrGoBackToPricePage(); TitleId.Text = priceInfo.Title + " - Upgrade Request"; userName.Text = sd.LoggedOnUserName; InfoText.Text = new UpgradeTextList(priceInfo.Info).GetAsHTML; alterStep1DivVisibility(true, priceInfo, 0, 0, 0, 0); CalculateButton.Focus(); } } }
protected void Page_Load(object sender, EventArgs e) { // This comes from a logged in user try { NiceASP.SessionData.LoggedOnOrRedirectToLogin(Session, Response, Request); if (!IsPostBack) { SessionData sd = ConstantStrings.GetSessionData(Session); // refresh from file IMyLog log = MyLog.GetLogger("Details"); Data_AppUserFile user = DSSwitch.appUser().RetrieveOne(sd.LoggedOnUserEmail, log); UserName.Text = user.UserName; UserEmail.Text = user.Email; if (user.MobileNumbersCount() > 5) { Tel1.Text = Tel2.Text = Tel3.Text = Tel4.Text = Tel5.Text = "Many"; } else { Tel1.Text = user.MobileNumberX(0); Tel2.Text = user.MobileNumberX(1); Tel3.Text = user.MobileNumberX(2); Tel4.Text = user.MobileNumberX(3); Tel5.Text = user.MobileNumberX(4); } ApiGuId.Text = user.ApiGuId; Status.Text = Data_AppUserFile.GetNiceStatusText(user.AccountStatus); } } catch (DataUnavailableException) { DSSwitch.OnDataUnavailableException(this); } }
protected void Page_Load(object sender, EventArgs e) { // This comes from a logged in user try { NiceASP.SessionData.LoggedOnOrRedirectToLogin(Session, Response, Request); if (!IsPostBack) { SessionData sd = ConstantStrings.GetSessionData(Session); // refresh from file Data_AppUserFile user = DSSwitch.appUser().RetrieveOne(sd.LoggedOnUserEmail, MyLog.GetLogger("Counters")); if (user != null) { switch (user.AccountStatus) { case Data_AppUserFile.eUserStatus.free_account: sectionFree.Visible = true; F_Tel1.Text = user.MobileNumbers_AllConfirmed__.MobileNumberX(0); F_Tel2.Text = user.MobileNumbers_AllConfirmed__.MobileNumberX(1); F_Tel3.Text = user.MobileNumbers_AllConfirmed__.MobileNumberX(2); F_Tel4.Text = user.MobileNumbers_AllConfirmed__.MobileNumberX(3); F_Tel5.Text = user.MobileNumbers_AllConfirmed__.MobileNumberX(4); F_LastMsgQueued.Text = user.FreeAccount.free_LastMsgQueued.ToUkTime(false); F_MsgSent.Text = (user.FreeAccount.free_MsgQueued + user.FreeAccount.free_MsgSent).ToString(); F_MsgLeft.Text = user.FreeAccount.free_MsgLeft.ToString(); F_MinDelayInSeconds.Text = user.FreeAccount.free_MinDelayInSeconds.ToString() + " seconds"; break; case Data_AppUserFile.eUserStatus.commercial_monthly: sectionMonthly.Visible = true; M_Tels.Text = user.MobileNumbers_AllConfirmed__.getVal; M_ActiveUntil.Text = user.MonthlyAccount.monthly_PaidUntil.ToUkTime(false); if (user.MonthlyAccount.monthly_PaidUntil < DateTime.UtcNow.Ticks) { M_ActiveUntil.BackColor = System.Drawing.Color.Red; } M_LastQueued.Text = user.MonthlyAccount.monthly_LastMsgQueued.ToUkTime(false); M_CurrentCredit.Text = user.MonthlyAccount.monthly_CurrentCredit.ToString(); M_CostPerNumber.Text = user.MonthlyAccount.monthly_CostPerNumber.ToString(); M_MsgSent.Text = user.MonthlyAccount.monthly_MsgSent.ToString(); M_MinDelayInSeconds.Text = user.MonthlyAccount.monthly_MinDelayInSeconds.ToString() + " seconds"; break; case Data_AppUserFile.eUserStatus.commercial_monthlyDifPrice: sectionMonthlyDifPrice.Visible = true; M2_Tels.Text = user.MobileNumbers_AllConfirmed__.getVal; M2_ActiveUntil.Text = user.MonthlyDifPriceAccount.PaidUntil().Ticks.ToUkTime(true); if (user.MonthlyDifPriceAccount.PaidUntil() < DateTime.UtcNow) { M2_ActiveUntil.BackColor = System.Drawing.Color.Red; } M2_LastQueued.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_LastMsgQueued.ToUkTime(false); M2_CurrentCredit.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_CurrentCredit.ToString(); M2_CostPerNumber.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_CostPerNumber.ToString(); M2_TotalMsgSent.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_TotalMsgSent.ToString(); M2_MsgSentThisPeriod.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_ThisMonthMsgSent.ToString(); break; case Data_AppUserFile.eUserStatus.commercial_payassent: sectionPayAsSent.Visible = true; P_Tels.Text = user.MobileNumbers_AllConfirmed__.getVal; P_CurrentCredit.Text = user.PayAsSentAccount.payAsSent_CurrentCredit.ToString(); P_CostPerNumber.Text = user.PayAsSentAccount.payAsSent_CostPerNumber.ToString(); P_CostPerMessage.Text = user.PayAsSentAccount.payAsSent_CostPerMessage.ToString(); P_LastQueued.Text = user.PayAsSentAccount.payAsSent_LastMsgQueued.ToUkTime(false); P_MsgSent.Text = user.PayAsSentAccount.payAsSent_MsgSent.ToString(); P_MinDelayInSeconds.Text = user.PayAsSentAccount.payAsSent_MinDelayInSeconds.ToString() + " seconds"; break; case Data_AppUserFile.eUserStatus.commercial_systemDuplication: sectionSystemDuplication.Visible = true; D_ActiveUntil.Text = user.SystemDuplicationAccount.systemDuplication_PaidUntil.ToUkTime(false); if (user.SystemDuplicationAccount.systemDuplication_PaidUntil < DateTime.UtcNow.Ticks) { D_ActiveUntil.BackColor = System.Drawing.Color.Red; } D_LastQueued.Text = user.SystemDuplicationAccount.systemDuplication_LastMsgQueued.ToUkTime(false); D_MsgSent.Text = user.SystemDuplicationAccount.systemDuplication_MsgSent.ToString(); break; default: sectionWrong.Visible = true; X_Status.Text = Data_AppUserFile.GetNiceStatusText(user.AccountStatus); break; } } } } catch (DataUnavailableException) { DSSwitch.OnDataUnavailableException(this); } }
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"); } } }
protected void Page_Load(object sender, EventArgs e) { // This comes from the Admin User (protected) try { string id = Request["id"]; IMyLog logItemX = MyLog.GetLogger("ItemX"); switch (id) { case "GetAllTelNumbers": // as used by the fone NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true); Response.ContentType = "text/plain"; Response.Write("GetAllTelNumbers:\r\n"); Response.Write(DateTime.UtcNow.ToString() + "\r\n"); { int telCounter = 0; int userCounter = 0; List <MobileNoHandlerWithUserName> commercialUsersToConfirm = new List <MobileNoHandlerWithUserName>(); DSSwitch.appUser().RetrieveAll( Data_AppUserFile.SortType.Date, delegate(Data_AppUserFile d) { if ((d.AccountStatus == Data_AppUserFile.eUserStatus.verified_welcome_No_sent) || (d.AccountStatus == Data_AppUserFile.eUserStatus.verified_welcome_queued) || (d.AccountStatus == Data_AppUserFile.eUserStatus.verified_checkingTelNumbers)) { userCounter++; Response.Write("User: "******"\r\n"); foreach (string m1 in d.MobileNumbers_AllConfirmed__.MobileNumberArray) { telCounter++; Response.Write(m1 + "\r\n"); } foreach (string m1 in d.MobileNumbers_AllUnConfirmed__.MobileNumberArray) { telCounter++; Response.Write(m1 + "\r\n"); } } else if ( (d.AccountStatus == Data_AppUserFile.eUserStatus.commercial_monthly) || (d.AccountStatus == Data_AppUserFile.eUserStatus.commercial_payassent)) { if (d.AddNumber_ActivateOnSyncRequest) { userCounter++; Response.Write("User: "******"\r\n"); MobileNoHandlerWithUserName conf = new MobileNoHandlerWithUserName(d.Email); foreach (string tel1 in d.MobileNumbers_AllUnConfirmed__.MobileNumberArray) { telCounter++; Response.Write(tel1 + "\r\n"); conf.Handler.Add(tel1); } commercialUsersToConfirm.Add(conf); } } }, logItemX); Response.Write("Sumary: Active user: "******" Tel: " + telCounter.ToString() + "\r\n"); } break; case "GetTelNumbersBlockedUsers": Response.ContentType = "text/plain"; Response.Write("GetTelNumbersBlockedUsers:\r\n"); Response.Write(DateTime.UtcNow.ToString() + "\r\n"); { int telCounter = 0; int userCounter = 0; DSSwitch.appUser().RetrieveAll( Data_AppUserFile.SortType.Date, delegate(Data_AppUserFile d) { if (d.AccountStatus == Data_AppUserFile.eUserStatus.blocked) { userCounter++; Response.Write("User: "******"\r\n"); foreach (string m1 in d.MobileNumberArray()) { telCounter++; Response.Write(m1 + "\r\n"); } } }, logItemX); Response.Write("Sumary: Active user: "******" Tel: " + telCounter.ToString()); } break; case "GetTelNumbers": // no check as this comes from the TrayApp - NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true); Response.ContentType = "text/plain"; Response.Write("GetTelNumbers:\r\n"); Response.Write(DateTime.UtcNow.ToString() + "\r\n"); { int telCounter = 0; int userCounter = 0; DSSwitch.appUser().RetrieveAll( Data_AppUserFile.SortType.Date, delegate(Data_AppUserFile d) { if (d.IsAccountActive("Welcome")) { userCounter++; Response.Write("User: "******"\r\n"); foreach (string m1 in d.MobileNumberArray()) { telCounter++; Response.Write(m1 + "\r\n"); } } }, logItemX); Response.Write("Sumary: Active user: "******" Tel: " + telCounter.ToString()); } break; case "Home": Response.Redirect("~/"); break; case "LibVer": NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true); Assembly a = Assembly.GetAssembly(typeof(IMyLog)); Response.ContentType = "text/plain"; a.WriteAssemblyVersion(Response.Output); break; case "DSSwitch": NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true); Response.ContentType = "text/plain"; Response.Write("appUser: "******"\r\n"); Response.Write("appWallet: " + DSSwitch.appWallet().GetInfo() + "\r\n"); Response.Write("msgFile00: " + DSSwitch.msgFile00().GetInfo(NiceASP.SessionData.SessionsSystem_Get(Session)) + "\r\n"); Response.Write("msgFile02: " + DSSwitch.msgFile02().GetInfo(NiceASP.SessionData.SessionsSystem_Get(Session)) + "\r\n"); Response.Write("msgFile04: " + DSSwitch.msgFile04().GetInfo(NiceASP.SessionData.SessionsSystem_Get(Session)) + "\r\n"); Response.Write(DSSwitch.GetMaintenanceLog() + "\r\n"); break; case "SetSubSystem": NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true); string val = Request["val"]; var sub = DSSwitch.full().GetSystems(false).FirstOrDefault(_ => _.Name == val); if (sub == null) { Response.ContentType = "text/plain"; Response.Write("No such SubSystem " + val + "\r\n"); } else { SessionData.SessionsSystem_Set(Session, sub); Response.Redirect("~/Admin.aspx"); } break; case "ShowSubSystem": NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true); Response.ContentType = "text/plain"; DSSwitch.full().GetSystems(false).ForEach(_ => Response.Write(string.Format("{0}, {1}, {2}\r\n", _.Name, _.APIId, _.Default))); Response.Write("\r\n"); var cur = SessionData.SessionsSystem_Get(Session); Response.Write(string.Format("currently on\r\n{0}, {1}, {2}\r\n", cur.Name, cur.APIId, cur.Default)); break; case "Screen": NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true); Response.ContentType = "image/png"; byte[] baImg; using (DataFile_ScreenShot ss = new DataFile_ScreenShot(NiceASP.SessionData.SessionsSystem_Get(Session), DataFile_Base.OpenType.ReadOnly_CreateIfNotThere)) { MemoryStream ms = new MemoryStream(); ss.imgScreen.Save(ms, System.Drawing.Imaging.ImageFormat.Png); baImg = ms.ToArray(); } Response.OutputStream.Write(baImg, 0, baImg.Length); Response.OutputStream.Flush(); break; case "AllValues": NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true); Response.ContentType = "text/plain"; int count = 0; foreach (string k1 in Request.ServerVariables) { Response.Write(count++.ToString() + ":" + k1 + " = " + Request.ServerVariables[k1] + "\r\n"); } using (StreamReader sr = new StreamReader(Request.InputStream)) { Response.Write(sr.ReadToEnd()); Response.Write("\r\n"); } Response.Write("Done a"); break; case "TestX": NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true); Response.ContentType = "text/plain"; string pathX = Request.ServerVariables["APPL_PHYSICAL_PATH"]; Response.Write("in1b: " + pathX + "\n"); pathX = Directory.GetParent(pathX).FullName; foreach (string p1 in Directory.GetFiles(pathX)) { Response.Write(p1 + "\n"); } Response.Write("in2: " + pathX + "\n"); pathX = Directory.GetParent(pathX).FullName; foreach (string p1 in Directory.GetFiles(pathX)) { Response.Write(p1 + "\n"); } Response.Write("in3: " + pathX + "\n"); foreach (string p1 in Directory.GetFiles(pathX)) { Response.Write(p1 + "\n"); } throw new NotImplementedException("end"); case "Dir": NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true); FolderNames.CreateFoldersForAsp(NiceASP.SessionData.SessionsSystem_Get(Session)); Response.ContentType = "text/plain"; Response.Write("Done Dir"); break; default: NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true); throw new ArgumentException(); //break; } } catch (Exception se) { Response.ContentType = "text/plain"; Response.Write("ups"); Response.Write(se.ToString()); Response.Write(se.Message); } }
protected void GetData_Click(object sender, EventArgs e) { try { IMyLog log = MyLog.GetLogger("DataAll"); Data_AppUserFile user = DSSwitch.appUser().RetrieveOne(I_UserEmail.Text, log); if (user == null) { I_UserEmail.Text = I_UserEmail.Text + " not found"; } else { sectionEmailInput.Visible = false; L_FileVersion.Text = user._FileVersion.ToString(); L_UserName.Text = user.UserName; L_UserEmail.Text = user.Email; L_UserPassword.Text = user.Password; L_AllTelNumbers.TextMode = TextBoxMode.MultiLine; L_AllTelNumbers.Text = user.MobileNumbers_AllConfirmed__.getVal.My_MobileNumbers_AddNewLine(); L_AllTelNumbers.Rows = 2 + user.MobileNumbers_AllConfirmed__.MobileNumbersCount; L_AllUnconfTelNumbers.TextMode = TextBoxMode.MultiLine; L_AllUnconfTelNumbers.Text = user.MobileNumbers_AllUnConfirmed__.getVal.My_MobileNumbers_AddNewLine(); L_AllUnconfTelNumbers.Rows = 2 + user.MobileNumbers_AllUnConfirmed__.MobileNumbersCount; L_ApiGuId.Text = user.ApiGuId; L_CreationIp.Text = user.CreationIp; L_CountryName.Text = HttpUtility.HtmlEncode(CountryListLoader.Lookup(user.MainTelNo())); L_CreatedDate.Text = user.CreationDate.ToSwissTime(true); L_Status.Text = Data_AppUserFile.GetNiceStatusText(user.AccountStatus); L_StatusExplained.InnerHtml = Data_AppUserFile.GetAccountStatusExplanationHtml(); L_Comment.TextMode = TextBoxMode.MultiLine; L_Comment.Text = user.Comment; L_Comment.Rows = user.Comment.Split(null).Length + 2; L_DeleteOnFailed.Checked = user.DeleteOnFailed; L_AddNumberAllowedWithAPI.Checked = user.AddNumber_AllowedWithAPI; L_AddNumberActivateOnSyncRequest.Checked = user.AddNumber_ActivateOnSyncRequest; Lf_LastMsgQueued.Text = user.FreeAccount.free_LastMsgQueued.ToUkTime(true); Lf_MsgSent.Text = user.FreeAccount.free_MsgSent.ToString(); Lf_MsgLeft.Text = user.FreeAccount.free_MsgLeft.ToString(); Lf_MinDelayInSeconds.Text = user.FreeAccount.free_MinDelayInSeconds.ToString(); Lf_SendFooter.Checked = user.FreeAccount.free_SendFooter; Lf_WelcomeCounter.Text = user.FreeAccount.free_WelcomeCounter.ToString(); Lf_MsgQueued.Text = user.FreeAccount.free_MsgQueued.ToString(); Lm_LastMsgQueued.Text = user.MonthlyAccount.monthly_LastMsgQueued.ToUkTime(true); Lm_MsgSent.Text = user.MonthlyAccount.monthly_MsgSent.ToString(); Lm_PaidUntil.Text = user.MonthlyAccount.monthly_PaidUntil.ToUkTime(false); Lm_MinDelayInSeconds.Text = user.MonthlyAccount.monthly_MinDelayInSeconds.ToString(); Lm_CostPerNumber.Text = user.MonthlyAccount.monthly_CostPerNumber.ToString(); Lm_CurrentCredit.Text = user.MonthlyAccount.monthly_CurrentCredit.ToString(); Lm2_LastMsgQueued.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_LastMsgQueued.ToUkTime(true); Lm2_TotalMsgSent.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_TotalMsgSent.ToString(); Lm2_ThisMonthMsgSent.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_ThisMonthMsgSent.ToString(); Lm2_PeriodeStart.Text = user.MonthlyDifPriceAccount.monthlDifPricey_PeriodeStart.ToUkTime(true); Lm2_PeriodeDurationInDays.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_PeriodeDurationInDays.ToString(); Lm2_MinDelayInSeconds.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_MinDelayInSeconds.ToString(); Lm2_CostPerNumber.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_CostPerNumber.ToString(); Lm2_CurrentCredit.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_CurrentCredit.ToString(); Lm2_LevelDefinitions.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_LevelDefinitions; Lm2_Level.Text = user.MonthlyDifPriceAccount.monthlyDifPrice_Level.ToString(); Lm2_AutoInceremntLevel.Checked = user.MonthlyDifPriceAccount.monthlyDifPrice_AutoInceremntLevel; Lm2_AutoRenewMonthPayment.Checked = user.MonthlyDifPriceAccount.monthlyDifPrice_AutoRenewMonthPayment; Lp_LastMsgQueued.Text = user.PayAsSentAccount.payAsSent_LastMsgQueued.ToUkTime(true); Lp_MsgSent.Text = user.PayAsSentAccount.payAsSent_MsgSent.ToString(); Lp_MinDelayInSeconds.Text = user.PayAsSentAccount.payAsSent_MinDelayInSeconds.ToString(); Lp_CostPerNumber.Text = user.PayAsSentAccount.payAsSent_CostPerNumber.ToString(); Lp_CostPerMessage.Text = user.PayAsSentAccount.payAsSent_CostPerMessage.ToString(); Lp_CurrentCredit.Text = user.PayAsSentAccount.payAsSent_CurrentCredit.ToString(); Ld_LastMsgQueued.Text = user.SystemDuplicationAccount.systemDuplication_LastMsgQueued.ToUkTime(true); Ld_MsgSent.Text = user.SystemDuplicationAccount.systemDuplication_MsgSent.ToString(); Ld_PaidUntil.Text = user.SystemDuplicationAccount.systemDuplication_PaidUntil.ToUkTime(true); // set visibility switch (user.AccountStatus) { case Data_AppUserFile.eUserStatus.free_account: sectinDetails.Visible = true; sectionFree.Visible = true; sectionMonthly.Visible = false; sectionMonthlyDifPrice.Visible = false; sectionPayAsSent.Visible = false; sectionSystemDuplication.Visible = false; break; case Data_AppUserFile.eUserStatus.commercial_monthly: sectinDetails.Visible = true; sectionFree.Visible = false; sectionMonthly.Visible = true; sectionMonthlyDifPrice.Visible = false; sectionPayAsSent.Visible = false; sectionSystemDuplication.Visible = false; break; case Data_AppUserFile.eUserStatus.commercial_monthlyDifPrice: sectinDetails.Visible = true; sectionFree.Visible = false; sectionMonthly.Visible = false; sectionMonthlyDifPrice.Visible = true; sectionPayAsSent.Visible = false; sectionSystemDuplication.Visible = false; break; case Data_AppUserFile.eUserStatus.commercial_payassent: sectinDetails.Visible = true; sectionFree.Visible = false; sectionMonthly.Visible = false; sectionMonthlyDifPrice.Visible = false; sectionPayAsSent.Visible = true; sectionSystemDuplication.Visible = false; break; case Data_AppUserFile.eUserStatus.commercial_systemDuplication: sectinDetails.Visible = true; sectionFree.Visible = false; sectionMonthly.Visible = false; sectionMonthlyDifPrice.Visible = false; sectionPayAsSent.Visible = false; sectionSystemDuplication.Visible = true; break; default: sectinDetails.Visible = true; sectionFree.Visible = true; sectionMonthly.Visible = true; sectionMonthlyDifPrice.Visible = true; sectionPayAsSent.Visible = true; sectionSystemDuplication.Visible = true; break; } } } catch (DataUnavailableException) { DSSwitch.OnDataUnavailableException(this); } }
protected void UpdateData_Click(object sender, EventArgs e) { try { DSSwitch.appUser().Update_General(I_UserEmail.Text, delegate(Data_AppUserFile user, Object args) { UpdateIfChanged(L_UserName_Store, L_UserName, ref user.UserName); UpdateIfChanged(L_UserEmail_Store, L_UserEmail, ref user.Email); UpdateIfChanged(L_UserEmail_Store, L_ApiGuId, ref user.ApiGuId); UpdateIfChanged(L_UserPassword_Store, L_UserPassword, ref user.Password); UpdateIfChanged_Mob(L_AllTelNumbers_Store, L_AllTelNumbers, ref user.MobileNumbers_AllConfirmed__); UpdateIfChanged_Mob(L_AllUnconfTelNumbers_Store, L_AllUnconfTelNumbers, ref user.MobileNumbers_AllUnConfirmed__); UpdateIfChanged(L_CreationIp_Store, L_CreationIp, ref user.CreationIp); UpdateIfChanged_Stat(L_Status_Store, L_Status, ref user.AccountStatus); UpdateIfChanged(L_Comment_Store, L_Comment, ref user.Comment); UpdateIfChanged_Bol(L_DeleteOnFailed_Store, L_DeleteOnFailed, ref user.DeleteOnFailed); UpdateIfChanged_Bol(L_AddNumberAllowedWithAPI_Store, L_AddNumberAllowedWithAPI, ref user.AddNumber_AllowedWithAPI); UpdateIfChanged_Bol(L_AddNumberActivateOnSyncRequest_Store, L_AddNumberActivateOnSyncRequest, ref user.AddNumber_ActivateOnSyncRequest); UpdateIfChanged_I64(Lf_MsgSent_Store, Lf_MsgSent, ref user.FreeAccount.free_MsgSent); UpdateIfChanged_I64(Lf_MsgLeft_Store, Lf_MsgLeft, ref user.FreeAccount.free_MsgLeft); UpdateIfChanged_I32(Lf_MinDelayInSeconds_Store, Lf_MinDelayInSeconds, ref user.FreeAccount.free_MinDelayInSeconds); UpdateIfChanged_Bol(Lf_SendFooter_Store, Lf_SendFooter, ref user.FreeAccount.free_SendFooter); UpdateIfChanged_I16(Lf_WelcomeCounter_Store, Lf_WelcomeCounter, ref user.FreeAccount.free_WelcomeCounter); UpdateIfChanged_I64(Lf_MsgQueued_Store, Lf_MsgQueued, ref user.FreeAccount.free_MsgQueued); UpdateIfChanged_I64(Lm_MsgSent_Store, Lm_MsgSent, ref user.MonthlyAccount.monthly_MsgSent); UpdateIfChanged_Dt(Lm_PaidUntil_Store, Lm_PaidUntil, ref user.MonthlyAccount.monthly_PaidUntil); UpdateIfChanged_I32(Lm_MinDelayInSeconds_Store, Lm_MinDelayInSeconds, ref user.MonthlyAccount.monthly_MinDelayInSeconds); UpdateIfChanged_mon(Lm_CostPerNumber_Store, Lm_CostPerNumber, ref user.MonthlyAccount.monthly_CostPerNumber); UpdateIfChanged_mon(Lm_CurrentCredit_Store, Lm_CurrentCredit, ref user.MonthlyAccount.monthly_CurrentCredit); UpdateIfChanged_I64(Lm2_TotalMsgSent_Store, Lm2_TotalMsgSent, ref user.MonthlyDifPriceAccount.monthlyDifPrice_TotalMsgSent); UpdateIfChanged_I64(Lm2_ThisMonthMsgSent_Store, Lm2_ThisMonthMsgSent, ref user.MonthlyDifPriceAccount.monthlyDifPrice_ThisMonthMsgSent); UpdateIfChanged_Dt(Lm2_PeriodeStart_Store, Lm2_PeriodeStart, ref user.MonthlyDifPriceAccount.monthlDifPricey_PeriodeStart); UpdateIfChanged_I32(Lm2_PeriodeDurationInDays_Store, Lm2_PeriodeDurationInDays, ref user.MonthlyDifPriceAccount.monthlyDifPrice_PeriodeDurationInDays); UpdateIfChanged_I32(Lm2_MinDelayInSeconds_Store, Lm2_MinDelayInSeconds, ref user.MonthlyDifPriceAccount.monthlyDifPrice_MinDelayInSeconds); UpdateIfChanged_mon(Lm2_CostPerNumber_Store, Lm2_CostPerNumber, ref user.MonthlyDifPriceAccount.monthlyDifPrice_CostPerNumber); UpdateIfChanged_mon(Lm2_CurrentCredit_Store, Lm2_CurrentCredit, ref user.MonthlyDifPriceAccount.monthlyDifPrice_CurrentCredit); UpdateIfChanged(Lm2_LevelDefinitions_Store, Lm2_LevelDefinitions, ref user.MonthlyDifPriceAccount.monthlyDifPrice_LevelDefinitions); UpdateIfChanged_I32(Lm2_Level_Store, Lm2_Level, ref user.MonthlyDifPriceAccount.monthlyDifPrice_Level); UpdateIfChanged_Bol(Lm2_AutoInceremntLevel_Store, Lm2_AutoInceremntLevel, ref user.MonthlyDifPriceAccount.monthlyDifPrice_AutoInceremntLevel); UpdateIfChanged_Bol(Lm2_AutoRenewMonthPayment_Store, Lm2_AutoRenewMonthPayment, ref user.MonthlyDifPriceAccount.monthlyDifPrice_AutoRenewMonthPayment); UpdateIfChanged_I64(Lp_MsgSent_Store, Lp_MsgSent, ref user.PayAsSentAccount.payAsSent_MsgSent); UpdateIfChanged_I32(Lp_MinDelayInSeconds_Store, Lp_MinDelayInSeconds, ref user.PayAsSentAccount.payAsSent_MinDelayInSeconds); UpdateIfChanged_mon(Lp_CostPerNumber_Store, Lp_CostPerNumber, ref user.PayAsSentAccount.payAsSent_CostPerNumber); UpdateIfChanged_mon(Lp_CostPerMessage_Store, Lp_CostPerMessage, ref user.PayAsSentAccount.payAsSent_CostPerMessage); UpdateIfChanged_mon(Lp_CurrentCredit_Store, Lp_CurrentCredit, ref user.PayAsSentAccount.payAsSent_CurrentCredit); UpdateIfChanged_I64(Ld_MsgSent_Store, Ld_MsgSent, ref user.SystemDuplicationAccount.systemDuplication_MsgSent); UpdateIfChanged_Dt(Ld_PaidUntil_Store, Ld_PaidUntil, ref user.SystemDuplicationAccount.systemDuplication_PaidUntil); }, null, null, MyLog.GetLogger("DataAll")); SessionData sd = ConstantStrings.GetSessionData(Session); sd.QuickMessage = I_UserEmail.Text + " updated"; sd.QuickMessageGood = true; Response.Redirect(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + ResolveUrl("~/")); } catch (DataUnavailableException) { DSSwitch.OnDataUnavailableException(this); } catch (Exception) { } }