/// <summary> /// This functions executes query to Cassandra DB TO Save Data . /// </summary> /// <param name="exportList"></param> /// <returns>Returns bool</returns> public bool SaveDataToDb(List<PocoObjectListForExport> exportList) { var conn = new ConnectionToCluster(); var isAvailableKeyspaceNdColumnFamily = false; var keyspaceCollection = conn.FetchKeyspacesfromCluster(); foreach (var parentItem in exportList) { var stringBuilder = new StringBuilder(); isAvailableKeyspaceNdColumnFamily = conn.CheckAvailableKeyspaceName(keyspaceCollection, parentItem); if (!isAvailableKeyspaceNdColumnFamily) continue; isAvailableKeyspaceNdColumnFamily = conn.CheckAvailableColumnFamilyNames(parentItem); if (isAvailableKeyspaceNdColumnFamily) { var tempScript = Reader.ReadPerScriptFromExportList(parentItem); stringBuilder.AppendLine(tempScript); string selectfromstorebyconsumer = stringBuilder.ToString().ToLower(); try { conn.ExceuteDyamicQueriesToCassandraDb(selectfromstorebyconsumer); } catch (Exception) { return isAvailableKeyspaceNdColumnFamily; } } break; } return isAvailableKeyspaceNdColumnFamily; }
/// <summary> /// This Function Connects to Database as DBType Provided. /// </summary> /// <param name="dbType"></param> /// <returns>Returns isConnected</returns> public bool ConnectToDatabase(DatabaseType dbType) { var isConnected = false; switch (dbType) { case DatabaseType.Cassandra: var clusterCon = new ConnectionToCluster(); isConnected = clusterCon.GetConnectionObject(_userNm, _passwrd, _clusterNm); break; case DatabaseType.Mongo: break; case DatabaseType.SimpleDb: break; } return isConnected; }