Autodesk Forge Create Activity - c#

I am using Autodesk Forge DesignAutomatin V3 in C# and am getting an error when creating an Activity.
this is the error i receive: System.IO.InvalidDataException: 'CommandLine is a required property for Activity and cannot be null'
Here is how i am setting up the activity.
var activity = new Activity()
{
CommandLine = new List<string>() { $"$(engine.path)\\accoreconsole.exe /i $(args[InputModel].path) /al $(appbundles[{_bundleId}].path) /s $(settings[script].path)" },
Parameters = new Dictionary<string, ModelParameter>()
{
{ "HostDwg", new ModelParameter() { Verb = ModelParameter.VerbEnum.Get, LocalName = "$(HostDwg)", Required = true } },
{ "InputModel", new ModelParameter() { Verb = ModelParameter.VerbEnum.Get, LocalName = "3DBuild.dxf", Required = true, } },
{ "Result", new ModelParameter() { Verb = ModelParameter.VerbEnum.Put, Zip = true, LocalName = _outPutFileName, Required = true } }
},
Engine = _engineVersion,
Appbundles = new List<string>() { myApp },
Settings = new Dictionary<string, dynamic>()
{
{ "script", new StringSetting() { Value = string.Format("DXFIN\n\"3DBuild.dxf\"\nExplodeModel\n-view sw\nDXFOUT\n{0}\n16\n", _outPutFileName) } }
},
Description = "DXF processor",
Version = 1,
Id = _activityName
};

Please use exclusive Design Automation .NET core SDK for v3, it appears that you are referring Design Automation namespace from autodesk.forge.
When you add new SDK, make sure you remove this - using Autodesk.Forge.Model.DesignAutomation.v3; from your code.
var activity = new Activity() {
CommandLine = new List < string > () {
$ "$(engine.path)\\accoreconsole.exe /i $(args[InputModel].path) /al $(appbundles[{PackageName}].path) /s $(settings[script].path)"
}, Parameters = new Dictionary < string, Parameter > () {
{
"HostDwg",
new Parameter() {
Verb = Verb.Get, LocalName = "$(HostDwg)", Required = true
}
}, {
"InputModel",
new Parameter() {
Verb = Verb.Get, LocalName = "3DBuild.dxf", Required = true,
}
}, {
"Result",
new Parameter() {
Verb = Verb.Put, Zip = true, LocalName = outputFile, Required = true
}
}
}, Engine = TargetEngine, Appbundles = new List < string > () {
myApp
}, Settings = new Dictionary < string, ISetting > () {
{
"script",
new StringSetting() {
Value = string.Format("DXFIN\n\"3DBuild.dxf\"\nExplodeModel\n-view sw\nDXFOUT\n{0}\n16\n", outputFile)
}
}
}, Description = "DXF processor", Version = 1, Id = ActivityName
};

Related

TestWebACL Error reason: Your statement has multiple values set for a field that requires exactly one value

