public InsertOperatorCommand(OperatorPart sourceOutput, OperatorPart targetInput, Operator compositionOp, Operator opToInsert, int multiInputIndexAtTarget) { _name = "Insert Operator"; var usedSingleInputs = new List <MetaInput>(); var usedMultiInputsCounter = new Dictionary <MetaInput, int>(); var compositionMeta = opToInsert.Parent.Definition; if (opToInsert.Outputs.Count == 1) { var sourceOp = sourceOutput.Parent; var targetOp = targetInput.Parent; var sourceOpID = (sourceOp.ID == compositionOp.ID) ? Guid.Empty : sourceOp.ID; var targetOpID = (targetOp.ID == compositionOp.ID) ? Guid.Empty : targetOp.ID; var sourceOpPartID = sourceOutput.ID; var targetOpPartID = targetInput.ID; var inputOpType = sourceOutput.Type; Func <FunctionType, bool> isValidInputType = type => inputOpType == type || type == FunctionType.Generic; Func <MetaInput, bool> isInputUsable = input => input.IsMultiInput || !usedSingleInputs.Contains(input); var matchingTargetInput = (from input in opToInsert.Definition.Inputs where isValidInputType(input.OpPart.Type) && isInputUsable(input) select input).FirstOrDefault(); if (matchingTargetInput == null) { return; } // extract previous connection var matchingConnections = (from con in compositionMeta.Connections where con.TargetOpPartID == targetOpPartID && con.TargetOpID == targetOpID select con).ToList(); var prevConnection = matchingConnections[multiInputIndexAtTarget]; // Split existing connections for single selected operators if (prevConnection != null) { var conNewOpToPrevTarget = new MetaConnection(opToInsert.ID, opToInsert.Definition.Outputs[0].ID, prevConnection.TargetOpID, prevConnection.TargetOpPartID); _commands.Add(new RemoveConnectionCommand(compositionMeta, prevConnection, multiInputIndexAtTarget)); _commands.Add(new InsertConnectionCommand(compositionMeta, conNewOpToPrevTarget, multiInputIndexAtTarget)); } // insert new connection var newConnection = new MetaConnection(sourceOpID, sourceOpPartID, opToInsert.ID, matchingTargetInput.ID); int index = 0; if (matchingTargetInput.IsMultiInput) { usedMultiInputsCounter.TryGetValue(matchingTargetInput, out index); usedMultiInputsCounter[matchingTargetInput] = index + 1; } else { usedSingleInputs.Add(matchingTargetInput); } _commands.Add(new InsertConnectionCommand(compositionMeta, newConnection, index)); } }
public void Do() { var metaInput = InputParent.GetMetaInput(InputToPublish); var newMetaInput = metaInput.Clone(); newMetaInput.Name = _newName; var addInputCommand = new AddInputCommand(CompositionOperator, newMetaInput); addInputCommand.Do(); var opPartToUpdate = CompositionOperator.Inputs[CompositionOperator.Inputs.Count - 1]; var func = InputToPublish.Func.Clone() as Utilities.ValueFunction; var updateFuncCommand = new UpdateOperatorPartValueFunctionCommand(opPartToUpdate, func.Value); updateFuncCommand.Do(); var connection = new MetaConnection(Guid.Empty, newMetaInput.ID, InputToPublish.Parent.ID, metaInput.ID); var insertConnectionCommand = new InsertConnectionCommand(CompositionOperator.Definition, connection, 0); insertConnectionCommand.Do(); _commands.Clear(); _commands.AddRange(new ICommand[] { addInputCommand, updateFuncCommand, insertConnectionCommand }); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destType) { if (context != null && value != null) { MetaSource source = context.Instance as MetaSource; if (context.Instance is ReportModel) { source = ((ReportModel)context.Instance).Source; } else if (context.Instance is ReportTask) { source = ((ReportTask)context.Instance).Source; } if (source != null) { if (source is ReportSource && value.ToString() == ReportSource.DefaultRepositoryConnectionGUID) { return(string.Format("{0} ({1})", DefaultRepositoryStr, ((ReportSource)source).RepositoryConnection.Name)); } if (value.ToString() == ReportSource.DefaultReportConnectionGUID) { return(DefaultReportStr); } MetaConnection connection = source.Connections.FirstOrDefault(i => i.GUID == value.ToString()); if (connection != null) { return(connection.Name + (!connection.IsEditable ? " (Repository)" : "")); } } } return(base.ConvertTo(context, culture, value, destType)); }
private string PromptForConnectionString(MetaConnection connection, string currentConnectionString, string initialConnectionString) { MSDASC.DataLinks dataLinks = new MSDASC.DataLinks(); string generatedConnectionString = currentConnectionString; string resultConnectionString = ""; ADODB.Connection dialogConnection = (ADODB.Connection)dataLinks.PromptNew(); if (dialogConnection != null) { connection.UserName = ""; connection.ClearPassword = ""; generatedConnectionString = dialogConnection.ConnectionString.ToString(); if (dialogConnection.Properties["Password"] != null && dialogConnection.Properties["Password"].Value != null && !generatedConnectionString.Contains("Password="******";Password={0}", dialogConnection.Properties["Password"].Value); } foreach (string config in generatedConnectionString.Split(';')) { if (config.StartsWith("User ID=")) { connection.UserName = config.Replace("User ID=", "").Replace("\"", ""); continue; } if (config.StartsWith("Password="******"Password="******""); continue; } if (resultConnectionString != "") { resultConnectionString += ";"; } resultConnectionString += config; } if (!string.IsNullOrEmpty(connection.UserName) && string.IsNullOrEmpty(connection.ClearPassword)) { MessageBox.Show("Note that the Password is empty (Perhaps did you not check the option 'Allow Saving Password')", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } DatabaseType newType = GetDatabaseType(resultConnectionString); if (newType != connection.DatabaseType) { connection.DatabaseType = newType; MessageBox.Show(string.Format("The database type has been set to {0}", newType), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { resultConnectionString = initialConnectionString; } return(resultConnectionString); }
public void Do() { var originalToCopyMap = new Dictionary <Guid, Guid>(); // get top left corner of all ops var topLeft = new Point(double.MaxValue, double.MaxValue); foreach (var opId in _opIdsToCopy) { if (!_sourceCompositionOp.GetVisible(opId)) { continue; } var opEntry = _sourceCompositionOp.Operators[opId]; topLeft.X = Math.Min(topLeft.X, opEntry.Item2.Position.X); topLeft.Y = Math.Min(topLeft.Y, opEntry.Item2.Position.Y); } foreach (var opId in _opIdsToCopy) { var opEntry = _sourceCompositionOp.Operators[opId]; var newOpId = _targetCompositionOp.AddOperator(opEntry.Item1, opEntry.Item2.Clone(), Guid.NewGuid()); _targetCompositionOp.SetPosition(newOpId, _targetCompositionOp.GetPosition(newOpId) - topLeft + _basePosition); originalToCopyMap[opId] = newOpId; } // copy connections var internalConnections = (from con in _sourceCompositionOp.Connections from sourceOpID in _opIdsToCopy from targetOpID in _opIdsToCopy where con.SourceOpID == sourceOpID where con.TargetOpID == targetOpID select con).ToList(); // create a group for each input var groupedConnections = (from con in internalConnections group con by(con.TargetOpID.ToString() + con.TargetOpPartID.ToString()) into @group select @group).ToArray(); // insert the connections to new op foreach (var conGroup in groupedConnections) { int index = 0; foreach (var con in conGroup) { var conBetweenNewOps = new MetaConnection(originalToCopyMap[con.SourceOpID], con.SourceOpPartID, originalToCopyMap[con.TargetOpID], con.TargetOpPartID); _targetCompositionOp.InsertConnectionAt(conBetweenNewOps, index); ++index; } } }
public InsertConnectionCommand(Operator compositionOp, Connection connectionToInsert) { _opMetaID = compositionOp.Definition.ID; _metaConnectionToInsert = new MetaConnection(connectionToInsert); if (_metaConnectionToInsert.SourceOpID == compositionOp.ID) { _metaConnectionToInsert.SourceOpID = Guid.Empty; } if (_metaConnectionToInsert.TargetOpID == compositionOp.ID) { _metaConnectionToInsert.TargetOpID = Guid.Empty; } _connectionIndex = connectionToInsert.Index; }
void setContext(ITypeDescriptorContext context) { _metaConnection = context.Instance as MetaConnection; _metaEnum = context.Instance as MetaEnum; _metaTable = context.Instance as MetaTable; _metaColumn = context.Instance as MetaColumn; _metaJoin = context.Instance as MetaJoin; _reportView = context.Instance as ReportView; _reportOutput = context.Instance as ReportOutput; _reportSchedule = context.Instance as ReportSchedule; _parameter = context.Instance as Parameter; _security = context.Instance as SealSecurity; _emailDevice = context.Instance as OutputEmailDevice; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (!Helper.CheckOLEDBOS()) { return(value); } MetaConnection connection = (MetaConnection)context.Instance; if (value == null || value is string) { value = PromptForConnectionString(connection, connection.FullConnectionString, connection.ConnectionString); } return(value); }
public RemoveConnectionCommand(Operator op, Connection connectionToRemove) { _opMetaID = op.Definition.ID; _metaConnectionToRemove = new MetaConnection(connectionToRemove); if (_metaConnectionToRemove.SourceOpID == op.ID) { _metaConnectionToRemove.SourceOpID = Guid.Empty; } if (_metaConnectionToRemove.TargetOpID == op.ID) { _metaConnectionToRemove.TargetOpID = Guid.Empty; } _connectionIndex = connectionToRemove.Index; }
public static Tuple <bool, string> EvaluateTests(Operator testingOp, string filterPattern) { try { //connect it to a testsevaluator var compositionOp = testingOp.Parent; var evaluatorMetaOpID = Guid.Parse("0316356c-b1fe-490a-89ce-73c8f67ebccc"); var evaluatorMetaOp = MetaManager.Instance.GetMetaOperator(evaluatorMetaOpID); var addOpCmd = new AddOperatorCommand(compositionOp, evaluatorMetaOpID); addOpCmd.Do(); var evaluatorOp = evaluatorMetaOp.GetOperatorInstance(addOpCmd.AddedInstanceID); var connection = new MetaConnection(testingOp.ID, testingOp.Outputs[0].ID, evaluatorOp.ID, evaluatorOp.Inputs[0].ID); var addConnectionCmd = new InsertConnectionCommand(compositionOp.Definition, connection, 0); addConnectionCmd.Do(); //configure the testsevaluator op and start testing var startTestsTriggerOpPart = evaluatorOp.Inputs[1]; var filterOpPart = evaluatorOp.Inputs[3]; //we must create a down flank for the startTestsTrigger value to start the tests properly var updateStartTestsCmd = new UpdateOperatorPartValueFunctionCommand(startTestsTriggerOpPart, new Float(1.0f)); updateStartTestsCmd.Do(); var updateFilterCmd = new UpdateOperatorPartValueFunctionCommand(filterOpPart, new Text(filterPattern)); updateFilterCmd.Do(); evaluatorOp.Outputs[0].Eval(new OperatorPartContext()); updateStartTestsCmd.Value = new Float(0.0f); updateStartTestsCmd.Do(); var resultLog = evaluatorOp.Outputs[0].Eval(new OperatorPartContext()).Text; var result = new Tuple <bool, string>(resultLog.StartsWith(compositionOp.Definition.Name + " : passed"), resultLog); var deleteOperatorCmd = new DeleteOperatorsCommand(compositionOp, new List <Operator>() { evaluatorOp }); deleteOperatorCmd.Do(); return(result); } catch (Exception ex) { Logger.Error("Failed to evaluate operator definition {0}: {1}", testingOp.Name, ex.ToString()); return(new Tuple <bool, string>(false, "")); } }
public void Ctor_InitWithoutIDAndOnlyWithConnectionIDs_AllAreSetCorrectAndIDIsNotEmpty() { var sourceOpID = Guid.NewGuid(); var sourceOpPartID = Guid.NewGuid(); var targetOpID = Guid.NewGuid(); var targetOpPartID = Guid.NewGuid(); var con = new MetaConnection(sourceOpID, sourceOpPartID, targetOpID, targetOpPartID); Assert.AreNotEqual(Guid.Empty, con.ID); Assert.AreEqual(sourceOpID, con.SourceOpID); Assert.AreEqual(sourceOpPartID, con.SourceOpPartID); Assert.AreEqual(targetOpID, con.TargetOpID); Assert.AreEqual(targetOpPartID, con.TargetOpPartID); }
public void Ctor_InitWithIDAndConnectionIDs_AllAreSetCorrect() { var id = Guid.NewGuid(); var sourceOpID = Guid.NewGuid(); var sourceOpPartID = Guid.NewGuid(); var targetOpID = Guid.NewGuid(); var targetOpPartID = Guid.NewGuid(); var con = new MetaConnection(id, sourceOpID, sourceOpPartID, targetOpID, targetOpPartID); Assert.AreEqual(id, con.ID); Assert.AreEqual(sourceOpID, con.SourceOpID); Assert.AreEqual(sourceOpPartID, con.SourceOpPartID); Assert.AreEqual(targetOpID, con.TargetOpID); Assert.AreEqual(targetOpPartID, con.TargetOpPartID); }
void setContext(ITypeDescriptorContext context) { _metaConnection = context.Instance as MetaConnection; _metaEnum = context.Instance as MetaEnum; _metaTable = context.Instance as MetaTable; _metaColumn = context.Instance as MetaColumn; _metaJoin = context.Instance as MetaJoin; _reportView = context.Instance as ReportView; _reportOutput = context.Instance as ReportOutput; _reportSchedule = context.Instance as ReportSchedule; _parameter = context.Instance as Parameter; _security = context.Instance as SealSecurity; _emailDevice = context.Instance as OutputEmailDevice; _fileServerDevice = context.Instance as OutputFileServerDevice; _model = context.Instance as ReportModel; _configuration = context.Instance as SealServerConfiguration; _widget = context.Instance as DashboardWidget; }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { MetaSource source = getSource(context); if (source != null) { if (source is ReportSource && ((ReportSource)source).RepositoryConnection != null && value.ToString() == string.Format("{0} ({1})", DefaultRepositoryStr, ((ReportSource)source).RepositoryConnection.Name)) { return(ReportSource.DefaultRepositoryConnectionGUID); } if (value.ToString() == ReportSource.DefaultReportConnectionGUID) { return(DefaultReportStr); } MetaConnection connection = source.Connections.FirstOrDefault(i => i.Name + (!i.IsEditable ? " (Repository)" : "") == value.ToString()); if (connection != null) { return(connection.GUID); } } return(base.ConvertFrom(context, culture, value)); }
private List <ICommand> SetupSingleAnimation(OperatorPart opPart, double keyframeTime) { var context = new OperatorPartContext() { Time = (float)keyframeTime }; float currentValue = opPart.Eval(context).Value; // this command is needed to restore the original value correctly when undoing this, for doing it it's redundant var setValueCommand = new SetFloatValueCommand(opPart, currentValue); var compOp = opPart.Parent.Parent; var addCurveOpCommand = new AddOperatorCommand(compOp, CurveID, 100, 100, 100, false); var curveOpInstanceId = addCurveOpCommand.AddedInstanceID; var addTimeOpCommand = new AddOperatorCommand(compOp, CurrentTimeID, 100, 100, 100, false); var curveMetaOp = MetaManager.Instance.GetMetaOperator(CurveID); var timeMetaOp = MetaManager.Instance.GetMetaOperator(CurrentTimeID); var timeToCurve = new MetaConnection(addTimeOpCommand.AddedInstanceID, timeMetaOp.Outputs[0].ID, addCurveOpCommand.AddedInstanceID, curveMetaOp.Inputs[0].ID); var connectionTimeToCurveCommand = new InsertConnectionCommand(compOp.Definition, timeToCurve, 0); var curveToCurrent = new MetaConnection(addCurveOpCommand.AddedInstanceID, curveMetaOp.Outputs[0].ID, opPart.Parent.ID, opPart.ID); var connectionCurveToCurrentCommand = new InsertConnectionCommand(compOp.Definition, curveToCurrent, 0); var addKeyframeCommand = new AddOrUpdateKeyframeCommand(keyframeTime, currentValue, compOp, curveOpInstanceId, curveMetaOp.Inputs[0].ID); return(new List <ICommand>() { setValueCommand, addCurveOpCommand, addTimeOpCommand, connectionTimeToCurveCommand, connectionCurveToCurrentCommand, addKeyframeCommand }); }
public void ExecuteNonQuery(MetaConnection connection, string sql, string commandsSeparator = null) { ExecuteNonQuery(connection.ConnectionType, connection.FullConnectionString, sql, commandsSeparator); }
public DataTable LoadDataTable(MetaConnection connection, string sql) { return(LoadDataTable(connection.ConnectionType, connection.FullConnectionString, sql)); }
private string PromptForConnectionString(MetaConnection connection, string currentConnectionString, string initialConnectionString) { // Try with DataConnectionDialog, but unable to select OleDbSource first... we keep MSDASC :-( //Update with VS 2017, still no easy/standard way to do it... we keep MSDASC :-( /* DataConnectionDialog dcd = new DataConnectionDialog(); * * DataSource.AddStandardDataSources(dcd); * dcd.SelectedDataSource = DataSource.OdbcDataSource; * * // dcd.DataSources.Add(DataSource.OdbcDataSource); * // dcd.DataSources.Add(DataSource.); * * if (DataConnectionDialog.Show(dcd) == DialogResult.OK) * { * } * */ MSDASC.DataLinks dataLinks = new MSDASC.DataLinks(); string generatedConnectionString = currentConnectionString; string resultConnectionString = ""; ADODB.Connection dialogConnection = (ADODB.Connection)dataLinks.PromptNew(); if (dialogConnection != null) { connection.UserName = ""; connection.ClearPassword = ""; generatedConnectionString = dialogConnection.ConnectionString.ToString(); if (dialogConnection.Properties["Password"] != null && dialogConnection.Properties["Password"].Value != null && !generatedConnectionString.Contains("Password="******";Password={0}", dialogConnection.Properties["Password"].Value); } foreach (string config in generatedConnectionString.Split(';')) { if (config.StartsWith("User ID=")) { connection.UserName = config.Replace("User ID=", "").Replace("\"", ""); continue; } if (config.StartsWith("Password="******"Password="******""); continue; } if (resultConnectionString != "") { resultConnectionString += ";"; } resultConnectionString += config; } if (!string.IsNullOrEmpty(connection.UserName) && string.IsNullOrEmpty(connection.ClearPassword)) { MessageBox.Show("Note that the Password is empty (Perhaps did you not check the option 'Allow Saving Password')", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } DatabaseType newType = GetDatabaseType(resultConnectionString); if (newType != connection.DatabaseType) { connection.DatabaseType = newType; MessageBox.Show(string.Format("The database type has been set to {0}", newType), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { resultConnectionString = initialConnectionString; } return(resultConnectionString); }
public void ExecuteNonQuery(MetaConnection connection, string sql, string commandsSeparator = null) { DatabaseHelper.ExecuteNonQuery(connection, sql, commandsSeparator); }
public object ExecuteScalar(MetaConnection connection, string sql) { return(DatabaseHelper.ExecuteScalar(connection, sql)); }
public DataTable LoadDataTable(MetaConnection connection, string sql) { return(DatabaseHelper.LoadDataTable(connection, sql)); }
public object ExecuteScalar(MetaConnection connection, string sql) { return(DatabaseHelper.ExecuteScalar(connection.ConnectionType, connection.FullConnectionString, sql, true)); }
public RemoveConnectionCommand(MetaOperator metaOp, MetaConnection connectionToRemove, int index) { _opMetaID = metaOp.ID; _metaConnectionToRemove = connectionToRemove; _connectionIndex = index; }
public object ExecuteScalar(MetaConnection connection, string sql) { return(ExecuteScalar(connection.ConnectionType, connection.FullConnectionString, sql)); }
public DuplicateOperatorsCommand(MetaOperator sourceCompositionOp, MetaOperator targetCompositionOp, IEnumerable <Operator> opsToDuplicate) { _name = "Duplicate Operators"; _commands = new List <ICommand>(); var offset = new Point(100, 100); var originalToCopyMap = new Dictionary <Guid, Guid>(); var toDuplicate = opsToDuplicate as Operator[] ?? opsToDuplicate.ToArray(); foreach (var op in toDuplicate) { var position = new Point(op.Position.X + offset.X, op.Position.Y + offset.Y); // copy op var addOperatorCmd = new AddOperatorCommand(targetCompositionOp, op.Definition.ID, position.X, position.Y, op.Width, op.Visible); foreach (var state in sourceCompositionOp.Operators[op.ID].Item2.OperatorPartStates) { addOperatorCmd.OperatorPartStates.Add(state.Key, state.Value.Clone()); } originalToCopyMap[op.ID] = addOperatorCmd.AddedInstanceID; _commands.Add(addOperatorCmd); // copy op properties var updatePropertiesCmd = new UpdateOperatorPropertiesCommand(op.Definition.ID, addOperatorCmd.AddedInstanceID, new UpdateOperatorPropertiesCommand.Entry(op) { Position = position }); _commands.Add(updatePropertiesCmd); // copy input parameters foreach (var input in op.Inputs) { if (!input.IsDefaultFuncSet) { // if default func is not set update the input value var value = (input.Func as Utilities.ValueFunction).Value; // var setInputValueCmd = new UpdateOperatorPartValueFunctionCommand(op.Definition.ID, addOperatorCmd.AddedInstanceID, input.ID, // true, value); // _commands.Add(setInputValueCmd); } } } // copy connections between duplicated ops // first get the connections between the original ops var internalConnections = from con in sourceCompositionOp.Connections from sourceOp in toDuplicate from targetOp in toDuplicate where con.SourceOpID == sourceOp.ID where con.TargetOpID == targetOp.ID select con; // sort them as stored in parent op in order to preserve multi input order var allConnectionsSorted = new List <MetaConnection>(); // these are later on needed to restore multi input order! foreach (var con in sourceCompositionOp.Connections) { if (internalConnections.Contains(con)) { allConnectionsSorted.Add(con); } } // create a group for each input var groupedConnections = (from con in allConnectionsSorted group con by(con.TargetOpID.ToString() + con.TargetOpPartID.ToString()) into g select g).ToList(); // insert the connections to new op foreach (var conGroup in groupedConnections) { var index = 0; foreach (var con in conGroup) { var conBetweenNewOps = new MetaConnection(originalToCopyMap[con.SourceOpID], con.SourceOpPartID, originalToCopyMap[con.TargetOpID], con.TargetOpPartID); _commands.Add(new InsertConnectionCommand(targetCompositionOp, conBetweenNewOps, index)); index++; } } }
public AddOperatorAndConnectToInputsCommand(Operator compositionOp, MetaOperator metaOpToAdd, IEnumerable <Operator> inputOps, Point position) { _name = "Add Operator And Connect"; var addOperatorCommand = new AddOperatorCommand(compositionOp, metaOpToAdd.ID); _commands.Add(addOperatorCommand); var addedInstanceID = addOperatorCommand.AddedInstanceID; double maxY = Double.NegativeInfinity; double sumX = 0; var connectedOps = new List <Operator>(); var usedSingleInputs = new List <MetaInput>(); var usedMultiInputsCounter = new Dictionary <MetaInput, int>(); // select usable input ops, the ones with at least one output - for now var usableInputOps = from op in inputOps where op.Outputs.Count > 0 select op; foreach (var inputOp in usableInputOps) { maxY = Math.Max(maxY, inputOp.Position.Y); sumX += inputOp.Position.X; var sourceOpID = inputOp.ID; var sourceOpPartID = inputOp.Outputs[0].ID; var inputOpType = inputOp.Definition.Outputs[0].OpPart.Type; Func <FunctionType, bool> isValidInputType = type => { return(inputOpType == type || type == FunctionType.Generic); }; Func <MetaInput, bool> isInputUsable = input => { return(input.IsMultiInput || !usedSingleInputs.Contains(input)); }; var matchingTargetInput = (from input in metaOpToAdd.Inputs where isValidInputType(input.OpPart.Type) && isInputUsable(input) select input).FirstOrDefault(); if (matchingTargetInput == null) { continue; // try next input op } var prevConnection = (from con in compositionOp.Definition.Connections where con.SourceOpPartID == sourceOpPartID && con.SourceOpID == sourceOpID select con).FirstOrDefault(); // Split existing connections for single selected operators if (prevConnection != null && inputOps.Count() == 1) { var firstOccuranceOfTargetOpID = compositionOp.Definition.Connections.FindIndex(con => (con.TargetOpID == prevConnection.TargetOpID) && (con.TargetOpPartID == prevConnection.TargetOpPartID)); var idxOfPrevConnection = compositionOp.Definition.Connections.FindIndex(con => (con.SourceOpID == prevConnection.SourceOpID) && (con.SourceOpPartID == prevConnection.SourceOpPartID) && (con.TargetOpID == prevConnection.TargetOpID) && (con.TargetOpPartID == prevConnection.TargetOpPartID)); int multiInputIdx = idxOfPrevConnection - firstOccuranceOfTargetOpID; var conNewOpToPrevTarget = new MetaConnection(addedInstanceID, metaOpToAdd.Outputs[0].ID, prevConnection.TargetOpID, prevConnection.TargetOpPartID); _commands.Add(new RemoveConnectionCommand(compositionOp.Definition, prevConnection, multiInputIdx)); _commands.Add(new InsertConnectionCommand(compositionOp.Definition, conNewOpToPrevTarget, multiInputIdx)); } // insert new connection var newConnection = new MetaConnection(sourceOpID, sourceOpPartID, addedInstanceID, matchingTargetInput.ID); int index = 0; if (matchingTargetInput.IsMultiInput) { usedMultiInputsCounter.TryGetValue(matchingTargetInput, out index); usedMultiInputsCounter[matchingTargetInput] = index + 1; } else { usedSingleInputs.Add(matchingTargetInput); } _commands.Add(new InsertConnectionCommand(compositionOp.Definition, newConnection, index)); connectedOps.Add(inputOp); } var posX = position.X; var posY = position.Y; var width = 100.0; // Position above connected inputs operators if (connectedOps.Count == 0) { // find free position in center } else if (connectedOps.Count == 1) { posX = connectedOps[0].Position.X; posY = connectedOps[0].Position.Y - 25; addOperatorCommand.Width = width; } else if (connectedOps.Count > 1) { posX = sumX / inputOps.Count(); posY = maxY - 40; } addOperatorCommand.Position = new Point(posX, posY); }
public bool LoadTableFromExternalSource(MetaConnection sourceConnection, string sourceSelectStatement, string destinationTableName, bool useAllConnections = false, string sourceCheckSelect = "", string destinationCheckSelect = "") { bool result = false; try { LogMessage("Starting Loading Table using '{0}'", sourceSelectStatement); DataTable table = null; foreach (var connection in _task.Source.Connections.Where(i => useAllConnections || i.GUID == _task.Connection.GUID)) { if (_task.CancelReport) { break; } LogMessage("Importing table for connection '{0}'.", connection.Name); bool doIt = true; if (!string.IsNullOrEmpty(sourceCheckSelect) && !string.IsNullOrEmpty(destinationCheckSelect)) { LogMessage("Checking if load is required using '{0}' and '{1}'", sourceCheckSelect, destinationCheckSelect); doIt = false; try { DataTable checkTable1 = LoadDataTable(sourceConnection, sourceCheckSelect); if (_task.CancelReport) { break; } DataTable checkTable2 = LoadDataTable(connection, destinationCheckSelect); if (_task.CancelReport) { break; } if (!DatabaseHelper.AreTablesIdentical(checkTable1, checkTable2)) { doIt = true; } } catch { doIt = true; } } if (doIt && !_task.CancelReport) { result = true; var sourceSelect = _task.Repository.ReplaceRepositoryKeyword(sourceSelectStatement); if (DatabaseHelper.LoadBurstSize > 0 && !string.IsNullOrEmpty(DatabaseHelper.LoadSortColumn)) { //Load big tables... int lastIndex = 0; while (true) { if (_task.CancelReport) { break; } string sql = string.Format("select * from (select ROW_NUMBER() over (order by {0}) rn, a.* from ({1}) a) b where rn > {2} and rn <= {3}", DatabaseHelper.LoadSortColumn, sourceSelect, lastIndex, lastIndex + DatabaseHelper.LoadBurstSize); table = LoadDataTable(sourceConnection, sql); if (table.Rows.Count == 0) { break; } table.TableName = destinationTableName; var dbCommand = _task.GetDbCommand(connection); try { if (lastIndex == 0) { LogMessage("Dropping and creating table '{1}' in '{0}'", connection.Name, destinationTableName); DatabaseHelper.SetDatabaseDefaultConfiguration(connection.DatabaseType); DatabaseHelper.CreateTable(dbCommand, table); } LogMessage("Copying {0} rows in '{1}' for index {2} to {3}", table.Rows.Count, destinationTableName, lastIndex, lastIndex + DatabaseHelper.LoadBurstSize); DatabaseHelper.InsertTable(dbCommand, table, connection.DateTimeFormat, false); lastIndex += DatabaseHelper.LoadBurstSize; } finally { dbCommand.Connection.Close(); } } } else { if (table == null) { table = LoadDataTable(sourceConnection, sourceSelect); table.TableName = destinationTableName; } var dbCommand = _task.GetDbCommand(connection); try { LogMessage("Dropping and creating table '{1}' in '{0}'", connection.Name, destinationTableName); DatabaseHelper.SetDatabaseDefaultConfiguration(connection.DatabaseType); DatabaseHelper.CreateTable(dbCommand, table); LogMessage("Copying {0} rows in '{1}'", table.Rows.Count, destinationTableName); DatabaseHelper.InsertTable(dbCommand, table, connection.DateTimeFormat, false); } finally { dbCommand.Connection.Close(); } } } else { LogMessage("No import done"); } } } finally { LogDebug(); } return(result); }
private void BuildTree(Operator fbxOp, List <ICommand> importFbxCommandList, Operator parent, OperatorPart input, Node node, double x, double y, string rootName = "") { Guid metaIDToAdd = GetIDOfNode(node); var newOpName = ""; if (node is Group) { newOpName = "+ " + node.Name; } else if (node is Transform) { newOpName = "Transform"; } else if (node is TransformMatrix) { newOpName = "TransformMatrix"; } else if (node is Material) { newOpName = "Material"; } else { newOpName = node.Name; } if (parent == null) { newOpName += rootName; } var addOperatorCommand = new AddOperatorCommand(fbxOp, metaIDToAdd, x, y, TreeWidth(node), true, newOpName); importFbxCommandList.Add(addOperatorCommand); addOperatorCommand.Do(); var newOp = (from o in fbxOp.InternalOps where addOperatorCommand.AddedInstanceID == o.ID select o).Single(); SetupValues(newOp, node); if (input != null) { var newConnection = new MetaConnection(newOp.ID, newOp.Outputs[0].ID, parent == null ? Guid.Empty : parent.ID, input.ID); var firstOccuranceOfTargetOpID = fbxOp.Definition.Connections.FindIndex(con => (con.TargetOpID == newConnection.TargetOpID) && (con.TargetOpPartID == newConnection.TargetOpPartID)); var lastOccuranceOfTargetOpID = fbxOp.Definition.Connections.FindLastIndex(con => (con.TargetOpID == newConnection.TargetOpID) && (con.TargetOpPartID == newConnection.TargetOpPartID)); int index = 0; if (firstOccuranceOfTargetOpID > -1 && lastOccuranceOfTargetOpID > -1) { index = lastOccuranceOfTargetOpID - firstOccuranceOfTargetOpID + 1; } var addConnectionCommand = new InsertConnectionCommand(fbxOp.Definition, newConnection, index); addConnectionCommand.Do(); importFbxCommandList.Add(addConnectionCommand); } double childX = 0; foreach (Node child in node.Children) { BuildTree(fbxOp, importFbxCommandList, newOp, newOp.Inputs[0], child, x + childX, y + CompositionGraphView.GRID_SIZE); childX += TreeWidth(child); } }
public InsertConnectionCommand(MetaOperator compositionMetaOp, MetaConnection connectionToInsert, int index) { _opMetaID = compositionMetaOp.ID; _metaConnectionToInsert = connectionToInsert; _connectionIndex = index; }