Is There Any Way to use a custom generator with nswag on the command line? - msbuild

We are using NSwag to generate web clients.
We have some custom generators for TypeName and OperationName.
Currently we use the NSwag class library and have custom code written to call in a console application.
Here is our CSharpClientGeneratorSettings. As you can see we have a custom class for TypeNameGenerator and OperationNameGenerator.
var cSharpClientGeneratorSettings = new CSharpClientGeneratorSettings
{
ClassName = "{controller}Client",
CSharpGeneratorSettings =
{
Namespace = this._clientNamespace,
ClassStyle = CSharpClassStyle.Inpc,
DateTimeType = "System.DateTime",
DateType = "System.DataTime",
TypeNameGenerator = new CustomTypeNameGenerator(),
JsonLibrary = CSharpJsonLibrary.SystemTextJson
},
GenerateClientInterfaces = true,
GenerateClientClasses = true,
OperationNameGenerator = new TClientGenerator(),
ExceptionClass = "YadaYada.Library.Client.SwaggerException",
InjectHttpClient = true,
SerializeTypeInformation = true,
DisposeHttpClient = true,
WrapDtoExceptions = false,
GenerateOptionalParameters = true,
ExposeJsonSerializerSettings = false,
ParameterArrayType = "System.Collections.Generic.IList",
ResponseArrayType = "System.Collections.Generic.IList",
GenerateExceptionClasses = false,
UseBaseUrl = false,
GenerateDtoTypes = false,
AdditionalNamespaceUsages = this._additionalNamespaces
};
I would like to run this code generation as an MSBuild task without have to build and deploy our console application. Is there any way to 'inject' our custom name operators into the command line version of NSwag? (nswag.exe)?

Related

Module with multiple providers

I have a question regarding the following.
I am using terraform with fortios provider
tree:
these are my providers in the root-prod:
provider "fortios" {
hostname = "xxxxx"
token = "xxxxx"
insecure = "true"
vdom = "PROD"
}
provider "fortios" {
hostname = "xxxx"
token = "xxxx"
insecure = "true"
vdom = "OPS"
alias = "isops"
}
I h got my root-module-prod:
module "AWS_xxx"{
source = "../modules"
name = "AWS_PROD"
prefix_lists = local.aws_prod
providers = {
fortios.dc1 = fortios
fortios.dc2 = fortios.isops
}
}
provider & resource within-child-modules:
terraform {
required_providers {
fortios = {
source = "fortinetdev/fortios"
version = "1.13.1"
configuration_aliases = [ fortios.dc1, fortios.dc2 ]
}
}
}
resource "fortios_router_prefixlist" "prefix_lists" {
name = var.name
dynamic "rule" {
for_each = var.prefix_lists
content {
id = rule.value["id"]
action = rule.value["action"]
prefix = rule.value["prefix"]
ge = rule.value["ge"]
le = rule.value["le"]
}
}
}
my goal is for the above module to create two instances of the resource, one in each of the declared providers.
My issue is that while the resource is created in the first provider PROD it doesn't crated in OPS.
Do you have any clue on this..?
Not really did not work through Terraform-multi-providers.
In our case, I found a way through Jenkins Parallelism.
We launch in parallel multiple envs with the credentials saved encrypted in Jenkins server.

Inserting image corrupts Open XML SDK generated Word file

I have tried to adapt the code in https://learn.microsoft.com/en-us/office/open-xml/how-to-insert-a-picture-into-a-word-processing-document to insert an image to a table cell in my .Net Core MVC app. However, inserting the image just corrupts the word file.
I have noticed that when I extract the corrupt docx file, the "media" folder is outside the "word" folder. However, when I manually add an image to a docx file, the "media" folder is present inside the "word" folder.
...code here...
ImagePart imagePart = wordDoc.MainDocumentPart.AddImagePart(ImagePartType.Jpeg);
using (FileStream stream = new FileStream(#$"{_env.WebRootPath}\images\mono.jpg", FileMode.Open))
{
imagePart.FeedData(stream);
}
var element = new Drawing( new DW.Inline( new DW.Extent() { Cx = 990000L, Cy = 792000L },
new DW.EffectExtent(){ LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L },
new DW.DocProperties(){ Id = (UInt32Value)11U, Name = "Picture 1" },
new DW.NonVisualGraphicFrameDrawingProperties( new A.GraphicFrameLocks() { NoChangeAspect = true }),
new A.Graphic( new A.GraphicData( new PIC.Picture(
new PIC.NonVisualPictureProperties(
new PIC.NonVisualDrawingProperties(){ Id = (UInt32Value)10U, Name = "New Bitmap Image.jpg" },
new PIC.NonVisualPictureDrawingProperties()),
new PIC.BlipFill(
new A.Blip(new A.BlipExtensionList(new A.BlipExtension(){ Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" })) { Embed = wordDoc.MainDocumentPart.GetIdOfPart(imagePart), CompressionState = A.BlipCompressionValues.Print, },
new A.Stretch(new A.FillRectangle())),
new PIC.ShapeProperties( new A.Transform2D(
new A.Offset() { X = 0L, Y = 0L },
new A.Extents() { Cx = 990000L, Cy = 792000L }),
new A.PresetGeometry(new A.AdjustValueList()){ Preset = A.ShapeTypeValues.Rectangle }))){ Uri = "https://schemas.openxmlformats.org/drawingml/2006/picture" })) { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)0U, DistanceFromRight = (UInt32Value)0U, EditId = "50D07946" });
Table table0 = new Table();
TableProperties props0 = new TableProperties(...code here...);
table0.AppendChild<TableProperties>(props0);
var tr0 = new TableRow();
var tc0 = new TableCell();
var pp0 = new ParagraphProperties(new SpacingBetweenLines() { After = "0" }, new Justification() { Val = JustificationValues.Center });
var rn0 = new Run(element);
var pg0 = new Paragraph(pp0, rn0);
tc0.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Dxa, Width = "1792" })), new HorizontalMerge { Val = MergedCellValues.Restart });
tc0.Append(pg0);
tr0.Append(tc0);
table0.Append(tr0);
body.Append(table0);
doc.Append(body);
...code here...
I have figured it out. The MSDN docs are to blame.
This line in the MSDN docs:
) { Uri = "https://schemas.openxmlformats.org/drawingml/2006/picture" })
is invalid, because of the https that should be http.
Changing that makes the document open without issue.

