Ejemplo n.º 1
0
    protected void ActivateCustomer_Click(object sender, EventArgs e)
    {
        ClearMessages();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        string customer_id = State["ServerAdminCustomerID"].ToString();
        if (customer_id == "0")
        {
            AdminMessage.Text = "Select a customer and try again.";
            return;
        }

        //check if admin
        string sql = "SELECT status FROM customers WHERE customer_id='" + customer_id + "'";
        DB db = new DB();
        string status = db.ViziAppsExecuteScalar(State, sql);
        if (status == "admin")
        {
            db.CloseViziAppsDatabase(State);
            AdminMessage.Text = "Status of Admin Customer can not be changed.";
        }
        else
        {
            sql = "UPDATE customers SET status='active' WHERE customer_id='" + customer_id + "'";
            db.ViziAppsExecuteNonQuery(State, sql);
            db.CloseViziAppsDatabase(State);
            CustomerStatus.Text = "active";
            AdminMessage.Text = "Customer has been activated.";
        }
    }
Ejemplo n.º 2
0
    protected void Applications_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        ClearMessages();
        //get initial values
        if (e.Text.IndexOf("->") > 0)
        {
            HideForApplications();
            return;
        }

        ShowForApplications();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        string customer_id = State["ServerAdminCustomerID"].ToString();
        Util util = new Util();

        State["SelectedAdminApp"] = e.Text;
        string sql = "SELECT * FROM applications WHERE customer_id='" + customer_id + "' AND application_name='" + e.Text + "'";
        DB db = new DB();
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        string status = "";
        DataRow row = rows[0];
        string application_id = row["application_id"].ToString();

         State["application_id"] = application_id;

        status = row["status"].ToString();
        ApplicationStatus.Text = status;
        db.CloseViziAppsDatabase(State);
    }
Ejemplo n.º 3
0
    public XmlDocument GetCustomerInfo()
    {
        XmlUtil x_util = new XmlUtil();
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        XmlNode status = null;
        XmlDocument Response = new XmlDocument();
        XmlNode root = Response.CreateElement("response");
        Response.AppendChild(root);
        try
        {
            DB db = new DB();
            String sql = "SELECT COUNT(*) FROM customers WHERE status!='inactive'";
            String count = db.ViziAppsExecuteScalar(State, sql);
            x_util.CreateNode(Response, root, "customer_count", count);
            db.CloseViziAppsDatabase(State);
            x_util.CreateNode(Response, root, "status", "success");
        }
        catch (System.Exception SE)
        {
            util.LogError(State, SE);

            if (status == null)
            {
                Response = new XmlDocument();
                XmlNode root2 = Response.CreateElement("response");
                Response.AppendChild(root2);
                status = x_util.CreateNode(Response, root2, "status");

            }
            status.InnerText = SE.Message;
            util.LogError(State, SE);
        }
        return Response;
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../Default.aspx');", true); return; }

        DB db = new DB();
        string sql = "SELECT * FROM stock_images WHERE ";
        if (State["SelectedAppType"].ToString() == Constants.WEB_APP_TYPE || State["SelectedAppType"].ToString() == Constants.HYBRID_APP_TYPE)
            sql += "type='jquery_buttons' or type='blank_buttons'";
        else
            sql += "type='blank_buttons'";
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        DataSet paramsDS = new DataSet("ParameterDataSet");
        DataTable paramTable = paramsDS.Tables.Add("ParamTable");
        DataColumn paramCol = paramTable.Columns.Add("image_url", typeof(String));

        foreach (DataRow row in rows)
        {
            string type = row["type"].ToString();
            string url = row["image_url"].ToString();

            DataRow paramRow = paramTable.NewRow();
            string[] row_array = new string[1];
            row_array[0] = url;
            paramRow.ItemArray = row_array;
            paramTable.Rows.Add(paramRow);
        }

        ParamRepeater.DataSource = paramsDS;
        ParamRepeater.DataBind();
        db.CloseViziAppsDatabase((Hashtable)HttpRuntime.Cache[Session.SessionID]);
    }
Ejemplo n.º 5
0
    public void InitApplicationCustomers(Hashtable State)
    {
        RadComboBox CustomersByAccount = (RadComboBox)State["CustomersByAccount"];
        if (CustomersByAccount == null)
            return;

        string sql = "SELECT username FROM customers ORDER BY username";
        DB db = new DB();
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        CustomersByAccount.Items.Clear();
        foreach (DataRow row in rows)
        {
            CustomersByAccount.Items.Add(new RadComboBoxItem(row["username"].ToString()));
        }
        CustomersByAccount.Items.Insert(0, new RadComboBoxItem("Select Customer ->"));

        RadComboBox CustomersByEmail = (RadComboBox)State["CustomersByEmail"];

        sql = "SELECT email FROM customers ORDER BY email";
        rows = db.ViziAppsExecuteSql(State, sql);
        CustomersByEmail.Items.Clear();
        foreach (DataRow row in rows)
        {
            CustomersByEmail.Items.Add(new RadComboBoxItem(row["email"].ToString()));
        }
        CustomersByEmail.Items.Insert(0, new RadComboBoxItem("Select Customer ->"));
        db.CloseViziAppsDatabase(State);
    }
 public string GetApplicationTypeForAdmin(Hashtable State)
 {
     DB db = new DB();
     string sql = "SELECT application_type FROM applications WHERE application_name='" + State["SelectedAdminApp"].ToString() + "' AND customer_id='" + State["ServerAdminCustomerID"].ToString() + "'";
     string application_type = db.ViziAppsExecuteScalar(State, sql);
     db.CloseViziAppsDatabase(State);
     return application_type;
 }
Ejemplo n.º 7
0
 public string GetDefaultTimeZone(Hashtable State)
 {
     DB db = new DB();
     string sql = "SELECT default_time_zone_delta_hours FROM customers WHERE customer_id='" + State["CustomerID"].ToString() + "'";
     string default_time_zone_delta_hours = db.ViziAppsExecuteScalar(State,sql);
     db.CloseViziAppsDatabase(State);
     State["TimeZoneDeltaHours"] = default_time_zone_delta_hours;
     return default_time_zone_delta_hours;
 }
Ejemplo n.º 8
0
    //Get the SKU from paid_services table for the AppID.
    public String getAppPaidSKU(Hashtable State)
    {
        DB db = new DB();
            string sql = "SELECT sku FROM paid_services WHERE application_id='" + State["application_id"].ToString() + "' AND status='paid'";
            string sku = db.ViziAppsExecuteScalar(State, sql);
            db.CloseViziAppsDatabase(State);
            State["SelectedAppSKU"] = sku;
            string AppSKU = sku;

            System.Diagnostics.Debug.WriteLine("AppSKU =" + AppSKU);
            return AppSKU;
    }
Ejemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        Util util = new Util();
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

           try
        {
            Message.Text = "";
            ToEmail.Text = Request.QueryString.Get("email");
            EmailType.Text = Request.QueryString.Get("type");

            //fill in customers applications
            string sql = "SELECT application_name FROM applications WHERE customer_id='" +  State["CustomerID"].ToString() + "' ORDER BY application_name";
            DB db = new DB();
            DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
            ApplicationList.Items.Clear();
            if (rows != null && rows.Length > 0)
            {
                foreach (DataRow row in rows)
                {
                    ApplicationList.Items.Add(row["application_name"].ToString());
                }
            }
            ApplicationList.Items.Insert(0, "No Application Issue");

            sql = "SELECT email FROM customers WHERE customer_id='" +  State["CustomerID"].ToString() + "'";
            string from = db.ViziAppsExecuteScalar(State, sql);
            if (EmailType.Text == "Customer Email")
            {
                FromEmail.Text =   HttpRuntime.Cache["TechSupportEmail"].ToString();
            }
            else if (from == null)
            {
                FromEmail.Text = "";
            }
            else
            {
                FromEmail.Text = from;
            }
            db.CloseViziAppsDatabase(State);
        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
Ejemplo n.º 10
0
    protected void AgreeButton_Click(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        Util util = new Util();
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

        DB db = new DB();
        string sql = "SELECT agreed_to_eula FROM customers WHERE customer_id = '" +  State["CustomerID"].ToString() + "'";
        string agreed_to_eula = db.ViziAppsExecuteScalar((Hashtable)HttpRuntime.Cache[Session.SessionID], sql);
        if (agreed_to_eula.ToLower() == "false" || agreed_to_eula == "0")
        {
            sql = "UPDATE customers SET agreed_to_eula=true WHERE customer_id = '" +  State["CustomerID"].ToString() + "'";
            db.ViziAppsExecuteNonQuery((Hashtable)HttpRuntime.Cache[Session.SessionID], sql);
            SendEmailToSalesandCustomer(db);
        }
        db.CloseViziAppsDatabase(State);
         State["LoggedinFromEula"] = true;
        Response.Redirect("Default.aspx", false);
    }
Ejemplo n.º 11
0
 public XmlDocument GetAppXmlForAdmin(Hashtable State)
 {
     XmlDocument doc = new XmlDocument();
     DB db = new DB();
     StringBuilder b_sql = new StringBuilder();
     b_sql.Append("SELECT  staging_app_xml FROM applications ");
     b_sql.Append("WHERE application_name='" + State["SelectedAdminApp"].ToString() + "'");
     b_sql.Append(" AND customer_id='" + State["ServerAdminCustomerID"].ToString() + "'");
     DataRow[] rows = db.ViziAppsExecuteSql(State, b_sql.ToString());
     DataRow row = rows[0];
     if (row["staging_app_xml"] == DBNull.Value || row["staging_app_xml"] == null)
     {
         State["AppXmlDoc"] = null;
         return null;
     }
     string xml = row["staging_app_xml"].ToString();
     Util util = new Util();
     doc.LoadXml(util.DecodeMySql(xml));
     db.CloseViziAppsDatabase(State);
     return doc;
 }
Ejemplo n.º 12
0
    public void CancelPaidServicesDB(Hashtable State)
    {
        try
            {
                Util util = new Util();

                string NOW = DateTime.Now.ToUniversalTime().ToString("u").Replace("Z", "");
                string application_id = State["application_id"].ToString();

                DB db = new DB();

                StringBuilder b_sql = new StringBuilder("UPDATE paid_services SET ");
                b_sql.Append("cancellation_date_time='" + NOW + "',");
                b_sql.Append("status='cancelled'");
                b_sql.Append("WHERE application_id='" + application_id + "'");

                System.Diagnostics.Debug.WriteLine("b_sql =" + b_sql.ToString());
                string sql_string = b_sql.ToString();

                try
                {
                    db.ViziAppsExecuteNonQuery(State, sql_string);
                }
                catch (Exception ex)
                {
                    util.LogError(State, ex);

                    if (!ex.Message.ToLower().Contains("duplicate"))
                        throw new Exception(ex.Message);
                }

                db.CloseViziAppsDatabase(State);

            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message.ToString() + ex.StackTrace.ToString());

            }
    }
Ejemplo n.º 13
0
 public void UpdateStagingAppXmlFromAdmin(Hashtable State)
 {
     try
     {
         string NOW = DateTime.Now.ToUniversalTime().ToString("u").Replace("Z", "");
         DB db = new DB();
         StringBuilder b_sql = new StringBuilder("UPDATE applications SET ");
         b_sql.Append("application_type='" + State["SelectedAdminAppType"].ToString() + "',");
         XmlDocument doc = (XmlDocument)State["AdminAppDesign"];
         Util util = new Util();
         b_sql.Append("staging_app_xml='" + util.MySqlFilter(doc.OuterXml) + "',");
         b_sql.Append("date_time_modified='" + NOW + "' ");
         b_sql.Append("WHERE application_name='" + State["SelectedAdminApp"].ToString() + "'");
         b_sql.Append(" AND customer_id='" + State["ServerAdminCustomerID"].ToString() + "'");
         db.ViziAppsExecuteNonQuery(State, b_sql.ToString());
         db.CloseViziAppsDatabase(State);
     }
     catch (Exception ex)
     {
         throw new Exception("Error in UpdateStagingAppXmlFromAdmin: " + ex.Message + ": " + ex.StackTrace);
     }
 }
    protected void LoginToUser_Click(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        Util util = new Util();
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

        if (State["CustomerID"] == null)
        {
            Warning.Visible = true;
            Warning.Text = "Unknown user credentials from email.";
            return;
        }
        DB db = new DB();
        string sql = "SELECT username,password FROM customers WHERE customer_id='" +  State["CustomerID"].ToString() + "'";
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        DataRow row = rows[0];
        db.CloseViziAppsDatabase(State);

         State["Username"] = row["username"].ToString();
         State["Password"] = row["password"].ToString();
         State["LoggedInFromAdmin"] = true;
        Response.Redirect("Default.aspx", false);
    }
Ejemplo n.º 15
0
    public void InitAccountList(Hashtable State, RadComboBox Accounts, bool Initialize)
    {
        string sql = "SELECT username FROM customers ORDER BY username";
        DB db = new DB();
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        Accounts.Items.Clear();
        int index = 0;
        foreach (DataRow row in rows)
        {
            string username = row["username"].ToString();
            Accounts.Items.Add(new RadComboBoxItem(username,username));
            if (Initialize)
            {
                if (username == State["Username"].ToString())
                    Accounts.SelectedIndex = index;
                index++;
            }
        }
        if (!Initialize)
            Accounts.Items.Insert(0, new RadComboBoxItem("Select Account ->","Select Account ->"));

        db.CloseViziAppsDatabase(State);
    }
    protected void FromAccounts_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "../Default.aspx")) return;

        if (e.Text.IndexOf("->") > 0)
        {
            Applications.Visible = false;
            CopyApplicationButton.Visible = false;
            return;
        }
        Applications.Visible = true;

        DB db = new DB();
        string sql = "SELECT customer_id FROM customers WHERE username='******'";
        string customer_id = db.ViziAppsExecuteScalar(State, sql);
         State["CopyApplicationFromCustomerID"] = customer_id;

        Init init = new Init();
        init.InitAppsList(State, Applications, customer_id);

        db.CloseViziAppsDatabase(State);
    }
