Exemplo n.º 1
0
    public void InitApplicationCustomers(Hashtable State)
    {
        RadComboBox CustomersByAccount = (RadComboBox)State["CustomersByAccount"];
        if (CustomersByAccount == null)
            return;

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

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

        sql = "SELECT email FROM customers ORDER BY email";
        rows = db.ViziAppsExecuteSql(State, sql);
        CustomersByEmail.Items.Clear();
        foreach (DataRow row in rows)
        {
            CustomersByEmail.Items.Add(new RadComboBoxItem(row["email"].ToString()));
        }
        CustomersByEmail.Items.Insert(0, new RadComboBoxItem("Select Customer ->"));
        db.CloseViziAppsDatabase(State);
    }
Exemplo n.º 2
0
    protected void SendEmails_Click(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (EmailBody.Text.Length == 0)
        {
            Message.Text = "The email body has no text";
            return;
        }
        if (EmailSubject.Text.Length == 0)
        {
            Message.Text = "The email subject has no text";
            return;
        }
        string type = EmailType.SelectedValue;
        string sql = "";
        DB db = new DB();
        DataRow[] rows = null;
        if (type == "Production Customers")
        {
            sql = "SELECT username,email FROM customers WHERE status='active'";
            rows = db.ViziAppsExecuteSql(State, sql);
        }
        else
        {
            sql = "SELECT username,email FROM customers WHERE status!='inactive'";
            rows = db.ViziAppsExecuteSql(State, sql);
        }
        StringBuilder no_emails = new StringBuilder();
        StringBuilder sent_users = new StringBuilder();
        Email email = new Email();
        foreach (DataRow row in rows)
        {
            string username = row["username"].ToString();
            string to_email = row["email"].ToString();
            if (to_email.Length > 0)
            {
                email.SendEmail(State,  HttpRuntime.Cache["TechSupportEmail"].ToString(), to_email, "", "", EmailSubject.Text, EmailBody.Text, "",false);
                sent_users.Append(username + "\n");
            }
            else if(username!="admin" && username != "prompts")
            {
                no_emails.Append(username + "; ");
            }
        }
        if (no_emails.Length > 0)
        {
            Message.Text = "The emails were sent successfully, except for the following users: " + no_emails.ToString();
        }
        else
            Message.Text = "The emails were all sent successfully.";

        SentUsers.Text = sent_users.ToString();
    }
Exemplo n.º 3
0
    protected void Applications_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        ClearMessages();
        //get initial values
        if (e.Text.IndexOf("->") > 0)
        {
            HideForApplications();
            return;
        }

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

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

         State["application_id"] = application_id;

        status = row["status"].ToString();
        ApplicationStatus.Text = status;
        db.CloseViziAppsDatabase(State);
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../Default.aspx');", true); return; }

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

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

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

        ParamRepeater.DataSource = paramsDS;
        ParamRepeater.DataBind();
        db.CloseViziAppsDatabase((Hashtable)HttpRuntime.Cache[Session.SessionID]);
    }
Exemplo n.º 5
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);
        }
    }
 public XmlDocument GetAppXmlForAdmin(Hashtable State)
 {
     XmlDocument doc = new XmlDocument();
     DB db = new DB();
     StringBuilder b_sql = new StringBuilder();
     b_sql.Append("SELECT  staging_app_xml FROM applications ");
     b_sql.Append("WHERE application_name='" + State["SelectedAdminApp"].ToString() + "'");
     b_sql.Append(" AND customer_id='" + State["ServerAdminCustomerID"].ToString() + "'");
     DataRow[] rows = db.ViziAppsExecuteSql(State, b_sql.ToString());
     DataRow row = rows[0];
     if (row["staging_app_xml"] == DBNull.Value || row["staging_app_xml"] == null)
     {
         State["AppXmlDoc"] = null;
         return null;
     }
     string xml = row["staging_app_xml"].ToString();
     Util util = new Util();
     doc.LoadXml(util.DecodeMySql(xml));
     db.CloseViziAppsDatabase(State);
     return doc;
 }
    protected void LoginToUser_Click(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        Util util = new Util();
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

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

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

        db.CloseViziAppsDatabase(State);
    }
Exemplo n.º 9
0
    public string LoginToViziAppsFromGoogleApps(Hashtable State, string username)
    {
        try
        {
            string sql = "SELECT * FROM customers WHERE username='******' AND account_type like '%google_apps%'";
            DB db = new DB();
            DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
            if (rows.Length == 0)
            {
                db.CloseViziAppsDatabase(State);
                return "The username is incorrect.";
            }
            DataRow row = rows[0];
            if (row["status"].ToString() == "inactive")
            {
                db.CloseViziAppsDatabase(State);
                return "Your account is inactive. Contact ViziApps to re-activate your account.";
            }

            //check expiration date
            string expiration_date = row["expiration_date"].ToString();
            if (expiration_date.Length > 0)
            {
                DateTime expiration = DateTime.Parse(expiration_date);
                if (expiration < DateTime.Now.ToUniversalTime())
                {
                    sql = "UPDATE customers SET status='inactive' WHERE customer_id='" + row["customer_id"].ToString() + "'";
                    db.ViziAppsExecuteNonQuery(State, sql);
                    db.CloseViziAppsDatabase(State);
                    return "Your account has expired.";
                }
            }

            State["CustomerID"] = row["customer_id"].ToString();

            string account_type = GetAccountType(row["account_type"].ToString());
            State["AccountType"] = account_type;
            State["CustomerEmail"] = row["email"].ToString();

            Hashtable UsersList = (Hashtable)HttpRuntime.Cache["UsersList"];
            if (UsersList == null)
            {
                //this shouldn't happen so report this now and go on
                String error = "Application Cache UsersList has been set to null";
                string NOW = GetCurrentDateTimeUTCMySqlFormat();

                sql = "INSERT INTO error_log SET log_id=UUID(), timestamp='" + NOW + "',username='******',app='no app selectred',error='" + error + "',stacktrace='no stack trace'";
                db.ViziAppsExecuteNonQuery(State, sql);
                db.CloseViziAppsDatabase(State);

                HttpRuntime.Cache["UsersList"] = new Hashtable();
                UsersList = (Hashtable)HttpRuntime.Cache["UsersList"];
            }

            string force_1_user_sessions = row["force_1_user_sessions"].ToString();
            bool one_user_allowed = force_1_user_sessions == "1" || force_1_user_sessions.ToLower() == "true";
            if (UsersList[username] != null)
            {
                Hashtable UserTable = (Hashtable)UsersList[username];
                //check if only 1 user is allowed
                if (one_user_allowed && State["PageRequestIPAddress"] != null && UserTable["PageRequestIPAddress"].ToString() != State["PageRequestIPAddress"].ToString())
                    return "The account is already in use.";
                UserTable["PageRequestIPAddress"] = State["PageRequestIPAddress"].ToString();
                UserTable["SessionID"] = State["SessionID"];
            }
            else
            {
                Hashtable UserTable = new Hashtable();
                UserTable["PageRequestIPAddress"] = State["PageRequestIPAddress"].ToString();
                UserTable["SessionID"] = State["SessionID"];
                UsersList[username] = UserTable;
            }

            //initialize configurations
            State["CustomerStatus"] = row["status"].ToString();
            State["Password"] = "";
            State["Username"] = username;
            SetLoggedIn(State);

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

            IncrementNLogins(State);
            LogLastUsed(State);

            string agreed_to_eula = row["agreed_to_eula"].ToString();

            if (username.ToLower() == "admin")
                return "admin";

            else if (agreed_to_eula == "1" || agreed_to_eula.ToLower() == "true")
            {
                return "OK";
            }

            else
                return "agree_to_EULA";

        }
        catch (Exception ex)
        {
            LogError(State, ex);
            return "Internal error in login process.";
        }
    }
