diff --git a/src/GoProject.Sample/App_Data/CasSp.sql b/src/GoProject.Sample/App_Data/CasSp.sql new file mode 100644 index 0000000..3e493e9 --- /dev/null +++ b/src/GoProject.Sample/App_Data/CasSp.sql @@ -0,0 +1,276 @@ +USE [CAS] +GO +/****** Object: StoredProcedure [dbo].[sp_GetDiagramNodes] Script Date: 05/12/1395 09:56:00 ق.ظ ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'sp_GetDiagramNodes') AND type IN ( N'P', N'PC' ) ) + DROP PROCEDURE [dbo].[sp_GetDiagramNodes] +Go +CREATE PROCEDURE [dbo].[sp_GetDiagramNodes] + @DiagramId VARCHAR(100) +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + -- All Expense Centers Data + --SELECT ec.ExpenseCenterId, + -- ec.[Name] , + -- ec.ExpenseCenterTypeId , + -- ect.Title AS ExpenseCenterTypeName, + -- ec.ExpenseCenterCode , + -- ec.LineCode, + -- wtp.WorkStationToProductId, + -- wtp.WorkStationId, + -- w.Name, + -- wtp.ProductId, + -- p.ProductName, + -- p.group1_code, + -- CONVERT(BIT, CASE WHEN p.ProductName IS NULL THEN 0 ELSE 1 END) AS EndProduct, + -- wtp.OrderWorksatation + --FROM [CAS].[dbo].[ExpenseCenter] ec + -- INNER JOIN [CAS].[dbo].[ExpenseCenterType] ect ON ec.ExpenseCenterTypeId = ect.ExpenseCenterTypeId + -- INNER JOIN dbo.WorkStationToProduct wtp ON wtp.ExpenseCenterId = ec.ExpenseCenterId + -- INNER JOIN dbo.WorkStation w ON w.WorkStationId = wtp.WorkStationId + -- Left JOIN dbo.Product p ON p.ProductId = wtp.ProductId + -- ORDER BY ec.ExpenseCenterId, wtp.OrderWorksatation; + + DECLARE @Nodes TABLE ( + [Key] [VARCHAR](100) NOT NULL, + [Category] [INT] NOT NULL, + [Loc] [VARCHAR](50) NULL, + [Text] [NVARCHAR](150) NULL, + [EventType] [INT] NULL, + [EventDimension] [INT] NULL, + [GatewayType] [INT] NULL, + [TaskType] [INT] NULL, + [Group] [VARCHAR](100) NULL, + [IsGroup] [BIT] NULL, + [Color] [VARCHAR](50) NULL, + [Size] [VARCHAR](50) NULL, + [IsSubProcess] [BIT] NULL, + [Name] [NVARCHAR](150) NULL, + OrderWorksatation INT NOT NULL, + IsInput BIT NULL, + ProductId INT NULL + ) + + DECLARE @Links TABLE ( + [From] [INT] NOT NULL, + [To] [INT] NOT NULL + ) + + DECLARE @PoolKey VARCHAR(100) = 'Pool_'+ @DiagramId + DECLARE @LaneKey VARCHAR(100) = 'Lane_'+ @DiagramId + + + + -- Pool Node: + INSERT INTO @Nodes + ( [Key] , + Category , + Loc , + Text , + EventType , + EventDimension , + GatewayType , + TaskType , + [Group] , + IsGroup , + Name, + OrderWorksatation + ) + SELECT + @PoolKey AS [Key], + 7 AS Category, + NULL AS Loc, + N'مرکز هزینه ' + [NAME] AS [Text], + NULL AS EventType, + NULL AS EventDimension, + NULL AS GatewayType, + NULL AS TaskType, + NULL AS [Group], + 1 AS IsGroup, + 'PoolNode' AS [Name], + 0 + FROM dbo.ExpenseCenter + WHERE ExpenseCenterId = @DiagramId + + -- Lane Node: + INSERT INTO @Nodes + ( [Key] , + Category , + Loc , + Text , + EventType , + EventDimension , + GatewayType , + TaskType , + [Group] , + IsGroup , + Name, + OrderWorksatation + ) + SELECT + @LaneKey AS [Key], + 8 AS Category, + NULL AS Loc, + N'خط تولید' AS [Text], + NULL AS EventType, + NULL AS EventDimension, + NULL AS GatewayType, + NULL AS TaskType, + @PoolKey AS [Group], + 1 AS IsGroup, + 'LaneNode' AS [Name], + 0 + + + -- Activity Nodes: + INSERT INTO @Nodes + ( [Key] , + Category , + Loc , + Text , + EventType , + EventDimension , + GatewayType , + TaskType , + [Group] , + IsGroup , + Name, + OrderWorksatation + ) + SELECT + CONVERT(VARCHAR(10), wtp.OrderWorksatation) + CONVERT(VARCHAR(10), wtp.WorkStationId) AS [Key], + 1, --activity + NULL AS Loc, + w.[Name] AS [Text], + NULL AS EventType, + NULL AS EventDimension, + NULL AS GatewayType, + 6 AS TaskType, + @LaneKey as [Group], + 0 as IsGroup, + 'ActivityNode' AS [Name], + wtp.OrderWorksatation + FROM [CAS].[dbo].[ExpenseCenter] ec + INNER JOIN dbo.WorkStationToProduct wtp ON wtp.ExpenseCenterId = ec.ExpenseCenterId + INNER JOIN dbo.WorkStation w ON w.WorkStationId = wtp.WorkStationId + WHERE ec.ExpenseCenterId = @DiagramId + GROUP BY wtp.OrderWorksatation, CONVERT(VARCHAR(10), wtp.OrderWorksatation) + CONVERT(VARCHAR(10), wtp.WorkStationId), w.[Name] + ORDER BY wtp.OrderWorksatation + + + -- Event Nodes + INSERT INTO @Nodes + ( [Key] , + Category , + Loc , + Text , + EventType , + EventDimension , + GatewayType , + TaskType , + [Group] , + IsGroup , + Name, + OrderWorksatation, + IsInput, + ProductId + ) + SELECT + wtp.WorkStationToProductId AS [Key], + 0 AS Category, + NULL AS Loc, + p.code_name AS [Text], + CASE p.TypeCodeKala + WHEN 0 THEN 1 -- مواد اولیه + WHEN 1 THEN 11 -- نیمه ساخته + WHEN 2 THEN 13 -- نهایی + ELSE 11 + END AS EventType, + CASE p.TypeCodeKala + WHEN 0 THEN 1 -- مواد اولیه + WHEN 1 THEN 6 -- نیمه ساخته + WHEN 2 THEN 8 -- نهایی + ELSE 6 + END AS EventDimension, + NULL AS GatewayType, + NULL AS TaskType, + @LaneKey as [Group], + 0 as IsGroup, + 'EventNode' AS [Name], + wtp.OrderWorksatation, + CASE p.TypeCodeKala + WHEN 2 THEN 0 -- محصول نهایی + ELSE 1 + END AS IsInput, + wtp.ProductId + FROM [CAS].[dbo].[ExpenseCenter] ec + INNER JOIN dbo.WorkStationToProduct wtp ON wtp.ExpenseCenterId = ec.ExpenseCenterId + INNER JOIN dbo.WorkStation w ON w.WorkStationId = wtp.WorkStationId + Left JOIN [dbo].[ProductView] p ON p.coding_main_id = wtp.ProductId + WHERE ec.ExpenseCenterId = @DiagramId + ORDER BY wtp.OrderWorksatation + + + + + + + -- Add Nodes Links + + -- Input event nodes to task node and task node to output event nodes links + INSERT INTO @Links + ( [From], [To] ) + SELECT + CASE WHEN eventNodes.IsInput = 1 then eventNodes.[Key] ELSE taskNodes.[Key] END AS [From], + CASE WHEN eventNodes.IsInput = 1 then taskNodes.[Key] ELSE eventNodes.[Key] END AS [To] + FROM @Nodes eventNodes + INNER JOIN @Nodes taskNodes ON tasknodes.OrderWorksatation = eventNodes.OrderWorksatation + WHERE eventNodes.Category = 0 -- event nodes + AND taskNodes.Category = 1 -- activity + ORDER BY eventNodes.OrderWorksatation, tasknodes.OrderWorksatation + + -- Output event nodes to next task nodes links + INSERT INTO @Links + ( [From], [To] ) + SELECT eventNodes.[Key] AS [From], taskNodes.[Key] AS [To] + FROM @Nodes eventNodes + INNER JOIN @Nodes taskNodes ON tasknodes.OrderWorksatation = eventNodes.OrderWorksatation + 1 + WHERE eventNodes.Category = 0 -- event nodes + AND taskNodes.Category = 1 -- activity + AND eventNodes.IsInput = 0 -- just output event nodes + ORDER BY eventNodes.OrderWorksatation, tasknodes.OrderWorksatation + + -- Output event nodes to next task nodes links + INSERT INTO @Links + ( [From], [To] ) + SELECT preTasks.[Key] AS [From], nextTasks.[Key] AS [To] + FROM @Nodes preTasks + INNER JOIN @Nodes nextTasks ON nextTasks.OrderWorksatation = preTasks.OrderWorksatation + 1 + WHERE preTasks.Category = 1 -- task nodes + AND nextTasks.Category = 1 -- task nodes + ORDER BY preTasks.OrderWorksatation, nextTasks.OrderWorksatation + + + + -- Get Result to Application + + -- nodes + SELECT * FROM @Nodes + + + -- node details + SELECT n.[Key], pv.cod AS N'کد محصول', pv.typename AS N'نوع', pv.code_desc AS N'توضیحات' + FROM [dbo].[ProductView] pv + INNER JOIN @Nodes n ON n.ProductId = pv.coding_main_id + + + -- links + SELECT * FROM @Links +END diff --git a/src/GoProject.Sample/App_Data/Connections.cs b/src/GoProject.Sample/App_Data/Connections.cs index fee5cc5..67bc968 100644 --- a/src/GoProject.Sample/App_Data/Connections.cs +++ b/src/GoProject.Sample/App_Data/Connections.cs @@ -2,7 +2,7 @@ // // This code was generated by a tool. // Runtime Version: 4.0.30319.42000 -// Generated at 02/22/2017 15:05:15 +// Generated at 02/27/2017 12:09:51 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -33,5 +33,7 @@ static Connections() public static AdoManager.ConnectionManager GoProjectDb { get { return ConnectionManager.Find("GoProjectDb"); } } + + public static AdoManager.ConnectionManager CAS { get { return ConnectionManager.Find("CAS"); } } } \ No newline at end of file diff --git a/src/GoProject.Sample/App_Start/BundleConfig.cs b/src/GoProject.Sample/App_Start/BundleConfig.cs index 9e6062a..cb6adfe 100644 --- a/src/GoProject.Sample/App_Start/BundleConfig.cs +++ b/src/GoProject.Sample/App_Start/BundleConfig.cs @@ -11,7 +11,8 @@ public static void RegisterBundles(BundleCollection bundles) bundles.Add(new ScriptBundle("~/bundles/goJs").Include("~/Scripts/GoJs/go.js")); bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js", - "~/Scripts/jquery-ui-{version}.js" + "~/Scripts/jquery-ui-{version}.js", + "~/Scripts/bootstrap.min.js" )); bundles.Add(new ScriptBundle("~/bundles/bpmnJs").Include( diff --git a/src/GoProject.Sample/Content/GoJs/BPMN.css b/src/GoProject.Sample/Content/GoJs/BPMN.css index 4613240..afe18a1 100644 --- a/src/GoProject.Sample/Content/GoJs/BPMN.css +++ b/src/GoProject.Sample/Content/GoJs/BPMN.css @@ -10,9 +10,7 @@ #myDiagramDiv { float: left; border: solid 1px blue; - width: 80%; height: 600px; - margin-right: 12px; background-color: ghostwhite; } @@ -31,27 +29,28 @@ #PaletteAndDiagram { position: relative; - overflow: hidden; + overflow-y: auto; + overflow-x: hidden; width: 100%; } #sideBar { float: left; - width: 15%; - min-height: 500px; text-align: center; border: 1px solid gray; + padding-right: 14px; + padding-left: 2px; } .myPaletteDiv { width: 100%; - min-height: 625px; + min-height: 300px; + overflow-x: hidden !important; } #accordion { - margin: 0px; + margin: 0; width: 97%; - min-height: 625px; } #myOverviewDiv { @@ -92,7 +91,7 @@ input { font-family: iransans, Arial, tahoma; font-weight: bold; font-size: 14px; - padding: 3px 0px; + padding: 3px 0; color: white; } @@ -144,41 +143,11 @@ figure { margin: 10px; } - -#infoBoxHolder { - z-index: 300; - position: absolute; - left: 5px; -} - -#infoBox { - border: 1px dashed #AAA; - padding: 8px; - background-color: azure; - opacity: 1; - position: relative; - width: 180px; - /*height: 60px;*/ - font-family: iransans, Arial, tahoma, helvetica, sans-serif; - font-weight: bold; - font-size: 11px; -} - /* this is known as the "clearfix" hack to allow - floated objects to add to the height of a div */ - #infoBox:after { - visibility: hidden; - display: block; - font-size: 0; - content: " "; - clear: both; - height: 0; - } - div.infoTitle { width: 50%; font-weight: normal; color: #777777; - float: left; + float: left; } div.infoValues { @@ -191,12 +160,32 @@ label:hover, label:focus { background: #CEDFF2; } -.aline{ +.aline { clear: both; width: 100%; } -.tooltipTitle{ + +.tooltipTitle { font-size: 13px; padding-top: 5px; padding-bottom: 10px; -} \ No newline at end of file +} + +.frm { + padding: 10px 40px; +} + +#frmNodeEditor { + padding: 10px; + font-family: iransans, Arial, tahoma; + font-weight: lighter; + font-size: 9pt; +} + + #frmNodeEditor input { + font-size: 9pt; + } + + #frmNodeEditor label { + padding: 3px 0; + } diff --git a/src/GoProject.Sample/Content/Site.css b/src/GoProject.Sample/Content/Site.css index cbbfacf..558875f 100644 --- a/src/GoProject.Sample/Content/Site.css +++ b/src/GoProject.Sample/Content/Site.css @@ -8,6 +8,7 @@ body { width:100%; padding-top: 50px; padding-bottom: 200px; + overflow-x: hidden; } /* Set padding to keep content from hitting the edges */ @@ -33,3 +34,7 @@ textarea { canvas, div, * { font-family: iransans, Arial, tahoma !important; } + +.frm { + padding: 10px; +} \ No newline at end of file diff --git a/src/GoProject.Sample/Controllers/GoApiController.cs b/src/GoProject.Sample/Controllers/GoApiController.cs index 1163e52..b06b9b5 100644 --- a/src/GoProject.Sample/Controllers/GoApiController.cs +++ b/src/GoProject.Sample/Controllers/GoApiController.cs @@ -1,11 +1,13 @@ using Newtonsoft.Json; using System; +using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Globalization; using System.IO; using System.Linq; +using System.Reflection; using System.Web.Http; -using GoProject.Extensions; using GoProject.Nodes; using GoProject.Sample.Core; using GoProject.Sample.Models; @@ -44,7 +46,9 @@ public IHttpActionResult GetDiagram() public IHttpActionResult GetDiagram(string id) { - var diagram = Connections.GoProjectDb.SqlConn.LoadFromDb(id); + //var diagram = Connections.GoProjectDb.SqlConn.LoadFromDb(id); + var diagram = Connections.CAS.SqlConn.LoadFromCasDb(id); + return Ok(diagram); } @@ -83,5 +87,16 @@ public IHttpActionResult GetCustomPaletteNodes() return Ok(diagram); } + public IHttpActionResult GetLocalization() + { + var jsonResources = GoProject.Properties.Localization + .ResourceManager.GetResourceSet(CultureInfo.DefaultThreadCurrentCulture, true, true) + .Cast() + .ToDictionary(x => x.Key.ToString(), + x => x.Value.ToString()); + + + return Ok(jsonResources); + } } } diff --git a/src/GoProject.Sample/Controllers/GoController.cs b/src/GoProject.Sample/Controllers/GoController.cs index 134e200..cde3bfd 100644 --- a/src/GoProject.Sample/Controllers/GoController.cs +++ b/src/GoProject.Sample/Controllers/GoController.cs @@ -43,13 +43,17 @@ public ActionResult BpmnEditorSample() public ActionResult BpmnEditorSample(string id) { ViewBag.Title = "BpmnEditorSample"; - var model = Connections.GoProjectDb.SqlConn.LoadFromDb(id); + // var model = Connections.GoProjectDb.SqlConn.LoadFromDb(id); + var model = Connections.CAS.SqlConn.LoadFromCasDb(id); + return View(model); } public ActionResult GoDiagramsTablePartial() { - var model = Connections.GoProjectDb.SqlConn.Query("Select * From Diagrams"); + //var model = Connections.GoProjectDb.SqlConn.Query("Select * From Diagrams"); + var model = Connections.CAS.SqlConn.Query("SELECT ExpenseCenterId AS Id, [NAME], UserId AS CreatorUserId FROM dbo.ExpenseCenter"); + return PartialView("_GoDiagramsTablePartial", model); } diff --git a/src/GoProject.Sample/Core/ExtensionHelper.cs b/src/GoProject.Sample/Core/ExtensionHelper.cs index 698d7ab..f5afdd7 100644 --- a/src/GoProject.Sample/Core/ExtensionHelper.cs +++ b/src/GoProject.Sample/Core/ExtensionHelper.cs @@ -1,10 +1,27 @@ using System.Collections.Generic; using System.Data; +using System.Dynamic; +using System.Linq; namespace GoProject.Sample.Core { public static class ExtensionHelper { - + public static dynamic DapperDynamicToExpandoObject(this object value) + { + IDictionary dapperRowProperties = value as IDictionary; + + IDictionary expando = new ExpandoObject(); + + foreach (KeyValuePair property in dapperRowProperties) + expando.Add(property.Key, property.Value); + + return expando as ExpandoObject; + } + + public static dynamic ToExpandoObjects(this IEnumerable value) + { + return value.Select(x => (ExpandoObject)DapperDynamicToExpandoObject(x)); + } } } \ No newline at end of file diff --git a/src/GoProject.Sample/Core/GoDiagramDbHelper.cs b/src/GoProject.Sample/Core/GoDiagramDbHelper.cs index 4448493..0036a23 100644 --- a/src/GoProject.Sample/Core/GoDiagramDbHelper.cs +++ b/src/GoProject.Sample/Core/GoDiagramDbHelper.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Data; using System.Data.Common; +using System.Dynamic; using System.Linq; using Dapper; using GoProject.DataTableHelper; @@ -88,6 +90,53 @@ public static Diagram LoadFromDb(this DbConnection dbConn, string diagramId, int } } + public static Diagram LoadFromCasDb(this DbConnection dbConn, string diagramId, int userId = 0, bool forceReadonly = false) + { + try + { + var diagram = + dbConn.Query("SELECT ExpenseCenterId AS Id, [NAME], UserId AS CreatorUserId FROM dbo.ExpenseCenter Where ExpenseCenterId = @diagramId", new { diagramId }).FirstOrDefault(); + + if (diagram == null) return null; + + if (diagram.IsReadOnly == false) + diagram.IsReadOnly = forceReadonly; // set force to readonly when from database is false + + using (var res = dbConn.QueryMultiple("sp_GetDiagramNodes", new { DiagramId = diagramId }, commandType: CommandType.StoredProcedure)) + { + var nodes = res.Read()?.ToList(); + IEnumerable nodeDetails = res.Read()?.ToExpandoObjects(); + + if (nodes != null && nodeDetails != null) + { + foreach (var node in nodes) + { + //node.Details = nodeDetails?.FirstOrDefault(d => string.Equals(((IDictionary)d)["Key"].ToString(), node.Key))?.Where(x=>x.Key != "Key").Select(x=> (IDictionary)x); + foreach (IDictionary d in nodeDetails) + { + if (node.Key == d["Key"].ToString()) + { + d.Remove("Key"); + node.Details = d; + } + } + } + + diagram.TreeNodes = nodes.ConvertToTreeNodes(); + } + + diagram.LinkDataArray = res.Read().ToList(); + } + + return diagram; + } + catch (Exception exp) + { + throw; + } + } + + public static IEnumerable GetPaletteNodesByUserRole(this DbConnection dbConn, int userId) { var shapes = dbConn.Query("SELECT * FROM fn_GetPaletteNodes(@UserId)", new { UserId = userId }); diff --git a/src/GoProject.Sample/GoProject.Sample.csproj b/src/GoProject.Sample/GoProject.Sample.csproj index aa4a5b5..744e575 100644 --- a/src/GoProject.Sample/GoProject.Sample.csproj +++ b/src/GoProject.Sample/GoProject.Sample.csproj @@ -169,6 +169,7 @@ + TextTemplatingFileGenerator Connections.cs diff --git a/src/GoProject.Sample/Scripts/GoJs/BPMN.js b/src/GoProject.Sample/Scripts/GoJs/BPMN.js index 765a84d..6ea9ddb 100644 --- a/src/GoProject.Sample/Scripts/GoJs/BPMN.js +++ b/src/GoProject.Sample/Scripts/GoJs/BPMN.js @@ -7,7 +7,10 @@ // Setup all of the Diagrams and what they need. // This is called after the page is loaded. -function init(paletteApi) { +function init(paletteApi, localizationConfig) { + // load localization + window.goLocalization = localizationConfig; + var $ = go.GraphObject.make; // for more concise visual tree definitions // constants for design choices @@ -117,30 +120,34 @@ function init(paletteApi) { return geo; }); - // define the appearance of tooltips, shared by various templates - var tooltiptemplate = - $(go.Adornment, go.Panel.Auto, - $(go.Shape, "RoundedRectangle", - { - fill: "white", // the default fill, if there is no data-binding - portId: "", cursor: "pointer", // the Shape is the port, not the whole Node - // allow all kinds of links from and to this port - fromLinkable: true, fromLinkableSelfNode: true, fromLinkableDuplicates: true, - toLinkable: true, toLinkableSelfNode: true, toLinkableDuplicates: true - }), - $(go.TextBlock, - { - font: "bold 14px iransans, sans-serif", - stroke: '#333', - margin: 6, // make some extra space for the shape around the text - isMultiline: true, // don't allow newlines in text - editable: true // allow in-place editing by user - }, + var tooltiptemplate = $(go.Adornment, // This go.Adornment or go.HTMLInfo is shown when the mouse stays motionless in the background. The default value is null, which means no tooltip is shown. + go.Panel.Auto, + $(go.Shape, + "RoundedRectangle", + { + fill: "white", // the default fill, if there is no data-binding + portId: "", + cursor: "pointer", // the Shape is the port, not the whole Node + // allow all kinds of links from and to this port + fromLinkable: true, + fromLinkableSelfNode: true, + fromLinkableDuplicates: true, + toLinkable: true, + toLinkableSelfNode: true, + toLinkableDuplicates: true + }), + $(go.TextBlock, + { + font: "9pt tahoma, sans-serif", + stroke: '#333', + margin: 6, // make some extra space for the shape around the text + isMultiline: true, // don't allow newlines in text + editable: true // allow in-place editing by user + }, new go.Binding("text", "", nodeInfo)) ); - // conversion functions used by data Bindings function nodeActivityTaskTypeConverter(s) { @@ -263,50 +270,29 @@ function init(paletteApi) { //------------------------------------------ Activity Node contextMenu ---------------------------------------------- - //var activityNodeMenu = - // $(go.Adornment, "Vertical", - // $("ContextMenuButton", - // $(go.TextBlock, "Add Email Event", { margin: 3, font: "10px iransans, sans-serif" }), - // { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 2, 5); } }), - // $("ContextMenuButton", - // $(go.TextBlock, "Add Timer Event", { margin: 3, font: "10px iransans, sans-serif" }), - // { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 3, 5); } }), - // $("ContextMenuButton", - // $(go.TextBlock, "Add Escalation Event", { margin: 3, font: "10px iransans, sans-serif" }), - // { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 4, 5); } }), - // $("ContextMenuButton", - // $(go.TextBlock, "Add Error Event", { margin: 3, font: "10px iransans, sans-serif" }), - // { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 7, 5); } }), - // $("ContextMenuButton", - // $(go.TextBlock, "Add Signal Event", { margin: 3, font: "10px iransans, sans-serif" }), - // { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 10, 5); } }), - // $("ContextMenuButton", - // $(go.TextBlock, "Add N-I Escalation Event", { margin: 3, font: "10px iransans, sans-serif" }), - // { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 4, 6); } }), - // $("ContextMenuButton", - // $(go.TextBlock, "Rename", { margin: 3, font: "10px iransans, sans-serif" }), - // { click: function (e, obj) { rename(myDiagram, obj); } })); - var activityNodeMenu = - $(go.Adornment, "Vertical", - $("ContextMenuButton", - $(go.TextBlock, "اضافه کردن رخداد ایمیل", { margin: 3, font: "10px iransans, sans-serif" }), - { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 2, 5); } }), - $("ContextMenuButton", - $(go.TextBlock, "اضافه کردن رخداد زماندار", { margin: 3, font: "10px iransans, sans-serif" }), - { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 3, 5); } }), - $("ContextMenuButton", - $(go.TextBlock, "اضافه کردن رخداد تشدید", { margin: 3, font: "10px iransans, sans-serif" }), - { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 4, 5); } }), - $("ContextMenuButton", - $(go.TextBlock, "اضافه کردن رخداد خطا", { margin: 3, font: "10px iransans, sans-serif" }), - { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 7, 5); } }), - $("ContextMenuButton", - $(go.TextBlock, "اضافه کردن رخداد سیگنال", { margin: 3, font: "10px iransans, sans-serif" }), - { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 10, 5); } }), - $("ContextMenuButton", - $(go.TextBlock, "تغییر نام", { margin: 3, font: "10px iransans, sans-serif" }), - { click: function (e, obj) { rename(myDiagram, obj); } })); + $(go.Adornment, "Vertical", + $("ContextMenuButton", + $(go.TextBlock, goLocalization.AddEmailEvent, { margin: 3, font: "10px iransans, sans-serif" }), + { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 2, 5); } }), + $("ContextMenuButton", + $(go.TextBlock, goLocalization.AddTimerEvent, { margin: 3, font: "10px iransans, sans-serif" }), + { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 3, 5); } }), + $("ContextMenuButton", + $(go.TextBlock, goLocalization.AddEscalationEvent, { margin: 3, font: "10px iransans, sans-serif" }), + { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 4, 5); } }), + $("ContextMenuButton", + $(go.TextBlock, goLocalization.AddErrorEvent, { margin: 3, font: "10px iransans, sans-serif" }), + { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 7, 5); } }), + $("ContextMenuButton", + $(go.TextBlock, goLocalization.AddSignalEvent, { margin: 3, font: "10px iransans, sans-serif" }), + { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 10, 5); } }), + $("ContextMenuButton", + $(go.TextBlock, goLocalization.AddN_IEscalationEvent, { margin: 3, font: "10px iransans, sans-serif" }), + { click: function (e, obj) { addActivityNodeBoundaryEvent(myDiagram, 4, 6); } }), + $("ContextMenuButton", + $(go.TextBlock, goLocalization.Rename, { margin: 3, font: "10px iransans, sans-serif" }), + { click: function (e, obj) { rename(myDiagram, obj); } })); // sub-process, loop, parallel, sequential, ad doc and compensation markers in horizontal array @@ -688,7 +674,8 @@ function init(paletteApi) { $(go.TextBlock, { margin: 5, - editable: true + editable: true, + font: "bold 11px iransans, sans-serif" }, new go.Binding("text").makeTwoWay()) ); @@ -841,7 +828,7 @@ function init(paletteApi) { var laneEventMenu = // context menu for each lane $(go.Adornment, "Vertical", $("ContextMenuButton", - $(go.TextBlock, "ایجاد بخش"), + $(go.TextBlock, goLocalization.AddLane), // in the click event handler, the obj.part is the Adornment; its adornedObject is the port { click: function (e, obj) { addLaneEvent(myDiagram, obj.part.adornedObject); } }) ); @@ -1120,20 +1107,37 @@ function init(paletteApi) { //------------------------------------------the main Diagram---------------------------------------------- - window.myDiagram = $(go.Diagram, "myDiagramDiv", { + // more options: http://gojs.net/latest/api/symbols/Diagram.html nodeTemplateMap: nodeTemplateMap, linkTemplateMap: linkTemplateMap, groupTemplateMap: groupTemplateMap, - + allowZoom: true, allowDrop: true, // accept drops from palette - + "undoManager.isEnabled": true, // enable undo & redo + initialContentAlignment: go.Spot.Center, // center the content + //contentAlignment: go.Spot.Center, // content is always centered in the viewport + initialAutoScale: go.Diagram.Uniform, // scale all content fitting in the viewport + //autoScale: go.Diagram.Uniform, // scale always has all content fitting in the viewport + "animationManager.isEnabled": false, // turn off automatic animations, don't bother with layout animation + "grid.visible": true, // display a background grid for the whole diagram + "grid.gridCellSize": new go.Size(20, 20), + //"clickCreatingTool.archetypeNodeData": { text: "Node" }, // allow double-click in background to create a new node + + // allow Ctrl-G to call the groupSelection command + //"commandHandler.archetypeGroupData": { text: "Group", isGroup: true, color: "blue" }, + "commandHandler.copiesTree": true, // for the copy command + "commandHandler.deletesTree": true, // for the delete command + "toolManager.hoverDelay": 10, // how quickly tooltips are shown + "toolManager.mouseWheelBehavior": go.ToolManager.WheelZoom, // mouse wheel zooms instead of scrolls + "draggingTool.dragsTree": true, // dragging for both move and copy + "draggingTool.isGridSnapEnabled": true, + //layout: $(go.TreeLayout, { angle: 90, sorting: go.TreeLayout.SortingAscending }), + // "ModelChanged": function(e) { if (e.isTransactionFinished) saveModel(); }, // a Changed listener on the Diagram.model commandHandler: new DrawCommandHandler(), // defined in DrawCommandHandler.js - // default to having arrow keys move selected nodes - "commandHandler.arrowKeyBehavior": "move", - + "commandHandler.arrowKeyBehavior": "move", // default to having arrow keys move selected nodes mouseDrop: function (e) { // when the selection is dropped in the diagram's background, // make sure the selected Parts no longer belong to any Group @@ -1141,15 +1145,11 @@ function init(paletteApi) { if (!ok) myDiagram.currentTool.doCancel(); }, linkingTool: new BPMNLinkingTool(), // defined in BPMNClasses.js - "SelectionMoved": function () { relayoutDiagram(myDiagram) }, // defined below - "SelectionCopied": function () { relayoutDiagram(myDiagram) }, - - //"animationManager.isEnabled": true, // don't bother with layout animation - //contentAlignment: go.Spot.Center, // content is always centered in the viewport - //autoScale: go.Diagram.Uniform // scale always has all content fitting in the viewport + //click: doMouseOver // this event handler is defined below + //mouseOver: doMouseOver // this event handler is defined below //isReadOnly: true, // don't let users modify anything - // ,mouseOver: doMouseOver, // this event handler is defined below - // click: doMouseOver // this event handler is defined below + "SelectionMoved": function () { relayoutDiagram(myDiagram) }, // defined below + "SelectionCopied": function () { relayoutDiagram(myDiagram) } }); myDiagram.toolManager.mouseDownTools.insertAt(0, new LaneResizingTool()); @@ -1209,40 +1209,6 @@ function init(paletteApi) { jQuery.getJSON(paletteApi, function (jsondata) { myPaletteLevel.model = go.Model.fromJson(jsondata); //$(go.GraphLinksModel, jsondata); }); - //myPaletteLevel.model = $(go.GraphLinksModel, - // { - // copiesArrays: true, - // copiesArrayObjects: true, - // nodeDataArray: [ - // // -------------------------- Event Nodes - // { category: "event", text: "Start", eventType: 1, eventDimension: 1 }, - // { category: "event", text: "Message", eventType: 2, eventDimension: 2 }, // BpmnTaskMessage - // { category: "event", text: "Timer", eventType: 3, eventDimension: 3 }, - // { category: "event", text: "End", eventType: 1, eventDimension: 8 }, - // { category: "event", text: "Message", eventType: 2, eventDimension: 8 },// BpmnTaskMessage - // { category: "event", text: "Terminate", eventType: 13, eventDimension: 8 }, - // // -------------------------- Task/Activity Nodes - // { key: 131, category: "activity", text: "Task", item: "generic task", taskType: 0 }, - // { key: 132, category: "activity", text: "User Task", item: "User task", taskType: 2 }, - // { key: 133, category: "activity", text: "Service\nTask", item: "service task", taskType: 6 }, - // // subprocess and start and end - // { key: 134, category: "subprocess", loc: "0 0", text: "Subprocess", isGroup: true, isSubProcess: true, taskType: 0 }, - // { key: -802, category: "event", loc: "0 0", group: 134, text: "Start", eventType: 1, eventDimension: 1, item: "start" }, - // { key: -803, category: "event", loc: "350 0", group: 134, text: "End", eventType: 1, eventDimension: 8, item: "end", name: "end" }, - // // -------------------------- Gateway Nodes, Data, Pool and Annotation - // { key: 201, category: "gateway", text: "Parallel", gatewayType: 1 }, - // { key: 204, category: "gateway", text: "Exclusive", gatewayType: 4 }, - // { key: 301, category: "dataobject", text: "Data\nObject" }, - // { key: 302, category: "datastore", text: "Data\nStorage" }, - // { key: 401, category: "privateProcess", text: "Black Box" }, - - // { key: "501", "text": "Pool 1", "isGroup": "true", "category": "Pool" }, - // { key: "Lane5", "text": "Lane 1", "isGroup": "true", "group": "501", "color": "lightyellow", "category": "Lane" }, - // { key: "Lane6", "text": "Lane 2", "isGroup": "true", "group": "501", "color": "lightgreen", "category": "Lane" }, - - // { key: 701, category: "annotation", text: "note" } - // ] // end nodeDataArray - // }); // end model //------------------------------------------ Overview ---------------------------------------------- @@ -1251,6 +1217,194 @@ function init(paletteApi) { // change color of viewport border in Overview myOverview.box.elt(0).stroke = "dodgerblue"; + myDiagram.addDiagramListener("ObjectSingleClicked", onNodeClick); return myDiagram; -} // end init \ No newline at end of file +} // end init + + + +// this is called after nodes have been moved or lanes resized, to layout all of the Pool Groups again +function relayoutDiagram(diagram) { + if (diagram === undefined || diagram === null) diagram = window.myDiagram; + diagram.layout.invalidateLayout(); + diagram.findTopLevelGroups().each(function (g) { if (g.category === "Pool") g.layout.invalidateLayout(); }); + diagram.layoutDiagram(); +} + + +// changes the item of the object +function rename(diagram, obj) { + diagram.startTransaction("rename"); + var newName = prompt(goLocalization.Rename + " " + obj.part.data.item + " " + goLocalization.to + ":"); + diagram.model.setDataProperty(obj.part.data, "item", newName); + diagram.commitTransaction("rename"); +} + +// shows/hides gridlines +// to be implemented onclick of a button +function updateGridOption(diagram) { + diagram.startTransaction("grid"); + var grid = document.getElementById("grid"); + diagram.grid.visible = grid.checked; + diagram.commitTransaction("grid"); +} + + +// enables/disables snapping tools, to be implemented by buttons +function updateSnapOption(diagram) { + // no transaction needed, because we are modifying tools for future use + var snap = document.getElementById("snap"); + if (snap.checked) { + diagram.toolManager.draggingTool.isGridSnapEnabled = true; + diagram.toolManager.resizingTool.isGridSnapEnabled = true; + } else { + diagram.toolManager.draggingTool.isGridSnapEnabled = false; + diagram.toolManager.resizingTool.isGridSnapEnabled = false; + } +} + +function setCurrentFileName(diagram, name) { + var currentFile = document.getElementById("currentFile"); + if (diagram.isModified) { + name += "*"; + } + currentFile.textContent = name; +} + +function newDocument(diagram) { + // checks to see if all changes have been saved + if (diagram.isModified) { + var save = confirm(goLocalization.Would_you_like_save_changes); + if (save) { + saveDocument(); + } + } + setCurrentFileName(diagram, "(Unsaved File)"); + // loads an empty diagram + diagram.model = new go.GraphLinksModel(); + resetModel(diagram); +} + +function resetModel(diagram) { + diagram.model.undoManager.isEnabled = true; + diagram.model.linkFromPortIdProperty = "fromPort"; + diagram.model.linkToPortIdProperty = "toPort"; + + diagram.model.copiesArrays = true; + diagram.model.copiesArrayObjects = true; + diagram.isModified = false; +} + +function saveDocument(diagram, apiName) { + if (diagram.isModified) { + saveDiagramProperties(diagram); + var data = JSON.parse(myDiagram.model.toJson()); + if (diagram.model.id !== undefined && diagram.model.id !== null) { + data.name = diagram.model.name; + data.id = diagram.model.id; + } else { + data.name = prompt(goLocalization.PleaseEnterDiagramName, "Test Diagram1"); + } + $.post(window.location.origin + '/' + apiName, data, function (d) { + msgShow(goLocalization.StoredSuccessfullAtPath + " " + d + "!", "success"); + }) + .fail(function (d) { + msgShow(goLocalization.FailToStoreOnPath + " \n" + d.responseText, "danger"); + }); + myDiagram.isModified = false; // save and have no changes + } +} + + +// these functions are called when panel buttons are clicked + +function loadJSON(diagram, file, callback) { + jQuery.getJSON(file, function (jsondata) { + // set these kinds of Diagram properties after initialization, not now + diagram.addDiagramListener("InitialLayoutCompleted", function (e) { loadDiagramProperties(e, diagram); }); // defined below + // create the model from the data in the JavaScript object parsed from JSON text + //diagram.model = new go.GraphLinksModel(jsondata["nodes"], jsondata["links"]); + diagram.model = go.Model.fromJson(jsondata); + loadDiagramProperties(null, diagram); + diagram.model.undoManager.isEnabled = true; + diagram.isModified = false; + diagram.isReadOnly = jsondata.isReadOnly; + if (callback !== undefined) + callback(); + }); +} + +// Store shared model state in the Model.modelData property +// (will be loaded by loadDiagramProperties) +function saveDiagramProperties(diagram) { + diagram.model.modelData.position = go.Point.stringify(myDiagram.position); +} + +// Called by loadFile and loadJSON. +function loadDiagramProperties(e, diagram) { + // set Diagram.initialPosition, not Diagram.position, to handle initialization side-effects + var pos = diagram.model.modelData.position; + if (pos) diagram.initialPosition = go.Point.parse(pos); +} + + +function nodeInfo(d) { // Tooltip info for a node data object + var str = d.text + "\n\n"; + + if (d.details !== undefined && d.details !== null) { + for (var prop in d.details) { + str += prop + ": " + d.details[prop] + "\n"; + } + } + return str; +} + +function onNodeClick(e) { + var part = e.subject.part; + var html = ""; + if (!(part instanceof go.Link) && part.data.details !== undefined && part.data.details !== null) { + + if (Object.prototype.hasOwnProperty.call(part.data, "text")) { + html += "
"; + html += "
"; + } + + for (var key in part.data.details) { + if (Object.prototype.hasOwnProperty.call(part.data.details, key)) { + var val = part.data.details[key]; + var id = ("node_" + key + "_" + part.data["key"]).replace(/\s/g, ''); + + html += "
" + "
"; + } + } + var btnId = "Save_" + part.data["key"]; + html += "