Ejemplo n.º 17
0
 protected void UpdatePassword_Click(object sender, EventArgs e)
 {
     DB db = new DB();
     Util util = new Util();
     if (Password.Text.Length < 6)
     {
         AdminMessage.Text = "Passwords must 6 characters or more.";
         return;
     }
     Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
     string sql = "UPDATE customers SET password='******' WHERE customer_id='" + State["ServerAdminCustomerID"].ToString() + "'";
     db.ViziAppsExecuteNonQuery(State, sql);
     db.CloseViziAppsDatabase(State);
     AdminMessage.Text = "Password has been set.";
 }
Ejemplo n.º 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State,Response,"Default.aspx")) return;
        try
        {
            if (!IsPostBack)
            {
                CopyRight.InnerText = HttpRuntime.Cache["CopyRight"].ToString();
                UserLabel.Text = State["Username"].ToString();
            }

            if ( HttpRuntime.Cache["TechSupportEmail"] != null)
            {
                util.AddEmailToButton(SupportButton,  HttpRuntime.Cache["TechSupportEmail"].ToString(), "Email To Tech Support");
            }

            util.UpdateSessionLog(State, "post", "TabMyProfile");

            if (State["ServerAdminCustomerUsername"] != null)
                UsernameLabel.Text = State["ServerAdminCustomerUsername"].ToString();
            else
                UsernameLabel.Text = State["Username"].ToString();

            Message.Text = "";

            string sql = null;
            if (State["Username"].ToString() != "admin")
            {
                sql = "SELECT * FROM customers WHERE customer_id='" + State["CustomerID"].ToString() + "'";
            }
            else
            {
                sql = "SELECT * FROM customers WHERE customer_id='" + State["ServerAdminCustomerID"].ToString() + "'";
            }
            DB db = new DB();
            DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
            DataRow row = rows[0];

            PasswordTextBox.Text = "";
            ConfirmPasswordBox.Text = "";
            CompanyTextBox.Text = util.DecodeMySql(row["company"].ToString());
            RoleTextBox.Text = util.DecodeMySql(row["role"].ToString());
            FirstNameTextBox.Text = util.DecodeMySql(row["first_name"].ToString());
            LastNameTextBox.Text = util.DecodeMySql(row["last_name"].ToString());
            StreetTextBox.Text = util.DecodeMySql(row["street_address"].ToString());
            CityTextBox.Text = util.DecodeMySql(row["city"].ToString());

            if (row["state"] != null && row["state"].ToString().Length > 0)
                StateList.Text = row["state"].ToString();

            PostalCodeTextBox.Text = row["postal_code"].ToString();
            CountryTextBox.Text = util.DecodeMySql(row["country"].ToString());

            PhoneTextbox.Text = row["phone"].ToString();
            EmailTextBox.Text = row["email"].ToString();
            string status = row["status"].ToString();

            //Additions for the CC fields
            if (!IsPostBack)
            {
                CCFirstNameTextbox.Text = util.DecodeMySql(row["first_name"].ToString());
                CCLastNameTextBox.Text = util.DecodeMySql(row["last_name"].ToString());
                CCZipTextBox.Text = row["postal_code"].ToString();
            }

            db.CloseViziAppsDatabase(State);

            TimeZones zone_util = new TimeZones();
            string default_time_zone_delta_hours = row["default_time_zone_delta_hours"].ToString();
            zone_util.InitTimeZones(State, DateTime.Now.ToUniversalTime(), TimeZoneList, default_time_zone_delta_hours);

            string force_1_user_sessions = row["force_1_user_sessions"].ToString();
            Force1UserSessions.Checked = force_1_user_sessions == "1" || force_1_user_sessions.ToLower() == "true";

        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
Ejemplo n.º 19
0
    protected bool CheckAppName(string app)
    {
        try
        {
            ClearMessages();
            if (app.Length == 0)
            {
                Message.Text = "Enter Application Name";
                return false;
            }

            //check for valid name
            if (!Check.ValidateObjectName(Message, app))
            {
                return false;
            }

            //check for previous name
            DB db = new DB();
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
            string sql = "SELECT * FROM applications WHERE customer_id='" + State["CustomerID"] + "' AND application_name='" + app + "'";
            string n_matches = db.ViziAppsExecuteScalar(State, sql);
            db.CloseViziAppsDatabase(State);
            if (n_matches != null && n_matches != "0")
            {
                Message.Text = "The app name " + app + " already exists.";
                return false;
            }

            return true;
        }
        catch (Exception ex)
        {
            Util util = new Util();
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
            util.LogError(State, ex);
            Message.Text = "Internal Error: " + ex.Message + ": " + ex.StackTrace;
            return false;
        }
    }
    private void PreFillBillingFormDetails()
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        Util util = new Util();
        if (State["ServerAdminCustomerUsername"] != null)
            UserLabel.Text = State["ServerAdminCustomerUsername"].ToString();
        else
            UserLabel.Text = State["Username"].ToString();

        string sql = null;
        if (State["Username"].ToString() != "admin")
        {
            sql = "SELECT * FROM customers WHERE customer_id='" + State["CustomerID"].ToString() + "'";
        }
        else
        {
            sql = "SELECT * FROM customers WHERE customer_id='" + State["ServerAdminCustomerID"].ToString() + "'";
        }
        DB db = new DB();
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        db.CloseViziAppsDatabase(State);

        DataRow row = rows[0];

        CompanyTextBox.Text = util.DecodeMySql(row["company"].ToString());
        EmailTextBox.Text = row["email"].ToString();
        FirstNameTextBox.Text = util.DecodeMySql(row["first_name"].ToString());
        LastNameTextBox.Text = util.DecodeMySql(row["last_name"].ToString());
        StreetTextBox.Text = util.DecodeMySql(row["street_address"].ToString());
        CityTextBox.Text = util.DecodeMySql(row["city"].ToString());

        if (row["state"] != null && row["state"].ToString().Length > 0)
            StateList.SelectedValue = row["state"].ToString();

        //StateList.Text = row["state"].ToString();

        PostalCodeTextBox.Text = row["postal_code"].ToString();
        CountryTextBox.Text = util.DecodeMySql(row["country"].ToString());
        PhoneTextbox.Text = row["phone"].ToString();

        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++
        CCFirstNameTextbox.Text = util.DecodeMySql(row["first_name"].ToString());
        CCLastNameTextBox.Text = util.DecodeMySql(row["last_name"].ToString());
        CCZipTextBox.Text = row["postal_code"].ToString();

        //++++++++++++++ To be Removed at the end ++++++++++++++++++++++++++
        //CCNumberTextBox.Text = "4111111111111111";
        //CCExpirationTextBox.Text = "12/2012";
        //CCCardCodeTextBox.Text = "222";
    }
Ejemplo n.º 21
0
    protected void UpdateProfile_Click(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

        Message.Text = "";

        PasswordTextBox.Text = Request.Form.Get("PasswordTextBox");
        ConfirmPasswordBox.Text = Request.Form.Get("ConfirmPasswordBox");
        CompanyTextBox.Text = Request.Form.Get("CompanyTextBox");
        RoleTextBox.Text = Request.Form.Get("RoleTextBox");
        FirstNameTextBox.Text = Request.Form.Get("FirstNameTextBox");
        LastNameTextBox.Text = Request.Form.Get("LastNameTextBox");
        StreetTextBox.Text = Request.Form.Get("StreetTextBox");
        CityTextBox.Text = Request.Form.Get("CityTextBox");
        StateList.Text = Request.Form.Get("StateList");
        PostalCodeTextBox.Text = Request.Form.Get("PostalCodeTextBox");
        CountryTextBox.Text = Request.Form.Get("CountryTextBox");
        PhoneTextbox.Text = Request.Form.Get("PhoneTextbox");
        EmailTextBox.Text = Request.Form.Get("EmailTextBox");
        string force_1_user_sessions = Request.Form.Get("Force1UserSessions");
        Force1UserSessions.Checked = force_1_user_sessions == "on" ? true : false;

        //validation
        if (CompanyTextBox.Text.Length > 0 && !Check.ValidateName(Message, CompanyTextBox.Text))
        {
            return;
        }
        if (RoleTextBox.Text.Length > 0 && !Check.ValidateString(Message, RoleTextBox.Text))
        {
            return;
        }
        if (FirstNameTextBox.Text.Length > 0 && !Check.ValidateName(Message, FirstNameTextBox.Text))
        {
            return;
        }
        if (LastNameTextBox.Text.Length > 0 && !Check.ValidateName(Message, LastNameTextBox.Text))
        {
            return;
        }
        if (StreetTextBox.Text.Length > 0 && !Check.ValidateText(Message, StreetTextBox.Text))
        {
            return;
        }
        if (CityTextBox.Text.Length > 0 && !Check.ValidateName(Message, CityTextBox.Text))
        {
            return;
        }
        if (PostalCodeTextBox.Text.Length > 0 && !Check.ValidateZipcode(Message, PostalCodeTextBox.Text))
        {
            return;
        }
        if (CountryTextBox.Text.Length > 0 && !Check.ValidateName(Message, CountryTextBox.Text))
        {
            return;
        }
        if (!Check.ValidatePhone(Message, PhoneTextbox.Text))
        {
            return;
        }
        if (!Check.ValidateEmail(Message, EmailTextBox.Text))
        {
            return;
        }

        StringBuilder sql = null;
        DB db = new DB();
        string username = null;
        if (State["Username"].ToString() != "admin")
        {
            username =  State["Username"].ToString();
        }
        else
        {
            username =  State["ServerAdminUsername"].ToString();
        }

        if (PasswordTextBox.Text.Length > 0 || ConfirmPasswordBox.Text.Length > 0)
        {
            if (PasswordTextBox.Text == ConfirmPasswordBox.Text)
            {
                if (!Check.ValidatePassword(Message, PasswordTextBox.Text))
                {
                    return;
                }
                sql = new StringBuilder("UPDATE customers SET password='******'");
                sql.Append(" WHERE username='******'");
                db.ViziAppsExecuteNonQuery(State, sql.ToString());

                sql = new StringBuilder("SELECT email from customers WHERE username='******'");
                string to_email = db.ViziAppsExecuteScalar(State, sql.ToString());

                Email email = new Email();
                StringBuilder body = new StringBuilder("\nYour ViziApps password has been changed.\n\n");

                body.Append("If you did not change it, contact our support team at [email protected] right away. ");
                body.Append("\n\n - The ViziApps Team \n");

                email.SendEmail(State,   HttpRuntime.Cache["TechSupportEmail"].ToString(), to_email, "", "", "ViziApps Notice", body.ToString(), "",false);
            }
            else
            {
                Message.Text = "New password and confirmation password do not match. Your account information has not been updated";
                return;
            }
        }

        sql = new StringBuilder("UPDATE customers SET ");
        sql.Append("company='" + util.MySqlFilter(CompanyTextBox.Text) + "'");
        sql.Append(",role='" + util.MySqlFilter(RoleTextBox.Text) + "'");
        sql.Append(",first_name='" + util.MySqlFilter(FirstNameTextBox.Text) + "'");
        sql.Append(",last_name='" + util.MySqlFilter(LastNameTextBox.Text) + "'");
        sql.Append(",street_address='" + util.MySqlFilter(StreetTextBox.Text) + "'");
        sql.Append(",city='" + util.MySqlFilter(CityTextBox.Text) + "'");
        if (StateList.SelectedValue.IndexOf("->") < 0)
            sql.Append(",state='" + StateList.SelectedValue + "'");
        else
            sql.Append(",state=''");

        sql.Append(",postal_code='" + PostalCodeTextBox.Text + "'");
        sql.Append(",country='" + util.MySqlFilter(CountryTextBox.Text) + "'");
        sql.Append(",phone='" + PhoneTextbox.Text + "'");
        sql.Append(",email='" + EmailTextBox.Text + "'");
        sql.Append(",default_time_zone_delta_hours='" + TimeZoneList.SelectedValue + "'");
        force_1_user_sessions = force_1_user_sessions == "on" ? "1" : "0";
        sql.Append(",force_1_user_sessions=" + force_1_user_sessions);
        sql.Append(" WHERE username='******'");
        db.ViziAppsExecuteNonQuery(State, sql.ToString());
        db.CloseViziAppsDatabase(State);

        TimeZones zone_util = new TimeZones();
        zone_util.GetDefaultTimeZone(State);

        //Update with CheddarGetter the CreditCardDetails if the Checkbox for CreditCardUpdate is checked.
        if (Update_CC_Details_CheckBox.Checked)
        {
            if (UpdateCheddarGetterWithCC() == true)
                Message.Text = "Your account profile has been updated. ";
            else
                Message.Text = "There was a problem updating your credit card info. Please contact [email protected] for assistance.";
        }
        else
            Message.Text = "Your account profile has been updated. ";
        //End CC Update
    }