Exemplo n.º 10
0
    protected XmlDocument GetDesign(string application_id, string user_id, string customer_id,
        int device_display_width, int device_display_height, string app_status, string time_stamp)
    {
        XmlUtil x_util = new XmlUtil();
        Util util = new Util();
        DB db = new DB();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        string sql = "SELECT application_name,application_type FROM applications WHERE application_id='" + application_id + "'";
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        DataRow row = rows[0];
        string application_name = row["application_name"].ToString();
        string application_type = row["application_type"].ToString();
        State["SelectedApp"] = application_name;

        XmlDocument Design = null;
        if (app_status == "staging")
        {
            Design = util.GetStagingAppXml(State, application_name);
        }
        else
        {
            Design = util.GetProductionAppXml(State, application_name);
        }

        if (Design == null)
            return null;

        if (application_type == Constants.HYBRID_APP_TYPE)
        {
            WebAppsUtil w_util = new WebAppsUtil();
            State["SelectedAppType"] = Constants.HYBRID_APP_TYPE;
             HttpRuntime.Cache["NewWebAppHtml"] = File.ReadAllText(Server.MapPath(".") + @"\App_Data\NewViziAppsWebApp.txt");
             HttpRuntime.Cache["NewHybridAppXml"] = File.ReadAllText(Server.MapPath(".") + @"\App_Data\NewViziAppsHybridApp.xml");
             HttpRuntime.Cache["ShareThisScripts"] = File.ReadAllText(Server.MapPath(".") + @"\App_Data\ShareThisScripts.txt");
             HttpRuntime.Cache["TempFilesPath"] = Server.MapPath(".") + @"\temp_files\";

            State["Username"] = util.GetUsernameFromCustomerID(State, customer_id);
            //get original design display width and height
            string device_design_width = Design.SelectSingleNode("//configuration/device_design_width").InnerText;
            string device_design_height = Design.SelectSingleNode("//configuration/device_design_height").InnerText;
            double x_size_factor = 1.0D;
            double y_size_factor = 1.0D;
            if (device_display_width > 600)
            {
                x_size_factor = Convert.ToDouble(device_display_width) / Convert.ToDouble(device_design_width);
                y_size_factor = Convert.ToDouble(device_display_height) / Convert.ToDouble(device_design_height);
            }
            if (app_status == "production")
                State["IsProduction"] = true;
            else
                State["IsProduction"] = false;
            string html = w_util.GetWebApp(State, Design, x_size_factor, y_size_factor);
            Design = x_util.GenerateHybridAppXml(State, Design, device_display_width.ToString(), device_display_height.ToString(), html);
        }
        XmlNode configuration = Design.SelectSingleNode("//configuration");

        if (user_id != null && user_id.Length > 0)
            x_util.CreateNode(Design, configuration, "user_id", user_id);
        x_util.CreateNode(Design, configuration, "customer_id", customer_id);
        XmlNode app_node = Design.SelectSingleNode("//application");
        if (time_stamp == null)
        {
            if (app_status == "staging")
            {
                time_stamp = util.GetStagingAppTimeStamp(State, application_id);
            }
            else
            {
                time_stamp = util.GetProductionAppTimeStamp(State, application_id);
            }
        }

        x_util.CreateNode(Design, app_node, "time_stamp", time_stamp);
        XmlNode id_node = app_node.SelectSingleNode("id");
        if (id_node == null)
            x_util.CreateNode(Design, app_node, "id", application_id);
        else
            id_node.InnerText = application_id;

        XmlNode root = Design.SelectSingleNode("app_project");
        if (root == null)
            root = Design.SelectSingleNode("mobiflex_project");

        XmlNode status_node = x_util.CreateNode(Design, root, "status", "OK");

        return Design;
    }
Exemplo n.º 11
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;
    }
Exemplo n.º 12
0
    protected void CustomersByAccount_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        ClearMessages();
        HideForCustomers();

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

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

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

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

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

        db.CloseViziAppsDatabase(State);

        ShowForCustomers();
    }
