RegData takes too long time to finish unknowable

Stimulsoft Reports.WEB discussion
teimue
Posts: 11
Joined: Wed Dec 03, 2014 3:12 pm

RegData takes too long time to finish unknowable

Post by teimue »

Hello,
I have a question in relation of RegData.
The used version is 2014.3.13.0.
We have the following code to view some reports.

Code: Select all

string appDataFolder = System.Web.HttpContext.Current.Server.MapPath(@"~/App_Data");
            StiReport report = new StiReport();
            
            switch ((String) TempData["reporttype"])
            {
                case "ProjectsList":
                    report.Load(appDataFolder + "\\ProjectsList.mrt");
                    report.RegData("Project", Repository.GetProjects((Guid)TempData["userid"]));

                    break;
                case "ProjectDetails":
                    String ProjectId = (String)TempData["projectid"];
                    Guid GProjectId = Guid.Parse(ProjectId);

                    report.Load(appDataFolder + "\\ProjectDetails.mrt");
                    report.RegData("Project", Repository.GetProject((Guid)TempData["userid"], GProjectId));
                    report.RegData("ProjectContact", Repository.GetProjectContacts(GProjectId));
                    break;
                case "ContactsList":
                    report.Load(appDataFolder + "\\ContactsList.mrt");
                    report.RegData("Contact", Repository.GetContacts((Guid)TempData["userid"]));
                    break;
                case "ContactDetails":
                    String ContactId = (String)TempData["contactid"];
                    Guid GContactId = Guid.Parse(ContactId);

                    report.Load(appDataFolder + "\\ContactDetails.mrt");
                    //report.RegData("Contact", Repository.GetContact((Guid)TempData["userid"], GContactId));
                    break;

            }
But suddenly the first report (ProjectsList) takes too long time to view in browser.
We have only 5 datasets and now we have to wait 5 minutes.
The other reports have the same structure and all is ok. Maybe 5 seconds.

I found that the problem is RegData. This function waste the time and I don't know why.
I recreate a clean report. Same behavior.
Repository.GetProjects is finished with the right data promptly.

Any ideas?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: RegData takes too long time to finish unknowable

Post by HighAley »

Hello.

Please, try to use next code a something like this:

Code: Select all

                        report.Load(appDataFolder + "\\ProjectsList.mrt");
                        var ds = Repository.GetProjects((Guid)TempData["userid"]);
                        report.RegData("Project", ds);
Which line will take much time?
If there is still RegData, please, send us a sample project with all necessary data.

Thank you.
teimue
Posts: 11
Joined: Wed Dec 03, 2014 3:12 pm

Re: RegData takes too long time to finish unknowable

Post by teimue »

I tried this code and it takes the time only on RegData (ca. 5 min)
The Result in the viewer is then correct.

I changed the Stimulsoft version to 2015.1 but there are no changes in problem.
It isn't so easy for me to create a sample project. I'm thinking about that.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: RegData takes too long time to finish unknowable

Post by HighAley »

Hello.

Please, send a sample project to support@stimulsoft.com.
We need to analyze your project to give you an answer.

Thank you.
teimue
Posts: 11
Joined: Wed Dec 03, 2014 3:12 pm

Re: RegData takes too long time to finish unknowable

Post by teimue »

Is it possible to make a TeamViewer session?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: RegData takes too long time to finish unknowable

Post by HighAley »

Hello.

Yes, it's possible to make TeamViewer session, but this won't solve your issue.
We need to connect your sample to our source code and find out why it takes so much time.

Thank you.
teimue
Posts: 11
Joined: Wed Dec 03, 2014 3:12 pm

Re: RegData takes too long time to finish unknowable

Post by teimue »

It is not possible for me to send you a sample project.
But I'm working on the problem.
Now I have an older revision that works and a new revision that takes too much time.
I will send you my findings, what we have changed on our code (GetProjects- data structure?) so that your RegData takes too long.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: RegData takes too long time to finish unknowable

Post by HighAley »

Hello.

We are waiting for any additional information about the issue.

Thank you.
teimue
Posts: 11
Joined: Wed Dec 03, 2014 3:12 pm

Re: RegData takes too long time to finish unknowable

Post by teimue »

OK, there are differences in Repository.GetProjects((Guid)TempData["userid"]);

Old code that works

Code: Select all

public IQueryable<Project> GetProjects(Guid UserId)
        {
            var query = from p in _context.Projects
                        where p.ParentProjectId == null
                        from up in _context.UserProjects
                        where up.UserId == UserId && up.ProjectId == p.Id
                        select p;

            return query;
        }
with this result query:

Code: Select all

{SELECT 
    [Extent1].[Id] AS [Id], 
    [Extent1].[Title] AS [Title], 
    [Extent1].[Number] AS [Number], 
    [Extent1].[Description] AS [Description], 
    [Extent1].[Created] AS [Created], 
    [Extent1].[Image] AS [Image], 
    [Extent1].[ParentProjectId] AS [ParentProjectId], 
    [Extent1].[RowVersion] AS [RowVersion]
    FROM  [dbo].[Projects] AS [Extent1]
    INNER JOIN [dbo].[UserProjects] AS [Extent2] ON [Extent2].[ProjectId] = [Extent1].[Id]
    WHERE ([Extent1].[ParentProjectId] IS NULL) AND ([Extent2].[UserId] = @p__linq__0)}
    
This is the old project entity:

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;

namespace BIMcube.DataAccess
{
    public class Project: BaseEntity
    {
        [Key]
        public Guid Id { get; set; }
        public string Title { get; set; }
        public string Number { get; set; }
        public string Description { get; set; }
        public DateTime Created { get; set; }
        public string Image { get; set; }

        public Guid? ParentProjectId { get; set; }

        [ForeignKey("ParentProjectId")]
        public virtual ICollection<Project> SubProjects { get; set; }

        public virtual ICollection<ProjectAttribute> ProjectAttributes { get; set; }
        public virtual ICollection<ProjectContact> ProjectContacts { get; set; }
    }

}
This is the old report dictionary section:

Code: Select all

<Dictionary Ref="1" type="Dictionary" isKey="true">
    <BusinessObjects isList="true" count="0" />
    <Databases isList="true" count="0" />
    <DataSources isList="true" count="1">
      <Project Ref="2" type="Stimulsoft.Report.Dictionary.StiBusinessObjectSource" isKey="true">
        <Alias>Project</Alias>
        <Columns isList="true" count="8">
          <value>Created,System.DateTime</value>
          <value>Description,System.String</value>
          <value>Id,System.Guid</value>
          <value>Image,System.String</value>
          <value>Number,System.String</value>
          <value>ParentProjectId,System.Nullable`1[System.Guid]</value>
          <value>RowVersion,System.Byte[]</value>
          <value>Title,System.String</value>
        </Columns>
        <Dictionary isRef="1" />
        <IsCloud>False</IsCloud>
        <Name>Project</Name>
        <NameInSource>Project</NameInSource>
      </Project>
    </DataSources>
    <Relations isList="true" count="0" />
    <Report isRef="0" />
    <Variables isList="true" count="0" />
  </Dictionary>
This is the new code that also works but RegData takes too long.

Code: Select all

public IQueryable<Project> GetProjects(Guid UserId)
        {
            var revisions = _context.ProjectRevisions.Where(r => r.Identifier == UserId && r.Parent == null && r.Action == RevisionAction.Created).Include("Childs");
            var result = new List<Project>();

            foreach (var rev in revisions)
            {
                if (rev.Childs.First().Action != RevisionAction.Deleted)
                {
                    var project = _context.Projects.Find(rev.Childs.First().DataId);
                    result.Add(project);
                }
            }

            return result.AsQueryable();
        }
The new result query:

Code: Select all

{System.Collections.Generic.List`1[BIMcube.DomainModels.Project]}   
The new project entity:

