コード例 #1
0
ファイル: Util.cs プロジェクト: dcolonvizi/ViziAppsPortal
    public void GetProductionAppInfo(Hashtable State, string app_name)
    {
        DynamoDB ddb = new DynamoDB();
        Hashtable item = ddb.GetItem(State, "apps", State["Username"].ToString(), app_name);
        if (item != null)
        {
            State["AppID"] = item["app_id"];
            State["IsProductionAppPaid"] = item["is_production_app_paid"];
            string expiration = null;
            if (item["free_production_expiration_date_time"] != null)
                expiration = item["free_production_expiration_date_time"].ToString();
            if (expiration == null || expiration.Length == 0)
            {
                State["IsFreeProductionValid"] = "false";
            }
            else
            {
                DateTime expirationDateTime = DateTime.Parse(expiration);
                State["IsFreeProductionValid"] = (DateTime.Now.ToUniversalTime() <= expirationDateTime) ? "true" : "false";
            }
            State["Use1UserCredential"] = item["use_1_user_credential"];
            State["AppDesignURL"] = item["app_design_url"];
            State["DateTimeModified"] = item["date_time_modified"];
            State["HasUnlimitedUsers"] = item["has_unlimited_users"];
            return;
        }
        else
        {
            DB db = new DB();
            string sql = "SELECT application_id,free_production_expiration_date_time, production_date_time, has_unlimited_users FROM applications WHERE production_app_name='" + app_name +
                   "' AND customer_id='" + State["CustomerID"].ToString() + "'";
            DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
            db.CloseViziAppsDatabase(State);
            if (rows.Length == 0)
            {
                State["IsProductionAppPaid"] = null;
                State["IsFreeProductionValid"] = null;
                State["Use1UserCredential"] = null;
                State["AppDesignURL"] = null;
                State["AppID"] = null;
                State["DateTimeModified"] = null;
                State["HasUnlimitedUsers"] = null;
                return;
            }
            else
            {
                DataRow row = rows[0];
                State["AppID"] = row["application_id"].ToString();
                Hashtable features = IsProductionAppPaid(State, row["application_id"].ToString());
                State["IsProductionAppPaid"] = (features != null) ? "true" : "false";
                string expiration = row["free_production_expiration_date_time"].ToString();
                State["FreeProductionExpirationDateTime"] = expiration;
                if (expiration == null || expiration.Length == 0)
                {
                    State["IsFreeProductionValid"] = "false";
                }
                else
                {
                    DateTime expirationDateTime = DateTime.Parse(expiration);
                    State["IsFreeProductionValid"] = (DateTime.Now.ToUniversalTime() <= expirationDateTime) ? "true" : "false";
                }
                State["Use1UserCredential"] = (GetUse1UserCredential(State, row["application_id"].ToString())) ? "true" : "false";

                DateTime DateTimeModified = DateTime.Parse(row["production_date_time"].ToString());
                State["DateTimeModified"] = DateTimeModified.ToString("s") + "Z";
                State["HasUnlimitedUsers"] = (row["has_unlimited_users"] != null && row["has_unlimited_users"].ToString().ToLower() == "true") ? "true" : "false";

            }
        }
    }
コード例 #2
0
ファイル: Util.cs プロジェクト: dcolonvizi/ViziAppsPortal
    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);
            }
        }
    }