Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Upgrade from version 1.8 to 3.3 (Read 6771 times)
dusanv
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: Jan 20th, 2021
Upgrade from version 1.8 to 3.3
Jan 20th, 2021 at 10:16am
Print Post  
Hi, am trying to upgrade my legacy application to newest version of mvc diagrams. it is implemented on server side with custom node shapes derived from nodeshape. I have no idea what could be a problem
  

minderror.PNG ( 23 KB | 145 Downloads )
minderror.PNG
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Upgrade from version 1.8 to 3.3
Reply #1 - Jan 20th, 2021 at 11:01am
Print Post  
Hi,

I imagine you'd get such error if the control fails to instantiate your custom nodes for some reason. Try comparing your code with CustomNodes sample project to see how custom nodes are registered and handled in current version. Otherwise could you attach a test project reproducing that, or show some snippets from your code that register custom types and populate the diagram?

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
dusanv
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: Jan 20th, 2021
Re: Upgrade from version 1.8 to 3.3
Reply #2 - Feb 1st, 2021 at 1:58pm
Print Post  
Thank you very much, i managed to register custom nodes. But now i am facing different issue  Sad

When i try to load diagram from json string sent from frontend i got error 'operation is not valid due to the current state of the object', i tried to set
<add key="aspnet:MaxJsonDeserializerMembers" value="15000000000000" />
    <add key="aspnet:MaxHttpCollectionKeys" value="15000000000000" />
, also i tried with
view.SetMaxJsonLength(1500000000);
            view.SetRecursionLimit(1500000000);
in older version of mindfusion diagrams <add key="aspnet:MaxJsonDeserializerMembers" value="150000" /> was enough
  
Back to top
 
IP Logged
 
dusanv
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: Jan 20th, 2021
Re: Upgrade from version 1.8 to 3.3
Reply #3 - Feb 1st, 2021 at 2:07pm
Print Post  
the way data is gathered from diagram is flowChart.toJson(). json string is about 10% bigger in new version
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Upgrade from version 1.8 to 3.3
Reply #4 - Feb 1st, 2021 at 3:15pm
Print Post  
Please post exception's stack trace and code snippets showing your custom type's serialization, or better attach a test project reproducing that. Also let us know what .NET version you are using - the control's serialization in .NET Core is very different from classic .NET.
  
Back to top
 
IP Logged
 
dusanv
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: Jan 20th, 2021
Re: Upgrade from version 1.8 to 3.3
Reply #5 - Feb 1st, 2021 at 3:33pm
Print Post  
We are using .net 4.8.

code snippet:
public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var node = obj as T;
            if (node != null)
            {
                IDictionary<string, object> json = base.Serialize(obj, serializer);
                return json;
            }
            return null;
        }

stack trace:
   at System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDicti
onary`2 dictionary, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
   at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Obje
ct o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal
(Int32 depth)
   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeList(Int
32 depth)
   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal
(Int32 depth)
   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictiona
ry(Int32 depth)
   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal
(Int32 depth)
   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(St
ring input, Int32 depthLimit, JavaScriptSerializer serializer)
   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSeria
lizer serializer, String input, Type type, Int32 depthLimit)
   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)
   at MindFusion.Diagramming.Mvc.DiagramView.LoadJson(String json, Boolean clearDiagram)
   at OACloud.Web.Controllers.WorkflowProcessDefinitionVersionController.UpdateVersion
Diagram() in C:\mindfusion\OAModules\OACloud.Web.Controllers\Admin\Configuration\Workflow\Wor
kflowProcessDefinitionVersionController.cs:line 391
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c.<BeginInvokeSynchronousAct
ionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAs
yncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncRe
sult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c
__DisplayClass11_0.<InvokeActionMethodFilterAsynchronouslyRecursive>b__0()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c
__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()


  
Back to top
 
IP Logged
 
dusanv
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: Jan 20th, 2021
Re: Upgrade from version 1.8 to 3.3
Reply #6 - Feb 1st, 2021 at 3:35pm
Print Post  
public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var node = obj as T;
            if (node != null)
            {
                IDictionary<string, object> json = base.Serialize(node, serializer);
                json.Add("WfState", node.WfState);
                return json;
            }
            return null;
        }
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Upgrade from version 1.8 to 3.3
Reply #7 - Feb 1st, 2021 at 4:08pm
Print Post  
What's the type of your WfState property, and have you created a JS serializer for it if a complex type? The exception comes from Deserialize method, so please post code for it too.
  
Back to top
 
IP Logged
 
dusanv
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: Jan 20th, 2021
Re: Upgrade from version 1.8 to 3.3
Reply #8 - Feb 1st, 2021 at 4:20pm
Print Post  
it is complex type, we didn't created js serializer

public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            var node = base.Deserialize(dictionary, type, serializer) as T;
            if (node != null)
            {
                var state = serializer.ConvertToType<WorkflowProcessDefinitionVersion.WfState>(dictionary["WfState"]);
                node.WfState = state;
            }

            return node;
        }
  
Back to top
 
IP Logged
 
dusanv
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: Jan 20th, 2021
Re: Upgrade from version 1.8 to 3.3
Reply #9 - Feb 1st, 2021 at 4:26pm
Print Post  
        [Serializable]
        [TableMapping(TableName = "wf_state")]
        public class WfState : PersistentObjectWithTypedId<Guid>
        {
            public WfState()
            {
                PreConditions = new List<WfCondition>();
                PostConditions = new List<WfCondition>();
            }

            [ColumnMapping(ColumnName = "state_id")]
            public override Guid Id { get; set; }

            [ColumnMapping(ColumnName = "state_name")]
            public string StateName { get; set; }

            [ColumnMapping(ColumnName = "parent_state_id")]
            public Guid? ParentStateId { get; set; }

            [ColumnMapping(ColumnName = "activity_id")]
            public Guid ActivityId { get; set; }

            [ColumnMapping(ColumnName = "is_start")]
            public bool IsStart { get; set; }

            [ColumnMapping(ColumnName = "is_end")]
            public bool IsEnd { get; set; }

            [ColumnMapping(ColumnName = "process_def_version_id")]
            public Guid ProcessDefVersionId { get; set; }

            [ColumnMapping(ColumnName = "field_set_id")]
            public Guid? FieldSetId { get; set; }

            [ColumnMapping(ColumnName = "location_x")]
            public int LocationX { get; set; }

            [ColumnMapping(ColumnName = "location_y")]
            public int LocationY { get; set; }

            [ColumnMapping(TableName = "wf_state_param", IsCollection = true, IsReadOnly = false, FKColumnName = "state_id", FKPropertyValueField = "Id")]
            public IList<WfStateParam> WfStateParams { get; set; }

            public IList<WfCondition> PreConditions { get; set; }

            public IList<WfCondition> PostConditions { get; set; }

        }
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Upgrade from version 1.8 to 3.3
Reply #10 - Feb 1st, 2021 at 4:45pm
Print Post  
Is this WfState type defined in a separate assembly? That sounds like issue from https://stackoverflow.com/questions/2005534/json-serialization-deserialization-m... . If it's same problem, we aren't sure we can do anything on our end, instead you'd have to add assembly part to __type field when saving on client side. Our developer will play with that tomorrow to verify.
  
Back to top
 
IP Logged
 
dusanv
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: Jan 20th, 2021
Re: Upgrade from version 1.8 to 3.3
Reply #11 - Feb 1st, 2021 at 4:51pm
Print Post  
yes it is defined in a separate assembly
  
Back to top
 
IP Logged
 
dusanv
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: Jan 20th, 2021
Re: Upgrade from version 1.8 to 3.3
Reply #12 - Feb 1st, 2021 at 5:16pm
Print Post  
Thanks, I managed to fix it Smiley
  
Back to top
 
IP Logged
 
dusanv
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: Jan 20th, 2021
Re: Upgrade from version 1.8 to 3.3
Reply #13 - Feb 1st, 2021 at 5:21pm
Print Post  
I changed custom node registration from MindFusion.AbstractionLayer.registerClass(MindFusion.Diagramming.BaseNode, "BaseNode", MindFusion.Diagramming.ShapeNode);

to MindFusion.AbstractionLayer.registerClass(MindFusion.Diagramming.BaseNode, "MindFusion.Diagramming.BaseNode", MindFusion.Diagramming.ShapeNode);
  
Back to top
 
IP Logged
 
dusanv
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 12
Joined: Jan 20th, 2021
Re: Upgrade from version 1.8 to 3.3
Reply #14 - Feb 4th, 2021 at 9:33am
Print Post  
Hi again  Sad

I have one more mystery that i can't understand. my diagram is in popup. first time popup is open everything is working fine, but next time popup is open without refreshing the page a got error 
VM2809:15 Uncaught TypeError: Cannot read property 'onLoad' of undefined
    at acO.<computed>.fromJson (eval at globalEval (jquery-2.1.1.js:330), <anonymous>:15:461464)

If i check if my custom shape is registered and don't register it second time i have no error by nothing is rendered.
The way i check my custom nodes registration is by name like this: MindFusion.Diagramming.BaseNode.getName() == ''
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint