private void SaveLastConnection( long groupId, long templateId ) { ConnectionType cnnType = SelectedConnectionType; if (cnnType != null) { string machineName = Environment.MachineName; LastConnectionProtocolRow lastConnectionProt = new LastConnectionProtocolRow { GroupId = groupId, TemplateId = templateId, MachineName = machineName, DbType = cnnType.Id }; long?lastConnectionId = this._storage.LastConnectionProtocolTable .SaveLastConnection(lastConnectionProt); if (lastConnectionId != null) { LastConnectionRow lastConnectionRow = new LastConnectionRow { MachineName = machineName, LastConnectionProtocolId = lastConnectionId.Value }; this._storage.LastConnectionTable .SaveLastConnection(lastConnectionRow); } } }
private Dictionary <string, ConnectionInfo> ReadLastConnections(List <ConnectionType> connectionTypes) { Dictionary <string, ConnectionInfo> lastConnections = new Dictionary <string, ConnectionInfo>(); string machineName = Environment.MachineName; foreach (ConnectionType connectionType in connectionTypes) { string cnnType = connectionType.Id; LastConnectionProtocolRow row = this._storage.LastConnectionProtocolTable .GetLastConnection(machineName, cnnType); if (row != null) { ConnectionGroupInfo group = this._connectionsManager.GetGroup(row.GroupId); TemplateRow templateRow = this._storage.TemplateDirectory.GetTemplate(row.TemplateId); if (group != null && templateRow != null) { ConnectionInfo connectionInfo = new ConnectionInfo { TemplateFile = templateRow.Id, TemplateDir = templateRow.Directory, TemplateId = templateRow.Name, ConnectionId = row.Identity, GroupName = group.Name, ConnectionType = cnnType }; lastConnections.Add(cnnType, connectionInfo); } } } return(lastConnections); }