public List <SubjectDTO> GetSubjects() { List <SubjectDTO> oSubjectList = new List <SubjectDTO>(); try { sb.Clear(); sb.Append("SELECT SubjectId, SubjectName"); sb.Append(" FROM [Subject]"); using (CloudConnection connection = new CloudConnection(DMSSWE.Common.ConnectionString)) { connection.CommandText = sb.ToString(); connection.Parameters.Clear(); using (IDataReader dr = connection.ExecuteReader()) { while (dr.Read()) { SubjectDTO oSubject = new SubjectDTO(); oSubject.SubjectId = dr["SubjectId"].ToString(); oSubject.SubjectName = dr["SubjectName"].ToString(); oSubjectList.Add(oSubject); } } } } catch (Exception ex) { throw ex; } return(oSubjectList); }
public bool DeleteGrade(int GradeId, string SubjectId) { bool result = false; try { sb.Clear(); sb.Append("DELETE FROM [Grade]"); sb.Append(" WHERE GradeId =?GradeId AND SubjectId=?SubjectId"); using (CloudConnection connection = new CloudConnection(DMSSWE.Common.ConnectionString)) { connection.CommandText = sb.ToString(); connection.Parameters.Clear(); connection.Parameters.Add(new Parameter { Name = "SubjectId", Value = SubjectId }); connection.Parameters.Add(new Parameter { Name = "GradeId", Value = GradeId }); if (connection.ExecuteQuery() > 0) { result = true; } } } catch (Exception ex) { throw ex; } return(result); }
/// <summary> /// Descarga un archivo del blob /// </summary> private async Task ProcessDownloadAsync(BlockLogModel parent, DownloadBlobSentence sentence) { using (BlockLogModel block = parent.CreateBlock(LogModel.LogType.Info, $"Start downloading from '{sentence.Source.ToString()}'")) { CloudConnection connection = GetConnection(sentence.StorageKey); if (connection == null) { AddError(block, $"Can't find the connection for '{sentence.StorageKey}'"); } else { try { // Descarga el archivo using (ICloudStorageManager manager = new StorageManager().OpenAzureStorageBlob(connection.StorageConnectionString)) { string fileName = Step.Project.GetFullFileName(sentence.FileName); // Crea el directorio LibHelper.Files.HelperFiles.MakePath(System.IO.Path.GetDirectoryName(fileName)); // Descarga el archivo await manager.DownloadAsync(GetContainerName(sentence.Source.Container), sentence.Source.Blob, fileName); } // Log block.Info($"Downloaded file '{sentence.FileName}' to '{sentence.Source.ToString()}'"); } catch (Exception exception) { AddError(block, $"Error when download '{sentence.FileName}' to '{sentence.Source.ToString()}'", exception); } } } }
public void GetTokenExpiryBufferSecondsTest() { string token = TokenHelper.CreateSasToken("azure.devices.net"); TimeSpan timeRemaining = CloudConnection.GetTokenExpiryTimeRemaining("foo.azuredevices.net", token); Assert.True(timeRemaining > TimeSpan.Zero); }
public async Task GetCloudConnectionForIdentityWithKeyTest() { IClientProvider clientProvider = GetMockDeviceClientProviderWithKey(); var tokenProvider = Mock.Of <ITokenProvider>(); var identity = Mock.Of <IIdentity>(i => i.Id == "d1"); var transportSettings = new ITransportSettings[] { new AmqpTransportSettings(TransportType.Amqp_Tcp_Only) }; var messageConverterProvider = new MessageConverterProvider(new Dictionary <Type, IMessageConverter> { [typeof(TwinCollection)] = Mock.Of <IMessageConverter>() }); CloudConnection cloudConnection = await CloudConnection.Create( identity, (_, __) => { }, transportSettings, messageConverterProvider, clientProvider, Mock.Of <ICloudListener>(), tokenProvider, TimeSpan.FromMinutes(60), true, TimeSpan.FromSeconds(20), DummyProductInfo, Option.None <string>()); Option <ICloudProxy> cloudProxy1 = cloudConnection.CloudProxy; Assert.True(cloudProxy1.HasValue); Assert.True(cloudProxy1.OrDefault().IsActive); }
public static CloudConnection CreateAndImplersonateUser(string username, string password) { string target = ConfigurationManager.AppSettings["target"]; string adminUser = ConfigurationManager.AppSettings["adminUsername"].ToString(); string adminPassword = ConfigurationManager.AppSettings["adminPassword"].ToString(); CloudCredentialsEncryption encryptor = new CloudCredentialsEncryption(); SecureString encryptedPassword = CloudCredentialsEncryption.GetSecureString(adminPassword); Uhuru.CloudFoundry.Connection.CloudClient cloudClient = new Connection.CloudClient(); try { cloudClient.CreateUser(adminUser, adminPassword, @"http://" + target); } catch (Uhuru.CloudFoundry.Connection.CloudClientException) { } CloudManager cloudManager = CloudManager.Instance(); CloudTarget cloudTarget = new CloudTarget(adminUser, encryptedPassword, new Uri(@"http://" + target)); CloudConnection cloudConnection = cloudManager.GetConnection(cloudTarget); cloudConnection.CreateUser(username, password); SecureString newPassword = CloudCredentialsEncryption.GetSecureString(password); cloudTarget = new CloudTarget(username, newPassword, new Uri(@"http://" + target)); cloudConnection = cloudManager.GetConnection(cloudTarget); return(cloudConnection); }
public async Task GetCloudConnectionThrowsTest() { var deviceClient = new Mock <IClient>(); deviceClient.SetupGet(dc => dc.IsActive).Returns(true); deviceClient.Setup(dc => dc.CloseAsync()) .Callback(() => deviceClient.SetupGet(dc => dc.IsActive).Returns(false)) .Returns(Task.FromResult(true)); deviceClient.Setup(dc => dc.OpenAsync()).ThrowsAsync(new TimeoutException()); var deviceClientProvider = new Mock <IClientProvider>(); deviceClientProvider.Setup(dc => dc.Create(It.IsAny <IIdentity>(), It.IsAny <ITokenProvider>(), It.IsAny <ITransportSettings[]>())) .Returns(deviceClient.Object); var tokenProvider = Mock.Of <ITokenProvider>(); var identity = Mock.Of <IIdentity>(i => i.Id == "d1"); var transportSettings = new ITransportSettings[] { new AmqpTransportSettings(TransportType.Amqp_Tcp_Only) }; var messageConverterProvider = new MessageConverterProvider(new Dictionary <Type, IMessageConverter> { [typeof(TwinCollection)] = Mock.Of <IMessageConverter>() }); await Assert.ThrowsAsync <TimeoutException>(() => CloudConnection.Create( identity, (_, __) => { }, transportSettings, messageConverterProvider, deviceClientProvider.Object, Mock.Of <ICloudListener>(), tokenProvider, TimeSpan.FromMinutes(60), true, TimeSpan.FromSeconds(20))); }
public async Task UpdateInvalidIdentityWithTokenTest() { var deviceClientProvider = new Mock <IClientProvider>(); deviceClientProvider.SetupSequence(dc => dc.Create(It.IsAny <IIdentity>(), It.IsAny <IAuthenticationMethod>(), It.IsAny <ITransportSettings[]>())) .Returns(GetMockDeviceClient()) .Throws(new UnauthorizedException("Unauthorized")); var transportSettings = new ITransportSettings[] { new AmqpTransportSettings(TransportType.Amqp_Tcp_Only) }; var messageConverterProvider = new MessageConverterProvider(new Dictionary <Type, IMessageConverter> { [typeof(TwinCollection)] = Mock.Of <IMessageConverter>() }); var cloudConnection = new CloudConnection((_, __) => { }, transportSettings, messageConverterProvider, deviceClientProvider.Object, Mock.Of <ICloudListener>(), TokenProvider, DeviceScopeIdentitiesCache, TimeSpan.FromMinutes(60)); IClientCredentials identity1 = GetMockClientCredentialsWithToken(); ICloudProxy cloudProxy1 = await cloudConnection.CreateOrUpdateAsync(identity1); Assert.True(cloudProxy1.IsActive); Assert.Equal(cloudProxy1, cloudConnection.CloudProxy.OrDefault()); IClientCredentials identity2 = GetMockClientCredentialsWithToken(); await Assert.ThrowsAsync <AggregateException>(() => cloudConnection.CreateOrUpdateAsync(identity2)); Assert.True(cloudProxy1.IsActive); Assert.Equal(cloudProxy1, cloudConnection.CloudProxy.OrDefault()); }
public List <StudentMarkCustomDTO> GetStudentmarks() { List <StudentMarkCustomDTO> oStudentMarkList = new List <StudentMarkCustomDTO>(); try { sb.Clear(); sb.Append("SELECT sub.SubjectName,stm.StudentId,stm.Marks FROM dbo.Subject AS sub RIGHT JOIN dbo.StudentMark AS stm ON sub.SubjectId = stm.SubjectId"); sb.Append(""); using (CloudConnection connection = new CloudConnection(DMSSWE.Common.ConnectionString)) { connection.CommandText = sb.ToString(); connection.Parameters.Clear(); using (IDataReader dr = connection.ExecuteReader()) { while (dr.Read()) { StudentMarkCustomDTO oStudentMark = new StudentMarkCustomDTO(); oStudentMark.StudentId = dr["StudentId"].ToString(); oStudentMark.SubjectName = dr["SubjectName"].ToString(); oStudentMark.Marks = Convert.ToInt32(dr["Marks"]); oStudentMarkList.Add(oStudentMark); } } } } catch (Exception ex) { throw ex; } return(oStudentMarkList); }
public async Task RefreshTokenTest() { string iothubHostName = "test.azure-devices.net"; string deviceId = "device1"; IClientCredentials GetClientCredentialsWithExpiringToken() { string token = TokenHelper.CreateSasToken(iothubHostName, DateTime.UtcNow.AddSeconds(10)); var identity = new DeviceIdentity(iothubHostName, deviceId); return(new TokenCredentials(identity, token, string.Empty)); } IAuthenticationMethod authenticationMethod = null; IClientProvider clientProvider = GetMockDeviceClientProviderWithToken((s, a, t) => authenticationMethod = a); var transportSettings = new ITransportSettings[] { new AmqpTransportSettings(TransportType.Amqp_Tcp_Only) }; var receivedStatus = CloudConnectionStatus.ConnectionEstablished; void ConnectionStatusHandler(string id, CloudConnectionStatus status) => receivedStatus = status; var messageConverterProvider = new MessageConverterProvider(new Dictionary <Type, IMessageConverter>()); var cloudConnection = new CloudConnection(ConnectionStatusHandler, transportSettings, messageConverterProvider, clientProvider); IClientCredentials clientCredentialsWithExpiringToken1 = GetClientCredentialsWithExpiringToken(); ICloudProxy cloudProxy1 = await cloudConnection.CreateOrUpdateAsync(clientCredentialsWithExpiringToken1); Assert.True(cloudProxy1.IsActive); Assert.Equal(cloudProxy1, cloudConnection.CloudProxy.OrDefault()); Assert.NotNull(authenticationMethod); var deviceAuthenticationWithTokenRefresh = authenticationMethod as DeviceAuthenticationWithTokenRefresh; Assert.NotNull(deviceAuthenticationWithTokenRefresh); // Wait for the token to expire await Task.Delay(TimeSpan.FromSeconds(10)); Task <string> getTokenTask = deviceAuthenticationWithTokenRefresh.GetTokenAsync(iothubHostName); Assert.False(getTokenTask.IsCompleted); Assert.Equal(receivedStatus, CloudConnectionStatus.TokenNearExpiry); IClientCredentials clientCredentialsWithExpiringToken2 = GetClientCredentialsWithExpiringToken(); ICloudProxy cloudProxy2 = await cloudConnection.CreateOrUpdateAsync(clientCredentialsWithExpiringToken2); // Wait for the task to complete await Task.Delay(TimeSpan.FromSeconds(10)); Assert.Equal(cloudProxy2, cloudConnection.CloudProxy.OrDefault()); Assert.True(cloudProxy2.IsActive); Assert.True(cloudProxy1.IsActive); Assert.Equal(cloudProxy1, cloudProxy2); Assert.True(getTokenTask.IsCompletedSuccessfully); Assert.Equal(getTokenTask.Result, (clientCredentialsWithExpiringToken2 as ITokenCredentials)?.Token); }
public static void ClassInitialize(TestContext context) { directoriesCreated = new List <string>(); target = ConfigurationManager.AppSettings["target"]; username = TestUtil.GenerateAppName() + "@uhurucloud.net"; password = TestUtil.GenerateAppName(); cloudConnection = TestUtil.CreateAndImplersonateUser(username, password); }
public static void ClassInitialize(TestContext context) { directoriesCreated = new List<string>(); target = ConfigurationManager.AppSettings["target"]; username = TestUtil.GenerateAppName() + "@uhurucloud.net"; password = TestUtil.GenerateAppName(); cloudConnection = TestUtil.CreateAndImplersonateUser(username, password); }
public static void ClassInitialize(TestContext context) { directoriesCreated = new List <string>(); target = ConfigurationManager.AppSettings["target"]; cloudTestAppDir = Path.GetFullPath(@"..\..\..\..\src\Uhuru.CloudFoundry.Test\TestApps\MongoTestApp\app"); username = TestUtil.GenerateAppName() + "@uhurucloud.net"; password = TestUtil.GenerateAppName(); cloudConnection = TestUtil.CreateAndImplersonateUser(username, password); }
public static void ClassInitialize(TestContext context) { directoriesCreated = new List<string>(); target = ConfigurationManager.AppSettings["target"]; cloudTestAppDir = Path.GetFullPath(@"..\..\..\..\src\Uhuru.CloudFoundry.Test\TestApps\MongoTestApp\app"); username = TestUtil.GenerateAppName() + "@uhurucloud.net"; password = TestUtil.GenerateAppName(); cloudConnection = TestUtil.CreateAndImplersonateUser(username, password); }
public bool InsertStudentMark(StudentMarkDTO oStudentMarkDTO) { bool result = false; try { sb.Clear(); sb.Append("INSERT INTO [StudentMark]"); sb.Append(" VALUES ("); sb.Append(" ?StudentId,"); sb.Append(" ?SubjectId,"); sb.Append(" ?Marks,"); sb.Append(" ?CreatedBy,"); sb.Append(" ?CreatedDateTime,"); sb.Append(" ?ModifiedBy,"); sb.Append(" ?ModifiedDateTime"); sb.Append(" )"); using (CloudConnection connection = new CloudConnection(DMSSWE.Common.ConnectionString)) { connection.CommandText = sb.ToString(); connection.Parameters.Clear(); connection.Parameters.Add(new Parameter { Name = "StudentId", Value = oStudentMarkDTO.StudentId }); connection.Parameters.Add(new Parameter { Name = "SubjectId", Value = oStudentMarkDTO.SubjectId }); connection.Parameters.Add(new Parameter { Name = "Marks", Value = oStudentMarkDTO.Marks }); connection.Parameters.Add(new Parameter { Name = "CreatedBy", Value = oStudentMarkDTO.CreatedBy }); connection.Parameters.Add(new Parameter { Name = "CreatedDateTime", Value = oStudentMarkDTO.CreatedDateTime }); connection.Parameters.Add(new Parameter { Name = "ModifiedBy", Value = oStudentMarkDTO.ModifiedBy }); connection.Parameters.Add(new Parameter { Name = "ModifiedDateTime", Value = oStudentMarkDTO.ModifiedDateTime }); if (connection.ExecuteQuery() > 0) { result = true; } } } catch (Exception ex) { throw ex; } return(result); }
public override bool OnStart() { ServicePointManager.DefaultConnectionLimit = 12; connection = new CloudConnection(); crawler = new WebCrawler(connection); bool result = base.OnStart(); Trace.TraceInformation("CrawlerWorker has been started"); return(result); }
public bool UpdateGrade(GradeDTO oGradeDTO) { bool result = false; try { sb.Clear(); sb.Append("UPDATE [Grade]"); sb.Append(" SET "); sb.Append(" Description=?Description,"); sb.Append(" SubjectId=?SubjectId,"); sb.Append(" LowerLimit=?LowerLimit,"); sb.Append(" UpperLimit=?UpperLimit,"); sb.Append(" ModifiedBy=?ModifiedBy,"); sb.Append(" ModifiedDateTime=?ModifiedDateTime"); sb.Append(" WHERE GradeId =?GradeId"); using (CloudConnection connection = new CloudConnection(DMSSWE.Common.ConnectionString)) { connection.CommandText = sb.ToString(); connection.Parameters.Clear(); connection.Parameters.Add(new Parameter { Name = "Description", Value = oGradeDTO.Description }); connection.Parameters.Add(new Parameter { Name = "SubjectId", Value = oGradeDTO.SubjectId }); connection.Parameters.Add(new Parameter { Name = "LowerLimit", Value = oGradeDTO.LowerLimit }); connection.Parameters.Add(new Parameter { Name = "UpperLimit", Value = oGradeDTO.UpperLimit }); connection.Parameters.Add(new Parameter { Name = "ModifiedBy", Value = oGradeDTO.ModifiedBy }); connection.Parameters.Add(new Parameter { Name = "ModifiedDateTime", Value = oGradeDTO.ModifiedDateTime }); connection.Parameters.Add(new Parameter { Name = "GradeId", Value = oGradeDTO.GradeId }); if (connection.ExecuteQuery() > 0) { result = true; } } } catch (Exception ex) { throw ex; } return(result); }
public void BuildConnection(CloudSocket cloudSocket, CTSMarker ctsMarker) { CloudConnection cloudConnection = new CloudConnection(cloudSocket); mCloudConnections.Add(cloudConnection); mMarkerToCloudConnectionMap.Add(ctsMarker, cloudConnection); mTcpToCloudSocketMap.Add(ctsMarker, cloudSocket); mCloudToTcpSocketMap.Add(cloudSocket, ctsMarker); }
public void GetIsTokenExpiredTest() { // Arrange DateTime tokenExpiry = DateTime.UtcNow.AddYears(1); string token = TokenHelper.CreateSasToken("azure.devices.net", tokenExpiry); // Act TimeSpan expiryTimeRemaining = CloudConnection.GetTokenExpiryTimeRemaining("azure.devices.net", token); // Assert Assert.True(expiryTimeRemaining - (tokenExpiry - DateTime.UtcNow) < TimeSpan.FromSeconds(1)); }
/// <summary> /// Procesa la sentencia de descarga de una carpeta /// </summary> private async Task ProcessDownloadFolderAsync(BlockLogModel parent, DownloadBlobFolderSentence sentence, CancellationToken cancellationToken) { using (BlockLogModel block = parent.CreateBlock(LogModel.LogType.Info, $"Start downloading from '{sentence.Source.ToString()}'")) { CloudConnection connection = GetConnection(sentence.StorageKey); if (connection == null) { AddError(block, $"Can't find the connection for '{sentence.StorageKey}"); } else { try { string path = Step.Project.GetFullFileName(sentence.Path); string container = GetContainerName(sentence.Source.Container); // Log block.Info($"Start download '{container}/{sentence.Source.Blob}' to '{path}'"); // Crea la carpeta LibHelper.Files.HelperFiles.MakePath(path); // Descarga la carpeta using (ICloudStorageManager manager = new StorageManager().OpenAzureStorageBlob(connection.StorageConnectionString)) { List <LibBlobStorage.Metadata.BlobModel> blobs = await manager.ListBlobsAsync(container, sentence.Source.Blob); foreach (LibBlobStorage.Metadata.BlobModel blob in blobs) { if (blob.Length != 0 && !cancellationToken.IsCancellationRequested) { string fileName = System.IO.Path.Combine(path, blob.LocalFileName); // Log block.Info($"Download '{blob.FullFileName}'"); // Crea el directorio LibHelper.Files.HelperFiles.MakePath(System.IO.Path.GetDirectoryName(fileName)); // Descarga el archivo await manager.DownloadAsync(container, blob.FullFileName, fileName); } } } // Log block.Info($"End download '{container}/{sentence.Source.Blob}' to '{path}'"); } catch (Exception exception) { AddError(block, $"Error when download to '{sentence.Path}'", exception); } } } }
public void TestFixtureSetUp() { target = ConfigurationManager.AppSettings["target"]; umbracoRootDir = ConfigurationManager.AppSettings["umbracoRootDir"]; userName = "******"; password = "******"; //client = new Client(); //client.Target(target); //client.AddUser(userName, password); //client.AddUser("*****@*****.**", "password1234!"); //client.Login(userName, password); cloudConnection = TestUtil.CreateAndImplersonateUser(userName, password); }
/// <summary> /// Procesa una copia de archivos /// </summary> private async Task ProcessCopyAsync(BlockLogModel parent, CopyBlobSentence sentence, CancellationToken cancellationToken) { string processType = sentence.Move ? "move" : "copy"; string blobTarget = sentence.Target.Blob; // Obtiene el nombre del archivo destino si hay que transformarlo en un nombre único if (sentence.TransformFileName) { blobTarget = System.IO.Path.GetFileNameWithoutExtension(sentence.Target.Blob) + $" {DateTime.UtcNow:yyyy-MM-dd HH_mm_ss_ms}" + System.IO.Path.GetExtension(sentence.Target.Blob); } // Procesa la instrucción using (BlockLogModel block = parent.CreateBlock(LogModel.LogType.Info, $"Start {processType} from '{sentence.Source.ToString()}' to '{sentence.Target.Container}/{blobTarget}'")) { CloudConnection connection = GetConnection(sentence.StorageKey); if (connection == null) { AddError(block, $"Can't find the connection for '{sentence.StorageKey}'"); } else { try { // Copia / mueve el archivo using (ICloudStorageManager manager = new StorageManager().OpenAzureStorageBlob(connection.StorageConnectionString)) { if (sentence.Move) { await manager.MoveAsync(GetContainerName(sentence.Source.Container), sentence.Target.Blob, GetContainerName(sentence.Target.Container), blobTarget, cancellationToken); } else { await manager.CopyAsync(GetContainerName(sentence.Source.Container), sentence.Target.Blob, GetContainerName(sentence.Target.Container), blobTarget, cancellationToken); } } // Log block.Info($"End {processType} from '{sentence.Source.ToString()}' to '{sentence.Target.Container}/{blobTarget}'"); } catch (Exception exception) { AddError(block, $"Error when {processType} from '{sentence.Source.ToString()}' to '{sentence.Target.Container}/{blobTarget}'", exception); } } } }
public CoreAttachWindow(IServiceProvider serviceProvider) { var serviceManager = new ServiceManager(); _taskContext = serviceManager.GetJoinableTaskContext(); _dialogUtil = new DialogUtil(); IExtensionOptions options = ((YetiVSIService)serviceManager.RequireGlobalService(typeof(YetiVSIService))) .Options; var managedProcessFactory = new ManagedProcess.Factory(); var progressDialogFactory = new ProgressDialog.Factory(); _cancelableTaskFactory = new CancelableTask.Factory(_taskContext, progressDialogFactory); _coreListRequest = new CoreListRequest.Factory().Create(); var jsonUtil = new JsonUtil(); var credentialConfigFactory = new CredentialConfig.Factory(jsonUtil); var accountOptionLoader = new VsiAccountOptionLoader(options); var credentialManager = new CredentialManager(credentialConfigFactory, accountOptionLoader); _developerAccount = credentialManager.LoadAccount(); IRemoteCommand remoteCommand = new RemoteCommand(managedProcessFactory); _remoteFile = new RemoteFile(managedProcessFactory); var cloudConnection = new CloudConnection(); var sdkConfigFactory = new SdkConfig.Factory(jsonUtil); // NOTE: the lifetime of this CloudRunner is limited to the current CoreAttachWindow. _cloudRunner = new CloudRunner(sdkConfigFactory, credentialManager, cloudConnection, new GgpSDKUtil()); _gameletClientFactory = new GameletClient.Factory(); var sshKeyLoader = new SshKeyLoader(managedProcessFactory); var sshKnownHostsWriter = new SshKnownHostsWriter(); _sshManager = new SshManager(_gameletClientFactory, _cloudRunner, sshKeyLoader, sshKnownHostsWriter, remoteCommand); _debugSessionMetrics = new DebugSessionMetrics( serviceProvider.GetService(typeof(SMetrics)) as IMetrics); _debugSessionMetrics.UseNewDebugSessionId(); _actionRecorder = new ActionRecorder(_debugSessionMetrics); InitializeComponent(); _instanceSelectionWindowFactory = new ProjectInstanceSelection.Factory(); _paramsFactory = new DebugEngine.DebugEngine.Params.Factory(jsonUtil); SelectInstanceOnInit(); }
public List <StudentDTO> SearchStudents(string Searchtext) { List <StudentDTO> oStudentList = new List <StudentDTO>(); try { sb.Clear(); sb.Append("SELECT StudentId, FirstName,LastName,DateodBirth,AddressLine1,AddressLine2,AddressLine3"); sb.Append(" FROM [Student]"); sb.Append(" WHERE FirstName LIKE '%' + ?FirstName + '%' or StudentId LIKE '%' + ?StudentId + '%'"); using (CloudConnection connection = new CloudConnection(DMSSWE.Common.ConnectionString)) { connection.CommandText = sb.ToString(); connection.Parameters.Clear(); connection.Parameters.Add(new Parameter { Name = "FirstName", Value = Searchtext }); connection.Parameters.Add(new Parameter { Name = "StudentId", Value = Searchtext }); using (IDataReader dr = connection.ExecuteReader()) { if (dr != null) { while (dr.Read()) { StudentDTO oStudent = new StudentDTO(); oStudent.StudentId = dr["StudentId"].ToString(); oStudent.FirstName = dr["FirstName"].ToString(); oStudent.LastName = dr["LastName"].ToString(); oStudent.DateodBirth = dr["DateodBirth"].ToString(); oStudent.AddressLine1 = dr["AddressLine1"].ToString(); oStudent.AddressLine2 = dr["AddressLine2"].ToString(); oStudent.AddressLine3 = dr["AddressLine3"].ToString(); oStudentList.Add(oStudent); } } } } } catch (Exception ex) { throw ex; } return(oStudentList); }
public bool UpdateStudentMark(StudentMarkDTO oStudentMarkDTO) { bool result = false; try { sb.Clear(); sb.Append("UPDATE [StudentMark]"); sb.Append(" SET"); sb.Append(" Marks=?Marks,"); sb.Append(" ModifiedBy=?ModifiedBy,"); sb.Append(" ModifiedDateTime=?ModifiedDateTime"); sb.Append(" WHERE StudentId=?StudentId AND SubjectId=?SubjectId"); using (CloudConnection connection = new CloudConnection(DMSSWE.Common.ConnectionString)) { connection.CommandText = sb.ToString(); connection.Parameters.Clear(); connection.Parameters.Add(new Parameter { Name = "StudentId", Value = oStudentMarkDTO.StudentId }); connection.Parameters.Add(new Parameter { Name = "SubjectId", Value = oStudentMarkDTO.SubjectId }); connection.Parameters.Add(new Parameter { Name = "Marks", Value = oStudentMarkDTO.Marks }); connection.Parameters.Add(new Parameter { Name = "ModifiedBy", Value = oStudentMarkDTO.ModifiedBy }); connection.Parameters.Add(new Parameter { Name = "ModifiedDateTime", Value = oStudentMarkDTO.ModifiedDateTime }); if (connection.ExecuteQuery() > 0) { result = true; } } } catch (Exception ex) { throw ex; } return(result); }
public static void DeleteUser(string username, List <string> directoriesCreated) { string target = ConfigurationManager.AppSettings["target"]; CloudCredentialsEncryption encryptor = new CloudCredentialsEncryption(); string adminPassword = ConfigurationManager.AppSettings["adminPassword"].ToString(); SecureString encryptedPassword = CloudCredentialsEncryption.GetSecureString(adminPassword); CloudManager cloudManager = CloudManager.Instance(); CloudTarget cloudTarget = new CloudTarget(ConfigurationManager.AppSettings["adminUsername"].ToString(), encryptedPassword, new Uri("http://" + target)); CloudConnection cloudConnection = cloudManager.GetConnection(cloudTarget); User tempUser = cloudConnection.Users.First(usr => usr.Email == username); tempUser.Delete(); foreach (string str in directoriesCreated) { Directory.Delete(str, true); } }
public void BuildConnection(CloudSocket cloudSocket, CTSMarker ctsMarker) { CloudConnection cloudConnection = new CloudConnection(cloudSocket, ctsMarker); mCloudConnections.Add(cloudConnection); mMarkerToCloudConnectionMap.Add(ctsMarker, cloudConnection); mTcpToCloudSocketMap.Add(ctsMarker, cloudSocket); mCloudToTcpSocketMap.Add(cloudSocket, ctsMarker); //1751578 string recordPath = Application.streamingAssetsPath + "/" + Launcher.instance.GetSceneName + "/history.txt"; Launcher.instance.history.getPath(recordPath); Launcher.instance.history.NewPath(ctsMarker.sessionId); //1751578 }
public List <GradeDTO> SearchGrade(string subjectId, string searchText) { List <GradeDTO> oGradeList = new List <GradeDTO>(); try { sb.Clear(); sb.Append("SELECT GradeId, Description, LowerLimit, UpperLimit"); sb.Append(" FROM [Grade]"); sb.Append(" WHERE SubjectId=?SubjectId AND Description LIKE '%' + ?Description + '%'"); using (CloudConnection connection = new CloudConnection(DMSSWE.Common.ConnectionString)) { connection.CommandText = sb.ToString(); connection.Parameters.Clear(); connection.Parameters.Add(new Parameter { Name = "SubjectId", Value = subjectId }); connection.Parameters.Add(new Parameter { Name = "Description", Value = searchText }); using (IDataReader dr = connection.ExecuteReader()) { if (dr != null) { while (dr.Read()) { GradeDTO oGrade = new GradeDTO(); oGrade.GradeId = Convert.ToInt16(dr["GradeId"]); oGrade.Description = dr["Description"].ToString(); oGrade.LowerLimit = Convert.ToInt16(dr["LowerLimit"].ToString()); oGrade.UpperLimit = Convert.ToInt16(dr["UpperLimit"].ToString()); oGradeList.Add(oGrade); } } } } } catch (Exception ex) { throw ex; } return(oGradeList); }
// Creates a DebugPortSupplier. This will be invoked by Visual Studio based on this class // Guid being in the registry. public DebugPortSupplier() { // Factory creation for the PortSupplier entry point. var serviceManager = new ServiceManager(); IExtensionOptions options = ((YetiVSIService)serviceManager.RequireGlobalService(typeof(YetiVSIService))) .Options; var taskContext = serviceManager.GetJoinableTaskContext(); var debugPropertyFactory = new DebugProperty.Factory(); var debugProgramFactory = new DebugProgram.Factory(debugPropertyFactory, options); var debugProcessFactory = new DebugProcess.Factory(debugProgramFactory); var managedProcessFactory = new ManagedProcess.Factory(); var processListRequestFactory = new ProcessListRequest.Factory(managedProcessFactory); var jsonUtil = new JsonUtil(); var sdkConfigFactory = new SdkConfig.Factory(jsonUtil); var credentialConfigFactory = new CredentialConfig.Factory(jsonUtil); var accountOptionLoader = new VsiAccountOptionLoader(options); var credentialManager = new CredentialManager(credentialConfigFactory, accountOptionLoader); _developerAccount = credentialManager.LoadAccount(); _dialogUtil = new DialogUtil(); var progressDialogFactory = new ProgressDialog.Factory(); _cancelableTaskFactory = new CancelableTask.Factory(taskContext, progressDialogFactory); var cloudConnection = new CloudConnection(); // NOTE: this CloudRunner is re-used for all subsequent Attach to Process windows. _cloudRunner = new CloudRunner(sdkConfigFactory, credentialManager, cloudConnection, new GgpSDKUtil()); var sshKeyLoader = new SshKeyLoader(managedProcessFactory); var sshKnownHostsWriter = new SshKnownHostsWriter(); _gameletClientFactory = new GameletClient.Factory(); var sshManager = new SshManager(_gameletClientFactory, _cloudRunner, sshKeyLoader, sshKnownHostsWriter, new RemoteCommand(managedProcessFactory)); _metrics = (IMetrics)serviceManager.RequireGlobalService(typeof(SMetrics)); _debugPortFactory = new DebugPort.Factory( debugProcessFactory, processListRequestFactory, _cancelableTaskFactory, _dialogUtil, sshManager, _metrics, _developerAccount); }
public WebCrawler(CloudConnection conn) { this.connection = conn; this.ramPerformance = new PerformanceCounter("Memory", "Available MBytes"); this.cpuPerformance = new PerformanceCounter("Process", "% Processor Time", Process.GetCurrentProcess().ProcessName); this.currentState = WorkerState.IDLE; this.worker = new WorkerInfoEntity(WORKER_NAME, cpuPerformance.NextValue() / Environment.ProcessorCount, ramPerformance.NextValue(), currentState); this.connection.UpdateWorkerInfo(this.worker); this.workerStatusCounter = 0; this.disallowedUrls = new List <string>(); this.allowedDomains = new List <string>() { "cnn.com", "bleacherreport.com/articles", "bleacherreport.com/nba/archives", "bleacherreport.com/nba" }; this.visitedUrls = new HashSet <string>(); this.seenUrls = new HashSet <string>(); this.httpClient = new HttpClient(); this.searcher = new PageSearcher(); }
public void SetUp() { filesystem = new MockFileSystem(); filesystem.AddDirectory(Path.GetDirectoryName(credentialPath)); filesystem.AddFile(credentialPath, new MockFileData(credentialData)); filesystem.AddFile(credentialPathBar, new MockFileData(credentialDataBar)); filesystem.AddFile(credentialPathScopes, new MockFileData(credentialDataScopes)); filesystem.AddFile(corruptCredentialPath, new MockFileData(corruptCredentialData)); filesystem.AddFile(emptyCredentialPath, new MockFileData(emptyCredentialData)); filesystem.AddFile(corruptExpiryCredentialPath, new MockFileData(correptExpiryCredentialData)); // Use a partial mock (actually a test spy) for channel factory, because there // is no good way to fake a channel. However, it's safe to create an unused channel! channelFactory = Substitute.ForPartsOf <CloudConnection.ChannelFactory>(); clock = Substitute.For <IClock>(); connection = new CloudConnection(filesystem, channelFactory); }
static async Task GetCloudConnectionTest(Func <IClientCredentials> credentialsGenerator, IClientProvider clientProvider) { var transportSettings = new ITransportSettings[] { new AmqpTransportSettings(TransportType.Amqp_Tcp_Only) }; var messageConverterProvider = new MessageConverterProvider(new Dictionary <Type, IMessageConverter>()); var cloudConnection = new CloudConnection((_, __) => { }, transportSettings, messageConverterProvider, clientProvider); IClientCredentials clientCredentials1 = credentialsGenerator(); ICloudProxy cloudProxy1 = await cloudConnection.CreateOrUpdateAsync(clientCredentials1); Assert.True(cloudProxy1.IsActive); Assert.Equal(cloudProxy1, cloudConnection.CloudProxy.OrDefault()); IClientCredentials clientCredentials2 = credentialsGenerator(); ICloudProxy cloudProxy2 = await cloudConnection.CreateOrUpdateAsync(clientCredentials2); Assert.Equal(cloudProxy2, cloudConnection.CloudProxy.OrDefault()); Assert.True(cloudProxy2.IsActive); Assert.False(cloudProxy1.IsActive); Assert.NotEqual(cloudProxy1, cloudProxy2); }
public ConnectionManager() { _appContext = GwupeClientAppContext.CurrentAppContext; _connection = new CloudConnection(); SaveServers(_connection.Servers); }
public void TestFixtureSetUp() { target = ConfigurationManager.AppSettings["target"]; umbracoRootDir = Path.GetFullPath(@"..\..\..\..\src\Uhuru.CloudFoundry.Test\TestApps\Umbraco\app"); userName = "******"; password = "******"; //client = new Client(); //client.Target(target); //client.AddUser(userName, password); //client.AddUser("*****@*****.**", "password1234!"); //client.Login(userName, password); cloudConnection = TestUtil.CreateAndImplersonateUser(userName, password); }
public void TestFixtureSetup() { cloudConnection = TestUtil.CreateAndImplersonateUser(username, password); }
public static void PushApp(string appName, string sourceDir, string url, List<string> directoriesCreated, CloudConnection cloudConnection, string vendor ,string serviceName, string path) { if (path == null) path = TestUtil.CopyFolderToTemp(sourceDir); directoriesCreated.Add(path); if (serviceName == null) serviceName = appName + "svc"; if (vendor != null) { cloudConnection.CreateProvisionedService(cloudConnection.SystemServices.FirstOrDefault(ss => ss.Vendor == vendor), serviceName, true); Thread.Sleep(10000); } CloudApplication cloudApp = new CloudApplication() { Name = appName, Urls = new string[1] { url }, DeploymentPath = path, Deployable = true, Framework = "dotNet", InstanceCount = 1, Memory = 128, Runtime = "iis", }; PushTracker pushTracker = new PushTracker(); Guid tracker = Guid.NewGuid(); pushTracker.TrackId = tracker; currentJobs.Add(tracker); cloudConnection.PushJob.Start(pushTracker, cloudApp); cloudConnection.PushJob.JobCompleted += new EventHandler<global::System.ComponentModel.AsyncCompletedEventArgs>(PushJob_JobCompleted); while (currentJobs.Contains(tracker)) { Thread.Sleep(1000); } App currentApp = cloudConnection.Apps.FirstOrDefault(app => app.Name == cloudApp.Name); ProvisionedService provisionedService = cloudConnection.ProvisionedServices.FirstOrDefault(ps => ps.Name == serviceName); if (vendor != null) { currentApp.BindService(provisionedService); Thread.Sleep(1000); } currentApp.Start(); int retryCount = 10; while (true) { App pushedApp = cloudConnection.Apps.FirstOrDefault(app => app.Name == cloudApp.Name); if (pushedApp.State == AppState.RUNNING) break; Thread.Sleep(1000); retryCount--; if (retryCount == 0) break; } }
public static void PushApp(string appName, string sourceDir, string url, List<string> directoriesCreated, CloudConnection cloudConnection) { PushApp(appName, sourceDir, url, directoriesCreated, cloudConnection, null, null, null); }