Exemplo n.º 13
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);
    }
    // Modified from original viziapps code with the Additional Branded check so only valid ones are added to the ComboBox.
    private bool InitAppsList(Hashtable State, RadComboBox AppsList)
    {
        Util util = new Util();
        BillingUtil billingutil = new BillingUtil();
        try
        {

            if (AppsList == null)
                return false;

            //string sql = "SELECT DISTINCT application_name FROM applications WHERE customer_id='" + State["CustomerID"].ToString() + "' ORDER BY application_name";
            string sql = "SELECT DISTINCT application_name,application_type FROM applications WHERE customer_id='" + State["CustomerID"].ToString() + "' ORDER BY application_name";
            DB db = new DB();
            DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
            AppsList.Items.Clear();
            foreach (DataRow row in rows)
            {
            string app_name = row["application_name"].ToString();
            string app_type = row["application_type"].ToString();

                //For native-hybrid apps do the branded check here inserting only Apps that have paid for branding.
            if (app_type.Contains("native") || app_type.Contains("hybrid"))
            {

                //Inserting only Apps which meet all these criteria.
                if ((billingutil.IsAppStoreSubmissionPaid(State, app_name) == true) &&          // + Submitted for App preparation.
                     (billingutil.IsAppPaid(State, app_name) == false))                       // + not yet paid for any service
                {
                    AppsList.Items.Add(new RadComboBoxItem(app_name, app_name));
                }
            }
            else
            {
                //Inserting only Apps which meet all these criteria.
                if (billingutil.IsAppPaid(State, app_name) == false)                            // not yet paid for any service
                    AppsList.Items.Add(new RadComboBoxItem(app_name, app_name));
            }

            }

            if (AppsList.IsEmpty)
                return false;

            AppsList.Items.Insert(0, new RadComboBoxItem("Select App ->", "Select App ->"));
            AppsList.Items[0].Selected = true;

            return true;
        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }

        return false;
    }
Exemplo n.º 15
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);
    }
Exemplo n.º 16
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;
    }
