Esempio n. 1
0
        public static string wmGetAWSObjectList(string sCloudID, string sObjectType)
        {
            awsMethods acAWS = new awsMethods();

            string sHTML = "";
            string sErr  = "";

            DataTable dt = acAWS.GetCloudObjectsAsDataTable(sCloudID, sObjectType, ref sErr);

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    GetAssociatedEcosystems(ref dt, sObjectType);
                    sHTML = DrawTableForType(sObjectType, dt);
                }
                else
                {
                    sHTML = "No data returned from the Cloud Provider.";
                }
            }
            else
            {
                sHTML += "<div class=\"ui-widget\" style=\"margin-top: 10px;\">";
                sHTML += "<div style=\"padding: 10px;\" class=\"ui-state-highlight ui-corner-all\">";
                sHTML += "<span style=\"float: left; margin-right: .3em;\" class=\"ui-icon ui-icon-info\"></span>";
                sHTML += "<p>" + sErr + "</p>";
                sHTML += "</div>";
                sHTML += "</div>";
            }

            return(sHTML);
        }
Esempio n. 2
0
        public static string wmGetEcosystemObjectByType(string sEcosystemID, string sType)
        {
            dataAccess dc    = new dataAccess();
            awsMethods acAWS = new awsMethods();

            acUI.acUI ui = new acUI.acUI();

            try
            {
                string sHTML = "";
                string sErr  = "";

                //So, we'll first get a distinct list of all clouds represented in this set
                //then for each cloud we'll get the objects.
                string sSQL = "select distinct cloud_id" +
                              " from ecosystem_object" +
                              " where ecosystem_id ='" + sEcosystemID + "'" +
                              " and ecosystem_object_type = '" + sType + "'";

                DataTable dtClouds = new DataTable();
                if (!dc.sqlGetDataTable(ref dtClouds, sSQL, ref sErr))
                {
                    return(sErr);
                }


                if (dtClouds.Rows.Count > 0)
                {
                    foreach (DataRow drCloud in dtClouds.Rows)
                    {
                        string sCloudID = drCloud["cloud_id"].ToString();

                        //get the cloud object rows
                        sSQL = "select eo.ecosystem_object_id, eo.ecosystem_object_type" +
                               " from ecosystem_object eo" +
                               " where eo.ecosystem_id ='" + sEcosystemID + "'" +
                               " and eo.ecosystem_object_type = '" + sType + "'" +
                               " and eo.cloud_id = '" + sCloudID + "'" +
                               " order by eo.ecosystem_object_type";

                        DataTable dtObjects = new DataTable();
                        if (!dc.sqlGetDataTable(ref dtObjects, sSQL, ref sErr))
                        {
                            return(sErr);
                        }


                        if (dtObjects.Rows.Count > 0)
                        {
                            //we only need to hit the API once... this result will contain all the objects
                            //and our DrawProperties will filter the DataTable on the ID.
                            DataTable dtAPIResults = acAWS.GetCloudObjectsAsDataTable(sCloudID, sType, ref sErr);

                            foreach (DataRow drObject in dtObjects.Rows)
                            {
                                //look up the cloud and get the name
                                Cloud c = new Cloud(sCloudID);
                                if (c.ID != null)
                                {
                                    //giving each section a guid so we can delete it on the client side after the ajax call.
                                    //not 100% the ecosystem_object_id will always be suitable as a javascript ID.
                                    string sGroupID = ui.NewGUID();

                                    sHTML += "<div class=\"ui-widget-content ui-corner-all ecosystem_item\" id=\"" + sGroupID + "\">";


                                    string sObjectID = drObject["ecosystem_object_id"].ToString();

                                    string sLabel = "Cloud: " + c.Name + " - " + sObjectID;

                                    sHTML += "<div class=\"ui-widget-header ecosystem_item_header\">";
                                    sHTML += "<div class=\"ecosystem_item_header_title\"><span>" + sLabel + "</span></div>";

                                    sHTML += "<div class=\"ecosystem_item_header_icons\">";

                                    sHTML += "<span class=\"ui-icon ui-icon-close ecosystem_item_remove_btn pointer\"" +
                                             " id_to_delete=\"" + drObject["ecosystem_object_id"].ToString() + "\"" +
                                             " id_to_remove=\"" + sGroupID + "\">";
                                    sHTML += "</span>";

                                    sHTML += "</div>";

                                    sHTML += "</div>";

                                    //the details section
                                    sHTML += "<div class=\"ecosystem_item_detail\">";

                                    if (dtAPIResults != null)
                                    {
                                        if (dtAPIResults.Rows.Count > 0)
                                        {
                                            sHTML += DrawAllProperties(dtAPIResults, sObjectID);
                                        }
                                    }


                                    //end detail section
                                    sHTML += "</div>";
                                    //end block
                                    sHTML += "</div>";
                                }
                            }
                        }
                        else
                        {
                            sHTML += "<span>This ecosystem does not contain any Cloud Objects.</span>";
                        }
                    }
                }



                return(sHTML);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }