private void SaveReport(Hashtable State, String application_id, String app_status, String customer_id, String user_id,
        String device_id, String device_model, String device_version, String viziapps_version,
        String latitude, String longitude, String app_use)
    {
        if (device_id == null)
            return;

        Document DDBDoc = new Document();
        DDBDoc["report_id"] = Guid.NewGuid().ToString();
        DDBDoc["app_use"] = app_use;
        DDBDoc["report_date_time"] = DateTime.UtcNow.ToString("s") + "Z";
        DDBDoc["app_id"] = application_id;
        DDBDoc["app_status"] = app_status;
        DDBDoc["customer_id"] = customer_id;
        DDBDoc["user_id"] = user_id;
        DDBDoc["device_id"] = device_id;
        DDBDoc["device_model"] = device_model;
        DDBDoc["device_version"] = device_version;
        DDBDoc["viziapps_version"] = viziapps_version;
        if (latitude != null && latitude.Length > 0)
            DDBDoc["gps_latitude"] = latitude;
        if (longitude != null && longitude.Length > 0)
            DDBDoc["gps_longitude"] = longitude;
        DynamoDB ddb = new DynamoDB();
        if (device_id != null && device_id.Length > 0)
            ddb.PutItem(State, "mobile_app_usage", DDBDoc);
        if (customer_id != null && customer_id.Length > 0)
            ddb.PutItem(State, "customer_usage", DDBDoc);
        if (application_id != null && application_id.Length > 0)
            ddb.PutItem(State, "app_usage", DDBDoc);

        /*StringBuilder sb_sql = new StringBuilder("INSERT INTO reports SET ");
        sb_sql.Append("report_id='" + Guid.NewGuid().ToString() + "'");
        DateTime now = DateTime.Now.ToUniversalTime();
        sb_sql.Append(",report_date_time='" + now.ToString("u").Replace("Z", "") + "'");
        sb_sql.Append(",application_id='" + application_id + "'");
        sb_sql.Append(",app_status='" + app_status + "'");
        sb_sql.Append(",customer_id='" + customer_id + "'");
        sb_sql.Append(",user_id='" + user_id + "'");
        sb_sql.Append(",device_id='" + device_id + "'");
        sb_sql.Append(",device_model='" + device_model + "'");
        sb_sql.Append(",device_version='" + device_version + "'");
        sb_sql.Append(",mobiflex_version='" + mobiflex_version + "'");
        if (latitude != null && latitude.Length > 0)
            sb_sql.Append(",gps_latitude='" + latitude + "'");
        if (longitude != null && longitude.Length > 0)
            sb_sql.Append(",gps_longitude='" + longitude + "'");

        db.ViziAppsExecuteNonQuery(State, sb_sql.ToString());
        db.CloseViziAppsDatabase(State);*/
    }
Example #2
0
    public void SaveProductionAppInfo(Hashtable State, string app_name, XmlDocument Design)
    {
        //save design in a file
        DynamoDB ddb = new DynamoDB();
        string file_name = app_name.Replace(" ", "_") + ".xml";
        string file_path =  HttpRuntime.Cache["TempFilesPath"].ToString() + State["Username"].ToString() + "." + file_name;
        Design.Save(file_path);

        //save design in S3
        string key = State["Username"].ToString() + "/" + app_name.Replace(" ", "_") + "/" + file_name;
        AmazonS3 s3 = new AmazonS3();
        State["AppDesignURL"] = s3.UploadFileWithKey(State, file_name, file_path, key);
        try
        {
            File.Delete(file_path);
        }
        catch (Exception ex) { }//in case there is a problem with deleting the file

        Document DDBDoc = new Document();
        DDBDoc["username"] = State["Username"].ToString();
        DDBDoc["appname"] = app_name;
        DDBDoc["app_id"] = State["AppID"].ToString();
        DDBDoc["is_production_app_paid"] = State["IsProductionAppPaid"].ToString();
        if (State["FreeProductionExpirationDateTime"] != null && State["FreeProductionExpirationDateTime"].ToString().Length > 0)
            DDBDoc["free_production_expiration_date_time"] = State["FreeProductionExpirationDateTime"].ToString();
        DDBDoc["use_1_user_credential"] = State["Use1UserCredential"].ToString();
        DDBDoc["app_design_url"] = State["AppDesignURL"].ToString();
        DDBDoc["date_time_modified"] = State["DateTimeModified"].ToString();
        DDBDoc["has_unlimited_users"] = State["HasUnlimitedUsers"].ToString();
        ddb.PutItem(State, "apps", DDBDoc);
    }
Example #3
0
 public void UpdateSessionLog(Hashtable State, string use, string page)
 {
     try
     {
         DynamoDB ddb = new DynamoDB();
         Document DDBDoc = new Document();
         DDBDoc["username"] = State["Username"].ToString();
         DDBDoc["session_date_time"] = DateTime.UtcNow.ToString("s") + "Z";
         DDBDoc["use"] = use;
         DDBDoc["page"] = page;
         int n_current_users = GetNumberOfCurrentUsers(State);
         DDBDoc["n_current_users"] = n_current_users.ToString();
         ddb.PutItem(State, "studio_usage", DDBDoc);
     }
     catch{} //if there is an error keep going
 }
Example #4
0
    public void GetProductionAccountInfo(Hashtable State, string username)
    {
        DynamoDB ddb = new DynamoDB();
        Hashtable item = ddb.GetItem(State, "customers", username);
        if (item.Count > 0)
        {
            State["Username"] = item["username"];
            State["Password"] = item["password"];
            State["CustomerID"] = item["customer_id"];
            State["AccountStatus"] = item["status"];
            return;
        }
        else
        {
            DB db = new DB();
            string sql = "SELECT password,customer_id,status FROM customers WHERE username='******'";
            DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
            db.CloseViziAppsDatabase(State);
            if (rows.Length == 0)
            {
                State["Username"] = null;
                State["Password"] = null;
                State["CustomerID"] = null;
                State["AccountStatus"] = null;
                return;
            }
            else
            {
                DataRow row = rows[0];
                State["Username"] = username;
                State["Password"] = row["password"].ToString();
                State["CustomerID"] = row["customer_id"].ToString();
                State["AccountStatus"] = row["status"].ToString();

                Document DDBDoc = new Document();
                DDBDoc["username"] = username;
                DDBDoc["password"] = row["password"].ToString();
                DDBDoc["customer_id"] = row["customer_id"].ToString();
                DDBDoc["status"] = row["status"].ToString();
                ddb.PutItem(State, "customers", DDBDoc);
            }
        }
    }