using CloudServiceDAO; using Grpc.Core; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using static CloudServiceDAO.servicioDAOService; using System.Threading; using System.Numerics; using System.Xml.Linq; namespace server { public class IDAOServices : servicioDAOServiceBase { private readonly ServicesDAO _servicesDAO; String messageError = "IDAOServices \n "; public IDAOServices(ServicesDAO servicesDAO) { _servicesDAO = servicesDAO; } #region catalogos_planes public override async Task getProductType(GetProductTypeRequest request, ServerCallContext context) { ProductsType listProducts = new ProductsType(); DataTable? result = _servicesDAO.getProductType(request.Iduser, request.Idorg); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for type catalog")); else { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { int id = 0; bool isavaible = false; productType productItem = new productType() { Id = (Int32.TryParse(row["id"].ToString(), out id) == true ? id : 0), ProductName = row["product_name"].ToString(), ProductDsc = row["product_dsc"].ToString(), IsAvaible = (Boolean.TryParse(row["is_available"].ToString(), out isavaible) == true ? isavaible : false), Steps = row["steps"].ToString() }; listProducts.Products.Add(productItem); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for product types information")); } return new ProductsType(listProducts); } public override async Task getPlansService(GetPlansServiceRequest request, ServerCallContext context) { PlansServices listPlans = new PlansServices(); var IdServiceRequest = request.IdService; DataTable? result = _servicesDAO.getPlansService(IdServiceRequest); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for type catalog")); else { if (result.Rows.Count > 0) { try { foreach (DataRow row in result.Rows) { int id = 0, serviceid = 0; bool active = false; double priceFactor = 0; Plan planItem = new Plan() { PlanId = (Int32.TryParse(row["PlanID"].ToString(), out id) == true ? id : 0), Name = row["name"].ToString(), Description = row["description"].ToString(), PriceFactor = (Double.TryParse(row["price_factor"].ToString(), out priceFactor) == true ? priceFactor : 0), Resources = row["resources"].ToString(), Model = row["model"].ToString(), ServiceId = (Int32.TryParse(row["service_id"].ToString(), out serviceid) == true ? serviceid : 0), Active = row["active"].ToString().Equals("1") ? true : false }; listPlans.Plan.Add(planItem); } } catch (Exception ex) { throw new RpcException(new Status(StatusCode.Aborted, "Error to extract data information")); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for plans information")); } return new PlansServices(listPlans); } public override async Task getServicesCatalog(GetServicesByProductTypeRequest request, ServerCallContext context) { String result = _servicesDAO.getServicesCatalog(request.IdProductType, request.IdUser, request.IdOrg); if (result == null || String.IsNullOrEmpty(result)) { throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for type catalog")); } cloudServiceDAO resultmessage = new cloudServiceDAO() { Response = result }; return new GetServicesByProductTypeResponse() { Response = resultmessage }; } public override async Task getGenericInformation(GetGenericInformationRequest request, ServerCallContext context) { String result = _servicesDAO.getDataTablefromClause(request.TabName, request.WcolNameFilter, request.WParam); if (result == null || String.IsNullOrEmpty(result)) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results information")); cloudServiceDAO resultmessage = new cloudServiceDAO() { Response = result }; return new GetGenericInformationResponse() { Response = resultmessage }; } public override async Task getStatusCatalog(GetStatusCatalogRequest request, ServerCallContext context) { allStatusCatalog allrequest = new allStatusCatalog(); DataTable? result = _servicesDAO.getStatusCatalog(request.StatusCatalogId, request.IdType); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for vdc information")); else { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { Int32 public_id = 0; statusCatalog item = new statusCatalog() { StatusCatalogID = Convert.ToInt32(row["StatusCatalogID"].ToString()), Status = row["status"].ToString(), StatusDesc = row["status_dsc"].ToString(), IdType = Convert.ToInt32(row["id_type"].ToString()) }; allrequest.StatusCatalog.Add(item); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for request queue information")); } return new allStatusCatalog(allrequest); } #endregion #region contratar_servicio public override async Task setContractedServicesService(SetContractedServicesRequest request, ServerCallContext context) { String result = _servicesDAO.setContractedServices(request.UserId, request.BackupScheduledId, request.PlanId, request.FirewallId, request.VdcVcdId); if (result == null || String.IsNullOrEmpty(result)) { throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for contracted service data access")); } cloudServiceDAO resultmessage = new cloudServiceDAO { Response = result }; return new SetContractedServicesResponse() { Response = resultmessage }; } public override async Task setfirewallServices(SetfirewallRequest request, ServerCallContext context) { var ipsRequest = request.Ips; String result = _servicesDAO.setFirewall(ipsRequest, request.IsSegment); if (result == null || String.IsNullOrEmpty(result)) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for firewall information")); cloudServiceDAO resultmessage = new cloudServiceDAO { Response = result }; return new SetfirewallResponse() { Response = resultmessage }; } /// /// Servicio para almacenar en tabla licenses a partir de un id_usuario /// /// Incluye los parametros Specs/form, name/orgname y contracted_services_id /// Utilizado en la contratación del servicio /// /// public override async Task setLicensesService(SetLicensesRequest request, ServerCallContext context) { var Specs = request.Specs; var name = request.Name; int contractedServicesId = 0; Int32.TryParse(request.ContractedServicesId.ToString(), out contractedServicesId); String result = _servicesDAO.saveLicenses(Specs, contractedServicesId, name); if (result == null || String.IsNullOrEmpty(result)) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for user/services contracted")); cloudServiceDAO resultmessage = new cloudServiceDAO() { Response = result }; return new SetLicensesResponse() { Response = resultmessage }; } public override async Task getTermsandConditions(GetTermsAndConditionsRequest request, ServerCallContext context) { alltermsandconditions allrequest = new alltermsandconditions(); DataTable? result = _servicesDAO.getConsumptionHistory(request.IdService, request.IdTermsConditions); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for ConsumptionHistory information")); else { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { bool active = false; termsandconditions item = new termsandconditions() { IdTermsConditions = Convert.ToInt32(row["idterms_conditions"].ToString()), TermsConditions = row["terms_conditions"].ToString(), Idservice = Convert.ToInt32(row["idservice"].ToString()), Bactive = row["bactive"].ToString().Equals("1") ? true : false }; allrequest.TermsConditions.Add(item); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for terms and conditions information")); } return new alltermsandconditions(allrequest); } public override async Task setTermsAndConditions (SetTermsAndConditionsRequest request, ServerCallContext context) { String result = _servicesDAO.setTermsConditions(request.IdTermsConditions, request.TermsConditions, request.Idservice, request.Bactive); if (result == null || String.IsNullOrEmpty(result)) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for update ConsumptionHistory")); cloudServiceDAO resultmessage = new cloudServiceDAO { Response = result }; return new SetTermsAndConditionsResponse() { Response = resultmessage }; } #endregion #region admin_services public override async Task getServicesAllContracted(GetAllContractedServicesRequest request, ServerCallContext context) { AllContractedServices listServices = new AllContractedServices(); DataTable? result = _servicesDAO.getServicesAllContracted(request.IdUser, request.IdPlan, request.ContractedServicesId, request.VdcVcdId); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for contracted services")); else { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { int id = 0, sid = 0, serviceStatusId = 0, planid = 0, requestId = 0, srvstatusid = 0, supplyid = 0; bool active = false; double priceFactor = 0; ContractedServices planItem = new ContractedServices() { ServicesID = (Int32.TryParse(row["ServicesID"].ToString(), out sid) == true ? sid : 0), ContractedServicesId = (Int32.TryParse(row["contracted_services_id"].ToString(), out id) == true ? id : 0), ServiceName = row["serviceName"].ToString(), ServiceDescription = row["serviceDescription"].ToString(), ServiceBasePrice = row["serviceBasePrice"].ToString(), EventsIds = row["events_ids"].ToString(), PlanID = (Int32.TryParse(row["PlanID"].ToString(), out planid) == true ? planid : 0), PlanName = row["planName"].ToString(), PlanDescription = row["planDescription"].ToString(), PriceFactor = (Double.TryParse(row["price_factor"].ToString(), out priceFactor) == true ? priceFactor : 0), Ips = row["IPs"].ToString(), FirewallID = row["FirewallID"].ToString(), IsSegment = row["is_segment"].ToString().Equals("1") ? true : false, RequestQueueID = (Int32.TryParse(row["RequestQueueID"].ToString(), out requestId) == true ? requestId : 0), ResourceSpecs = row["resource_specs"].ToString(), RequestDatetime = row["request_datetime"].ToString(), SupplyDatetime = row["supply_datetime"].ToString(), DownDatetime = row["down_datetime"].ToString(), SupplyStatusId = (Int32.TryParse(row["supply_status_id"].ToString(), out supplyid) == true ? supplyid : 0), ServiceStatusId = (Int32.TryParse(row["service_status_id"].ToString(), out srvstatusid) == true ? srvstatusid : 0), ErrorLog = row["error_log"].ToString(), Identificator = row["identificator"].ToString(), NameApp = row["name_app"].ToString(), Status = row["status"].ToString(), Port = row["port"].ToString(), VcdVcdId = row["vdc_vcd_id"].ToString(), Jsoncluster = row["jsoncluster"].ToString(), UrlImage = row["service_logo_url"].ToString() }; listServices.ContractedService.Add(planItem); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for contracted services information")); } return new AllContractedServices(listServices); } public override async Task getIpServiceById(GetIpServiceByIdRequest request, ServerCallContext context) { var IdServiceRequest = request.IdFirewall; String result = _servicesDAO.getIpServiceById(IdServiceRequest); if (result == null || String.IsNullOrEmpty(result)) { throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for type catalog")); } cloudServiceDAO resultmessage = new cloudServiceDAO() { Response = result }; return new GetIpServiceByIdResponse() { Response = resultmessage }; } public override async Task setUpdateLicenses(SetUpdateLicensesRequest request, ServerCallContext context) { String result = _servicesDAO.updateLicenses(request.Idlicenses, request.Name, request.Specs, request.IdContractedServices); if (result == null || String.IsNullOrEmpty(result)) { throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results to update licenses information")); } cloudServiceDAO resultmessage = new cloudServiceDAO() { Response = result }; return new SetUpdateLicensesResponse() { Response = resultmessage }; } public override async Task getRequestQueueService(GetRequestQueueRequest request, ServerCallContext context) { AllRequestQueue allrequest = new AllRequestQueue(); DataTable? result = _servicesDAO.getRequestQueue(request.UserId, request.ServicesId, request.ContractedServicesId , request.ServiceStatusId, request.SupplyDatetimeStart, request.SupplyDatetimeEnd, request.RequestDatetimeStart , request.RequestDatetimeEnd, request.RequestQueueId); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for request queue information")); else { try { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { Int32 public_id = 0; Requestqueue item = new Requestqueue() { RequestQueueID = Convert.ToInt32(row["RequestQueueID"].ToString()), ContractedServicesId = Convert.ToInt32(row["contracted_services_id"].ToString()), ResourceSpecs = row["resource_specs"].ToString(), RequestDatetime = row["request_datetime"].ToString(), SupplyDatetime = row["supply_datetime"].ToString(), DownDatetime = row["down_datetime"].ToString(), SupplyStatusId = Int32.TryParse(row["supply_status_id"].ToString(), out public_id) == true ? public_id : 0, ServiceStatusId = Int32.TryParse(row["service_status_id"].ToString(), out public_id) == true ? public_id : 0, ErrorLog = row["error_log"].ToString(), Identificator = row["identificator"].ToString(), NameApp = row["name_app"].ToString(), Status = row["status"].ToString(), Port = Int32.TryParse(row["port"].ToString(), out public_id) == true ? public_id : 0, UserId = Convert.ToInt32(row["user_id"].ToString()), PlanId = Convert.ToInt32(row["plan_id"].ToString()), ServiceId = Convert.ToInt32(row["service_id"].ToString()), ServicesName = row["name"].ToString(), ServicesProductTypeId = Convert.ToInt32(row["product_type_id"].ToString()), IdexpTypeValue = Convert.ToInt32(row["idexp_type_value"].ToString()), IdexpTypeCatalog = Convert.ToInt32(row["idexp_type_catalog"].ToString()), TypeCatalogName = row["type_catalog_name"].ToString(), IdexpCategory = Convert.ToInt32(row["idexp_category"].ToString()), ExpositionCategoryName = row["exposition_category_name"].ToString(), ExpValue = row["value"].ToString(), ExpIdentificator = row["identificator"].ToString() }; allrequest.Requestqueue.Add(item); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for request queue information")); } catch (Exception ex) { Console.WriteLine($"Warning: Error setting response for getRequestQueue - {ex.Message}"); } } return new AllRequestQueue(allrequest); } public override async Task GetLicenses(GetLicensesRequest request, ServerCallContext context) { AllLicenses allLicenses = new AllLicenses(); DataTable? result = _servicesDAO.getLicenses(request.Idlicenses, request.PublicId, request.OrgId, request.IdService, request.ContractedServicesId); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for licenses information")); else { try { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { Int32 public_id = 0; Licenses item = new Licenses() { Idlicenses = Convert.ToInt32(row["idlicenses"].ToString()), NameLicenses = row["name_licenses"].ToString(), Specs = row["specs"].ToString(), ContractedServicesId = Convert.ToInt32(row["contracted_services_id"].ToString()), UserId = Convert.ToInt32(row["user_id"].ToString()), PlanId = Convert.ToInt32(row["plan_id"].ToString()), PublicId = Int32.TryParse(row["public_id"].ToString(), out public_id) == true ? public_id : 0, OrgId = Convert.ToInt32(row["org_id"].ToString()), NamePlan = row["name_plan"].ToString(), ServiceId = Convert.ToInt32(row["service_id"].ToString()), NameService = row["name_service"].ToString(), ProductTypeId = Convert.ToInt32(row["product_type_id"].ToString()), ProductName = row["product_name"].ToString() }; allLicenses.Licenses.Add(item); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for licenses information")); } catch (Exception ex) { Console.WriteLine($"Warning: Error setting response for getLicenses - {ex.Message}"); } } return new AllLicenses(allLicenses); } public override async Task setUpdateRequestQueue(SetUpdateRequestQueueRequest request, ServerCallContext context) { String result = _servicesDAO.setRequestQueue(request.ContractedServicesId, request.RequestQueueId, request.ResourceSpecs, request.RequestDatetime, request.SupplyDatetime, request.DownDatetime, request.SupplyStatusId, request.ServiceStatusId, request.ErrorLog, request.Identificator, request.NameApp, request.Status, request.Port); if (result == null || String.IsNullOrEmpty(result)) { throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for update request_queue")); } cloudServiceDAO resultmessage = new cloudServiceDAO { Response = result }; return new SetUpdateRequestQueueResponse() { Response = resultmessage }; } public override async Task getConsumptionHistory(GetConsumptionHistoryRequest request, ServerCallContext context) { allConsumptionHistory allrequest = new allConsumptionHistory(); DataTable? result = _servicesDAO.getConsumptionHistory(request.ConsumptionHistoryId, request.RequestServicesId, request.StartDate, request.EndDate); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for ConsumptionHistory information")); else { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { Int32 public_id = 0; consumptionHistory item = new consumptionHistory() { ConsumptionHistoryID = Convert.ToInt32(row["ConsumptionHistoryID"].ToString()), StartDate = row["start_date"].ToString(), EndDate = row["end_date"].ToString(), RequestsQueueId = Convert.ToInt32(row["requests_queue_id"].ToString()), PodIdentificator = row["pod_identificator"].ToString() }; allrequest.ConsumptionHistory.Add(item); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for consumption history information")); } return new allConsumptionHistory(allrequest); } public override async Task setInsertConsumptionHistoryIdentificator (SetInsertConsumptionHistoryIdentificatorRequest request, ServerCallContext context) { String result = _servicesDAO.setInsertConsumptionHistoryIdentificator( request.StartDate, request.EndDate, request.Identificator, request.PodIdentificator); if (result == null || String.IsNullOrEmpty(result)) { throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for update ConsumptionHistory")); } cloudServiceDAO resultmessage = new cloudServiceDAO { Response = result }; return new SetInsertConsumptionHistoryIdentificatorResponse() { Response = resultmessage }; } public override async Task getServicesToDeploy(GetServicesToDeployRequest request, ServerCallContext context) { allServicesToDeploy allrequest = new allServicesToDeploy(); DataTable? result = _servicesDAO.getServicesToDeploy(request.Status); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for contracted services list information")); else { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { bool active = false; servicestodeploy item = new servicestodeploy() { RequestQueueID = Convert.ToInt32(row["RequestQueueID"].ToString()), ContractedServicesId = Convert.ToInt32(row["contracted_services_id"].ToString()), ResourceSpecs = row["name"].ToString(), Identificator = row["name"].ToString(), NameApp = row["name"].ToString(), Status = row["name"].ToString(), PlanId = Convert.ToInt32(row["plan_id"].ToString()), ServiceId = Convert.ToInt32(row["service_id"].ToString()), Resources = row["name"].ToString(), EventsIds = row["events_ids"].ToString(), Name = row["name"].ToString(), ProductTypeId = Convert.ToInt32(row["product_type_id"].ToString()), SupplyDatetime = row["supply_datetime"].ToString(), OrgId = Convert.ToInt32(row["OrgVcdID"].ToString()), OrgName = Convert.ToInt32(row["name"].ToString()), RegionName = row["region_name"].ToString(), RegionId = Convert.ToInt32(row["region_id"].ToString()) }; allrequest.Services.Add(item); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for profile's information")); } return new allServicesToDeploy(allrequest); } #endregion #region admin_usuarios_org /// /// Servicio para almacenar usuarios en tabla user_vcd /// /// /// /// /// public override async Task setUserVCD(SetUserVCDRequest request, ServerCallContext context) { String result = _servicesDAO.setUserVcd(request.Username, request.Email, request.Orgid); if (result == null || String.IsNullOrEmpty(result)) { throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results to save user interface")); } cloudServiceDAO resultmessage = new cloudServiceDAO() { Response = result }; return new SetUserVCDResponse() { Response = resultmessage }; } public override async Task getUserVCD(GetUserVCDRequest request, ServerCallContext context) { var user = new userVCD() ; UsersVCD userslist = new UsersVCD(); DataTable? result = _servicesDAO.getUserfromUserName(request.UserName, request.PublicId, request.UserId, request.OrgId); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for user information")); else{ if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { int apublicID; user = new userVCD() { UserVCDId = Convert.ToInt32(row["UserVcdID"].ToString()), Username = row["username"].ToString(), PublicId = (Int32.TryParse(row["public_id"].ToString(), out apublicID)==true ? apublicID : 0 ), OrgId = Convert.ToInt32(row["org_id"].ToString()), Password = "" }; userslist.Users.Add(user); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for user information")); } return new UsersVCD(userslist); } public override async Task getOrgVCD(GetOrgVCDRequest request, ServerCallContext context) { orgsVCD listOrgs = new orgsVCD(); DataTable? result = _servicesDAO.getOrgfromName(request.Name, request.OrgId); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for organization information")); else { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { orgVCD orgItem = new orgVCD() { OrgVcdId = Convert.ToInt32(row["OrgVcdID"].ToString()), Name = row["name"].ToString(), Host = row["host"].ToString(), ApiVersion = row["api_version"].ToString() }; listOrgs.Orgs.Add(orgItem); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for organizations information")); } return new orgsVCD(listOrgs); } public override async Task setOrgVCD(SetOrgVCDRequest request, ServerCallContext context) { String result = _servicesDAO.setOrgVcd(request.Name, request.Host, request.ApiVersion); if (result == null || String.IsNullOrEmpty(result)) { throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results to save organization information")); } cloudServiceDAO resultmessage = new cloudServiceDAO() { Response = result }; return new SetOrgVCDResponse() { Response = resultmessage }; } public override async Task getfieldsvdc(getfieldsvdcRequest request, ServerCallContext context) { allfieldsvdc allrequest = new allfieldsvdc(); DataTable? result = _servicesDAO.getfieldsvdc(request.VdcId, request.OrgId, request.UrnId); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for vdc information")); else { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { Int32 public_id = 0; fieldvdc item = new fieldvdc() { Id= Convert.ToInt32(row["id"].ToString()), Name = row["name"].ToString(), UrnId = row["urn_id"].ToString(), SubscriptionId = row["subscription_id"].ToString(), OrgId = Convert.ToInt32(row["org_id"].ToString()) }; allrequest.Fieldvdc.Add(item); } } else throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results for request queue information")); } return new allfieldsvdc(allrequest); } public override async Task setfieldsvdc(setfieldsvdcRequest request, ServerCallContext context) { allfieldsvdc allrequest = new allfieldsvdc(); String result = _servicesDAO.setfieldsvdc(request.VdcId , request.Name, request.UrnId, request.SubscriptionId, request.OrgId, request.Active); if (result == null || String.IsNullOrEmpty(result)) { throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results to update vdc information")); } cloudServiceDAO resultmessage = new cloudServiceDAO() { Response = result }; return new setfieldsvdcResponse() { Response = resultmessage }; } public override async Task insertfieldsvdc(insertfieldsvdcRequest request, ServerCallContext context) { allfieldsvdc allrequest = new allfieldsvdc(); String result = _servicesDAO.insertfieldsvdc(request.Name, request.UrnId, request.SubscriptionId, request.OrgId); if (result == null || String.IsNullOrEmpty(result)) { throw new RpcException(new Status(StatusCode.NotFound, messageError + "No results to update licenses information")); } cloudServiceDAO resultmessage = new cloudServiceDAO() { Response = result }; return new insertfieldsvdcResponse() { Response = resultmessage }; } public override async Task getOrgVCD_Service(GetOrgVCD_ServiceRequest request, ServerCallContext context) { all_orgvdc_service allrequest = new all_orgvdc_service(); DataTable? result = _servicesDAO.getOrgVDCByService(request.Idservice); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, "No results for this service")); else { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { bool active = false; orgvdc_service item = new orgvdc_service() { Idorg = Convert.ToInt32(row["idOrg"].ToString()), Name = row["name"].ToString() }; allrequest.Response.Add(item); } } else throw new RpcException(new Status(StatusCode.NotFound, "No results for this service information")); } return new all_orgvdc_service(allrequest); } public override async Task getContainerImage(GetContainerImageRequest request, ServerCallContext context) { all_containerimage allrequest = new all_containerimage(); Console.WriteLine("Parametro recibido: " + request.Idservice); DataTable? result = _servicesDAO.getVersionImages(request.Idservice); if (result == null) throw new RpcException(new Status(StatusCode.NotFound, "No results for this service")); else { if (result.Rows.Count > 0) { foreach (DataRow row in result.Rows) { bool active = false; containerimage item = new containerimage() { Id = Convert.ToInt32(row["id"].ToString()), Name = row["name"].ToString(), RepositoryUrl = row["repository_url"].ToString(), AvailableVersions = row["available_versions"].ToString(), ChartVersion = row["chart_version"].ToString(), IsCustomManifest = (Boolean.TryParse(row["is_custom_manifest"].ToString(), out active) == true ? active : false), YmlFile = row["yml_file"].ToString(), Default = (Boolean.TryParse(row["default"].ToString(), out active) == true ? active : false), ServicesId = Convert.ToInt32(row["services_id"].ToString()), Active = (Boolean.TryParse(row["active"].ToString(), out active) == true ? active : false) }; allrequest.Response.Add(item); } } else throw new RpcException(new Status(StatusCode.NotFound, "No results for this service information")); } return new all_containerimage(allrequest); } } } #endregion