var ipSets = new CfnIPSet(scope, "IPSet", new CfnIPSetProps
{
Name = "IPTest",
Addresses = new string[] { "1.2.3.4/32" },
IpAddressVersion = "IPV4",
Scope= "REGIONAL"
});
new CfnWebACL.RuleProperty()
{
Name = "Black-List-Rules",
Priority = 5,
//statement not properly translated
Statement = new CfnWebACL.StatementOneProperty
{
IpSetReferenceStatement = ipSets.AttrArn
},
VisibilityConfig = new CfnWebACL.VisibilityConfigProperty
{
SampledRequestsEnabled = true,
CloudWatchMetricsEnabled = true,
MetricName = "Black-List-Rules"
},
Action = new CfnWebACL.RuleActionProperty
{
Allow = new CfnWebACL.RuleActionProperty { Allow = false}
},
}
TestWebACL Error reason: Your statement has multiple values set for a field that requires exactly one value., field: STATEMENT, parameter: Statement (Service: Wafv2, Status Code: 400, Request ID: dd0d6492-5aa9-41e2-ac15-ee7bc133d705, Extended Request ID: null)
C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7922:49
_ Kernel._wrapSandboxCode (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:8395:20)
_ Kernel._create (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7922:26)
_ Kernel.create (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7666:21)
_ KernelHost.processRequest (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7446:28)
_ KernelHost.run (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7384:14)
_ Immediate._onImmediate (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7387:37)
_ processImmediate (internal/timers.js:456:21)
cloud formation (cdk synth)
{
"Action": {
"Block": {
"block": true
}
},
"Name": "Black-List-Rules",
"Priority": 5,
"Statement": {}, //missing
"VisibilityConfig": {
"CloudWatchMetricsEnabled": true,
"MetricName": "Black-List-Rules",
"SampledRequestsEnabled": true
}
}
Solved
["Statement"] = new Dictionary<string, object>
{
["OrStatement"] = new Dictionary<string, object>
{
["Statements"] = new [] {
new Dictionary<string, object>
{
["IpSetReferenceStatement"] = new Dictionary<string , object> {
["Arn"] = ipSetsOne.AttrArn
},
},
new Dictionary<string, object>
{
["IpSetReferenceStatement"] = new Dictionary<string , object> {
["Arn"] = ipSetsTwo.AttrArn
},
}
}
}
},
https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html

Get Action.Submit event from OnTeamsMessagingExtensionSelectItemAsync

I am trying to get the action event after a button is pressed on a thumbnail card generated in OnTeamsMessagingExtensionSelectItemAsync method. All the samples around this have used only Action.OpenUrl. Anyone have tried this ?
protected override Task<MessagingExtensionResponse> OnTeamsMessagingExtensionSelectItemAsync(ITurnContext<IInvokeActivity> turnContext, JObject query, CancellationToken cancellationToken)
{
var packages1 = JsonConvert.DeserializeObject<TicketClass>(query.ToString());
var card = new ThumbnailCard
{
Title = $"{packages1.Title}, {packages1.ShortDescription}",
Subtitle = packages1.LongDescription,
Buttons = new List<CardAction>
{
new CardAction { Type = ActionTypes.ImBack, Title = "Action 1 ", Value = "Show me more" },
new CardAction { Type = ActionTypes.OpenUrl, Title = "Action 2", Value = "" },
},
};
var attachment = new MessagingExtensionAttachment
{
ContentType = ThumbnailCard.ContentType,
Content = card,
};
return Task.FromResult(new MessagingExtensionResponse
{
ComposeExtension = new MessagingExtensionResult
{
Type = "result",
AttachmentLayout = "list",
Attachments = new List<MessagingExtensionAttachment> { attachment }
}
});
}

Unable to create a company in Intercom

I'm using this code:
Authentication authentication = new Authentication("myAccessToken");
RestClientFactory restClientFactory = new RestClientFactory(authentication);
var _companyClient = new CompanyClient(restClientFactory);
var companyCustomAttributes = new Dictionary<string, object>()
{
{ "name", "TradingName" },
{ "company_id_str", "5432" },
{ "isoCode", "AU" },
{ "regionCode", "VIC" },
{ "isPropertyManagement", false },
{ "isSales", false },
{ "setupComplete", false },
{ "isSubscription", false },
{ "subscriptionSetupComplete", false },
{ "tradingName", "TradingName" },
{ "ofSMS", false },
{ "ofBankTransfer", false },
{ "ofCommercial", false },
{ "isEmailValidated", true },
{ "isLocked", false },
{ "isOutgoingEmailValidated", true },
{ "banks", "" },
{ "earlyAdopterProgram", false },
{ "propertyCount", 0 }
};
var company = new Company();
company.company_id = "5432";
company.custom_attributes = companyCustomAttributes;
var createdCompany = _companyClient.Create(company);
The createdCompany is not null:
But the company is not showing in the UI:
Why is the company not showing in the UI?
Intercom API version = 1.4
Intercom.Dotnet.Client version = 2.1.1
Github issue submitted:
https://github.com/intercom/intercom-dotnet/issues/158
The company won't show up if there are no users attached to it.

check the selected value in drop down list

I have the following drop down list. How can I check the selected value BEFORE saving the data into the module? I want to use the selected value in setting the values of Neighborhood's drop down list.
#Html.DropDownListFor(model => model.City, new SelectList(
new List<Object>{
new { value = "Abha", text = "Abha" },
new { value = "Al Qunfudhah", text = "Al Qunfudhah" },
new { value = "Al-Kharj", text = "Al-Kharj" },
new { value = "Al-Ahsa", text = "Al-Ahsa" },
new { value = "Buraidah", text = "Buraidah" },
new { value = "Dammam", text = "Dammam" },
new { value = "Ha'il", text = "Ha'il"},
new { value = "Hafar Al-Batin", text = "Hafar Al-Batin" },
new { value = "Jazan", text = "Jazan" },
new { value = "Jeddah", text = "Jeddah" },
new { value = "Jubail", text = "Jubail" },
new { value = "khobar", text = "khobar" },
new { value = "Khamis Mushait", text = "Khamis Mushait" },
new { value = "Mecca", text = "Mecca" },
new { value = "Medina", text = "Medina" },
new { value = "Najran", text = "Najran" },
new { value = "Qatif", text = "Qatif" },
new { value = "Riyadh", text = "Riyadh" },
new { value = "Tabuk", text = "Tabuk" },
new { value = "Ta'if", text = "Ta'if" },
new { value = "Yanbu", text = "Yanbu" }
},"value", "text", "Jeddah"))
#Html.ValidationMessageFor(model => model.City)
</div>
</div>
With jQuery, you can try
$('#City').val();
If you are not using jQuery, the vanilla javascript way would be
var element = document.getElementById("City");
var strVal = element.options[element.selectedIndex].value;

Open XML add picture to presentation