Exemplo n.º 17
0
    protected void RemoveCustomer_Click(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        string customer_id = State["ServerAdminCustomerID"].ToString();
        if (customer_id == "0")
        {
            AdminMessage.Text = "Select a customer and try again.";
            return;
        }

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

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

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

            HideForCustomers();

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

        db.CloseViziAppsDatabase(State);
        CustomersByAccount.Items[0].Selected = true;
        CustomersByEmail.Items[0].Selected = true;
        HideForApplications();
    }
    // Modified from original viziapps code with the additional checks so only valid ones are added to the ComboBox.
    private bool InitAppsList(Hashtable State, RadComboBox AppsList)
    {
        Util util = new Util();
        try
        {

            if (AppsList == null)
                return false;

           // string sql = "SELECT DISTINCT application_name FROM applications WHERE customer_id='" + State["CustomerID"].ToString() + "' ORDER BY application_name";

            //Get only native Apps to load onto this ComboBox.
            string sql = "SELECT DISTINCT application_name,application_id FROM applications WHERE customer_id='" + State["CustomerID"].ToString() + "' AND application_type <> 'web'" + " ORDER BY application_name";

            DB db = new DB();
            DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
            AppsList.Items.Clear();
            foreach (DataRow row in rows)
            {
                string app_name = row["application_name"].ToString();
                string application_id = row["application_id"].ToString();

                BillingUtil billingutil = new BillingUtil();

                                                                                                //Inserting only Apps which meet all these criteria.
                if ((billingutil.IsAppStoreSubmissionPaid(State, app_name) == false) &&          // + never submitted for App preparation as yet.
                     (billingutil.IsAppPaid(State, app_name) == false) &&                       // + not yet paid for anything
                     (util.IsFreeProductionValid(State, application_id) == true) &&             // + completed the Production Form Submission
                     (billingutil.IsAppCancelled(State, app_name) == false))                    // + never cancelled any service.
                    {
                      AppsList.Items.Add(new RadComboBoxItem(app_name, app_name));
                    }

            }

            if (AppsList.IsEmpty)
                return false;

            AppsList.Items.Insert(0, new RadComboBoxItem("Select App ->", "Select App ->"));
            AppsList.Items[0].Selected = true;

            return true;
        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
        return false;
    }
Exemplo n.º 19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State,Response,"Default.aspx")) return;
        try
        {
            if (!IsPostBack)
            {
                CopyRight.InnerText = HttpRuntime.Cache["CopyRight"].ToString();
                UserLabel.Text = State["Username"].ToString();
            }

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

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

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

            Message.Text = "";

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

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

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

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

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

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

            db.CloseViziAppsDatabase(State);

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

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

        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
    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);
        }
    }
    private bool InitAppsList(Hashtable State, RadComboBox AppsList)
    {
        Util util = new Util();
        try
        {

            if (AppsList == null)
            {
                showhistory.Visible = false;
                return false;
            }
            else
                showhistory.Visible = true;

            //Get only apps from paid_services table directly (even if status is not paid => Just App Preparation done it should have a record there.
            string sql = "SELECT app_name FROM paid_services WHERE customer_id='" + State["CustomerID"].ToString() + "' ORDER BY app_name";

            DB db = new DB();
            DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
            AppsList.Items.Clear();
            foreach (DataRow row in rows)
            {
                string app_name = row["app_name"].ToString();
                AppsList.Items.Add(new RadComboBoxItem(app_name, app_name));
            }

            if (AppsList.IsEmpty)
                return false;

            AppsList.Items.Insert(0, new RadComboBoxItem("Select App ->", "Select App ->"));
            AppsList.Items[0].Selected = true;
            return true;

        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
        return false;
    }
    //Init the ComboBox with the specific check required for BillingHistory
    private bool InitAppsList(Hashtable State, RadComboBox AppsList)
    {
        Util util = new Util();
            try
            {

                if (AppsList == null)
                    return false;

                //Get only paid_apps from paid_services table directly.
                string sql = "SELECT app_name FROM paid_services WHERE customer_id='" + State["CustomerID"].ToString() + "' AND status='paid' AND sku != '" +  HttpRuntime.Cache["iOSSubmitServiceSku"].ToString() + "' AND  sku != '" +  HttpRuntime.Cache["AndroidSubmitServiceSku"].ToString() + "' ORDER BY app_name";
                //string sql = "SELECT app_name FROM paid_services WHERE customer_id='" + State["CustomerID"].ToString() + "' AND status='paid' ORDER BY app_name";

                DB db = new DB();
                DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
                AppsList.Items.Clear();
                foreach (DataRow row in rows)
                {
                    string app_name = row["app_name"].ToString();
                    AppsList.Items.Add(new RadComboBoxItem(app_name, app_name));
                }

                if (AppsList.IsEmpty)
                    return false;

                AppsList.Items.Insert(0, new RadComboBoxItem("Select App ->", "Select App ->"));
                AppsList.Items[0].Selected = true;

                return true;
            }
            catch (Exception ex)
            {
                util.ProcessMainExceptions(State, Response, ex);
            }
            return false;
    }
    protected void Publish_Click(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "../../Default.aspx")) return;

        //check if entries were set
        DB db = new DB();
        StringBuilder b_sql = new StringBuilder("SELECT * FROM applications ");
        b_sql.Append("WHERE application_name='" + State["SelectedApp"].ToString() + "'");
        b_sql.Append(" AND customer_id='" +  State["CustomerID"].ToString() + "'");
        DataRow[] rows = db.ViziAppsExecuteSql(State, b_sql.ToString());
        DataRow row = rows[0];
         if (row["production_app_name"] == DBNull.Value || row["production_app_name"].ToString().Length == 0)
         {
             PublishMessage.Text = "The Published App Name needs to be set and saved";
            return;
         }
         if (row["production_app_xml"] == DBNull.Value)
         {
             PublishMessage.Text = "The Publish Design needs to be saved";
            return;
         }

        string icon_url = util.GetApplicationLargeIcon(State,  State["ApplicationID"].ToString());
        if (icon_url == null || icon_url.Length == 0)
        {
            PublishMessage.Text = "The Icon image needs to be uploaded";
            return;
        }
        string splash_url = util.GetApplicationSplashImage(State,  State["ApplicationID"].ToString());
        if (splash_url == null || splash_url.Length == 0)
        {
            PublishMessage.Text = "The splash image needs to be uploaded";
            return;
        }

        //check on paid service
        //is payment current
        XmlUtil x_util = new XmlUtil();
        Hashtable features = util.IsProductionAppPaid(State);
        if (features == null)
        {
            PublishMessage.Text = "A production service needs to be paid for your app.";
            return;
        }
        else //check number of pages
        {
            int page_count = x_util.GetProductionAppPageCount(State);
            int sku_page_count = (int)features["max_pages"];
            if (page_count > sku_page_count)
            {
                PublishMessage.Text = "Your production app of " + page_count.ToString() + " pages exceeds the page limit of " + sku_page_count .ToString() + " for the production service you paid for.";
                return;
            }
        }

        State["UrlAccountIdentifier"] = util.GetUrlAccountIdentifier(State);
        if (State["UrlAccountIdentifier"].ToString().Length == 0)
        {
            PublishMessage.Text = "The Account Identifier has not been set. Go the Design Page and set the Account Identifier in the app properties";
            return;
        }

        WebAppsUtil web_util = new WebAppsUtil();
        AmazonS3 s3 = new AmazonS3();
        State["IsProduction"] = true;

        string file_name = State["SelectedApp"].ToString() + "/index.html";
        file_name = file_name.Replace(" ", "_");
        string save_file_path =  HttpRuntime.Cache["TempFilesPath"].ToString() + State["Username"].ToString() + "." + file_name.Replace("/index.html", ".html");

        if (File.Exists(save_file_path))
            File.Delete(save_file_path);

        string html = web_util.GetWebApp(State,util.GetStagingAppXml(State),1.0D,1.0D);
        File.WriteAllText(save_file_path, html);
         string key =  State["UrlAccountIdentifier"].ToString() + "/" + file_name;
        s3.UploadFileWithKey(State, file_name, save_file_path, key);

        if (File.Exists(save_file_path))
            File.Delete(save_file_path);

        string filename =  State["SelectedApp"].ToString().Replace(" ", "_") + "_qrcode.png";

        string url = "http://viziapps.s3-website-us-east-1.amazonaws.com/" +  State["UrlAccountIdentifier"].ToString() + "/" +  State["SelectedApp"].ToString().Replace(" ", "_");
        PublishMessage.Text = "Pulished App URL: " + url;

        BitlyData.LoginName = ConfigurationManager.AppSettings["BitlyLoginName"];
        BitlyData.APIKEY = ConfigurationManager.AppSettings["BitlyAPIKey"];
        String bitly_url = Bitly.ShortURL(url, Bitly.Format.TXT);
        QRCode.Src = Bitly.GetQRCodeURL(bitly_url);
        PublishedAppURL.Text = "Short-length published App URL: " + bitly_url;

        QRCode.Style.Value = "";
        QRCodeLabel.Style.Value = "";
        QRCodeLabel.Text = "QR Code for Published Web App: " + State["SelectedApp"].ToString() + ". Capture the URL from this image with any app that reads QR codes and you will see your app on your device in seconds.";
    }
