public RefreshSolutionConnectionsResponse Post(RefreshSolutionConnectionsRequest request) { RefreshSolutionConnectionsResponse res = new RefreshSolutionConnectionsResponse(); bool status = true; try { using (DbConnection _dbconnection = this.InfraConnectionFactory.DataDB.GetNewConnection() as Npgsql.NpgsqlConnection) { _dbconnection.Open(); string sql = @"SELECT EI.id, EI.type as con_type, EC.con_obj, EC.type as config_type, EI.preference FROM eb_integrations EI, eb_integration_configs EC WHERE EI.solution_id = @solution_id AND EI.eb_integration_conf_id = EC.id AND EI.eb_del = 'F' AND EC.eb_del = 'F'; "; EbConnectionsConfig cons = new EbConnectionsConfig(); DbParameter[] parameters = new DbParameter[] { this.InfraConnectionFactory.DataDB.GetNewParameter("solution_id", EbDbTypes.String, request.SolnId) }; EbDataTable dt = this.InfraConnectionFactory.DataDB.DoQuery(sql, parameters); if (dt.Rows.Count != 0) { foreach (EbDataRow dr in dt.Rows) { if (dr["con_type"].ToString() == EbConnectionTypes.EbDATA.ToString()) { cons.DataDbConfig = EbSerializers.Json_Deserialize <EbDbConfig>(dr["con_obj"].ToString()); cons.DataDbConfig.Id = (int)dr["id"]; } //else if (dr["con_type"].ToString() == EbConnections.EbDATA_RO.ToString()) //{ // cons.DataDbConnection = EbSerializers.Json_Deserialize<EbDataDbConnection>(dr["con_obj"].ToString()); // cons.DataDbConnection.Id = (int)dr["id"]; //} else if (dr["con_type"].ToString() == EbConnectionTypes.EbOBJECTS.ToString()) { cons.ObjectsDbConfig = EbSerializers.Json_Deserialize <EbDbConfig>(dr["con_obj"].ToString()); cons.ObjectsDbConfig.Id = (int)dr["id"]; } else if (dr["con_type"].ToString() == EbConnectionTypes.EbFILES.ToString()) { if (cons.FilesDbConfig == null) { cons.FilesDbConfig = new FilesConfigCollection(); } EbIntegrationConf temp = EbSerializers.Json_Deserialize <EbIntegrationConf>(dr["con_obj"].ToString()); temp.Id = (int)dr["id"]; cons.FilesDbConfig.Integrations.Add(temp); if ((ConPreferences)Convert.ToInt32(dr["preference"]) == ConPreferences.PRIMARY) { cons.FilesDbConfig.DefaultConId = temp.Id; } } else if (dr["con_type"].ToString() == EbConnectionTypes.Chat.ToString()) { if (cons.ChatConfigs == null) { cons.ChatConfigs = new ChatConfigCollection(); } EbSlackConfig temp = EbSerializers.Json_Deserialize <EbSlackConfig>(dr["con_obj"].ToString()); temp.Id = (int)dr["id"]; cons.ChatConfigs.Fallback.Add(temp); if ((ConPreferences)Convert.ToInt32(dr["preference"]) == ConPreferences.PRIMARY) { cons.ChatConfigs.Default = temp; } } else if (dr["con_type"].ToString() == EbConnectionTypes.EbLOGS.ToString()) { cons.LogsDbConfig = EbSerializers.Json_Deserialize <EbDbConfig>(dr["con_obj"].ToString()); cons.LogsDbConfig.Id = (int)dr["id"]; } else if (dr["con_type"].ToString() == EbConnectionTypes.SMTP.ToString()) { if (cons.EmailConfigs == null) { cons.EmailConfigs = new EmailConfigCollection(); } EbEmailConfig temp = EbSerializers.Json_Deserialize <EbEmailConfig>(dr["con_obj"].ToString()); temp.Id = (int)dr["id"]; if ((ConPreferences)Convert.ToInt32(dr["preference"]) == ConPreferences.PRIMARY) { cons.EmailConfigs.Primary = temp; } else if ((ConPreferences)Convert.ToInt32(dr["preference"]) == ConPreferences.FALLBACK) { cons.EmailConfigs.FallBack = temp; } } else if ((dr["con_type"].ToString() == EbConnectionTypes.IMAP.ToString())) { if (cons.EmailConfigs == null) { cons.EmailConfigs = new EmailConfigCollection(); } cons.EmailConfigs?.ImapConfigs.Add(EbSerializers.Json_Deserialize <EbEmailConfig>(dr["con_obj"].ToString())); } else if ((dr["con_type"].ToString() == EbConnectionTypes.POP3.ToString())) { if (cons.EmailConfigs == null) { cons.EmailConfigs = new EmailConfigCollection(); } cons.EmailConfigs?.Pop3Configs.Add(EbSerializers.Json_Deserialize <EbEmailConfig>(dr["con_obj"].ToString())); } else if (dr["con_type"].ToString() == EbConnectionTypes.SMS.ToString()) { if (cons.SMSConfigs == null) { cons.SMSConfigs = new SmsConfigCollection(); } EbSmsConfig temp = EbSerializers.Json_Deserialize <EbSmsConfig>(dr["con_obj"].ToString()); temp.Id = (int)dr["id"]; if ((ConPreferences)Convert.ToInt32(dr["preference"]) == ConPreferences.PRIMARY) { cons.SMSConfigs.Primary = temp; } else if ((ConPreferences)Convert.ToInt32(dr["preference"]) == ConPreferences.FALLBACK) { cons.SMSConfigs.FallBack = temp; } } else if (dr["con_type"].ToString() == EbConnectionTypes.Cloudinary.ToString()) { if (cons.CloudinaryConfigs == null) { cons.CloudinaryConfigs = new CloudinaryConfigCollection(); } EbCloudinaryConfig temp = EbSerializers.Json_Deserialize <EbCloudinaryConfig>(dr["con_obj"].ToString()); temp.Id = (int)dr["id"]; cons.CloudinaryConfigs.Add(temp); } else if (dr["con_type"].ToString() == EbConnectionTypes.AUTHENTICATION.ToString()) { if (cons.AUTHENTICATIONConfigs == null) { cons.AUTHENTICATIONConfigs = new AuthenticationCollection(); } EbfacebbokConfig temp = EbSerializers.Json_Deserialize <EbfacebbokConfig>(dr["con_obj"].ToString()); temp.Id = (int)dr["id"]; cons.AUTHENTICATIONConfigs.Add(temp); } else if (dr["con_type"].ToString() == EbConnectionTypes.MAPS.ToString()) { if (cons.MapConfigs == null) { cons.MapConfigs = new MapConfigCollection(); } EbMapConfig temp = EbSerializers.Json_Deserialize <EbMapConfig>(dr["con_obj"].ToString()); temp.Id = (int)dr["id"]; cons.MapConfigs.Integrations.Add(temp); if ((ConPreferences)Convert.ToInt32(dr["preference"]) == ConPreferences.PRIMARY) { cons.MapConfigs.DefaultConId = temp.Id; } } else if (dr["con_type"].ToString() == EbConnectionTypes.MOBILECONFIG.ToString()) { cons.MobileConfig = EbSerializers.Json_Deserialize <MobileConfig>(dr["con_obj"].ToString()); cons.MobileConfig.Id = (int)dr["id"]; } else if (dr["con_type"].ToString() == EbConnectionTypes.SUPPORTINGDATA.ToString()) { if (cons.SupportingDataDbConfig == null) { cons.SupportingDataDbConfig = new List <EbDbConfig>(); } EbDbConfig temp = EbSerializers.Json_Deserialize <EbDbConfig>(dr["con_obj"].ToString()); temp.Id = (int)dr["id"]; cons.SupportingDataDbConfig.Add(temp); } //else if (dr["con_type"].ToString() == EbConnectionTypes.FTP.ToString()) //{ // cons.FTPConnection = EbSerializers.Json_Deserialize<EbFTPConnection>(dr["con_obj"].ToString()); // cons.FTPConnection.Id = (int)dr["id"]; //}// ... More to come } Redis.Set <EbConnectionsConfig>(string.Format(CoreConstants.SOLUTION_INTEGRATION_REDIS_KEY, request.SolnId), cons); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(request.SolnId + " ConnectionObject Updated"); Console.ForegroundColor = ConsoleColor.White; } } //if (!String.IsNullOrEmpty(request.UserAuthId)) //{ // this.ServerEventClient.BearerToken = request.BToken; // this.ServerEventClient.RefreshToken = request.RToken; // this.ServerEventClient.RefreshTokenUri = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_GET_ACCESS_TOKEN_URL); // this.ServerEventClient.Post(new NotifyUserIdRequest() // { // Msg = "Connection Updated Successfully", // Selector = "cmd.OnConnectionUpdateSuccess", // ToUserAuthId = request.UserAuthId // }); //} } catch (Exception e) { Log.Info("Exception:" + e.ToString()); status = false; res.ResponseStatus = new ResponseStatus { Message = e.Message }; } res.Status = status; return(res); }
public EbCloudinary(EbCloudinaryConfig conf) { _account = new CloudinaryDotNet.Account(conf.Cloud, conf.ApiKey, conf.ApiSecret); InfraConId = conf.Id; }