Пример #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.";
        }
    }
Пример #2
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;
    }
 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;
 }
Пример #4
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;
 }
Пример #5
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;
    }
Пример #6
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);
        }
    }
    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);
    }
    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);
    }
    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;
        }
    }
Пример #10
0
 protected void EmailUpgradeNotice_Click(object sender, EventArgs e)
 {
     Hashtable UsersList = (Hashtable)HttpRuntime.Cache["UsersList"];
     DB db = new DB();
     Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
     foreach (string username in UsersList.Keys)
     {
         string To = db.ViziAppsExecuteScalar(State, "SELECT email FROM customers WHERE username='******'");
         Email email = new Email();
         string From =   HttpRuntime.Cache["TechSupportEmail"].ToString();
         string Body = "The ViziApps Studio will be down in 1 minute for 5 minutes for an upgrade maintenance.\n\nSorry for the inconvenience.\n\n--ViziApps Support";
         string status = email.SendEmail(State, From, To, "", "", "ViziApps Studio Maintenance Notice", Body, "",false);
         if (status.IndexOf("OK") < 0)
         {
             Message.Text = "There was a problem sending the emails: " + status;
             db.CloseViziAppsDatabase(State);
             return;
         }
     }
     db.CloseViziAppsDatabase(State);
     Message.Text = "Maintenance notice has been emailed to " + UsersList.Keys.Count.ToString() + " current users";
 }
Пример #11
0
 public bool HasAgreedToEula(Hashtable State)
 {
     DB db = new DB();
     string sql = "SELECT agreed_to_eula FROM customers WHERE customer_id = '" + State["CustomerID"].ToString() + "'";
     string agreed_to_eula = db.ViziAppsExecuteScalar(State, sql);
     db.CloseViziAppsDatabase(State);
     return (agreed_to_eula.ToLower() == "false" || agreed_to_eula == "0") ? false : true;
 }
Пример #12
0
    public bool ActivateCustomerAccount(Hashtable State, string customer_id)
    {
        DB db = new DB();
        string sql = "SELECT COUNT(*) FROM customers WHERE customer_id='" + customer_id + "'";
        string count = db.ViziAppsExecuteScalar(State, sql);
        if (count == "0")
            return false;

        sql = "UPDATE customers SET status='trial' WHERE customer_id='" + customer_id + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

        db.CloseViziAppsDatabase(State);
        return true;
    }
Пример #13
0
 public bool IsAppSelectedForTesting(Hashtable State)
 {
     DB db = new DB();
     string sql = "SELECT status FROM applications WHERE application_name='" + State["SelectedApp"].ToString() +
                 "' AND customer_id='" + State["CustomerID"].ToString() + "'";
     string status = db.ViziAppsExecuteScalar(State, sql);
     db.CloseViziAppsDatabase(State);
     return (status.Contains("staging")) ? true : false;
 }
Пример #14
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;
    }
Пример #15
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;
        }
    }
Пример #16
0
 public bool IsFreeProductionValid(Hashtable State, string application_id)
 {
     DB db = new DB();
     string sql = "SELECT free_production_expiration_date_time FROM applications WHERE application_id ='" + application_id + "' AND customer_id='" + State["CustomerID"].ToString() + "'";
     string expiration = db.ViziAppsExecuteScalar(State, sql);
     db.CloseViziAppsDatabase(State);
     if (expiration == null || expiration.Length == 0)
         return false;
     DateTime expirationDateTime = DateTime.Parse(expiration);
     return (DateTime.Now.ToUniversalTime() <= expirationDateTime) ? true : false;
 }
Пример #17
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;
    }