Exemplo n.º 24
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);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../../Default.aspx');", true); return; }

        try
        {
            ClearMessages();

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

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

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

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

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

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

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

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

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

            }

        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
Exemplo n.º 26
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;
    }
    private void PreFillBillingFormDetails()
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        Util util = new Util();
        if (State["ServerAdminCustomerUsername"] != null)
            UserLabel.Text = State["ServerAdminCustomerUsername"].ToString();
        else
            UserLabel.Text = State["Username"].ToString();

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

        DataRow row = rows[0];

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

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

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

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

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

        //++++++++++++++ To be Removed at the end ++++++++++++++++++++++++++
        //CCNumberTextBox.Text = "4111111111111111";
        //CCExpirationTextBox.Text = "12/2012";
        //CCCardCodeTextBox.Text = "222";
    }
Exemplo n.º 28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../Default.aspx');", true); return; }

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

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

            Message.Text = "";

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

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

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

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

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

            db.CloseViziAppsDatabase(State);

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

            string force_1_user_sessions = row["force_1_user_sessions"].ToString();
            Force1UserSessions.Checked = force_1_user_sessions == "1" || force_1_user_sessions.ToLower() == "true";
        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
Exemplo n.º 29
0
    private bool UpdateCheddarGetterWithCC()
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];

        //Get all paid_apps from paid_services table directly.
        string sql = "SELECT application_id FROM paid_services WHERE customer_id='" + State["CustomerID"].ToString() + "' AND status='paid' ORDER BY app_name";

        DB db = new DB();
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);

        bool status = false;
        foreach (DataRow row in rows)
        {
            string AppID = row["application_id"].ToString();
            status = UpdateCheddarGetterPerApp(AppID);
        }
        return status;
    }
