-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AddInstanceParam and AddTypeParam are added. (#15)
- Loading branch information
Showing
33 changed files
with
516 additions
and
759,547 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Autodesk.DataExchange.ConsoleApp.Commands.Options; | ||
using Autodesk.DataExchange.ConsoleApp.Helper; | ||
using Autodesk.DataExchange.ConsoleApp.Interfaces; | ||
using Autodesk.DataExchange.DataModels; | ||
|
||
namespace Autodesk.DataExchange.ConsoleApp.Commands | ||
{ | ||
internal class AddInstanceParamCommand : AddParamCommand | ||
{ | ||
public AddInstanceParamCommand(IConsoleAppHelper consoleAppHelper) : base(consoleAppHelper) | ||
{ | ||
this.IsInstanceParameter = true; | ||
this.Name = "AddInstanceParameter"; | ||
Description = "Add instance parameters to element."; | ||
} | ||
|
||
public AddInstanceParamCommand(AddInstanceParamCommand addTypeParamCommand) : base(addTypeParamCommand) | ||
{ | ||
this.IsInstanceParameter = addTypeParamCommand.IsInstanceParameter; | ||
} | ||
|
||
public override Command Clone() | ||
{ | ||
return new AddInstanceParamCommand(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Autodesk.DataExchange.ConsoleApp.Commands.Options; | ||
using Autodesk.DataExchange.ConsoleApp.Helper; | ||
using Autodesk.DataExchange.ConsoleApp.Interfaces; | ||
using Autodesk.DataExchange.DataModels; | ||
|
||
namespace Autodesk.DataExchange.ConsoleApp.Commands | ||
{ | ||
internal abstract class AddParamCommand : Command | ||
{ | ||
public bool IsInstanceParameter = false; | ||
public AddParamCommand(IConsoleAppHelper consoleAppHelper) : base(consoleAppHelper) | ||
{ | ||
Options = new List<CommandOption> | ||
{ | ||
new ExchangeTitle(), | ||
new ElementId(), | ||
new ParameterName(), | ||
new ParameterValue(), | ||
new ParameterValueDataType() | ||
}; | ||
} | ||
|
||
public AddParamCommand(AddParamCommand addParamCommand) : base(addParamCommand) | ||
{ | ||
} | ||
|
||
public override Task<bool> Execute() | ||
{ | ||
if (this.ValidateOptions() == false) | ||
{ | ||
Console.WriteLine("Invalid inputs!!!"); | ||
return Task.FromResult(false); | ||
} | ||
|
||
var exchangeTitle = this.GetOption<ExchangeTitle>(); | ||
var elementId = this.GetOption<ElementId>(); | ||
var parameterName = this.GetOption<ParameterName>(); | ||
var parameterValue = this.GetOption<ParameterValue>(); | ||
var parameterValueType = this.GetOption<ParameterValueDataType>(); | ||
var exchangeData = ConsoleAppHelper.GetExchangeData(exchangeTitle.Value); | ||
if (exchangeData == null) | ||
{ | ||
Console.WriteLine("Exchange data not found.\n"); | ||
return Task.FromResult(false); | ||
} | ||
|
||
var elementDataModel = ElementDataModel.Create(ConsoleAppHelper.GetClient(), exchangeData); | ||
var element = elementDataModel.Elements.ToList().FirstOrDefault(n => n.Id == elementId.Value); | ||
if (element == null) | ||
{ | ||
Console.WriteLine("Element not found"); | ||
return Task.FromResult(false); | ||
} | ||
|
||
DataModels.Parameter parameter = null; | ||
if (parameterName.Value != null) | ||
parameter = ConsoleAppHelper.GetParameterHelper().AddBuiltInParameter(element, parameterName.Value.Value, parameterValue.Value, parameterValueType.Value, !IsInstanceParameter); | ||
else | ||
parameter = ConsoleAppHelper.GetParameterHelper().AddCustomParameter(parameterName.SchemaName, element, parameterValue.Value, parameterValueType.Value, !IsInstanceParameter); | ||
|
||
ConsoleAppHelper.SetExchangeUpdated(exchangeTitle.Value, true); | ||
if (parameter == null) | ||
{ | ||
Console.WriteLine("Parameter is not added.\n"); | ||
} | ||
else | ||
{ | ||
var builtInParameter = parameterName.Value == null ? "Custom" : "Built-In"; | ||
Console.WriteLine("Parameter is added.\nThis is "+builtInParameter+" parameter"+"\nParameter value type is "+ parameterValueType.Value); | ||
} | ||
|
||
return Task.FromResult(true); | ||
return base.Execute(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Autodesk.DataExchange.ConsoleApp.Commands.Options; | ||
using Autodesk.DataExchange.ConsoleApp.Helper; | ||
using Autodesk.DataExchange.ConsoleApp.Interfaces; | ||
using Autodesk.DataExchange.DataModels; | ||
|
||
namespace Autodesk.DataExchange.ConsoleApp.Commands | ||
{ | ||
internal class AddTypeParamCommand: AddParamCommand | ||
{ | ||
public AddTypeParamCommand(IConsoleAppHelper consoleAppHelper) : base(consoleAppHelper) | ||
{ | ||
this.IsInstanceParameter = false; | ||
this.Name = "AddTypeParameter"; | ||
Description = "Add type parameters to element."; | ||
} | ||
|
||
public AddTypeParamCommand(AddTypeParamCommand addTypeParamCommand) : base(addTypeParamCommand) | ||
{ | ||
this.IsInstanceParameter = addTypeParamCommand.IsInstanceParameter; | ||
} | ||
|
||
public override Command Clone() | ||
{ | ||
return new AddTypeParamCommand(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 0 additions & 75 deletions
75
src/ConsoleConnector/Commands/CreateInstanceParameterCommand.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.