public static tblConnector ConvertDTOToTable(ConnectorDTO _dtoConnector) { tblConnector _tblConnector = new tblConnector(); _tblConnector.ID = _dtoConnector.ConnectionID; _tblConnector.Connection_Name = _dtoConnector.ConnectionName; _tblConnector.User_Name = StringEncryDecry.Encrypt(_dtoConnector.ServerUserName, _dtoConnector.SessionId); _tblConnector.Password = StringEncryDecry.Encrypt(_dtoConnector.ServerPassword, _dtoConnector.SessionId); _tblConnector.Server_Name = StringEncryDecry.Encrypt(_dtoConnector.ServerOrIP, _dtoConnector.SessionId); _tblConnector.Port_Number = _dtoConnector.PortNumber; _tblConnector.Data_Connector_Connection_Type = _dtoConnector.DataConnectorType.ToString(); _tblConnector.Gateway_Type = _dtoConnector.DataConnectorType.ToString(); _tblConnector.Is_Active = _dtoConnector.IsActive; _tblConnector.SessionID = _dtoConnector.SessionId; _tblConnector.Database_Name = _dtoConnector.DatabaseName; _tblConnector.Default_Path = _dtoConnector.DefaultPath; if (_dtoConnector.Mode != null) { _tblConnector.FTP_Mode = _dtoConnector.Mode.ToString(); } return(_tblConnector); }
public static ConnectorDTO ConvertTableToDTO(tblConnector _tblConnector) { ConnectorDTO _dtoConnector = new ConnectorDTO(); _dtoConnector.ConnectionID = _tblConnector.ID; _dtoConnector.ConnectionName = _tblConnector.Connection_Name; _dtoConnector.ServerUserName = StringEncryDecry.Decrypt(_tblConnector.User_Name, _tblConnector.SessionID); _dtoConnector.ServerPassword = StringEncryDecry.Decrypt(_tblConnector.Password, _tblConnector.SessionID); _dtoConnector.ServerOrIP = StringEncryDecry.Decrypt(_tblConnector.Server_Name, _tblConnector.SessionID); _dtoConnector.PortNumber = _tblConnector.Port_Number; _dtoConnector.DataConnectorType = (DataSouceConnectionType)Enums.TryParse(typeof(DataSouceConnectionType), _tblConnector.Data_Connector_Connection_Type.ToString()); _dtoConnector.GatewayType = (DataGatewayType)Enums.TryParse(typeof(DataGatewayType), _tblConnector.Gateway_Type.ToString()); _dtoConnector.IsActive = _tblConnector.Is_Active; _dtoConnector.SessionId = _tblConnector.SessionID; _dtoConnector.DatabaseName = _tblConnector.Database_Name; _dtoConnector.DefaultPath = _tblConnector.Default_Path; if (_tblConnector.FTP_Mode != null) { _dtoConnector.Mode = (FTPMode)Enums.TryParse(typeof(FTPMode), _tblConnector.FTP_Mode); } return(_dtoConnector); }
private void saveFTPConnection() { try { //_dbcontext = new InnonAnalyticsEngineEntities(); tblConnector objtblConnector = _dbcontext.tblConnectors.SingleOrDefault(t => t.ID == this._connectorDTO.ConnectionID); if (objtblConnector == null) { ConnectorDTO.ConvertDTOToTable(this._connectorDTO, ref objtblConnector); _dbcontext.tblConnectors.Add(objtblConnector); //ConnectorConvert.ConvertDTOtoTable(this._dataconnector, ref objtblConnector); //_dbcontext.tblConnectors.Add(objtblConnector); } else { ConnectorDTO.ConvertDTOToTable(this._connectorDTO, ref objtblConnector); } _dbcontext.SaveChanges(); } catch (Exception ex) { throw ex; } }
public static ConnectorCredentialDTO ConvertTableToConnectorCredentialDTO(tblConnector objtblConnector) { return(new ConnectorCredentialDTO { PortNumber = objtblConnector.Port_Number, ServerOrIP = objtblConnector.Server_Name, ServerPassword = objtblConnector.Password, ServerUserName = objtblConnector.User_Name }); }
public static ExistingConnectionNameDTO ConvertTableToDTO(tblConnector _tblConnector) { ExistingConnectionNameDTO _dtoExistingConnection = new ExistingConnectionNameDTO(); _dtoExistingConnection.ConnectionID = _tblConnector.ID; _dtoExistingConnection.ConnectionName = _tblConnector.Connection_Name; _dtoExistingConnection.DataConnectorType = (DataSouceConnectionType)Enums.TryParse(typeof(DataSouceConnectionType), _tblConnector.Data_Connector_Connection_Type.ToString()); _dtoExistingConnection.IsActive = _tblConnector.Is_Active; return(_dtoExistingConnection); }
public static DataConnectorsDTO ConvertTableToDTO(tblConnector objDbtbl) { DataConnectorsDTO objDataConnectorDTO = new DataConnectorsDTO(); objDataConnectorDTO.ConnectorCredential.ServerUserName = StringEncryDecry.Decrypt(objDbtbl.User_Name, objDbtbl.SessionID); objDataConnectorDTO.ConnectorCredential.ServerPassword = StringEncryDecry.Decrypt(objDbtbl.Password, objDbtbl.SessionID); objDataConnectorDTO.ConnectorCredential.ServerOrIP = StringEncryDecry.Decrypt(objDbtbl.Server_Name, objDbtbl.SessionID); objDataConnectorDTO.ConnectorCredential.PortNumber = objDbtbl.Port_Number; objDataConnectorDTO.NameofConnection = DescriptionConvert.DescriptionConvertDTOToTbl(objDbtbl.tblDescription); objDataConnectorDTO.ID = objDbtbl.ID; if (Enum.IsDefined(typeof(DataSouceConnectionType), objDbtbl.Data_Connector_Connection_Type)) { objDataConnectorDTO.DataConnectorConnectionType = (DataSouceConnectionType)Enum.Parse(typeof(DataSouceConnectionType), objDbtbl.Data_Connector_Connection_Type); switch ((DataSouceConnectionType)Enum.Parse(typeof(DataSouceConnectionType), objDbtbl.Data_Connector_Connection_Type)) { case DataSouceConnectionType.Database: objDataConnectorDTO.objConnectionDatabaseDTO = new ConnectionDataBaseDTO(); objDataConnectorDTO.objConnectionDatabaseDTO.strDatabaseName = objDbtbl.Database_Name; break; case DataSouceConnectionType.API: objDataConnectorDTO.objConnectionAPIDTO = new ConnectionAPIDTO(); throw new NotImplementedException(); case DataSouceConnectionType.FTP: objDataConnectorDTO.objConnectionFTPDTO = new ConnectionFTPDTO(); objDataConnectorDTO.objConnectionFTPDTO.DefaultFolder = objDbtbl.Default_Path; FTPMode enumFTPMode; if (Enum.TryParse(objDbtbl.FTP_Mode, out enumFTPMode)) { objDataConnectorDTO.objConnectionFTPDTO.Mode = enumFTPMode; } else { throw new Exception(string.Format(Resources.FTPModeTypeInvalid + "- {0}" + objDbtbl.tblDescription.tblLanguageDescriptions.FirstOrDefault().Short_Desription)); } break; default: throw new Exception(string.Format(Resources.DataSouceConnectionTypeInvalid + "- {0}" + objDbtbl.tblDescription.tblLanguageDescriptions.FirstOrDefault().Short_Desription)); } } else { throw new DataConnectorExcetion(Resources.DataSouceConnectionTypeInvalid); // Handle values not in enum here if needed } return(objDataConnectorDTO); }
/// <summary> /// Get connection by ConnectorID this is for general use /// </summary> /// <param name="ConnectorID"></param> /// <returns>ExistingConnectionNameDTO</returns> public ExistingConnectionNameDTO GetExistingConnectionGeneralInfoById(int ConnectorID) { try { //_dbcontext = new InnonAnalyticsEngineEntities(); tblConnector objtblConnector = _dbcontext.tblConnectors.SingleOrDefault(s => s.ID == ConnectorID); if (objtblConnector == null) { throw new ConnectorException(Resources.ConnectorNotFound); } return(ExistingConnectionNameDTO.ConvertTableToDTO(objtblConnector)); } catch { throw; } }
public static void ConvertDTOtoTable(DataConnectorsDTO objConnectorDTO, ref tblConnector objConnector) { if (objConnector == null) { objConnector = new tblConnector(); } objConnector.Data_Connector_Connection_Type = objConnectorDTO.DataConnectorConnectionType.ToString(); if (objConnectorDTO.DataConnectorConnectionType == DataSouceConnectionType.Database) { objConnector.Database_Name = objConnectorDTO.objConnectionDatabaseDTO.strDatabaseName; } else if (objConnectorDTO.DataConnectorConnectionType == DataSouceConnectionType.API) { throw new NotImplementedException(); } else if (objConnectorDTO.DataConnectorConnectionType == DataSouceConnectionType.FTP) { objConnector.Default_Path = objConnectorDTO.objConnectionFTPDTO.DefaultFolder; objConnector.FTP_Mode = objConnectorDTO.objConnectionFTPDTO.Mode.ToString(); } else { throw new DataConnectorExcetion(Resources.DataSouceConnectionTypeInvalid); } objConnector.ID = objConnectorDTO.ID; objConnector.User_Name = StringEncryDecry.Encrypt(objConnectorDTO.ConnectorCredential.ServerUserName, objConnectorDTO.SessionId); objConnector.Password = StringEncryDecry.Encrypt(objConnectorDTO.ConnectorCredential.ServerPassword, objConnectorDTO.SessionId); objConnector.Server_Name = StringEncryDecry.Encrypt(objConnectorDTO.ConnectorCredential.ServerOrIP, objConnectorDTO.SessionId); objConnector.Port_Number = objConnectorDTO.ConnectorCredential.PortNumber; objConnector.SessionID = objConnectorDTO.SessionId; //if (objConnector.tblDescription == null) // objConnector.tblDescription = new tblDescription(); tblDescription objtblDescription = objConnector.tblDescription; DescriptionConvert.DescriptionConvertDTOToTbl(objConnectorDTO.NameofConnection, ref objtblDescription); objConnector.tblDescription = objtblDescription; }