Exemplo n.º 30
0
    private void SendEmailToSalesandCustomer(DB db)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        Util util = new Util();
        //send an email with all the stuff
        string sql = "SELECT first_name, last_name, email, phone,referral_source,app_to_build,account_type,password FROM customers WHERE customer_id='" +  State["CustomerID"].ToString() + "'";
        DataRow[] rows = db.ViziAppsExecuteSql((Hashtable)HttpRuntime.Cache[Session.SessionID], sql);
        DataRow row = rows[0];
        string email_template_path = null;
        string body = null;

        string subject = null;
        if (!row["account_type"].ToString().Contains("google_apps"))
        {
            subject = "New Account Signup for ViziApps";
            email_template_path = Server.MapPath(".") + @"\templates\NewViziAppsSignupEmail.txt";
            body = File.ReadAllText(email_template_path)
                     .Replace("[USERNAME]", State["Username"].ToString())
                     .Replace("[FIRST_NAME]", row["first_name"].ToString())
                     .Replace("[LAST_NAME]", row["last_name"].ToString())
                     .Replace("[EMAIL]", row["email"].ToString());

            if (row["phone"] != null && row["phone"] != DBNull.Value && row["phone"].ToString().Length > 0)
                 body = body.Replace("[PHONE]", row["phone"].ToString());
            else
                body = body.Replace("[PHONE]", "Unknown");

            if (row["referral_source"] != null && row["referral_source"] != DBNull.Value && row["referral_source"].ToString() != "unknown")
                body = body.Replace("[FOUND_BY]", row["referral_source"].ToString());
            else
                body = body.Replace("[FOUND_BY]", "Unknown");

            if (row["app_to_build"] != null && row["app_to_build"] != DBNull.Value && row["app_to_build"].ToString().Length > 0)
                body = body.Replace("[APP_TO_BUILD]", row["app_to_build"].ToString());
            else
                body = body.Replace("[APP_TO_BUILD]", "Unknown");
        }
        else if (row["account_type"].ToString().Contains("google_apps"))
        {
            subject = "New Account Signup for ViziApps From Google Apps";
            email_template_path = Server.MapPath(".") + @"\templates\NewGoogleAppsViziAppsSignupEmail.txt";
            body = File.ReadAllText(email_template_path)
                    .Replace("[USERNAME]", State["Username"].ToString())
                    .Replace("[FIRST_NAME]", row["first_name"].ToString())
                    .Replace("[LAST_NAME]", row["last_name"].ToString())
                    .Replace("[EMAIL]", row["email"].ToString());
        }

        Email email = new Email();
        email.SendEmail((Hashtable)HttpRuntime.Cache[Session.SessionID],   HttpRuntime.Cache["TechSupportEmail"].ToString(),   HttpRuntime.Cache["SalesEmail"].ToString(), "", "", subject, body.ToString(), "",true);

        string welcome_body = null;
        if ( State["LoggedInFromGoogleApps"] != null)
        {
            email_template_path = Server.MapPath(".") + @"\templates\GoogleAppsCustomerWelcomeEmail.txt";
             State["LoggedInFromGoogleApps"] = "true";
            welcome_body = File.ReadAllText(email_template_path).Replace("[NAME]", row["first_name"].ToString()).Replace("[PASSWORD]", row["password"].ToString());
        }
        else
        {
            email_template_path = Server.MapPath(".") + @"\templates\CustomerWelcomeEmail.txt";
            welcome_body = File.ReadAllText(email_template_path).Replace("[NAME]", row["first_name"].ToString());
        }
        email.SendEmail((Hashtable)HttpRuntime.Cache[Session.SessionID],   HttpRuntime.Cache["SalesEmail"].ToString(), row["email"].ToString(), "", "", "Welcome to ViziApps", welcome_body, "",true);
    }