Ejemplo n.º 22
0
    protected void RemoveCustomer_Click(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        string customer_id = State["ServerAdminCustomerID"].ToString();
        if (customer_id == "0")
        {
            AdminMessage.Text = "Select a customer and try again.";
            return;
        }

        string sql = "SELECT status,username FROM customers WHERE customer_id='" + customer_id + "'";
        DB db = new DB();
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        DataRow row = rows[0];

        string status = row["status"].ToString();
        string username = row["username"].ToString();

        if (status != "inactive")
        {
            AdminMessage.Text = "Customer can only be removed after it has been deactivated.";
        }
        else
        {
            DoRemoveCustomer(username, customer_id);
            AdminMessage.Text = "Customer has been removed.";

            HideForCustomers();

            Init init = new Init();
            init.InitApplicationCustomers(State);
            CustomerStatus.Text = "";
        }

        db.CloseViziAppsDatabase(State);
        CustomersByAccount.Items[0].Selected = true;
        CustomersByEmail.Items[0].Selected = true;
        HideForApplications();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../../Default.aspx');", true); return; }

        try
        {
            ClearMessages();

            State["ApplicationID"] = util.GetAppID(State);

            App.Text = "Test Web App Name: " +  State["SelectedApp"].ToString();

            if (util.IsAppStoreSubmissionPaid(State,  State["SelectedApp"].ToString()))
            {
                //SubmitForProvisioning.Visible = true;
                PurchaseButton.Visible = false;
             }
            else
            {
                //SubmitForProvisioning.Visible = false;
                PurchaseButton.Visible = true;
                //ProvisioningMessage.Text = "You can fill this form any time, but to submit your app for production, you need to first purchase one of the ViziApps services to submit the app to an app store.";
                PurchaseButton.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
        "http://stores.homestead.com/MobiFlexStore/StoreFront.bok", 700, 900, false, false, false, true));
            }

            if (!IsPostBack)
            {
                XmlUtil x_util = new XmlUtil();
                //State["SelectedDeviceView"] =
                State["SelectedDeviceType"] = x_util.GetAppDeviceType(State);
                if (State["SelectedDeviceType"] == null)
                {
                   // State["SelectedDeviceView"] =
                    State["SelectedDeviceType"] = Constants.IPHONE;
                }

                //check on device type
                switch(State["SelectedDeviceType"].ToString())
                {
                     case Constants.IPAD:
                        SplashUploadLabel.Text = "Splash Image ( 768 X 1004 pixels from .jpg file )";
                        ScreenSplashButton.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
                                "ScreenShot.aspx", 1004, 768, false, false, false, true));
                        break;
                     case Constants.ANDROID_TABLET:
                        SplashUploadLabel.Text = "Splash Image ( 800 X 1233 pixels from .jpg file )";
                        ScreenSplashButton.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
                                "ScreenShot.aspx", 1233, 800, false, false, false, true));
                        break;
                     case Constants.IPHONE:
                        SplashUploadLabel.Text = "Splash Image ( 320 X 460 pixels from .jpg file )";
                        ScreenSplashButton.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
                                "ScreenShot.aspx", 460, 320, false, false, false, true));
                       break;
                     case Constants.ANDROID_PHONE:
                        SplashUploadLabel.Text = "Splash Image ( 320 X 508 pixels from .jpg file )";
                         ScreenSplashButton.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
                                "ScreenShot.aspx", 508, 320, false, false, false, true));
                      break;
                }
                SelectedDeviceType.Text = State["SelectedDeviceType"].ToString();

                DB db = new DB();
                StringBuilder b_sql = new StringBuilder("SELECT * FROM applications ");
                b_sql.Append("WHERE application_name='" +  State["SelectedApp"].ToString() + "'");
                b_sql.Append(" AND customer_id='" +  State["CustomerID"].ToString() + "'");
                DataRow[] rows = db.ViziAppsExecuteSql(State, b_sql.ToString());
                DataRow row = rows[0];
                if (row["production_app_name"] != null)
                    ProductionAppName.Text = row["production_app_name"].ToString();

                if (row["production_app_xml"] != DBNull.Value)
                    ProductionDesignExists.Visible = true;
                else
                    ProductionDesignExists.Visible = false;

                 bool use_1_user_credential = false;
                if (row["use_1_user_credential"] != DBNull.Value)
                {
                    string use_1_cred =  row["use_1_user_credential"].ToString();
                    use_1_user_credential = (use_1_cred.ToLower() == "true") ? true : false;
                }
                bool has_unlimited_users = false;
                if (row["has_unlimited_users"] != DBNull.Value)
                {
                    string has_unlimited = row["has_unlimited_users"].ToString();
                    has_unlimited_users = (has_unlimited.ToLower() == "true") ? true : false;
                }

                b_sql = new StringBuilder("SELECT * FROM branding_images ");
                b_sql.Append("WHERE application_id='" +  State["ApplicationID"].ToString() + "'");
                rows = db.ViziAppsExecuteSql(State, b_sql.ToString());
                foreach (DataRow image_row in rows)
                {
                    if (image_row["type"].ToString() == "icon" && image_row["width"].ToString() == "512")
                    {
                        LargeIconButton.Visible = true;
                        DeleteIcon.Visible = true;
                    }
                    if (image_row["type"].ToString() == "splash")
                    {
                        ScreenSplashButton.Visible = true;
                        DeleteSplashImage.Visible = true;
                    }
                }
                db.CloseViziAppsDatabase(State);

            }

        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
Ejemplo n.º 24
0
 protected void UpdateAccountTypes_Click(object sender, EventArgs e)
 {
     DB db = new DB();
     Util util = new Util();
     if (AccountTypes.Text.Length == 0)
     {
         AdminMessage.Text = "Account Types cannot be empty.";
         return;
     }
     Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
     string sql = "UPDATE customers SET account_type='type=" + util.MySqlFilter(AccountTypes.Text.Trim()) + ";' WHERE customer_id='" + State["ServerAdminCustomerID"].ToString() + "'";
     db.ViziAppsExecuteNonQuery(State, sql);
     db.CloseViziAppsDatabase(State);
     AdminMessage.Text = "Account Types have been set";
 }
