private static CasePlanAggregate BuildCasePlan(tCase tCase, tDefinitions definitions, CaseFileAggregate caseFile) { var planModel = tCase.casePlanModel; var roles = new List <CasePlanRole>(); var files = new List <CasePlanFileItem>(); if (tCase.caseRoles != null && tCase.caseRoles.role != null) { foreach (var role in tCase.caseRoles.role) { roles.Add(new CasePlanRole { Id = role.id, Name = role.name }); } } if (tCase.caseFileModel != null && tCase.caseFileModel.caseFileItem != null) { foreach (var caseFileItem in tCase.caseFileModel.caseFileItem) { var caseFileItemDef = definitions.caseFileItemDefinition.First(c => c.id == caseFileItem.definitionRef.ToString()); files.Add(new CasePlanFileItem { DefinitionType = caseFileItemDef.definitionType, Id = caseFileItem.id, Name = caseFileItem.name }); } } return(CasePlanAggregate.New(planModel.id, planModel.name, planModel.name, caseFile.AggregateId, caseFile.Version, Serialize(planModel), roles, files)); }
public static ICollection <CasePlanAggregate> ExtractCasePlans(tDefinitions definitions, CaseFileAggregate caseFile) { var result = new List <CasePlanAggregate>(); foreach (var cmmnCase in definitions.@case) { result.Add(BuildCasePlan(cmmnCase, definitions, caseFile)); } return(result); }
public void ReadWSDLTest1() { ReadWSDL wsi = new ReadWSDL(); try { tDefinitions wsdlDefinition = wsi.readWSDL(null); } catch (ArgumentNullException) { } }
public static tDefinitions Parse(string bpmnTxt) { var xmlSerializer = new XmlSerializer(typeof(tDefinitions), "http://www.omg.org/spec/BPMN/20100524/MODEL"); tDefinitions defs = null; using (var txtReader = new StringReader(bpmnTxt)) { defs = (tDefinitions)xmlSerializer.Deserialize(txtReader); } return(defs); }
public static tDefinitions ParseWSDL(string cmmnTxt) { var xmlSerializer = new XmlSerializer(typeof(tDefinitions)); tDefinitions defs = null; using (var txtReader = new StringReader(cmmnTxt)) { defs = (tDefinitions)xmlSerializer.Deserialize(txtReader); } return(defs); }
public tDefinitions SerializeDictionariesToDmn(Dictionary <string, object> outputsDictionary, Dictionary <int, object> rulesDictionary, string fileName) { var tDecisionTable = new tDecisionTable(); tDecisionTable.input = new tInputClause[] { }; var tExpression = tDecisionTable; var tdecision = new tDecision(); tdecision.Item = tExpression; var tDefinitions = new tDefinitions(); tDefinitions.id = fileName; tDefinitions.Items = new tDRGElement[] { tdecision }; return(tDefinitions); }
void runTest(String pathAndFile) { Assume.That(File.Exists(pathAndFile)); ReadWSDL wsi = new ReadWSDL(); tDefinitions wsdlDefinition = wsi.readWSDL( pathAndFile ); Properties properties1 = new Properties(); properties1.put("keyDomain", "my.key.domain"); WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizer(), properties1); Assert.NotNull(wsdl2UDDI); Dictionary <QName, tPortType> portTypes1 = (Dictionary <QName, tPortType>)wsdlDefinition.getAllPortTypes(); Assert.NotNull(portTypes1); Assert.True(portTypes1.Count > 0); List <tModel> portTypeTModels1 = wsdl2UDDI.createWSDLPortTypeTModels(pathAndFile, portTypes1); Assert.NotNull(portTypeTModels1); Assert.True(portTypeTModels1.Count > 0); Dictionary <QName, tBinding> allBindings1 = wsdlDefinition.getAllBindings(); Assert.NotNull(allBindings1); Assert.True(allBindings1.Count > 0); List <tModel> createWSDLBindingTModels1 = wsdl2UDDI.createWSDLBindingTModels(pathAndFile, allBindings1); Assert.NotNull(createWSDLBindingTModels1); Assert.True(createWSDLBindingTModels1.Count > 0); businessService[] businessServices = wsdl2UDDI.createBusinessServices(wsdlDefinition); Assert.NotNull(businessServices); Assert.True(businessServices.Length > 0); for (int i = 0; i < businessServices.Length; i++) { foreach (description d in businessServices[i].description) { if (d.lang != null) { Assert.True(d.lang.Length <= UDDIConstants.MAX_xml_lang_length); } if (d.Value != null) { Assert.True(d.Value.Length <= UDDIConstants.MAX_description_length); } } foreach (bindingTemplate bt in businessServices[i].bindingTemplates) { Assert.NotNull(bt); Assert.NotNull(bt.bindingKey); Assert.NotNull(bt.Item); Assert.NotNull(bt.serviceKey); Assert.True(bt.Item is accessPoint); Assert.NotNull(((accessPoint)bt.Item).useType); Assert.NotNull(((accessPoint)bt.Item).Value); foreach (description d in bt.description) { if (d.lang != null) { Assert.True(d.lang.Length <= UDDIConstants.MAX_xml_lang_length); } if (d.Value != null) { Assert.True(d.Value.Length <= UDDIConstants.MAX_description_length); } } foreach (tModelInstanceInfo tm in bt.tModelInstanceDetails) { foreach (description d in tm.description) { if (d.lang != null) { Assert.True(d.lang.Length <= UDDIConstants.MAX_xml_lang_length); } if (d.Value != null) { Assert.True(d.Value.Length <= UDDIConstants.MAX_description_length); } } } } Assert.True(businessServices[i].bindingTemplates.Length > 0); Assert.NotNull(businessServices[i].description); Assert.True(businessServices[i].description.Length > 0); Assert.NotNull(businessServices[i].serviceKey); } }
public static ICollection <ProcessInstanceAggregate> BuildInstances(tDefinitions definitions, string processFileId) { var result = new List <ProcessInstanceAggregate>(); var processes = definitions.Items.Where(_ => _ is tProcess).Cast <tProcess>(); var messages = definitions.Items.Where(_ => _ is tMessage).Cast <tMessage>(); var itemDefs = definitions.Items.Where(_ => _ is tItemDefinition).Cast <tItemDefinition>(); foreach (var process in processes) { var builder = ProcessInstanceBuilder.New(processFileId); foreach (var message in messages) { builder.AddMessage(message.id, message.name, message.itemRef?.Name); } foreach (var itemDef in itemDefs) { builder.AddItemDef(itemDef.id, ItemKinds.Information, false, null); } foreach (var item in process.Items) { tStartEvent startEvt; tEndEvent endEvt; tTask task; tSequenceFlow sequenceFlow; tExclusiveGateway exclusiveGateway; tUserTask userTask; tServiceTask serviceTask; tBoundaryEvent boundaryEvent; if ((startEvt = item as tStartEvent) != null) { builder.AddStartEvent(startEvt.id, startEvt.name, cb => { Update(cb, startEvt); }); } else if ((endEvt = item as tEndEvent) != null) { builder.AddEndEvent(endEvt.id, endEvt.name); } else if ((userTask = item as tUserTask) != null) { builder.AddUserTask(userTask.id, userTask.name, (cb) => { Update(cb, item.id, process.Items); if (userTask.implementation == BPMNConstants.UserTaskImplementations.WSHUMANTASK) { var parameters = userTask.extensionElements?.Any.FirstOrDefault(_ => _.Name == "cmg:parameters"); List <tParameter> pars = new List <tParameter>(); if (parameters != null) { var xmlSerializer = new XmlSerializer(typeof(tParameter), "http://www.omg.org/spec/BPMN/20100524/MODEL"); foreach (XmlNode child in parameters.ChildNodes) { using (var txtReader = new StringReader(child.OuterXml)) { pars.Add((tParameter)xmlSerializer.Deserialize(txtReader)); } } } cb.SetWsHumanTask(userTask.wsHumanTaskDefName, pars.ToDictionary(_ => _.key, _ => _.value)); } }); } else if ((serviceTask = item as tServiceTask) != null) { builder.AddServiceTask(serviceTask.id, serviceTask.name, (cb) => { Update(cb, item.id, process.Items); if (serviceTask.implementation == BPMNConstants.ServiceTaskImplementations.CALLBACK) { cb.SetDelegate(serviceTask.delegateId); } }); } else if ((task = item as tTask) != null) { builder.AddEmptyTask(task.id, task.name, (cb) => { Update(cb, item.id, process.Items); }); } else if ((sequenceFlow = item as tSequenceFlow) != null) { builder.AddSequenceFlow(sequenceFlow.id, sequenceFlow.name, sequenceFlow.sourceRef, sequenceFlow.targetRef, sequenceFlow.conditionExpression?.Text.First()); } else if ((exclusiveGateway = item as tExclusiveGateway) != null) { builder.AddExclusiveGateway(exclusiveGateway.id, exclusiveGateway.name, MAPPING_GATEWAY_DIRECTIONS[exclusiveGateway.gatewayDirection], exclusiveGateway.@default); } else if ((boundaryEvent = item as tBoundaryEvent) != null) { builder.AddBoundaryEvent(boundaryEvent.id, boundaryEvent.name, cb => { Update(cb, boundaryEvent); }); } } result.Add(builder.Build()); } return(result); }
public static void main(string[] args) { Console.Out.Write("Enter WSDL url: >"); String input = Console.In.ReadLine(); if (String.IsNullOrEmpty(input)) { input = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"; } //String wsdlURL = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"; //if (String.IsNullOrEmpty(input)) Uri url = null; String host = "localhost"; int port = 80; try { url = new Uri(input); host = url.Host; port = url.Port; } catch { } ReadWSDL wsi = new ReadWSDL(); tDefinitions wsdlDefinition = wsi.readWSDL(input); Properties properties1 = new Properties(); properties1.put("serverName", host); properties1.put("businessName", host); properties1.put("keyDomain", "uddi:" + host); if (port <= 0) { if (url.ToString().StartsWith("https", StringComparison.CurrentCultureIgnoreCase)) { port = 443; } else { port = 80; } } properties1.put("serverPort", port.ToString()); tModel keypart = UDDIClerk.createKeyGenator(host, host + "'s key partition", "en"); WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizer(), properties1); List <tModel> tModels1 = new List <tModel>(); Dictionary <QName, tPortType> portTypes1 = (Dictionary <QName, tPortType>)wsdlDefinition.getAllPortTypes(); List <tModel> portTypeTModels1 = wsdl2UDDI.createWSDLPortTypeTModels(input, portTypes1); tModels1.AddRange(portTypeTModels1); Dictionary <QName, tBinding> allBindings1 = wsdlDefinition.getAllBindings(); List <tModel> createWSDLBindingTModels1 = wsdl2UDDI.createWSDLBindingTModels(input, allBindings1); tModels1.AddRange(createWSDLBindingTModels1); businessService[] services = wsdl2UDDI.createBusinessServices(wsdlDefinition); save_service ss = new save_service(); ss.businessService = services; Console.Out.WriteLine(new PrintUDDI <save_service>().print(ss)); save_tModel st = new save_tModel(); st.tModel = tModels1.ToArray(); Console.Out.WriteLine(new PrintUDDI <save_tModel>().print(st)); //save keypart //save tmodels //save business //TODO register the stuff }
public DmnV1Builder() { _dmn = new tDefinitions(); }
public IActionResult PostModelsToExcelDataDictionary() { var httpRequest = HttpContext.Request; HttpResponseMessage response = null; string okResponsText = null; var httpFiles = httpRequest.Form.Files; var httpForms = httpRequest.Form.Keys; var okDictionary = new Dictionary <string, string>(); var ErrorDictionary = new Dictionary <string, string>(); var dmnDataDictionaryModels = new List <DmnDataDictionaryModel>(); var bpmnDataDictionaryModels = new List <BpmnDataDictionaryModel>(); var dataDictionaryModels = new List <DataDictionaryModel>(); if (httpFiles == null && !httpFiles.Any()) { return(NotFound("Can't find any file")); } for (var i = 0; i < httpFiles.Count; i++) { string errorResponsText = null; string errorTemp = string.Empty; var file = httpFiles[i]; tDefinitions dmn = null; var fileExtention = Path.GetExtension(file.FileName); if (fileExtention == ".dmn") { //Deserialize DMN file if (file != null) { using (Stream dmnfile = httpFiles[i].OpenReadStream()) { dmn = new DmnServices().DeserializeStreamDmnFile(dmnfile); } } if (dmn == null) { ErrorDictionary.Add(file.FileName, "Can't validate Shema"); continue; } // check if DMN have desicion table var items = dmn.Items; var decision = items.Where(t => t.GetType() == typeof(tDecision)); var tDrgElements = decision as tDRGElement[] ?? decision.ToArray(); if (!tDrgElements.Any()) { ErrorDictionary.Add(file.FileName, "Dmn file have non decision"); continue; } foreach (tDecision tdecision in decision) { tDecisionTable decisionTable = null; try { DmnServices.GetDecisionsVariables(tdecision, Path.GetFileNameWithoutExtension(file.FileName), ref dmnDataDictionaryModels); } catch { ErrorDictionary.Add(file.FileName, "Can't add serialize info from DMN"); } } } if (fileExtention == ".bpmn") { XDocument bpmnXml = null; try { using (Stream dmnfile = httpFiles[i].OpenReadStream()) { bpmnXml = XDocument.Load(dmnfile); } } catch { ErrorDictionary.Add(file.FileName, "Can't add serialize bpmn to xml"); } if (bpmnXml != null) { try { DmnServices.GetDmnInfoFromBpmnModel(bpmnXml, ref bpmnDataDictionaryModels); } catch { ErrorDictionary.Add(file.FileName, "Can't add serialize bpmn to Data Model Dictionary"); } } } } foreach (var dmnDataInfo in dmnDataDictionaryModels) { var submodel = new BpmnDataDictionaryModel(); try { submodel = bpmnDataDictionaryModels.Single(b => b.DmnId == dmnDataInfo.DmnId); } catch { } dataDictionaryModels.Add(new DataDictionaryModel() { BpmnData = submodel, DmnData = dmnDataInfo }); } // create Excel Package ExcelPackage excelPkg = null; var fileName = "DataDictionaryFromModels"; try { excelPkg = new ExcelPackage(); ExcelWorksheet wsSheet = excelPkg.Workbook.Worksheets.Add("DmnTEK"); var dmnIds = dmnDataDictionaryModels.GroupBy(x => x.DmnId).Select(y => y.First()); var objectPropertyNames = new[] { "DmnId", "DmnNavn", "TekKapitel", "TekLedd", "TekTabell", "TekForskriften", "TekWebLink" }; ExcelServices.CreateDmnExcelTableDataDictionary(dmnIds, wsSheet, "dmnTek", objectPropertyNames); ExcelWorksheet wsSheet1 = excelPkg.Workbook.Worksheets.Add("Variables"); var dmnVariablesIds = dmnDataDictionaryModels.GroupBy(x => x.VariabelId).Select(y => y.First()); var dmnVariablesIdstPropertyNames = new[] { "VariabelId", "VariabelNavn", "VariabelBeskrivelse" }; ExcelServices.CreateDmnExcelTableDataDictionary(dmnVariablesIds, wsSheet1, "Variables", dmnVariablesIdstPropertyNames); ExcelWorksheet wsSheet2 = excelPkg.Workbook.Worksheets.Add("Dmn+Variables"); var objectPropertyNames1 = new[] { "DmnId", "VariabelId", "Type" }; ExcelServices.CreateDmnExcelTableDataDictionary(dmnDataDictionaryModels, wsSheet2, "Dmn+Variables", objectPropertyNames1); ExcelWorksheet wsSheet3 = excelPkg.Workbook.Worksheets.Add("summary"); var summaryPropertyNames = new[] { "DmnData.FilNavn", "BpmnData.BpmnId", "DmnData.DmnId", "DmnData.VariabelId", "DmnData.VariabelType", "DmnData.Type", "DmnData.Kilde" }; ExcelServices.CreateSummaryExcelTableDataDictionary(dataDictionaryModels, wsSheet3, "summary", summaryPropertyNames); } catch { ErrorDictionary.Add("Error", "Can't create Excel file"); } // Save Excel Package try { var path = Path.Combine(@"C:\", "DmnToExcel"); Directory.CreateDirectory(path); excelPkg.SaveAs(new FileInfo(Path.Combine(path, string.Concat(fileName, ".xlsx")))); okDictionary.Add(fileName, "Created in:" + path); } catch { ErrorDictionary.Add(fileName, "Can't be saved"); } if (ErrorDictionary.Any()) { if (okDictionary.Any()) { List <Dictionary <string, string> > dictionaries = new List <Dictionary <string, string> >(); dictionaries.Add(okDictionary); dictionaries.Add(ErrorDictionary); var result = dictionaries.SelectMany(dict => dict) .ToLookup(pair => pair.Key, pair => pair.Value) .ToDictionary(group => group.Key, group => group.First()); return(Ok(result)); } return(BadRequest(ErrorDictionary)); } return(Ok(okDictionary)); }
public IActionResult PosDmnToExcel() { var httpRequest = HttpContext.Request; HttpResponseMessage response = null; string okResponsText = null; var httpFiles = httpRequest.Form.Files; var okDictionary = new Dictionary <string, string>(); var ErrorDictionary = new Dictionary <string, string>(); if (httpFiles == null && !httpFiles.Any()) { return(NotFound("Can't find any file")); } for (var i = 0; i < httpFiles.Count; i++) { string errorResponsText = null; string errorTemp = string.Empty; var file = httpFiles[i]; tDefinitions dmn = null; //Deserialize DMN file if (file != null) { using (Stream dmnfile = httpFiles[i].OpenReadStream()) { dmn = new DmnServices().DeserializeStreamDmnFile(dmnfile); } } if (dmn == null) { ErrorDictionary.Add(file.FileName, "Can't validate Shema"); continue; } // check if DMN have desicion table var items = dmn.Items; var decision = items.Where(t => t.GetType() == typeof(tDecision)); var tDrgElements = decision as tDRGElement[] ?? decision.ToArray(); if (!tDrgElements.Any()) { ErrorDictionary.Add(file.FileName, "Dmn file have non decision"); continue; } // create Excel Package ExcelPackage excelPkg = null; try { excelPkg = new ExcelPackage(); foreach (var tdecision in tDrgElements) { tDecisionTable decisionTable = null; try { var dt = ((tDecision)tdecision).Item; decisionTable = (tDecisionTable)Convert.ChangeType(dt, typeof(tDecisionTable)); ExcelWorksheet wsSheet = excelPkg.Workbook.Worksheets.Add(tdecision.id); //Add Table Title ExcelServices.AddTableTitle(tdecision.name, wsSheet, decisionTable, tdecision.id); // Add "input" and "output" headet to Excel table ExcelServices.AddTableInputOutputTitle(wsSheet, decisionTable); //Add DMN Table to excel Sheet ExcelServices.CreateExcelTableFromDecisionTable(decisionTable, wsSheet, tdecision.id); } catch { ErrorDictionary.Add(file.FileName, string.Concat("Dmn: ", tdecision.name, " Can't be create")); } } } catch { ErrorDictionary.Add(file.FileName, "Can't create Excel file"); continue; } // Save Excel Package try { var filename = Path.GetFileNameWithoutExtension(file.FileName); var path = Path.Combine(@"C:\", "DmnToExcel"); Directory.CreateDirectory(path); excelPkg.SaveAs(new FileInfo(Path.Combine(path, string.Concat(filename, ".xlsx")))); okDictionary.Add(file.FileName, "Created in:" + path); } catch { ErrorDictionary.Add(file.FileName, "Can't be saved"); } } if (ErrorDictionary.Any()) { if (okDictionary.Any()) { List <Dictionary <string, string> > dictionaries = new List <Dictionary <string, string> >(); dictionaries.Add(okDictionary); dictionaries.Add(ErrorDictionary); var result = dictionaries.SelectMany(dict => dict) .ToLookup(pair => pair.Key, pair => pair.Value) .ToDictionary(group => group.Key, group => group.First()); return(Ok(result)); } return(BadRequest(ErrorDictionary)); } return(Ok(okDictionary)); }
public IActionResult PosDmnToExcel() { var httpRequest = HttpContext.Request; var httpFiles = httpRequest.Form.Files; var errorDictionary = new Dictionary <string, string>(); if (httpFiles == null && !httpFiles.Any()) { return(NotFound("Can't find any file")); } if (httpFiles.Count == 1) { var file = httpFiles.FirstOrDefault(); tDefinitions dmn = null; //Deserialize DMN file if (file != null) { using (Stream dmnfile = file.OpenReadStream()) { dmn = DmnConverter.DeserializeStreamDmnFile(dmnfile); } } if (dmn == null) { if (file != null) { return(BadRequest(new Dictionary <string, string>() { { file.FileName + ".dmn", "Can't Deserialize DMN file" } })); } } // check if DMN have desicion table var items = dmn.Items; var decision = items.Where(t => t.GetType() == typeof(tDecision)); var tDrgElements = decision as tDRGElement[] ?? decision.ToArray(); if (!tDrgElements.Any()) { if (file != null) { return(BadRequest(new Dictionary <string, string>() { { file.FileName + ".dmn", "Dmn file have non Decision tables" } })); } } // create Excel Package var excelPkg = new ExcelPackage(); foreach (var tdecision in tDrgElements) { try { var dt = ((tDecision)tdecision).Item; var decisionTable = (tDecisionTable)Convert.ChangeType(dt, typeof(tDecisionTable)); ExcelWorksheet wsSheet = excelPkg.Workbook.Worksheets.Add(tdecision.id); //Add Table Title ExcelConverter.AddTableTitle(tdecision.name, wsSheet, decisionTable.hitPolicy.ToString(), tdecision.id); // Add "input" and "output" headet to Excel table ExcelConverter.AddTableInputOutputTitle(wsSheet, decisionTable); //Add DMN Table to excel Sheet ExcelConverter.CreateExcelTableFromDecisionTable(decisionTable, wsSheet, tdecision.id); wsSheet.Protection.IsProtected = true; } catch { if (file != null) { return(BadRequest(new Dictionary <string, string>() { { file.FileName + ".dmn", "Can't be create ExcelPackage" } })); } } } // Create Excel Stream response try { if (file != null) { var filename = Path.GetFileNameWithoutExtension(file.FileName); excelPkg.Save(); var fileStream = excelPkg.Stream; fileStream.Flush(); fileStream.Position = 0; return(File(fileStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"{filename}.xlsx")); } } catch { if (file != null) { errorDictionary.Add(file.FileName, "Can't create excel Stream response"); } } } else { return(BadRequest(new Dictionary <string, string>() { { "Error", "Can't convert more than one file." } })); } return(Ok(new Dictionary <string, string>() { { "Error", "No data to process." } })); }