Code: Select all

using BIMcube.DataAccess;
using BIMcube.DomainModels.Revision;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BIMcube.DomainModels
{
    public class Project : BaseEntity, IRevision
    {
        public Project()
        {
            Id = Guid.NewGuid();
            Projects = new List<Project>();
            Created = DateTime.Now;
            ProjectContacts = new List<ProjectContact>();
            ProjectAttributes = new List<ProjectAttribute>();
        }

        public Project(Project Parent)
            : this()
        {
            this.Parent = Parent;
            Parent.Projects.Add(this);
        }

        public Guid Id { get; set; }
        public Project Parent { get; set; }
        public string Title { get; set; }
        public string Number { get; set; }
        public string Description { get; set; }
        public DateTime Created { get; set; }
        public virtual ICollection<Project> Projects { get; set; }
        public Guid UserId { get; set; }
        public bool Deleted { get; set; }
        public virtual ICollection<ProjectAttribute> ProjectAttributes { get; set; }
        public virtual ICollection<ProjectContact> ProjectContacts { get; set; }

        public ICollection<IRevision> GetChilds()
        {
            return new List<IRevision>(Projects);
        }

        public IRevision GetParent()
        {
            return Parent;
        }


        public void SetParent(IRevision Parent)
        {
            this.Parent = (Project)Parent;
        }

        public IRevision Clone()
        {
            var prj = new Project();
            prj.Id = Id;
            foreach (var p in Projects)
            {
                prj.Projects.Add(p);
            }
            foreach (var p in ProjectContacts)
            {
                prj.ProjectContacts.Add(p);
            }
            foreach (var p in ProjectAttributes)
            {
                prj.ProjectAttributes.Add(p);
            }
            prj.Parent = Parent;
            prj.Created = Created;
            prj.Description = Description;
            prj.Number = Number;
            prj.Title = Title;
            prj.Deleted = Deleted;
            prj.UserId = UserId;
            return prj;
        }

        public void ExchangeChilds(IRevision Add, IRevision Remove)
        {
            var list = Projects.ToList();
            int index = list.IndexOf((Project)Remove);
            list.Remove((Project)Remove);
            if (Add != null)
            {
                list.Insert(index, (Project)Add);
            }
            Projects = list;
        }


        public Guid GetIdentifier()
        {
            return UserId;
        }

        public void SetIdentifier(Guid Identifier)
        {
            UserId = Identifier;
        }
    }
}
This is the new dictionary section in report:

Code: Select all

<Dictionary Ref="1" type="Dictionary" isKey="true">
    <BusinessObjects isList="true" count="0" />
    <Databases isList="true" count="0" />
    <DataSources isList="true" count="1">
      <Project Ref="2" type="Stimulsoft.Report.Dictionary.StiBusinessObjectSource" isKey="true">
        <Alias>Project</Alias>
        <Columns isList="true" count="5">
          <value>Created,System.DateTime</value>
          <value>Description,System.String</value>
          <value>Id,System.Guid</value>
          <value>Number,System.String</value>
          <value>Title,System.String</value>
        </Columns>
        <Dictionary isRef="1" />
        <IsCloud>False</IsCloud>
        <Name>Project</Name>
        <NameInSource>Project</NameInSource>
      </Project>
    </DataSources>
    <Relations isList="true" count="0" />
    <Report isRef="0" />
    <Variables isList="true" count="0" />
  </Dictionary>
Perhaps you have an idea why RegData now has a problem with that?
But the report result is correct in both cases!
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: RegData takes too long time to finish unknowable

Post by HighAley »

Hello.

When working with business objects sometimes exceptions occurs in .Net Framework. The exceptions makes the application very slow.
To find out what is the cause of the slow RegData method we need to see a sample project.
Please, create a sample project that reproduces the issue, then we will be able to help you.

Thank you.
Post Reply