Ejemplo n.º 25
0
    public XmlDocument Login()
    {
        Init init = new Init();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        init.InitSkuConfigurations(State);
         HttpRuntime.Cache["TempFilesPath"] = Server.MapPath(".") + @"\temp_files\";
        Util util = new Util();
        XmlUtil x_util = new XmlUtil();
        XmlNode status = null;
        XmlDocument Design = null;

        try
        {
            DB db = new DB();

            HttpRequest request = Context.Request;

            string viziapps_version = request.QueryString.Get("viziapps_version");
            if (viziapps_version == null)
                viziapps_version = request.QueryString.Get("mobiflex_version");

            string device_id = request.QueryString.Get("deviceid");
            string device_model = request.QueryString.Get("device_model");
            string customer_username = request.QueryString.Get("customer");
            string app_status = (customer_username != null && customer_username.Length > 0) ? "production" : "staging";
            string application_name = request.QueryString.Get("app");
            string application_id = request.QueryString.Get("app_id");
            string unlimited = request.QueryString.Get("unlimited");
            string device_version = request.QueryString.Get("device_version");
            if (application_id == null)
                application_id = "";

            string sql = null;
            DataRow[] rows = null;
            string customer_id = null;
            string user_id = null;
            string user = request.QueryString.Get("user");
            string password = request.QueryString.Get("pwd");

            string display_width = request.QueryString.Get("display_width");
            if (display_width == null)
                display_width = "320";

            string display_height = request.QueryString.Get("display_height");
            if (display_height == null)
                display_height = "480";

            if (device_model == null)
                State["SelectedDeviceType"] = Constants.IPHONE;
            else if (device_model.ToLower().Contains("iphone") || device_model.ToLower().Contains("ipod"))
                State["SelectedDeviceType"] = Constants.IPHONE;
            else if (device_model.ToLower().Contains("ipad"))
                State["SelectedDeviceType"] = Constants.IPAD;
            else if (Convert.ToInt32(display_width) > 600)
                State["SelectedDeviceType"] = Constants.ANDROID_TABLET;
            else
                State["SelectedDeviceType"] = Constants.ANDROID_PHONE;

            if (unlimited == null || unlimited != "true")
            {
                if (user == null || password == null)
                {
                    Design = new XmlDocument();
                    XmlNode root2 = Design.CreateElement("login_response");
                    Design.AppendChild(root2);
                    status = x_util.CreateNode(Design, root2, "status", "Either the username or the password: "******" is incorrect.");
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: bad credentials");
                    return Design;
                }
            }

            if (app_status == "production")
            {
                util.GetProductionAccountInfo(State, customer_username);
                if (customer_id == null)
                    customer_id = State["CustomerID"].ToString();
                //State["Username"] = customer_username;
                //customer_id = util.GetCustomerIDFromUsername(State, customer_username);
                //State["CustomerID"] = customer_id;
                //string account_status = util.GetCustomerStatus(State);
                // if (account_status == "inactive")
                if (State["AccountStatus"].ToString() == "inactive")
                {
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: account inactive");
                    throw new System.InvalidOperationException("Your customer account is inactive.");
                }
                util.GetProductionAppInfo(State, application_name);
                application_id = State["AppID"].ToString();

                if (State["IsProductionAppPaid"] != null && State["IsProductionAppPaid"].ToString() != "true")
                {
                    //if (!util.IsFreeProductionValid(State, application_id))
                    if (State["IsFreeProductionValid"] != null && State["IsFreeProductionValid"].ToString() != "true")
                    {
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: publishing service expired");
                        throw new System.InvalidOperationException("The publishing service for your app has expired.");
                    }
                }

                if (unlimited == null || unlimited != "true")
                {
                    //check username and password
                    // sql = "SELECT * FROM users WHERE username='******' AND password='******' AND application_id='" + application_id + "'";

                    //rows = db.ViziAppsExecuteSql(State, sql);
                    //if (rows.Length == 0)
                    if (State["Password"] == null)
                    {
                        //db.CloseViziAppsDatabase(State);
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: bad credentials");
                        throw new System.InvalidOperationException("Either the username or the password: "******" is incorrect.");
                    }

                    //check number of users -- unlimited use never needs a login
                    //bool use_1_user_credential = util.GetUse1UserCredential(State, application_id);
                    //if (use_1_user_credential)
                    if (State["Use1UserCredential"] != null && State["Use1UserCredential"].ToString() == "true")
                    {
                        Hashtable features = util.IsProductionAppPaid(State, application_id);
                        DataRow row = rows[0];
                        sql = "SELECT COUNT(*) FROM users_device_ids WHERE user_id='" + row["user_id"].ToString() + "'";
                        int device_count = Convert.ToInt32(db.ViziAppsExecuteScalar(State, sql));

                        sql = "SELECT COUNT(*) FROM users_device_ids WHERE device_id='" + device_id + "'";
                        string device_exists = db.ViziAppsExecuteScalar(State, sql);

                        if (device_exists == "0")
                        {
                            if (device_count >= (int)features["max_users"])
                            {
                                db.CloseViziAppsDatabase(State);
                                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: reached limit of users");
                                throw new System.InvalidOperationException("Cannot download app: reached limit of users.");
                            }
                            else
                            {
                                sql = "INSERT INTO users_device_ids SET device_id='" + device_id + "',user_id='" + row["user_id"].ToString() + "'";
                                db.ViziAppsExecuteNonQuery(State, sql);
                            }
                        }
                        //else app is allowed
                    }
                }
            }
            else //staging
            {
                sql = "SELECT * FROM customers WHERE username='******'";
                rows = db.ViziAppsExecuteSql(State, sql);
                if (rows.Length == 0)
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: user not registered");
                    throw new Exception("The username " + user.ToLower() + " is not registered. Go to www.viziapps.com and create a free account.");
                }

                DataRow row = rows[0];
                if (row["password"].ToString() != password)
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: bad credentials");
                    throw new Exception("Either the username or the password: "******" is incorrect.");
                }
                if (row["status"].ToString() == "inactive")
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: account is inactive");
                    throw new Exception("Your account is inactive. Contact ViziApps to re-activate your account.");
                }
                customer_id = row["customer_id"].ToString();
                State["CustomerID"] = customer_id;
            }

            //user is now logged in

            if (app_status == "staging")
            {
                sql = "SELECT application_id FROM applications WHERE " +
                   "in_staging=1 AND customer_id='" + customer_id + "'";

                application_id = db.ViziAppsExecuteScalar(State, sql);
                if (application_id == null)
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: no app selected");
                    throw new System.InvalidOperationException("You need to select an app to test, on the design page of your ViziApps Studio account.");
                }
            }

            db.CloseViziAppsDatabase(State);

            //get design
            if (State["AppDesignURL"] == null)
            {
                Design = GetDesign(application_id, user_id, customer_id, Convert.ToInt32(display_width), Convert.ToInt32(display_height), app_status, null);
                //save design in a file if production
                if (app_status == "production")
                {
                    util.SaveProductionAppInfo(State, application_name, Design);
                }
            }
            else
            {
                Design = new XmlDocument();
                Design.LoadXml(util.GetWebPage(State["AppDesignURL"].ToString()));
            }
            if (Design == null)
            {
                Design = new XmlDocument();
                XmlNode root2 = Design.CreateElement("login_response");
                Design.AppendChild(root2);
                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: no app selected");
                status = x_util.CreateNode(Design, root2, "status", "You need to select an app to test, on the design page of your ViziApps Studio account.");
            }
            else
                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: design downloaded");

        }
        catch (System.Exception SE)
        {
            util.LogError(State, SE);

            if (status == null)
            {
                Design = new XmlDocument();
                XmlNode root2 = Design.CreateElement("login_response");
                Design.AppendChild(root2);
                status = x_util.CreateNode(Design, root2, "status");

            }
            status.InnerText = SE.Message;
            util.LogError(State, SE);
        }
        return Design;
    }
