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.";
        }
    }
    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.º 3
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());

            }
    }
 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);
     }
 }
Ejemplo n.º 5
0
 public void DeleteLargeIcon(Hashtable State, string application_id)
 {
     DB db = new DB();
     string sql = "DELETE FROM branding_images WHERE application_id='" + application_id + "' AND type='icon'";
     db.ViziAppsExecuteNonQuery(State, sql);
     db.CloseViziAppsDatabase(State);
 }
Ejemplo n.º 6
0
    public void DeleteAppPageImage(Hashtable State, string page_name)
    {
        DB db = new DB();
        string application_id = GetAppID(State);

        //delete image file
        string sql = "SELECT page_image_url FROM application_pages WHERE application_id='" + application_id +
            "' AND page_name='" + page_name + "'";
        string page_image_url = db.ViziAppsExecuteScalar(State, sql);
        if (page_image_url != null && page_image_url.Length > 0 && page_image_url != "../images/page_not_saved.jpg")
        {
            HtmlToImage util = new HtmlToImage();
            util.DeleteImageFromUrl(State, page_image_url);
        }

        //delete DB entry
        sql = "DELETE FROM application_pages WHERE application_id='" + application_id + "' AND page_name='" + page_name + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

        db.CloseViziAppsDatabase(State);
    }
Ejemplo n.º 7
0
 public void SetFreeProductionExpiration(Hashtable State, DateTime expirationDateTime)
 {
     DB db = new DB();
     string expiration = expirationDateTime.ToString("s").Replace("T", " ");
     string sql = "UPDATE applications SET free_production_expiration_date_time='" + expiration + "' WHERE application_name ='" + State["SelectedApp"].ToString() + "' AND customer_id='" + State["CustomerID"].ToString() + "'";
     db.ViziAppsExecuteNonQuery(State, sql);
     db.CloseViziAppsDatabase(State);
 }
Ejemplo n.º 8
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.º 9
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);
    }
Ejemplo n.º 10
0
 public void SetProductionAppName(Hashtable State, string production_app_name)
 {
     DB db = new DB();
     string sql = "UPDATE applications SET production_app_name='" + production_app_name + "' " +
     "WHERE application_name='" + State["SelectedApp"].ToString() + "'" +
     " AND customer_id='" + State["CustomerID"].ToString() + "'";
     db.ViziAppsExecuteNonQuery(State, sql);
     db.CloseViziAppsDatabase(State);
 }