Пример #18
0
 public string SetAppDescription(Hashtable State, string app_description)
 {
     DB db = new DB();
     StringBuilder b_sql = new StringBuilder("UPDATE applications SET description='" + app_description.Replace("'", "''").Replace(@"\", @"\\") + "' ");
     b_sql.Append("WHERE application_name='" + State["SelectedApp"].ToString() + "'");
     b_sql.Append(" AND customer_id='" + State["CustomerID"].ToString() + "'");
     string description = db.ViziAppsExecuteScalar(State, b_sql.ToString());
     db.CloseViziAppsDatabase(State);
     return description;
 }
Пример #19
0
    public void SetAppType(Hashtable State, string app_type)
    {
        XmlUtil x_util = new XmlUtil();
        x_util.SetAppType(State, app_type);
        DB db = new DB();
        string sql = "SELECT application_type FROM applications WHERE application_name='" + State["SelectedApp"].ToString() + "' AND customer_id='" + State["CustomerID"].ToString() + "'";
        string previous_app_type = db.ViziAppsExecuteScalar(State, sql);
        if (previous_app_type != app_type)
        {
            if (app_type == Constants.WEB_APP_TYPE)
            {

                x_util.ConvertNativeAppToWebApp(State);
            }
            sql = "UPDATE applications SET application_type='" + app_type + "' WHERE application_name='" + State["SelectedApp"].ToString() + "' AND customer_id='" + State["CustomerID"].ToString() + "'";
            db.ViziAppsExecuteNonQuery(State, sql);
        }
        db.CloseViziAppsDatabase(State);
    }
Пример #20
0
    public void SaveAppPageImage(Hashtable State, string image_url)
    {
        string application_id = GetAppID(State);
        DB db = new DB();
        string sql = "SELECT application_page_id FROM application_pages WHERE application_id='" + application_id +
            "' AND page_name='" + State["SelectedAppPage"].ToString() + "'";
        string application_page_id = db.ViziAppsExecuteScalar(State, sql);
        string query_type = (application_page_id == null || application_page_id.Length == 0) ? "insert" : "update";

        string NOW = DateTime.Now.ToUniversalTime().ToString("u").Replace("Z", "");
        if (query_type == "insert")
        {
            sql = "INSERT INTO application_pages (application_page_id,application_id,page_name,page_image_url,date_time_modified) VALUES (UUID(),'" +
             application_id + "','" +
             State["SelectedAppPage"].ToString() + "','" +
             image_url + "','" + NOW + "')";
        }
        else
        {
            sql = "UPDATE application_pages SET page_image_url='" + image_url +
                "',date_time_modified='" + NOW +
                "' WHERE application_page_id='" + application_page_id + "'";
        }
        db.ViziAppsExecuteNonQuery(State, sql);
        db.CloseViziAppsDatabase(State);
    }
Пример #21
0
    public void RemoveAppFromProductionService(Hashtable State, string app_name, string sku)
    {
        DB db = new DB();
        string sql = "UPDATE paid_services SET app_name=NULL, application_id=NULL " +
           "WHERE app_name='" + app_name + "' AND sku='" + sku + "' AND customer_id='" + State["CustomerID"].ToString() + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

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

        status = status.Replace("/production", "");

        sql = "UPDATE applications SET status='" + status + "' WHERE application_name='" + app_name + "' AND customer_id='" + State["CustomerID"].ToString() + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

        db.CloseViziAppsDatabase(State);

        ResetAppInDynamoDB(State);
    }
Пример #22
0
    public void MapAppToProductionService(Hashtable State, string app_name, string sku)
    {
        DB db = new DB();
        String application_id = GetAppIDFromAppName(State, app_name);
        string sql = "UPDATE paid_services SET app_name='" + app_name + "', application_id='" + application_id +
            "' WHERE application_id IS NULL AND sku='" + sku + "' AND customer_id='" + State["CustomerID"].ToString() + "' AND status='paid' LIMIT 1";
        db.ViziAppsExecuteNonQuery(State, sql);

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

        if (!status.Contains("production"))
            status += "/production";

        string has_unlimited_users = "0";
        sql = "SELECT sku FROM paid_services WHERE app_name='" + app_name + "' AND customer_id='" + State["CustomerID"].ToString() + "'";
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        if (rows.Length > 0)
        {
            foreach (DataRow row in rows)
            {
                sku = row["sku"].ToString();
                sql = "SELECT max_users FROM sku_list WHERE sku='" + sku + "'";
                string s_max_users = db.ViziAppsExecuteScalar(State, sql);
                db.CloseViziAppsDatabase(State);
                if (s_max_users != null && s_max_users.Length > 0)
                {
                    long n_users = Convert.ToInt64(s_max_users);
                    if (n_users > 1000)
                    {
                        has_unlimited_users = "1";
                        break;
                    }
                }

            }
        }

        long max_users = GetMaxUsers(State, app_name);
        sql = "UPDATE applications SET status='" + status + "'" +
        ",has_unlimited_users='" + has_unlimited_users +
        "' WHERE application_name='" + app_name + "' AND customer_id='" + State["CustomerID"].ToString() + "'";
        db.ViziAppsExecuteNonQuery(State, sql);

        db.CloseViziAppsDatabase(State);

        ResetAppInDynamoDB(State);
    }
Пример #23
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;
    }
Пример #24
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);
        }
    }
Пример #25
0
 public string GetUsernameFromCustomerID(Hashtable State, string customer_id)
 {
     DB db = new DB();
     string sql = "SELECT username  FROM customers WHERE customer_id='" + customer_id + "'";
     string username = db.ViziAppsExecuteScalar(State, sql);
     db.CloseViziAppsDatabase(State);
     return username;
 }
Пример #26
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);
    }
Пример #27
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
    }
Пример #28
0
 public bool IsAppStoreSubmissionPaid(Hashtable State, string app_name)
 {
     DB db = new DB();
     string sql = "SELECT COUNT(*) FROM paid_services WHERE (sku='" +  HttpRuntime.Cache["iOSSubmitServiceSku"].ToString() +
         "' OR sku='" +  HttpRuntime.Cache["AndroidSubmitServiceSku"].ToString() + "') AND app_name ='" + app_name + "' AND customer_id='" + State["CustomerID"].ToString() + "' AND status='paid'";
     string count = db.ViziAppsExecuteScalar(State, sql);
     db.CloseViziAppsDatabase(State);
     return (count == "0") ? false : true;
 }
Пример #29
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;
    }
Пример #30
0
 public bool IsPaidProductionApp(Hashtable State, string app_name)
 {
     DB db = new DB();
     string sql = "SELECT status FROM applications WHERE application_name='" + app_name + "' AND customer_id='" + State["CustomerID"].ToString() + "'";
     string status = db.ViziAppsExecuteScalar(State, sql);
     db.CloseViziAppsDatabase(State);
     return status.Contains("production") ? true : false;
 }