"; + + $(document).off("click", "#" + btnId); + $(document).on("click", "#" + btnId, function () { + updateNodeDataFromApi(e); + }); + } + $("#frmNodeEditor").html(html); // set target properties placea inner Html +} + +function updateNodeDataFromApi(e) { + var part = e.subject.part; + + if (part.data.details !== undefined && part.data.details !== null) { + for (var key in part.data.details) { + if (Object.prototype.hasOwnProperty.call(part.data.details, key)) { + var id = ("#node_" + key + "_" + part.data["key"]).replace(/\s/g, ''); + part.data.details[key] = $(id).val(); + } + } + e.diagram.isModified = true; + msgShow(goLocalization.SuccessfullyUpdatedNode, "success"); + } +} + +function msgShow(msg, type) { + var alertBody = "
" + msg + "
"; + $("#frmNodeEditor").append(alertBody); +} \ No newline at end of file diff --git a/src/GoProject.Sample/Scripts/GoJs/BPMNClasses.js b/src/GoProject.Sample/Scripts/GoJs/BPMNClasses.js index 0ad1607..952f0e9 100644 --- a/src/GoProject.Sample/Scripts/GoJs/BPMNClasses.js +++ b/src/GoProject.Sample/Scripts/GoJs/BPMNClasses.js @@ -349,140 +349,4 @@ function addActivityNodeBoundaryEvent(diagram, evType, evDim) { } }); diagram.commitTransaction("addBoundaryEvent"); -} - -// this is called after nodes have been moved or lanes resized, to layout all of the Pool Groups again -function relayoutDiagram(diagram) { - if (diagram === undefined || diagram === null) diagram = window.myDiagram; - diagram.layout.invalidateLayout(); - diagram.findTopLevelGroups().each(function (g) { if (g.category === "Pool") g.layout.invalidateLayout(); }); - diagram.layoutDiagram(); -} - - -// changes the item of the object -function rename(diagram, obj) { - diagram.startTransaction("rename"); - var newName = prompt("Rename " + obj.part.data.item + " to:"); - diagram.model.setDataProperty(obj.part.data, "item", newName); - diagram.commitTransaction("rename"); -} - -// shows/hides gridlines -// to be implemented onclick of a button -function updateGridOption(diagram) { - diagram.startTransaction("grid"); - var grid = document.getElementById("grid"); - diagram.grid.visible = grid.checked; - diagram.commitTransaction("grid"); -} - - -// enables/disables snapping tools, to be implemented by buttons -function updateSnapOption(diagram) { - // no transaction needed, because we are modifying tools for future use - var snap = document.getElementById("snap"); - if (snap.checked) { - diagram.toolManager.draggingTool.isGridSnapEnabled = true; - diagram.toolManager.resizingTool.isGridSnapEnabled = true; - } else { - diagram.toolManager.draggingTool.isGridSnapEnabled = false; - diagram.toolManager.resizingTool.isGridSnapEnabled = false; - } -} - -function setCurrentFileName(diagram, name) { - var currentFile = document.getElementById("currentFile"); - if (diagram.isModified) { - name += "*"; - } - currentFile.textContent = name; -} - -function newDocument(diagram) { - // checks to see if all changes have been saved - if (diagram.isModified) { - var save = confirm("Would you like to save changes ?"); - if (save) { - saveDocument(); - } - } - setCurrentFileName(diagram, "(Unsaved File)"); - // loads an empty diagram - diagram.model = new go.GraphLinksModel(); - resetModel(diagram); -} - -function resetModel(diagram) { - diagram.model.undoManager.isEnabled = true; - diagram.model.linkFromPortIdProperty = "fromPort"; - diagram.model.linkToPortIdProperty = "toPort"; - - diagram.model.copiesArrays = true; - diagram.model.copiesArrayObjects = true; - diagram.isModified = false; -} - -function saveDocument(diagram, apiName) { - if (diagram.isModified) { - saveDiagramProperties(diagram); - var data = JSON.parse(myDiagram.model.toJson()); - if (diagram.model.id !== undefined && diagram.model.id !== null) { - data.name = diagram.model.name; - data.id = diagram.model.id; - } else { - data.name = prompt("Please enter diagram name", "Test Diagram1"); - } - $.post(window.location.origin + '/' + apiName, data, function (d) { - alert("Stored Successfull at path: " + d + "!"); - }) - .fail(function (d) { alert("Fail to store on path: " + d); }); - myDiagram.isModified = false; // save and have no changes - } -} - - -// these functions are called when panel buttons are clicked - -function loadJSON(diagram, file, callback) { - jQuery.getJSON(file, function (jsondata) { - // set these kinds of Diagram properties after initialization, not now - diagram.addDiagramListener("InitialLayoutCompleted", function (e) { loadDiagramProperties(e, diagram); }); // defined below - // create the model from the data in the JavaScript object parsed from JSON text - //diagram.model = new go.GraphLinksModel(jsondata["nodes"], jsondata["links"]); - diagram.model = go.Model.fromJson(jsondata); - loadDiagramProperties(null, diagram); - diagram.model.undoManager.isEnabled = true; - diagram.isModified = false; - diagram.isReadOnly = jsondata.isReadOnly; - if (callback !== undefined) - callback(); - }); -} - -// Store shared model state in the Model.modelData property -// (will be loaded by loadDiagramProperties) -function saveDiagramProperties(diagram) { - diagram.model.modelData.position = go.Point.stringify(myDiagram.position); -} - -// Called by loadFile and loadJSON. -function loadDiagramProperties(e, diagram) { - // set Diagram.initialPosition, not Diagram.position, to handle initialization side-effects - var pos = diagram.model.modelData.position; - if (pos) diagram.initialPosition = go.Point.parse(pos); -} - - -function nodeInfo(d) { // Tooltip info for a node data object - var str = d.text + "\n\n"; - str += "Category: " + d.category + "\n"; - - if (d.details !== undefined && d.details !== null) { - str += "\n\n------ Detials ------\n"; - for (var prop in d.details) { - str += prop + ": " + d.details[prop] + "\n"; - } - } - return str; } \ No newline at end of file diff --git a/src/GoProject.Sample/Views/Go/BpmnEditorSample.cshtml b/src/GoProject.Sample/Views/Go/BpmnEditorSample.cshtml index 7d70115..ebafb7c 100644 --- a/src/GoProject.Sample/Views/Go/BpmnEditorSample.cshtml +++ b/src/GoProject.Sample/Views/Go/BpmnEditorSample.cshtml @@ -2,56 +2,60 @@ @model GoProject.Diagram -
-
+
+
@Html.Action("GoDiagramsTablePartial", "Go")
-
-
(@Localization.Unsaved)
- +
+ + + +
-
- -
- @*@Html.Diagram(AlloyHelper.GetAvailableFieldsByUserRole(0), Model, "diagramStore")*@ +
+ +
+
+
- -
@@ -91,14 +96,21 @@ }); //---------------------------------------------------------------------------- - var diagram = init('/api/goApi/GetPaletteNodes'); - updateSnapOption(diagram); + // load localization + var diagram; + jQuery.getJSON(window.location.origin + "/api/goApi/GetLocalization", function (json) { + diagram = init('/api/goApi/GetPaletteNodes', json); + updateSnapOption(diagram); + }); + + $(function () { pageGrids.diagramsGrid.onRowSelect(function (e) { loadJSON(diagram, window.location.origin + '/api/goApi/GetDiagram/?id=' + e.row.Id, function () { diagram.model.id = e.row.Id; diagram.model.name = e.row.Name; + diagram.layoutDiagram(true); }); }); }); diff --git a/src/GoProject.Sample/Web.config b/src/GoProject.Sample/Web.config index 5a31212..a450d4c 100644 --- a/src/GoProject.Sample/Web.config +++ b/src/GoProject.Sample/Web.config @@ -7,6 +7,7 @@ + diff --git a/src/GoProject/DataTableHelper/TypeReflector.cs b/src/GoProject/DataTableHelper/TypeReflector.cs index 6174873..654075a 100644 --- a/src/GoProject/DataTableHelper/TypeReflector.cs +++ b/src/GoProject/DataTableHelper/TypeReflector.cs @@ -9,6 +9,17 @@ namespace GoProject.DataTableHelper public static class TypeReflector { + public static Dictionary GetDictionary(this object lstObjects) + { + var dic = new Dictionary(); + + foreach (var prop in lstObjects.GetType().GetProperties()) + { + dic[prop.Name] = prop.GetValue(lstObjects); + } + + return dic; + } public static DataTable ToDataTable(this IEnumerable data) { diff --git a/src/GoProject/Extensions/GoHelper.cs b/src/GoProject/Extensions/GoHelper.cs index 9012a15..38a83d1 100644 --- a/src/GoProject/Extensions/GoHelper.cs +++ b/src/GoProject/Extensions/GoHelper.cs @@ -121,6 +121,6 @@ public static List ConvertToTreeNodes(this List nodes) return tree; } - + } } \ No newline at end of file diff --git a/src/GoProject/Link.cs b/src/GoProject/Link.cs index 4cdb1af..8becadf 100644 --- a/src/GoProject/Link.cs +++ b/src/GoProject/Link.cs @@ -27,7 +27,11 @@ public class Link [JsonIgnore] public string PointsJson { - get { return $"[{string.Join(",", Points)}]"; } + get + { + if (Points == null) return null; + return $"[{string.Join(",", Points)}]"; + } set { if (!string.IsNullOrEmpty(value) && value.Length > 2) diff --git a/src/GoProject/ModelData.cs b/src/GoProject/ModelData.cs index 6dc8eba..0037e20 100644 --- a/src/GoProject/ModelData.cs +++ b/src/GoProject/ModelData.cs @@ -1,4 +1,5 @@ using System.Drawing; +using System.Globalization; using Newtonsoft.Json; namespace GoProject @@ -15,7 +16,7 @@ public PointF? PositionPoint { if (string.IsNullOrEmpty(Position)) return null; var data = Position.Split(' '); - return new PointF(float.Parse(data[0]), float.Parse(data[1])); + return new PointF(float.Parse(data[0], CultureInfo.InvariantCulture), float.Parse(data[1], CultureInfo.InvariantCulture)); } set diff --git a/src/GoProject/Nodes/INode.cs b/src/GoProject/Nodes/INode.cs index 69a3cfd..c21abf0 100644 --- a/src/GoProject/Nodes/INode.cs +++ b/src/GoProject/Nodes/INode.cs @@ -72,7 +72,7 @@ public interface INode /// [TableIgnore] [JsonProperty(PropertyName = "details", NullValueHandling = NullValueHandling.Ignore)] - Dictionary Details { get; set; } + IDictionary Details { get; set; } [TableIgnore] [JsonIgnore] diff --git a/src/GoProject/Nodes/LaneNode.cs b/src/GoProject/Nodes/LaneNode.cs index f60dd3a..eb47530 100644 --- a/src/GoProject/Nodes/LaneNode.cs +++ b/src/GoProject/Nodes/LaneNode.cs @@ -32,7 +32,7 @@ public LaneNode() var rand = new Random(); HexColor = System.Drawing.Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)); - SizeF = new SizeF(300, 40); + SizeF = new SizeF(500, 40); } public LaneNode(INode node) : base(node) diff --git a/src/GoProject/Nodes/Node.cs b/src/GoProject/Nodes/Node.cs index 64ae9ba..36eec14 100644 --- a/src/GoProject/Nodes/Node.cs +++ b/src/GoProject/Nodes/Node.cs @@ -1,5 +1,7 @@ +using System; using System.Collections.Generic; using System.Drawing; +using System.Globalization; using GoProject.Enums; // ReSharper disable VirtualMemberCallInConstructor @@ -26,14 +28,14 @@ public class Node : INode public string Size { get; set; } public bool? IsSubProcess { get; set; } public string Name { get; set; } - public Dictionary Details { get; set; } + public IDictionary Details { get; set; } public PointF? Position { get { if (string.IsNullOrEmpty(Loc)) return null; var data = Loc.Split(' '); - return new PointF(float.Parse(data[0]), float.Parse(data[1])); + return new PointF(float.Parse(data[0], CultureInfo.InvariantCulture), float.Parse(data[1], CultureInfo.InvariantCulture)); } set @@ -47,7 +49,7 @@ public SizeF? SizeF { if (string.IsNullOrEmpty(Size)) return null; var data = Size.Split(' '); - return new SizeF(float.Parse(data[0]), float.Parse(data[1])); + return new SizeF(float.Parse(data[0], CultureInfo.InvariantCulture), float.Parse(data[1], CultureInfo.InvariantCulture)); } set @@ -73,7 +75,7 @@ public Color? HexColor #region Constructors - public Node(){} + public Node() { } public Node(INode node) : this() { diff --git a/src/GoProject/Properties/AssemblyInfo.cs b/src/GoProject/Properties/AssemblyInfo.cs index d15fb19..d0d9ddb 100644 --- a/src/GoProject/Properties/AssemblyInfo.cs +++ b/src/GoProject/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.11")] -[assembly: AssemblyFileVersion("1.2.11")] +[assembly: AssemblyVersion("1.2.26")] +[assembly: AssemblyFileVersion("1.2.26")] diff --git a/src/GoProject/Properties/Localization.Designer.cs b/src/GoProject/Properties/Localization.Designer.cs index cd62ccd..5648ce6 100644 --- a/src/GoProject/Properties/Localization.Designer.cs +++ b/src/GoProject/Properties/Localization.Designer.cs @@ -105,6 +105,15 @@ public static string AddLane { } } + /// + /// Looks up a localized string similar to Add N-I Escalation Event. + /// + public static string AddN_IEscalationEvent { + get { + return ResourceManager.GetString("AddN_IEscalationEvent", resourceCulture); + } + } + /// /// Looks up a localized string similar to Add Signal Event. /// @@ -249,6 +258,15 @@ public static string Devider { } } + /// + /// Looks up a localized string similar to ltr. + /// + public static string Direction { + get { + return ResourceManager.GetString("Direction", resourceCulture); + } + } + /// /// Looks up a localized string similar to Edit. /// @@ -303,6 +321,15 @@ public static string Exclusive { } } + /// + /// Looks up a localized string similar to Fail to store on path. + /// + public static string FailToStoreOnPath { + get { + return ResourceManager.GetString("FailToStoreOnPath", resourceCulture); + } + } + /// /// Looks up a localized string similar to File. /// @@ -339,6 +366,15 @@ public static string Group { } } + /// + /// Looks up a localized string similar to Identity. + /// + public static string Identity { + get { + return ResourceManager.GetString("Identity", resourceCulture); + } + } + /// /// Looks up a localized string similar to Layout. /// @@ -384,6 +420,15 @@ public static string NewLane { } } + /// + /// Looks up a localized string similar to NotAllowed. + /// + public static string NotAllowed { + get { + return ResourceManager.GetString("NotAllowed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Note. /// @@ -447,6 +492,15 @@ public static string Paste { } } + /// + /// Looks up a localized string similar to Please enter diagram name. + /// + public static string PleaseEnterDiagramName { + get { + return ResourceManager.GetString("PleaseEnterDiagramName", resourceCulture); + } + } + /// /// Looks up a localized string similar to Pool. /// @@ -582,6 +636,24 @@ public static string Start { } } + /// + /// Looks up a localized string similar to Store. + /// + public static string Store { + get { + return ResourceManager.GetString("Store", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Stored Successfull at path. + /// + public static string StoredSuccessfullAtPath { + get { + return ResourceManager.GetString("StoredSuccessfullAtPath", resourceCulture); + } + } + /// /// Looks up a localized string similar to Subprocess. /// @@ -591,6 +663,15 @@ public static string Subprocess { } } + /// + /// Looks up a localized string similar to Successfully updated the node!. + /// + public static string SuccessfullyUpdatedNode { + get { + return ResourceManager.GetString("SuccessfullyUpdatedNode", resourceCulture); + } + } + /// /// Looks up a localized string similar to Task. /// @@ -618,6 +699,15 @@ public static string Timer { } } + /// + /// Looks up a localized string similar to to. + /// + public static string to { + get { + return ResourceManager.GetString("to", resourceCulture); + } + } + /// /// Looks up a localized string similar to Tools. /// @@ -671,5 +761,14 @@ public static string UserTask { return ResourceManager.GetString("UserTask", resourceCulture); } } + + /// + /// Looks up a localized string similar to Would you like to save changes ?. + /// + public static string Would_you_like_save_changes { + get { + return ResourceManager.GetString("Would_you_like_save_changes", resourceCulture); + } + } } } diff --git a/src/GoProject/Properties/Localization.fa.resx b/src/GoProject/Properties/Localization.fa.resx index 27191c1..b6f212f 100644 --- a/src/GoProject/Properties/Localization.fa.resx +++ b/src/GoProject/Properties/Localization.fa.resx @@ -132,6 +132,9 @@ ایجاد بخش + + اضافه کردن رخداد تشدید N-I + اضافه کردن رخداد سیگنال @@ -180,6 +183,9 @@ تقسیم کننده + + rtl + ویرایش @@ -198,6 +204,9 @@ تفکیک + + عدم ذخیره فایل + فایل @@ -210,6 +219,9 @@ گروه + + شناسه + لایه بندی @@ -225,6 +237,9 @@ بخش جدید + + اجازه ندارد + توضیح @@ -246,6 +261,9 @@ چسباندن + + لطفا نام نمودار را وارد کنید + گروه بند @@ -291,9 +309,18 @@ مواد اولیه + + ذخیره + + + با موفقیت ذخیره شد در + زیرفرآیند + + با موفقیت نود بروز رسانی شد! + فرآیند @@ -303,6 +330,9 @@ تایمر + + به + ابزارها @@ -321,4 +351,7 @@ فرآیند کاربر + + آیا میخواهید تغییرات ذخیره گردد؟ + \ No newline at end of file diff --git a/src/GoProject/Properties/Localization.resx b/src/GoProject/Properties/Localization.resx index 2c3cd7e..c3f80a6 100644 --- a/src/GoProject/Properties/Localization.resx +++ b/src/GoProject/Properties/Localization.resx @@ -132,6 +132,9 @@ Add Lane + + Add N-I Escalation Event + Add Signal Event @@ -180,6 +183,9 @@ Devider + + ltr + Edit @@ -198,6 +204,9 @@ Exclusive + + Fail to store on path + File @@ -210,6 +219,9 @@ Group + + Identity + Layout @@ -225,6 +237,9 @@ New Lane + + NotAllowed + Note @@ -246,6 +261,9 @@ Paste + + Please enter diagram name + Pool @@ -291,9 +309,18 @@ Start + + Store + + + Stored Successfull at path + Subprocess + + Successfully updated the node! + Task @@ -303,6 +330,9 @@ Timer + + to + Tools @@ -321,4 +351,7 @@ User Task + + Would you like to save changes ? + \ No newline at end of file