Ejemplo n.º 26
0
    public XmlDocument Report()
    {
        Init init = new Init();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        init.InitSkuConfigurations(State);
         HttpRuntime.Cache["TempFilesPath"] = Server.MapPath(".") + @"\temp_files\";
        Util util = new Util();
        XmlUtil x_util = new XmlUtil();
        XmlNode status_node = null;
        XmlDocument Report = new XmlDocument();
        XmlNode root = Report.CreateElement("report_response");
        Report.AppendChild(root);
        try
        {
            DB db = new DB();

            HttpRequest request = Context.Request;
            string application_id = request.QueryString.Get("appid");
            string application_name = request.QueryString.Get("app");
            string isproduction = request.QueryString.Get("isproduction");
            string username = request.QueryString.Get("customer");
            string user_id = request.QueryString.Get("userid");
            string device_id = request.QueryString.Get("deviceid");
            string device_version = request.QueryString.Get("device_version");
            string device_model = request.QueryString.Get("device_model");

            string viziapps_version = request.QueryString.Get("viziapps_version");
            if (viziapps_version == null)
                viziapps_version = request.QueryString.Get("mobiflex_version");

            string latitude = request.QueryString.Get("latitude");
            string longitude = request.QueryString.Get("longitude");

            string app_status = "staging";
            if (isproduction == "yes")
            {
                app_status = "production";
            }

            string customer_id = request.QueryString.Get("custid");
            if (app_status == "production")
            {
                util.GetProductionAccountInfo(State, username);
                util.GetProductionAppInfo(State, application_name);
                application_id = State["AppID"].ToString();

                if (State["IsProductionAppPaid"] != null && State["IsProductionAppPaid"].ToString() != "true")
                {
                    //if (!util.IsFreeProductionValid(State, application_id))
                    if (State["IsFreeProductionValid"] != null && State["IsFreeProductionValid"].ToString() != "true")
                    {
                        x_util.CreateNode(Report, root, "status", "kill");
                        x_util.CreateNode(Report, root, "status_message", "The account for this app is inactive. Contact ViziApps to re-activate your account.");
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app killed due to inactive account");
                        throw new System.InvalidOperationException("The publishing service for your app has expired.");
                    }
                }
                if (State["AccountStatus"].ToString() == "inactive")
                {
                    x_util.CreateNode(Report, root, "status", "kill");
                    x_util.CreateNode(Report, root, "status_message", "The account for this app is inactive. Contact ViziApps to re-activate your account.");
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app killed due to inactive account");
                    return Report;
                }
            }
            //else app is staging
            else if (customer_id != null && customer_id.Length > 0)
            {
                State["CustomerID"] = customer_id;
                string active_sql = "SELECT COUNT(*) FROM customers where customer_id='" + customer_id + "' AND status!='inactive'";
                string active_count = db.ViziAppsExecuteScalar(State, active_sql);
                if (active_count == "0")
                {
                    x_util.CreateNode(Report, root, "status", "kill");
                    x_util.CreateNode(Report, root, "status_message", "The account for this app is inactive. Contact ViziApps to re-activate your account.");
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app killed due to inactive account");
                    return Report;
                }
            }

            string display_width = request.QueryString.Get("display_width");
            if (display_width == null)
                display_width = "320";

            string display_height = request.QueryString.Get("display_height");
            if (display_height == null)
                display_height = "480";

            if (device_model == null)
                State["SelectedDeviceType"] = Constants.IPHONE;
            else if (device_model.ToLower().Contains("iphone") || device_model.ToLower().Contains("ipod"))
                State["SelectedDeviceType"] = Constants.IPHONE;
            else if (device_model.ToLower().Contains("ipad"))
                State["SelectedDeviceType"] = Constants.IPAD;
            else if (Convert.ToInt32(display_width) > 600)
                State["SelectedDeviceType"] = Constants.ANDROID_TABLET;
            else
                State["SelectedDeviceType"] = Constants.ANDROID_PHONE;

            if (application_id != null && application_id.Length > 0)
            {
                string sql = null;
                if (app_status == "staging")
                {
                    sql = "SELECT status FROM applications WHERE application_id='" + application_id + "'";
                    string staging_status = db.ViziAppsExecuteScalar(State, sql);
                    if (staging_status == null || (!staging_status.Contains("staging") && customer_id != null))
                    {
                        sql = "SELECT application_id FROM applications WHERE customer_id='" + customer_id + "' AND status LIKE '%staging%'";
                        string new_application_id = db.ViziAppsExecuteScalar(State, sql);
                        if (new_application_id != null)
                        {
                            XmlDocument Design = GetDesign(new_application_id, user_id, customer_id, Convert.ToInt32(display_width), Convert.ToInt32(display_height), app_status, null);
                            if (Design != null)
                            {
                                Design.SelectSingleNode("//status").InnerText = "update_app";
                                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app updated");
                            }
                            else
                            {
                                Design = new XmlDocument();
                                XmlNode root2 = Design.CreateElement("report_response");
                                Design.AppendChild(root2);
                                x_util.CreateNode(Design, root2, "status", "kill");
                                x_util.CreateNode(Design, root2, "status_message", "Application no longer exists.");
                                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app does not exist");
                            }
                            return Design;
                        }
                    }
                    db.CloseViziAppsDatabase(State);
                }
            }

            string app_time_stamp = request.QueryString.Get("app_time_stamp");
            if (app_time_stamp != null && app_time_stamp.Length > 0)
            {
                string date_time_modified = null;
                if (app_status == "staging")
                    date_time_modified = util.GetStagingAppTimeStamp(State, application_id);
                else
                {
                    date_time_modified = State["DateTimeModified"].ToString();
                }
                DateTime AppDateTime;
                bool isGoodAppDateTime= DateTime.TryParse(app_time_stamp, out AppDateTime);
                DateTime DateTimeModified;
                bool isGoodDateTimeModified = DateTime.TryParse(date_time_modified, out DateTimeModified);
                if (isGoodAppDateTime && isGoodDateTimeModified && AppDateTime != DateTimeModified)
                { // assuming that there is a newer version
                    XmlDocument Design = null;
                    if (app_status == "staging")
                    {
                        Design = GetDesign(application_id, user_id, customer_id, Convert.ToInt32(display_width), Convert.ToInt32(display_height), app_status, date_time_modified);
                    }
                    else
                    {
                        Design = new XmlDocument();
                        Design.LoadXml(util.GetWebPage(State["AppDesignURL"].ToString()));
                    }
                    if (Design != null)
                    {
                        Design.SelectSingleNode("//status").InnerText = "update_app";
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app updated");
                    }
                    else
                    {
                        Design = new XmlDocument();
                        XmlNode root2 = Design.CreateElement("report_response");
                        Design.AppendChild(root2);
                        x_util.CreateNode(Design, root2, "status", "kill");
                        x_util.CreateNode(Design, root2, "status_message", "Application no longer exists.");
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app does not exist");
                    }

                    return Design;
                }
                else
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app opened");
            }
            else
                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app opened");

            string status = "OK";

            //check for unlimited use
            if (app_status == "production")
            {
                if (State["HasUnlimitedUsers"].ToString() == "true")
                    status += " unlimited";
            }

            status_node = x_util.CreateNode(Report, root, "status", status);
        }
        catch (System.Exception SE)
        {
            util.LogError(State, SE);
            if (status_node == null)
            {
                Report = new XmlDocument();
                XmlNode root2 = Report.CreateElement("report_response");
                Report.AppendChild(root2);
                status_node = x_util.CreateNode(Report, root2, "status");

            }
            status_node.InnerText = SE.Message + ": " + SE.StackTrace;
        }

        return Report;
    }
