Ejemplo n.º 1
0
    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);
        }
    }
Ejemplo n.º 2
0
    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);
        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SessionData sd = ConstantStrings.GetSessionData(Session);

        CommonHelper.DoLogout(sd);
        sd.QuickMessage     = "Your successfully logged out.";
        sd.QuickMessageGood = true;

        Response.Redirect(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + ResolveUrl("~/"));
    }
Ejemplo n.º 4
0
    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);
        }
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // This comes from the Admin User (protected)
        NiceASP.SessionData.LoggedOnOrRedirectToRoot(Session, Response, true);

        if (!IsPostBack)
        {
            SessionData sd = ConstantStrings.GetSessionData(Session);
            updateValuse();
        }
    }
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
    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.º 8
0
    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();
            }
        }
    }
Ejemplo n.º 9
0
    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);
        }
    }
Ejemplo n.º 10
0
    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);
        }
    }
Ejemplo n.º 11
0
    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)
        {
        }
    }
Ejemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // first page load
            SessionData sd = ConstantStrings.GetSessionData(Session);

            string root = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + ResolveUrl("~/");

            if (sd.LoggonOnUserIsAdmin)
            {
                // admin
                User_Admin.Text = User_Admin.Text
                                  .Replace("{_TheUserName_}", sd.LoggedOnUserName)
                                  .Replace("{_root_}", root);

                User_LoggedIn.Visible = false;
                User_Unknown.Visible  = false;
                User_Admin.Visible    = true;
                TheHeader.Style.Add(HtmlTextWriterStyle.BackgroundColor, "red");
            }
            else if (sd.LoggedOnUserEmail != null)
            {
                // user is logged on
                User_LoggedIn.Text = User_LoggedIn.Text
                                     .Replace("{_TheUserName_}", sd.LoggedOnUserName)
                                     .Replace("{_root_}", root);

                User_LoggedIn.Visible = true;
                User_Unknown.Visible  = false;
                User_Admin.Visible    = false;
            }
            else
            {
                // no user logged on
                User_Unknown.Text = User_Unknown.Text.Replace("{_root_}", root);

                User_LoggedIn.Visible = false;
                User_Unknown.Visible  = true;
                User_Admin.Visible    = false;
            }

            // myMessage
            if (!String.IsNullOrEmpty(sd.QuickMessage))
            {
                // message exists
                if (sd.QuickMessageGood)
                {
                    XmlHelper xh = new XmlHelper();
                    xh.AddRootElemet("br", "", "");
                    xh.AddRootElemet("div", "class", "text-primary").InnerXml = "<h3>" + sd.QuickMessage + "</h3>";
                    myMessage.Text    = xh.ToString();
                    myMessage.Visible = true;
                }
                else
                {
                    XmlHelper xh = new XmlHelper();
                    xh.AddRootElemet("br", "", "");
                    xh.AddRootElemet("div", "class", "text-danger").InnerXml = "<h3>" + sd.QuickMessage + "</h3>";
                    myMessage.Text    = xh.ToString();
                    myMessage.Visible = true;
                }
                sd.QuickMessage = null;
            }
            else
            {
                // No quick message
                myMessage.Text    = "";
                myMessage.Visible = false;
            }
        }
    }