Odoo Missing Dependencies: web.ControlPanelMixin

I'm trying to install some module In Odoo 13 Community. The dependency 'web.ControlPanelMixin' is missing, I'm trying to fing the problem, so far I got no succes.
The JavaScript Code:
odoo.define('crm_dashboard.dashboard', [
'web.core',
'web.framework',
'web.session',
'web.ajax',
'web.ActionManager',
'web.view_registry',
'web.Widget',
'web.AbstractAction',
'web.ControlPanelMixin'
], function (require) {
"use strict";
var core = require('web.core');
var framework = require('web.framework');
var session = require('web.session');
var ajax = require('web.ajax');
var ActionManager = require('web.ActionManager');
var view_registry = require('web.view_registry');
var Widget = require('web.Widget');
var AbstractAction = require('web.AbstractAction');
var ControlPanelMixin = require('web.ControlPanelMixin');
var QWeb = core.qweb;
...
});
I tried searching for where is 'web.ControlPanelMixin' declared:
[odoo-13.0]$ grep -rnw ./ -e 'ControlPanelMixin'
./doc/reference/javascript_reference.rst:2221: var ControlPanelMixin = require('web.ControlPanelMixin');
./doc/reference/javascript_reference.rst:2224: var ClientAction = AbstractAction.extend(ControlPanelMixin, {
./doc/reference/javascript_reference.rst:2262:- add ControlPanelMixin in the widget:
./doc/reference/javascript_reference.rst:2266: var ControlPanelMixin = require('web.ControlPanelMixin');
./doc/reference/javascript_reference.rst:2268: var MyClientAction = AbstractAction.extend(ControlPanelMixin, {
./doc/reference/javascript_reference.rst:2277: var SomeClientAction = Widget.extend(ControlPanelMixin, {
./mymodules/odoo_crm_dashboard/static/src/js/crm_dashboard.js:11: 'odoo.web.ControlPanelMixin'
./mymodules/odoo_crm_dashboard/static/src/js/crm_dashboard.js:25:var ControlPanelMixin = require('web.ControlPanelMixin');
./mymodules/odoo_crm_dashboard/static/src/js/crm_dashboard.js:31:var CRMDashboardView = AbstractAction.extend(ControlPanelMixin, {
Thank you!
I think there is a mistake:
odoo.define('crm_dashboard.dashboard', [
'web.core',
'web.framework',
'web.session',
'web.ajax',
'web.ActionManager',
'web.view_registry',
'web.Widget',
'web.AbstractAction',
'web.ControlPanelMixin'
]
It is web.ControlPanelMixin not odoo.web.ControlPanelMixin
You can review this documentation
ControlPanelMixin was removed in Odoo 13.0.
Instead of extending from it, objects can now use hasControlPanel: true. See the Odoo source code for an example.

CommonJS module in Titanium doesn't take callbacks

I have a QRcode scanner CommonJS module in Titanium mobile that I would like to add success and cancel callbacks to.
However my functions are always undefined inside the module.
My module:
var scanner = null,
successCallback = null,
cancelHandler = null;
function AndroidScanner(allowRotation, displayedMessage, allowMenu, allowInstructions, useLED){
this.scanner = require("ti.barcode");
if(allowRotation)
this.scanner.allowRotation = allowRotation;
if(displayedMessage)
this.scanner.displayedMessage = displayedMessage;
if(allowMenu)
this.scanner.allowMenu = allowMenu;
if(allowInstructions)
this.scanner.allowInstructions = allowInstructions;
if(useLED)
this.scanner.useLED = useLED;
};
//successListener changes the event to a common one for iOS and Android
AndroidScanner.prototype.successListener = function(event) {
Ti.API.info("Successcallback get: "+JSON.stringify(this.successCallback));
this.successCallback({barcode: event.result});
};
//Starts the scanner, pass the view to add the scanner to
AndroidScanner.prototype.startScanning = function(view) {
this.scanner.addEventListener('success', this.successListener);
this.scanner.addEventListener('cancel', this.cancelHandler);
this.scanner.capture({
animate : true,
overlay : null,
showCancel : true,
showRectangle : true,
keepOpen : false
});
};
//Removes event listeners from the scanner
AndroidScanner.prototype.stopScanning = function() {
this.scanner.removeEventListener('success', this.successHandler);
this.scanner.removeEventListener('cancel', this.cancelHandler);
};
//Add a success handler
AndroidScanner.prototype.successHandler = function(handler) {
Ti.API.info("Successhandler set: "+JSON.stringify(handler));
this.successCallback = handler;
};
//Add a cancel handler
AndroidScanner.prototype.cancelHandler = function(handler) {
Ti.API.info("Cancelhandler set: "+JSON.stringify(handler));
this.cancelHandler = handler;
};
module.exports = AndroidScanner;
In alloy.js:
if(OS_ANDROID) {
var AndroidScanner = require("/ui/AndroidScanner");
Alloy.Globals.scanner = new AndroidScanner(
true,
'',
false,
false,
false
);
}
Alloy.Globals.scanner.successHandler(function(e) {
Alloy.Globals.barcodeScannerOn = false;
//on successful scanning we know that windows is back
Alloy.Globals.barcodeScanSuccesfull = true;
Alloy.Globals.barcodeScanCanceled = false;
Alloy.Globals.scanner.stopScanning();
Alloy.Globals.barcodeScanResult = e.barcode;
Ti.API.info('scan result' + JSON.stringify(Alloy.Globals.barcodeScanResult));
});
Alloy.Globals.scanner.cancelHandler(function(e) {
Alloy.Globals.barcodeScannerOn = false;
Alloy.Globals.barcodeScanCanceled = true;
Alloy.Globals.barcodeScanSuccesfull = false;
Alloy.Globals.scanner.stopScanning();
});
The log always shows:
[INFO] : Successhandler set: undefined
[INFO] : Cancelhandler set: undefined
Any ideas why this is?

jqGrid ASP.NET MVC4 initial sort

I'm using jqGrid as TreeGrid with ASP.NET MVC4 and have one problem:
My Model:
OrdersGrid = new JQGrid
{
Columns = new List<JQGridColumn>()
{
new JQGridColumn
{
DataField = "MeasureId",
// always set PrimaryKey for Add,Edit,Delete operations
// if not set, the first column will be assumed as primary key
PrimaryKey = true,
Visible = false,
Sortable = false
},
new JQGridColumn
{
DataField = "Name",
Width = 100,
Sortable = true
},
new JQGridColumn
{
DataField = "Symbol",
Width = 100
},
},
Width = Unit.Pixel(640),
Height = Unit.Percentage(100),
TreeGridSettings = new TreeGridSettings
{
Enabled = true
},
SortSettings = new SortSettings
{
AutoSortByPrimaryKey = false,
InitialSortColumn = "Name",
InitialSortDirection = SortDirection.Asc
}
};
My Controller:
public JsonResult DataRequested()
{
// Get both the grid Model and the data Model
// The data model in our case is an autogenerated linq2sql database based on Northwind.
var gridModel = new NavigatorModel();
...
var hierarchyRows = from measure in measures
select new
{
MeasureId = measure.MeasureId,
Name = measure.Name,
Symbol = measure.Symbol,
//ParentID = measure.ParentMeasureId != null ? measure.ParentMeasureId.ToString() : "",
tree_loaded = true,
tree_parent = measure.ParentMeasureId,
tree_level =LoadAllRowsExpanded_GetRowLevel(measure.ParentMeasureId, measures),
tree_leaf = LoadAllRowsExpanded_IsLeafRow(measure.MeasureId, measures),
tree_expanded = true
};
//var dataModel = new
// return the result of the DataBind method, passing the datasource as a parameter
// jqGrid for ASP.NET MVC automatically takes care of paging, sorting, filtering/searching, etc
return gridModel.OrdersGrid.DataBind(hierarchyRows.AsQueryable());
}
As above you can see that I'm setting the AutoSortByPrimaryKey set to false, but when the page is loaded, grid looks like that:
When I click on one of columns (Name or Symbol) to sort everything becomes fine - the Measure which is wrongly displayed goes under it's parent.
I have tried also with event to sort after "gridInitialize" but also no success.
Any ideas?