Ejemplo n.º 27
0
    protected void CreateAccountSubmit_ServerClick(object sender, EventArgs e)
    {
        //check for competitors
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        string address = EmailTextBox.Text.ToLower();
        string bad_domains = Server.MapPath(".") + @"\App_Data\BadDomains.txt";
        string[] lines = File.ReadAllLines(bad_domains);
        foreach(string line in lines)
        {
            if (address.EndsWith(line))
            {
                MessageLabel.Text = "An email has been sent to you to complete your registration. Please follow the directions in the email.";
                return;
            }
        }

        Util util = new Util();
        DB db = new DB();

        Label Error = new Label();
        StringBuilder err = new StringBuilder();
        string username = UsernameBox.Text.Trim().ToLower();
        if (!Check.ValidateUsername(Error, username))
        {
            err.Append(Error.Text.Clone() + "<BR>");
        }
        else
        {
            string query = "SELECT username FROM customers WHERE username='******'";
            string prev_username = db.ViziAppsExecuteScalar(State,query);
            if (username == prev_username)
            {
               /* query = "SELECT password FROM customers WHERE username='******'";
                string password = db.ViziAppsExecuteScalar(State, query);
                if(password != PasswordTextBox.Text)*/
                     err.Append("The " + username + " account already exists.<BR>");
            }
            if (address.Length> 0 && address.ToLower() != "*****@*****.**") //for every email not for testing
            {
                query = "SELECT email FROM customers WHERE email='" + address + "'";
                string email = db.ViziAppsExecuteScalar(State, query);
                if (email == this.EmailTextBox.Text)
                {
                    err.Append("An account already exists with the same email.<BR>");
                }
            }
        }
        if (!Check.ValidatePassword(Error, PasswordTextBox.Text))
        {
            err.Append("Enter Password: "******"<BR>");
        }
        if (!Check.ValidateEmail(Error, EmailTextBox.Text))
        {
            err.Append(Error.Text.Clone() + "<BR>");
        }
        if (PasswordTextBox.Text != ConfirmPasswordBox.Text)
        {
            err.Append("The password and confirming password do not match. Try again.<BR>");
        }
        if (!Check.ValidateName(Error,FirstNameTextBox.Text))
        {
            err.Append("Enter First Name: " + Error.Text.Clone() + "<BR>");
        }
        if (!Check.ValidateName(Error, LastNameTextBox.Text))
        {
            err.Append("Enter Last Name: " + Error.Text.Clone() + "<BR>");
        }

        string phone = PhoneTextBox.Text.Trim ();
        if (PhoneTextBox.Text.Length > 0) //optional field
        {
            if (!Check.ValidatePhone(Error, PhoneTextBox.Text))
            {
                err.Append("Enter a valid phone number: " + Error.Text.Clone() + "<BR>");
            }
        }
        if (err.Length > 0)
        {
            MessageLabel.Text = "The following input(s) are required:<BR>" + err.ToString();
            db.CloseViziAppsDatabase(State);
            return;
        }
        try
        {

            string account_type = "type=viziapps;"; //set default for now
            string security_question = "";
            string security_answer = "";

            string customer_id = util.CreateMobiFlexAccount(State, username, PasswordTextBox.Text.Trim(), security_question, security_answer, FirstNameTextBox.Text.Trim(), LastNameTextBox.Text.Trim(),
                    EmailTextBox.Text.ToLower().Trim(), phone, account_type, ReferralSourceList.SelectedValue,AppToBuild.Text, "inactive");

            string email_template_path = Server.MapPath(".") + @"\templates\EmailValidation.txt";
            string url =   HttpRuntime.Cache["PublicViziAppsUrl"].ToString() + "/ValidateEmail.aspx?id=" + customer_id;
            string from =   HttpRuntime.Cache["TechSupportEmail"].ToString();
            string body = File.ReadAllText(email_template_path)
                    .Replace("[NAME]", FirstNameTextBox.Text.Trim())
                    .Replace("[LINK]",url)
                    .Replace("[SUPPORT]",from);

            Email email = new Email();
            string status = email.SendEmail(State, from, EmailTextBox.Text, "", "", "ViziApps Registration", body, "",true);
            if (status.IndexOf("OK") >= 0)
            {
                MessageLabel.Text = "An email has been sent to you to complete your registration. Please follow the directions in the email.";
            }
            else
            {
                MessageLabel.Text = status;
                //problem with email : delete account
                string sql = "DELETE FROM customers WHERE username='******'";
                db.ViziAppsExecuteNonQuery(State, sql);
            }
            db.CloseViziAppsDatabase(State);
        }
        catch (Exception ex)
        {
            util.LogError(State, ex);
            MessageLabel.Text = ex.Message + ": " + ex.StackTrace;
            db.CloseViziAppsDatabase(State);
            return;
        }
    }
Ejemplo n.º 28
0
    protected void CustomersByAccount_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        ClearMessages();
        HideForCustomers();

        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (e.Text.IndexOf("->") > 0)
        {
            CustomersByEmail.Items[0].Selected = true;
             AdminMessage.Text = "Select a customer and try again.";
            return;
        }

        State["ServerAdminCustomerUsername"] = e.Text;
        string sql = "SELECT * FROM customers WHERE username='******'";
        DB db = new DB();
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        DataRow row = rows[0];
        string customer_id = row["customer_id"].ToString();
        string email = row["email"].ToString();
        CustomersByAccount.FindItemByText(row["username"].ToString()).Selected = true;
        CustomersByEmail.FindItemByText(email).Selected = true;
        State["ServerAdminCustomerID"] = customer_id;
        Util util = new Util();
        RegisteredDateTime.Text = "Signed Up: " + row["registration_date_time"].ToString();
        LastUsedDateTime.Text = "Last used: " + row["last_use_date_time"].ToString();

        Password.Text = util.DecodeMySql(row["password"].ToString());
        AccountTypes.Text = util.DecodeMySql(row["account_type"].ToString().Replace("type=","").Replace(";",""));
        CustomerStatus.Text = row["status"].ToString();
        if (row["email"] != null && row["email"].ToString().Length > 0)
        {
            util.AddEmailToButton(EmailCustomer, row["email"].ToString(), "Customer Email");
        }

        sql = "SELECT application_name FROM applications WHERE customer_id='" + customer_id + "' ORDER BY application_name";
        rows = db.ViziAppsExecuteSql(State, sql);
        Applications.Items.Clear();
        foreach (DataRow row1 in rows)
        {

            Applications.Items.Add(new RadComboBoxItem(row1["application_name"].ToString()));
        }
        Applications.Items.Insert(0, new RadComboBoxItem("Select ViziApps App ->"));

        db.CloseViziAppsDatabase(State);

        ShowForCustomers();
    }
Ejemplo n.º 29
0
    protected void UpdateImageListing_Click(object sender, EventArgs e)
    {
        AmazonS3 util = new AmazonS3();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        ArrayList image_list = util.GetStockImageUrls(State);
        DB db = new DB();
        db.ViziAppsExecuteNonQuery(State, "DELETE FROM stock_images");

        foreach (String url in image_list)
        {
            int start = url.IndexOf("apps/images/") + 12;
            string type = url.Substring(start,url.IndexOf("/",start) - start);
            string sql = "INSERT INTO stock_images (image_url,type) VALUES ('" + url + "','" + type + "')";
            db.ViziAppsExecuteNonQuery(State, sql);

        }
        db.CloseViziAppsDatabase(State);
        Message.Text = "Image URLs have been updated in the database.";
    }
Ejemplo n.º 30
0
    private void DoRemoveCustomer(string username, string customer_id)
    {
        ClearMessages();
        DB db = new DB();
        string sql = "UPDATE customers SET status='inactive' WHERE customer_id='" + customer_id + "'";
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        db.ViziAppsExecuteNonQuery(State, sql);

        sql = "SELECT application_id FROM applications WHERE customer_id='" + customer_id + "'";
        DataRow[] rows3 = db.ViziAppsExecuteSql(State, sql);
        foreach (DataRow row3 in rows3)
        {
            string application_id = row3["application_id"].ToString();
            sql = "DELETE FROM application_pages WHERE application_id='" + application_id + "'";
            db.ViziAppsExecuteNonQuery(State, sql);
        }
        sql = "DELETE FROM applications WHERE customer_id='" + customer_id + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

        sql = "DELETE FROM customers WHERE status='inactive' AND customer_id='" + customer_id + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

        db.CloseViziAppsDatabase(State);
    }