Ejemplo n.º 11
0
    public void CopyAppToAccount(Hashtable State, string application_name)
    {
        DB db = new DB();
        StringBuilder b_sql = new StringBuilder("SELECT * FROM applications ");
        b_sql.Append("WHERE application_name='" + application_name + "'");
        b_sql.Append(" AND customer_id='" + State["CopyApplicationFromCustomerID"].ToString() + "'");
        DataRow[] rows = db.ViziAppsExecuteSql(State, b_sql.ToString());
        DataRow row = rows[0];

        string previous_application_id = row["application_id"].ToString();
        string application_id = Guid.NewGuid().ToString();

        XmlDocument doc = new XmlDocument();
        doc.LoadXml(DecodeMySql(row["staging_app_xml"].ToString()));

        //delete any app with the same name
        db.ViziAppsExecuteNonQuery(State, "DELETE FROM applications WHERE application_name='" + application_name + "' AND customer_id='" + State["CopyApplicationToCustomerID"].ToString() + "'");

        string username = db.ViziAppsExecuteScalar(State, "SELECT username FROM customers WHERE customer_id='" + State["CopyApplicationToCustomerID"].ToString() + "'");

        b_sql = new StringBuilder("INSERT into applications SET ");
        b_sql.Append("application_id='" + application_id + "',");
        b_sql.Append("customer_id='" + State["CopyApplicationToCustomerID"].ToString() + "',");
        b_sql.Append("username='******',");

        XmlUtil x_util = new XmlUtil();
        string new_xml = x_util.RenameAppXmlWithID(State, row["staging_app_xml"].ToString(), application_name, application_id);

        b_sql.Append("staging_app_xml='" + MySqlFilter(new_xml) + "',");
        if (row["custom_header_html"] != null)
            b_sql.Append("custom_header_html='" + MySqlFilter(row["custom_header_html"].ToString()) + "',");
        b_sql.Append("application_name='" + application_name + "',");
        b_sql.Append("application_type='" + row["application_type"].ToString() + "',");

        if (row["default_button_image"] != null)
            b_sql.Append("default_button_image='" + row["default_button_image"].ToString() + "',");

        b_sql.Append("description='" + row["description"].ToString().Replace("'", "''").Replace(@"\", @"\\") + "',");
        string NOW = DateTime.Now.ToUniversalTime().ToString("u").Replace("Z", "");
        b_sql.Append("date_time_modified='" + NOW + "'");
        db.ViziAppsExecuteNonQuery(State, b_sql.ToString());

        //get all the pages
        string sql = "SELECT * FROM application_pages WHERE application_id='" + previous_application_id + "'";
        rows = db.ViziAppsExecuteSql(State, sql);

        //insert all the pages into the new app
        foreach (DataRow page_row in rows)
        {
            sql = "INSERT INTO application_pages (application_page_id,application_id,page_name,page_image_url,date_time_modified) VALUES (UUID(),'" +
            application_id + "','" +
            page_row["page_name"].ToString() + "','" +
            page_row["page_image_url"].ToString() + "','" + NOW + "')";
            db.ViziAppsExecuteNonQuery(State, sql);
        }
        db.CloseViziAppsDatabase(State);
        //reset
        State["AppXmlDoc"] = null;
    }
Ejemplo n.º 12
0
    public void UpdateUserCredentials(Hashtable State,
        string application_id, string[] credential)
    {
        DB db = new DB();
        string sql = "DELETE FROM users WHERE application_id='" + application_id + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

        StringBuilder sb = new StringBuilder("INSERT INTO users (user_id,customer_id,application_id,username,password,status) VALUES ");
        string customer_id = State["CustomerID"].ToString();

        sb.Append("(UUID(),'" +
        customer_id +
        "','" + application_id +
        "','" + credential[0] +
        "','" + credential[1] +
        "','active')");

        db.ViziAppsExecuteNonQuery(State, sb.ToString());
        db.CloseViziAppsDatabase(State);
    }
Ejemplo n.º 13
0
    public void CancelPaidService(Hashtable State, string purchase_date, string sku)
    {
        DB db = new DB();
        string sql = "SELECT app_name FROM paid_services WHERE sku='" + sku + "' AND purchase_date='" + purchase_date + "'";
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        if (rows.Length > 0)
        {
            DataRow row = rows[0];
            string app_name = row["app_name"].ToString();
            if (app_name != null && app_name.Length != 0)
                RemoveAppFromProductionService(State, app_name, sku);
        }

        string NOW = DateTime.Now.ToUniversalTime().ToString("u").Replace("Z", "");
        int day_of_month = DateTime.Parse(purchase_date).Day;
        string expiration = DateTime.Now.ToUniversalTime()
            .AddDays(-Convert.ToDouble(DateTime.Now.ToUniversalTime().Day))
            .AddMonths(1)
            .AddDays(Convert.ToDouble(day_of_month))
            .ToString("u").Replace("Z", "");
        StringBuilder b_sql = new StringBuilder("UPDATE paid_services SET ");
        b_sql.Append("cancellation_date_time='" + NOW + "', ");
        b_sql.Append("expiration_date_time='" + expiration + "', ");
        b_sql.Append("app_name='NULL', ");
        b_sql.Append("application_id='NULL', ");
        b_sql.Append("status='cancelled' ");
        b_sql.Append("WHERE sku='" + sku + "' ");
        b_sql.Append("AND purchase_date='" + purchase_date + "'");
        db.ViziAppsExecuteNonQuery(State, b_sql.ToString());
        db.CloseViziAppsDatabase(State);

        ResetAppInDynamoDB(State);
    }
Ejemplo n.º 14
0
    public void UpdateUserCredentials(Hashtable State,
        string application_id, DataRowCollection data_rows, string update_type)
    {
        string sql = null;
        DB db = new DB();
        if (update_type == "replace")
        {
            sql = "DELETE FROM users WHERE application_id='" + application_id + "'";
            db.ViziAppsExecuteNonQuery(State, sql);
        }
        StringBuilder sb = new StringBuilder("INSERT INTO users (user_id,customer_id,application_id,username,password,status) VALUES ");
        string customer_id = State["CustomerID"].ToString();

        bool is_first = true;
        foreach (DataRow row in data_rows)
        {
            if (is_first)
            {
                is_first = false;
                continue;
            }
            sb.Append("(UUID(),'" +
            customer_id +
            "','" + application_id +
            "','" + row[0].ToString() +
            "','" + row[1].ToString() +
            "','active'),");
        }
        sb.Remove(sb.Length - 1, 1); //remove last comma
        db.ViziAppsExecuteNonQuery(State, sb.ToString());
        db.CloseViziAppsDatabase(State);
    }
Ejemplo n.º 15
0
 public void UpdateStagingAppXml(Hashtable State, string application_name)
 {
     try
     {
         string NOW = DateTime.Now.ToUniversalTime().ToString("u").Replace("Z", "");
         XmlDocument doc = (XmlDocument)State["AppXmlDoc"];
         DB db = new DB();
         StringBuilder b_sql = new StringBuilder("UPDATE applications SET ");
         if (State["SelectedAppType"] == null)
             State["SelectedAppType"] = Constants.NATIVE_APP_TYPE;
         b_sql.Append("application_type='" + State["SelectedAppType"].ToString() + "',");
         b_sql.Append("staging_app_xml='" + MySqlFilter(doc.OuterXml) + "',");
         b_sql.Append("date_time_modified='" + NOW + "' ");
         b_sql.Append("WHERE application_name='" + application_name + "'");
         b_sql.Append(" AND customer_id='" + State["CustomerID"].ToString() + "'");
         db.ViziAppsExecuteNonQuery(State, b_sql.ToString());
         db.CloseViziAppsDatabase(State);
     }
     catch (Exception ex)
     {
         throw new Exception("Error in UpdateStagingAppXml: " + ex.Message + ": " + ex.StackTrace);
     }
 }
Ejemplo n.º 16
0
 /*public void SetApplicationLongDescription(Hashtable State, string long_description)
 {
     DB db = new DB();
     StringBuilder b_sql = new StringBuilder("UPDATE applications SET appstore_description='" + MySqlFilter(long_description) + "'");
     b_sql.Append(" WHERE application_name='" + State["SelectedApp"].ToString() + "'");
     b_sql.Append(" AND customer_id='" + State["CustomerID"].ToString() + "'");
     db.ViziAppsExecuteNonQuery(State, b_sql.ToString());
     db.CloseViziAppsDatabase(State);
 }
 public void SetApplicationKeywords(Hashtable State, string keywords)
 {
     DB db = new DB();
     StringBuilder b_sql = new StringBuilder("UPDATE applications SET keywords='" + MySqlFilter(keywords) + "'");
     b_sql.Append(" WHERE application_name='" + State["SelectedApp"].ToString() + "'");
     b_sql.Append(" AND customer_id='" + State["CustomerID"].ToString() + "'");
     db.ViziAppsExecuteNonQuery(State, b_sql.ToString());
     db.CloseViziAppsDatabase(State);
 }
 public void SetApplicationPricing(Hashtable State, string price)
 {
     DB db = new DB();
     StringBuilder b_sql = new StringBuilder("UPDATE applications SET price='" + price + "'");
     b_sql.Append(" WHERE application_name='" + State["SelectedApp"].ToString() + "'");
     b_sql.Append(" AND customer_id='" + State["CustomerID"].ToString() + "'");
     db.ViziAppsExecuteNonQuery(State, b_sql.ToString());
     db.CloseViziAppsDatabase(State);
 }*/
 public void SetUnlimitedUsers(Hashtable State)
 {
     DB db = new DB();
     String sql = "UPDATE applications SET has_unlimited_users=1,use_1_user_credential=0 WHERE application_name='" +
         State["SelectedApp"].ToString() + "' AND customer_id='" + State["CustomerID"].ToString() + "'";
     db.ViziAppsExecuteNonQuery(State, sql);
     db.CloseViziAppsDatabase(State);
     string application_id = GetAppID(State);
     DeleteUserCredentials(State, application_id);
 }
Ejemplo n.º 17
0
 public void DeleteOldErrorsInLog(Hashtable State)
 {
     DB db = new DB();
     DateTime old = DateTime.UtcNow.AddDays(-Convert.ToDouble(ConfigurationManager.AppSettings["DaysToKeepErrorLogs"]));
     String OLD =  old.ToString("s").Replace("T", " ");
     string sql = "DELETE FROM error_log  WHERE timestamp<'" + OLD + "'";
     db.ViziAppsExecuteNonQuery(State, sql);
     db.CloseViziAppsDatabase(State);
 }
Ejemplo n.º 18
0
    public void SetLimitedUsersCredentialMethod(Hashtable State, bool UseSingleCredential, string username, string password)
    {
        DB db = new DB();
        string use_1_user_credential = UseSingleCredential ? "true" : "false";
        StringBuilder b_sql = new StringBuilder("UPDATE applications SET has_unlimited_users=0,use_1_user_credential=" + use_1_user_credential + " ");
        b_sql.Append(" WHERE application_name='" + State["SelectedApp"].ToString() + "'");
        b_sql.Append(" AND customer_id='" + State["CustomerID"].ToString() + "'");
        db.ViziAppsExecuteNonQuery(State, b_sql.ToString());

        string application_id = GetAppID(State);
        if (UseSingleCredential)
        {
            string[] credential = new string[2];
            credential[0] = username;
            credential[1] = password;
            UpdateUserCredentials(State, application_id, credential);
        }
        else
            DeleteUserCredentials(State, application_id);

        db.CloseViziAppsDatabase(State);
    }
    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
        {
            //Instantiate an instance of license and set the license file through its path
            string error = "The following applications had errors:<br>";
            StringBuilder error_list = new StringBuilder();

             DB db = new DB();

            //get all app and staging servers in Hashtable
            string sql = "SELECT app_server_id,server_name FROM app_servers WHERE use_type='production' OR use_type='staging'";
            DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
            Hashtable serverID_to_name = new Hashtable();
            foreach (DataRow row in rows)
            {
                serverID_to_name[row["app_server_id"].ToString()] = row["server_name"].ToString();
            }

            //get all customer names in Hashtable
            sql = "SELECT customer_id,username FROM customers ";
            rows = db.ViziAppsExecuteSql(State, sql);
            Hashtable customerID_to_username = new Hashtable();
            foreach (DataRow row in rows)
            {
                customerID_to_username[row["customer_id"].ToString()] = row["username"].ToString();
            }

            //get all customer names in Hashtable
            sql = "SELECT application_id,app_server_id,use_type FROM application_to_server_mappings ";
            rows = db.ViziAppsExecuteSql(State, sql);
            Hashtable applicationID_to_app_serverID = new Hashtable();
            foreach (DataRow row in rows)
            {
                if(row["app_server_id"] != null && row["app_server_id"].ToString().Length>0)
                    applicationID_to_app_serverID[row["application_id"].ToString()+row["use_type"].ToString()] = row["app_server_id"].ToString();
            }

            DataTable table = new DataTable();
            table.Columns.Add("username");
            table.Columns.Add("application_name");
            table.Columns.Add("staging_server_name");
            table.Columns.Add("date_time_modified");
            table.Columns.Add("production_server_name");
            table.Columns.Add("production_date_time");
            table.Columns.Add("status");

            string production_app_server_id = null;
            string application_id = null;
            Hashtable bad_customerID_list = new Hashtable();

            //get all application information
            sql = "SELECT * FROM applications WHERE (status='staging' OR status='staging/production' or status='production')";
            rows = db.ViziAppsExecuteSql(State, sql);
            foreach (DataRow row in rows)
            {
                try
                {
                    application_id = row["application_id"].ToString();
                    string status = row["status"].ToString();
                    DataRow data_row = table.NewRow();
                    string[] items = new string[10];
                    string customer_id = row["customer_id"].ToString();
                    if (customerID_to_username.Contains(customer_id))
                        items[0] = customerID_to_username[customer_id].ToString();
                    else
                    {
                        bad_customerID_list[customer_id] = true;
                    }
                    items[1] = row["application_name"].ToString();
                    string staging_app_server_id = null;
                    items[2] = "";
                    if (status.IndexOf("staging") >= 0)
                    {
                        string key = application_id + "staging";
                        if (applicationID_to_app_serverID.ContainsKey(key))
                        {
                            staging_app_server_id = applicationID_to_app_serverID[key].ToString();
                            items[2] = serverID_to_name[staging_app_server_id].ToString();
                        }
                    }
                    items[3] = row["date_time_modified"].ToString();
                    production_app_server_id = null;
                    items[4] = "";
                    if (status.IndexOf("production") >= 0)
                    {
                        production_app_server_id = applicationID_to_app_serverID[application_id + "production"].ToString();
                        items[4] = serverID_to_name[production_app_server_id].ToString();
                    }
                    items[5] = row["production_date_time"].ToString();
                    items[6] = status;
                    data_row.ItemArray = items;
                    table.Rows.Add(data_row);
                }
                catch (Exception ex)
                {
                    util.LogError(State, ex);
                    error_list.Append(ex.Message + ": " + ex.StackTrace + "<br>");
                    continue;
                }
            }
            if (error_list.Length > 0)
            {
                Message.Visible = true;
                Message.Text = error + error_list.ToString();
                return;
            }
            //get rid of applications with bad customer_id's
            foreach (string customer_id in bad_customerID_list.Keys)
            {
                sql = "DELETE FROM applications where customer_id='" + customer_id + "'";
                db.ViziAppsExecuteNonQuery(State, sql);
            }

          db.CloseViziAppsDatabase(State);
        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
Ejemplo n.º 20
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.º 21
0
 public void CopyStagingDesignToProduction(Hashtable State)
 {
     XmlDocument doc = new XmlDocument();
     DB db = new DB();
     StringBuilder b_sql = new StringBuilder("UPDATE applications SET production_app_xml = staging_app_xml,");
     string NOW = DateTime.Now.ToUniversalTime().ToString("u").Replace("Z", "");
     b_sql.Append("production_date_time='" + NOW + "' ");
     b_sql.Append("WHERE application_name='" + State["SelectedApp"].ToString() + "'");
     b_sql.Append(" AND customer_id='" + State["CustomerID"].ToString() + "'");
     db.ViziAppsExecuteNonQuery(State, b_sql.ToString());
     db.CloseViziAppsDatabase(State);
 }
Ejemplo n.º 22
0
    public void SetPaidService(Hashtable State, string confirm,
        string customer_id, string[] skus)
    {
        string NOW = DateTime.Now.ToUniversalTime().ToString("u").Replace("Z", "");
        string purchase_date = DateTime.Now.ToUniversalTime().ToString("d");

        DB db = new DB();
        int index = 0;
        foreach (string sku in skus)
        {
            StringBuilder b_sql = new StringBuilder("INSERT INTO paid_services SET ");
            b_sql.Append("purchase_date='" + purchase_date + "',");
            b_sql.Append("sku='" + sku + "',");
            b_sql.Append("confirmation='" + confirm + "',");
            string username = GetUsernameFromCustomerID(State, customer_id);
            b_sql.Append("username='******',");
            b_sql.Append("customer_id='" + customer_id + "',");
            b_sql.Append("purchase_date_time='" + NOW + "',");
            b_sql.Append("status='paid'");
            try
            {
                db.ViziAppsExecuteNonQuery(State, b_sql.ToString());
            }
            catch (Exception ex)
            {
                LogError(State, ex);

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

        string sql = "UPDATE customers SET status='active' WHERE status!='active' AND customer_id='" + customer_id + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

        db.CloseViziAppsDatabase(State);
    }
Ejemplo n.º 23
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.º 24
0
    public bool CopyTemplateApp(Hashtable State,
        string template_app_name, string new_app_name)
    {
        DB db = new DB();

        //This function assumes that the new_app_name is unique;
        string sql = "SELECT customer_id FROM customers WHERE username='******'";
        string customer_id = db.ViziAppsExecuteScalar(State, sql);

        StringBuilder b_sql = new StringBuilder("SELECT * FROM applications ");
        b_sql.Append("WHERE application_name='" + template_app_name + "'");
        b_sql.Append(" AND customer_id='" + customer_id + "'");
        DataRow[] rows = db.ViziAppsExecuteSql(State, b_sql.ToString());
        DataRow row = rows[0];

        string previous_application_id = row["application_id"].ToString();

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

        b_sql = new StringBuilder("INSERT into applications SET ");
        string application_id = Guid.NewGuid().ToString();
        b_sql.Append("application_id='" + application_id + "',");
        b_sql.Append("customer_id='" + State["CustomerID"] + "',");
        b_sql.Append("username='******',");

        XmlUtil x_util = new XmlUtil();
        string new_xml = x_util.RenameAppXmlWithID(State, row["staging_app_xml"].ToString(), new_app_name, application_id);

        b_sql.Append("staging_app_xml='" + MySqlFilter(new_xml) + "',");
        if (row["custom_header_html"] != null)
            b_sql.Append("custom_header_html='" + MySqlFilter(row["custom_header_html"].ToString()) + "',");
        b_sql.Append("application_name='" + new_app_name + "',");
        b_sql.Append("application_type='" + row["application_type"].ToString() + "',");

        if (row["default_button_image"] != null)
            b_sql.Append("default_button_image='" + row["default_button_image"].ToString() + "',");
        b_sql.Append("description='" + row["description"].ToString().Replace("'", "''").Replace(@"\", @"\\") + "',");
        b_sql.Append("date_time_modified='" + NOW + "'");
        db.ViziAppsExecuteNonQuery(State, b_sql.ToString());

        //get all the pages
        sql = "SELECT * FROM application_pages WHERE application_id='" + previous_application_id + "'";
        rows = db.ViziAppsExecuteSql(State, sql);

        //insert all the pages into the new app
        foreach (DataRow page_row in rows)
        {
            sql = "INSERT INTO application_pages (application_page_id,application_id,page_name,page_image_url,date_time_modified) VALUES (UUID(),'" +
            application_id + "','" +
            page_row["page_name"].ToString() + "','" +
            page_row["page_image_url"].ToString() + "','" + NOW + "')";
            db.ViziAppsExecuteNonQuery(State, sql);
        }
        db.CloseViziAppsDatabase(State);
        //reset
        State["AppXmlDoc"] = null;
        return true;
    }
Ejemplo n.º 25
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.º 26
0
    public void CreateApp(Hashtable State, string page_name, string primary_device_type, String app_description)
    {
        string NOW = DateTime.Now.ToUniversalTime().ToString("u").Replace("Z", "");

        //create basic app data
        string application_name = State["SelectedApp"].ToString();
        DB db = new DB();
        StringBuilder b_sql = new StringBuilder("INSERT into applications SET ");
        string application_id = Guid.NewGuid().ToString();
        b_sql.Append("application_id='" + application_id + "',");
        b_sql.Append("customer_id='" + State["CustomerID"].ToString() + "',");
        b_sql.Append("username='******',");
        b_sql.Append("application_name='" + application_name + "',");
        b_sql.Append("application_type='" + State["SelectedAppType"].ToString() + "',");
        if (State["DefaultButtonURL"] != null)
            b_sql.Append("default_button_image='" + State["DefaultButtonURL"].ToString() + "',");
        b_sql.Append("description='" + app_description.Replace("'", "''").Replace(@"\", @"\\") + "',");
        XmlUtil x_util = new XmlUtil();

        b_sql.Append("date_time_modified='" + NOW + "'");
        db.ViziAppsExecuteNonQuery(State, b_sql.ToString());

        db.CloseViziAppsDatabase(State);

        //create stage app xml in database
        x_util.CreateStagingAppXml(State, primary_device_type, application_name, application_id, page_name);
    }
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
    public string CreateMobiFlexAccount(Hashtable State,
        string username, string password, string security_question, string security_answer, string first_name, string last_name,
        string email, string phone, string account_type, string referral_source, string app_to_build, string status)
    {
        StringBuilder sql = new StringBuilder("INSERT INTO customers SET ");
        string customer_id = Guid.NewGuid().ToString();
        sql.Append("customer_id='" + customer_id + "'");
        sql.Append(",username='******'");
        sql.Append(",password='******'");
        if (security_question.Length > 0)
            sql.Append(",security_question='" + security_question.Replace("'", "''") + "'");
        if (security_answer.Length > 0)
            sql.Append(",security_answer='" + security_answer.Replace("'", "''") + "'");
        sql.Append(",first_name='" + MySqlFilter(first_name) + "'");
        sql.Append(",last_name='" + MySqlFilter(last_name) + "'");
        sql.Append(",email='" + email + "'");
        double DefaultTimeZoneDeltaHours = Convert.ToDouble( HttpRuntime.Cache["DefaultTimeZoneDeltaHours"].ToString());
        TimeZones zone_util = new TimeZones();
        string zone = Convert.ToString(DefaultTimeZoneDeltaHours + zone_util.GetDaylightSavingsTimeOffset(DateTime.Now.ToUniversalTime()));
        sql.Append(",default_time_zone_delta_hours='" + zone + "'");
        if (phone != null && phone.Length > 0)
        {
            sql.Append(",phone='" + phone + "'");
        }

        sql.Append(",account_type='" + account_type + "'");
        if (referral_source != null && referral_source.IndexOf("->") < 0)
        {
            sql.Append(",referral_source='" + referral_source + "'");
        }
        if (app_to_build != null && app_to_build.Length > 0)
        {
            sql.Append(",app_to_build='" + MySqlFilter(app_to_build) + "'");
        }
        string NOW = DateTime.Now.ToUniversalTime().ToString("s").Replace("T", " ");

        sql.Append(",registration_date_time='" + NOW + "',status='" + status + "'");
        DB db = new DB();
        db.ViziAppsExecuteNonQuery(State, sql.ToString());
        db.CloseViziAppsDatabase(State);
        return customer_id;
    }
Ejemplo n.º 29
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.º 30
0
    public void DeleteApplication(Hashtable State)
    {
        string application_name = State["SelectedApp"].ToString();

        DB db = new DB();
        string sql = "SELECT application_id FROM applications WHERE application_name='" + application_name + "' AND customer_id='" + State["CustomerID"].ToString() + "'";
        string application_id = db.ViziAppsExecuteScalar(State, sql);

        sql = "DELETE FROM applications WHERE application_id='" + application_id + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

        sql = "DELETE FROM application_pages WHERE application_id='" + application_id + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

        sql = "DELETE FROM branding_images WHERE application_id='" + application_id + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

        db.CloseViziAppsDatabase(State);

        if (State["SelectedAppType"] != null && (State["SelectedAppType"].ToString() == Constants.WEB_APP_TYPE || State["SelectedAppType"].ToString() == Constants.HYBRID_APP_TYPE) &&
            State["UrlAccountIdentifier"] != null)
        {
            AmazonS3 s3 = new AmazonS3();
            string Bucket = ConfigurationManager.AppSettings["WebAppBucket"];
            string file_name = State["SelectedApp"].ToString().Replace(" ", "_") + Constants.WEB_APP_TEST_SUFFIX + "/index.html";
            string key = State["UrlAccountIdentifier"].ToString() + "/" + file_name;
            s3.DeleteS3Object(Bucket, key);

            file_name = State["SelectedApp"].ToString().Replace(" ", "_") + "/index.html";
            key = State["UrlAccountIdentifier"].ToString() + "/" + file_name;
            if (s3.S3ObjectExists(Bucket, key))
                s3.DeleteS3Object(Bucket, key);
        }
    }