I am trying to create power point presentation on the fly (without usage of previuosly created template slide). So far I have results, but experiencing difficulties on adding picture (see code below)
When disable the P.Picture part it is working (means the created pptx file can be opened).
With the P.Picture part PowerPoint proposes repair and removes "found non-readable part" resulting of showing only placeholder of the picture with "Picture can not be shown message". If you expand the pptx in unrepaired state the media folder contains proper picture that can be opened... _rels folder contains file that properly links the existing image file with the image placeholder... I am surely missing sth. but what???
Any help appreciated! Many thanks!
public static void CreatePresentation(string filepath)
{
// Create a presentation at a specified file path. The presentation document type is pptx, by default.
PresentationDocument presentationDoc = PresentationDocument.Create(filepath, PresentationDocumentType.Presentation);
PresentationPart presentationPart = presentationDoc.AddPresentationPart();
presentationPart.Presentation = new Presentation();
SlideMasterIdList sldMasterIdList = new SlideMasterIdList(new SlideMasterId() { Id = (UInt32Value)2147483648U, RelationshipId = "rId1" });
SlideIdList sldIdList = new SlideIdList();
SlideSize sldSize = new SlideSize() { Cx = 2751 * mm / 10, Cy = 1905 * mm / 10, Type = SlideSizeValues.Screen4x3 }; // DIN A4 - Landscape.
NotesSize notesSize = new NotesSize() { Cx = 1905 * mm / 10, Cy = 2751 * mm / 10 }; // DIN A4 - Portrait.
DefaultTextStyle defaultTextStyle = new DefaultTextStyle();
presentationPart.Presentation.Append(sldMasterIdList, sldIdList, sldSize, notesSize, defaultTextStyle);
#region [ SlidePart ]
SlidePart slidePart = presentationPart.AddNewPart<SlidePart>("rId2");
sldIdList.AppendChild<SlideId>(new SlideId() { Id = (UInt32Value)256U, RelationshipId = "rId2" });
slidePart.Slide = new Slide
(
new CommonSlideData
(
new ShapeTree
(
new P.NonVisualGroupShapeProperties
(
new P.NonVisualDrawingProperties() { Id = (UInt32Value)1U, Name = "" },
new P.NonVisualGroupShapeDrawingProperties(),
new ApplicationNonVisualDrawingProperties()
),
new GroupShapeProperties(new DocumentFormat.OpenXml.Drawing.TransformGroup())
)
),
new ColorMapOverride(new MasterColorMapping())
);
ImagePart ip = slidePart.AddImagePart(ImagePartType.Jpeg, "rId2");
MyStream.Position = 0;
ip.FeedData(MyStream);
#endregion
#region [ slideLayoutPart ]
SlideLayoutPart slideLayoutPart = slidePart.AddNewPart<SlideLayoutPart>("rId1");
SlideLayout slideLayout = new SlideLayout
(
new CommonSlideData
(
new ShapeTree
(
new P.NonVisualGroupShapeProperties
(
new P.NonVisualDrawingProperties() { Id = (UInt32Value)1U, Name = "" },
new P.NonVisualGroupShapeDrawingProperties(),
new ApplicationNonVisualDrawingProperties()
),
new GroupShapeProperties
(
new DocumentFormat.OpenXml.Drawing.TransformGroup()
)
)
),
new ColorMapOverride
(
new MasterColorMapping()
)
);
slideLayoutPart.SlideLayout = slideLayout;
#endregion
#region [ slideMasterPart ]
SlideMasterPart slideMasterPart = slideLayoutPart.AddNewPart<SlideMasterPart>("rId1");
SlideMaster slideMaster = new SlideMaster(
new CommonSlideData(new ShapeTree(
new P.NonVisualGroupShapeProperties(
new P.NonVisualDrawingProperties() { Id = (UInt32Value)1U, Name = "" },
new P.NonVisualGroupShapeDrawingProperties(),
new ApplicationNonVisualDrawingProperties()),
new GroupShapeProperties(new DocumentFormat.OpenXml.Drawing.TransformGroup()),
new P.Shape(
new P.NonVisualShapeProperties(
new P.NonVisualDrawingProperties() { Id = (UInt32Value)2U, Name = "Title Placeholder 1" },
new P.NonVisualShapeDrawingProperties(new ShapeLocks() { NoGrouping = true }),
new ApplicationNonVisualDrawingProperties(new PlaceholderShape() { Type = PlaceholderValues.Title })),
new P.ShapeProperties(),
new P.TextBody(
new BodyProperties(),
new ListStyle(),
new Paragraph())))),
new P.ColorMap() { Background1 = D.ColorSchemeIndexValues.Light1, Text1 = D.ColorSchemeIndexValues.Dark1, Background2 = D.ColorSchemeIndexValues.Light2, Text2 = D.ColorSchemeIndexValues.Dark2, Accent1 = D.ColorSchemeIndexValues.Accent1, Accent2 = D.ColorSchemeIndexValues.Accent2, Accent3 = D.ColorSchemeIndexValues.Accent3, Accent4 = D.ColorSchemeIndexValues.Accent4, Accent5 = D.ColorSchemeIndexValues.Accent5, Accent6 = D.ColorSchemeIndexValues.Accent6, Hyperlink = D.ColorSchemeIndexValues.Hyperlink, FollowedHyperlink = D.ColorSchemeIndexValues.FollowedHyperlink },
new SlideLayoutIdList(new SlideLayoutId() { Id = (UInt32Value)2147483649U, RelationshipId = "rId1" }),
new TextStyles(new TitleStyle(), new BodyStyle(), new OtherStyle()));
slideMasterPart.SlideMaster = slideMaster;
slideMasterPart.AddPart(slideLayoutPart, "rId1");
presentationPart.AddPart(slideMasterPart, "rId1");
#endregion
#region [ Theme ]
ThemePart themePart = slideMasterPart.AddNewPart<ThemePart>("rId5");
D.Theme theme = new D.Theme() { Name = "Office Theme" };
D.ThemeElements themeElements = new D.ThemeElements(
new D.ColorScheme(
new D.Dark1Color(new D.SystemColor() { Val = D.SystemColorValues.WindowText, LastColor = "000000" }),
new D.Light1Color(new D.SystemColor() { Val = D.SystemColorValues.Window, LastColor = "FFFFFF" }),
new D.Dark2Color(new D.RgbColorModelHex() { Val = "1F497D" }),
new D.Light2Color(new D.RgbColorModelHex() { Val = "EEECE1" }),
new D.Accent1Color(new D.RgbColorModelHex() { Val = "4F81BD" }),
new D.Accent2Color(new D.RgbColorModelHex() { Val = "C0504D" }),
new D.Accent3Color(new D.RgbColorModelHex() { Val = "9BBB59" }),
new D.Accent4Color(new D.RgbColorModelHex() { Val = "8064A2" }),
new D.Accent5Color(new D.RgbColorModelHex() { Val = "4BACC6" }),
new D.Accent6Color(new D.RgbColorModelHex() { Val = "F79646" }),
new D.Hyperlink(new D.RgbColorModelHex() { Val = "0000FF" }),
new D.FollowedHyperlinkColor(new D.RgbColorModelHex() { Val = "800080" })) { Name = "Office" },
new D.FontScheme(
new D.MajorFont(
new D.LatinFont() { Typeface = "Calibri" },
new D.EastAsianFont() { Typeface = "" },
new D.ComplexScriptFont() { Typeface = "" }),
new D.MinorFont(
new D.LatinFont() { Typeface = "Calibri" },
new D.EastAsianFont() { Typeface = "" },
new D.ComplexScriptFont() { Typeface = "" })) { Name = "Office" },
new D.FormatScheme(
new D.FillStyleList(
new D.SolidFill(new D.SchemeColor() { Val = D.SchemeColorValues.PhColor }),
new D.GradientFill(
new D.GradientStopList(
new D.GradientStop(new D.SchemeColor(new D.Tint() { Val = 50000 },
new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 },
new D.GradientStop(new D.SchemeColor(new D.Tint() { Val = 37000 },
new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 35000 },
new D.GradientStop(new D.SchemeColor(new D.Tint() { Val = 15000 },
new D.SaturationModulation() { Val = 350000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 100000 }
),
new D.LinearGradientFill() { Angle = 16200000, Scaled = true }),
new D.NoFill(),
new D.PatternFill(),
new D.GroupFill()),
new D.LineStyleList(
new D.Outline(
new D.SolidFill(
new D.SchemeColor(
new D.Shade() { Val = 95000 },
new D.SaturationModulation() { Val = 105000 }) { Val = D.SchemeColorValues.PhColor }),
new D.PresetDash() { Val = D.PresetLineDashValues.Solid })
{
Width = 9525,
CapType = D.LineCapValues.Flat,
CompoundLineType = D.CompoundLineValues.Single,
Alignment = D.PenAlignmentValues.Center
},
new D.Outline(
new D.SolidFill(
new D.SchemeColor(
new D.Shade() { Val = 95000 },
new D.SaturationModulation() { Val = 105000 }) { Val = D.SchemeColorValues.PhColor }),
new D.PresetDash() { Val = D.PresetLineDashValues.Solid })
{
Width = 9525,
CapType = D.LineCapValues.Flat,
CompoundLineType = D.CompoundLineValues.Single,
Alignment = D.PenAlignmentValues.Center
},
new D.Outline(
new D.SolidFill(
new D.SchemeColor(
new D.Shade() { Val = 95000 },
new D.SaturationModulation() { Val = 105000 }) { Val = D.SchemeColorValues.PhColor }),
new D.PresetDash() { Val = D.PresetLineDashValues.Solid })
{
Width = 9525,
CapType = D.LineCapValues.Flat,
CompoundLineType = D.CompoundLineValues.Single,
Alignment = D.PenAlignmentValues.Center
}),
new D.EffectStyleList(
new D.EffectStyle(
new D.EffectList(
new D.OuterShadow(
new D.RgbColorModelHex(
new D.Alpha() { Val = 38000 }) { Val = "000000" }) { BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false })),
new D.EffectStyle(
new D.EffectList(
new D.OuterShadow(
new D.RgbColorModelHex(
new D.Alpha() { Val = 38000 }) { Val = "000000" }) { BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false })),
new D.EffectStyle(
new D.EffectList(
new D.OuterShadow(
new D.RgbColorModelHex(
new D.Alpha() { Val = 38000 }) { Val = "000000" }) { BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false }))),
new D.BackgroundFillStyleList(
new D.SolidFill(new D.SchemeColor() { Val = D.SchemeColorValues.PhColor }),
new D.GradientFill(
new D.GradientStopList(
new D.GradientStop(
new D.SchemeColor(new D.Tint() { Val = 50000 },
new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 },
new D.GradientStop(
new D.SchemeColor(new D.Tint() { Val = 50000 },
new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 },
new D.GradientStop(
new D.SchemeColor(new D.Tint() { Val = 50000 },
new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 }),
new D.LinearGradientFill() { Angle = 16200000, Scaled = true }),
new D.GradientFill(
new D.GradientStopList(
new D.GradientStop(
new D.SchemeColor(new D.Tint() { Val = 50000 },
new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 },
new D.GradientStop(
new D.SchemeColor(new D.Tint() { Val = 50000 },
new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 }),
new D.LinearGradientFill() { Angle = 16200000, Scaled = true }))) { Name = "Office" });
theme.Append(themeElements);
theme.Append(new D.ObjectDefaults());
theme.Append(new D.ExtraColorSchemeList());
themePart.Theme = theme;
presentationPart.AddPart(themePart, "rId5");
#endregion
P.Picture picture = new P.Picture
(
new P.NonVisualPictureProperties
(
new P.NonVisualDrawingProperties() { Id = (UInt32Value)1026U, Name = "Photo", Description = "" },
new P.NonVisualPictureDrawingProperties
(
new D.PictureLocks() { NoChangeAspect = true }
),
new ApplicationNonVisualDrawingProperties()
),
new D.BlipFill
(
new D.Blip
(
new D.NonVisualPicturePropertiesExtensionList()
) { Embed = "rId2" },
new D.Stretch
(
new D.FillRectangle()
)
),
new P.ShapeProperties
(
new D.Transform2D
(
new D.Offset() { X = 1 * cm, Y = 3 * cm },
new D.Extents() { Cx = 16 * cm, Cy = 14 * cm }
),
new D.PresetGeometry
(
new D.AdjustValueList()
) { Preset = D.ShapeTypeValues.Rectangle }
)
);
slidePart.Slide.CommonSlideData.ShapeTree.AppendChild<P.Picture>(picture);
//Close the presentation handle
presentationDoc.Close();
}
My problem was really very simple - just found it comparing the repaired against genererated version (serialized XML)...
Unrepaired there was in the BlipFill portion the Prefix a: repaired p:...
There are BlipFills both in Presentation and Drawing
So my mistake was in using the D.BlipFill instead of P.BlipFill
Now it works as expected.
Indeed, the author of the post uses the class BlipFill from DocumentFormat.OpenXml.Drawing instead of DocumentFormat.OpenXml.Presentation namespace. The PPTX file is created successfully, but when opening the file in PowerPoint it alerts that the file has to be repaired.
For whose who has a similar problem in other parts of the code, Open XML SDK has a validator that allows to diagnose such issues. This approach is mush simpler than comparing the repaired and unrepaired presentations manually.
The code is below.
OpenXmlValidator validator = new OpenXmlValidator();
var doc = PresentationDocument.Open(pptPath, true);
var errors = validator.Validate(doc);
The errors then contains the issues in the presentation.

Categories

Resources