为什么nhibernate会在select期间退出执行

时间:2014-02-11 09:24:56

标签: nhibernate

当我使用消息选择PREVISION nhibernate退出执行的集合时: 我不知道是否有infinte循环或其他任何东西。 我的电脑迷开始变得如此迅速和热身。

作为PREVISION表空的通知,每次都没问题。 我正在使用ORacle 10g

我需要你的解决方案。

 The thread '<No Name>' (0x570) has exited with code 0 (0x0).
 The thread '<No Name>' (0x1200) has exited with code 0 (0x0).
 The thread '<No Name>' (0xb68) has exited with code 0 (0x0).
 The thread '<No Name>' (0x10b0) has exited with code 0 (0x0).
 The thread '<No Name>' (0xc84) has exited with code 0 (0x0).
 The thread '<No Name>' (0x1004) has exited with code 0 (0x0).
 The thread '<No Name>' (0x604) has exited with code 0 (0x0).
 The thread '<No Name>' (0xbb4) has exited with code 0 (0x0).


    //code:



using Iesi.Collections.Generic;
using System.Text;
using System;


namespace Sample.FluentNHibernate.Domain.Objects
{
 public class PREVISION
 {
    public PREVISION() { }

    public virtual long ID_PREVISION { get; set; }

    public virtual REVISION_PROGRAMME REVISION_PROGRAMME { get; set; }
    public virtual ORGANISATION ORGANISATION { get; set; }
    public virtual BARRAGE BARRAGE { get; set; }
    public virtual PROGRAMME_PREVISIONNEL PROGRAMME_PREVISIONNEL { get; set; }

    public virtual long BAR_ID_ORGANISATION { get; set; }
    public virtual long MOIS_PREVISION { get; set; }
    public virtual int ID_BAR { get; set; }
    public virtual float HAUT { get; set; }
    public virtual float VOL { get; set; }
    public virtual float CONTRAINTE { get; set; }
    public virtual float RESERVE { get; set; }
    public virtual float FREQUENCE { get; set; }
    public virtual long ANNEE_TYPE { get; set; }
    public virtual float VALEUR_MIN { get; set; }
    public virtual float EVAPORATION { get; set; }
    public virtual float FUITES { get; set; }
    public virtual float AEP { get; set; }
    public virtual float IRRIGATION { get; set; }
    public virtual float AUTRES { get; set; }
    public virtual float DVTE { get; set; }
    public virtual float DATATION_AEP { get; set; }
    public virtual float DATATION_IRRIG { get; set; }
    public virtual float VALEUR_FREQUENCE { get; set; }
    public virtual float VALEUR_ANNEE_TYPE { get; set; }
    public virtual long ANNEE_MIN { get; set; }
    public virtual long TE { get; set; }

    public override bool Equals(object obj)
    {
        if (obj == null)
            return false;
        var t = obj as PREVISION;
        if (t == null)
            return false;
        if (this.ID_PREVISION == t.ID_PREVISION
            && this.REVISION_PROGRAMME.ID_REVISION_PROGRAMME == 
   t.REVISION_PROGRAMME.ID_REVISION_PROGRAMME)
            return true;
        return false;
    }

    public override int GetHashCode()
    {
        return (this.ID_PREVISION  + "|" + this.REVISION_PROGRAMME.ID_REVISION_PROGRAMME     
  ).GetHashCode();
    }
  }
}



//

using Iesi.Collections.Generic;
using System.Text;
using System;


  namespace Sample.FluentNHibernate.Domain.Objects
 {
  public class REVISION_PROGRAMME
  {
    public REVISION_PROGRAMME()
    {
        PREVISIONS = new HashedSet<PREVISION>();
    }
    public virtual long ID_REVISION_PROGRAMME { get; set; }

    public virtual ORGANISATION ORGANISATION { get; set; }
    public virtual PROGRAMME_PREVISIONNEL PROGRAMME_PREVISIONNEL { get; set; }

    public virtual ISet<PREVISION> PREVISIONS { get; set; }

    public virtual DateTime DATE_REVISION { get; set; }

    public override bool Equals(object obj)
    {
        if (obj == null)
            return false;
        var t = obj as REVISION_PROGRAMME;
        if (t == null)
            return false;
        if (this.ID_REVISION_PROGRAMME == t.ID_REVISION_PROGRAMME
            && this.PROGRAMME_PREVISIONNEL.ID_PROGRAMME == 
        t.PROGRAMME_PREVISIONNEL.ID_PROGRAMME)
            return true;
        return false;
    }

    public override int GetHashCode()
    {
        return (this.ID_REVISION_PROGRAMME + "|" + 
    this.PROGRAMME_PREVISIONNEL.ID_PROGRAMME).GetHashCode();
      }

    }
  }



//

using Iesi.Collections.Generic;
using System.Text;
using System;


namespace Sample.FluentNHibernate.Domain.Objects
{

 public class PROGRAMME_PREVISIONNEL
 {
    public PROGRAMME_PREVISIONNEL()
    {
        FREQUENCE_APPORTS = new HashedSet<FREQUENCE_APPORT>();
        REVISION_PROGRAMMES = new HashedSet<REVISION_PROGRAMME>();
    }

    public virtual int ID_PROGRAMME { get; set; }

    public virtual ORGANISATION ORGANISATION { get; set; }
    public virtual BARRAGE BARRAGE { get; set; }
    public virtual SYSTEME_HYDRAULIQUE SYSTEME_HYDRAULIQUE { get; set; }

    public virtual ISet<FREQUENCE_APPORT> FREQUENCE_APPORTS { get; set; }
    public virtual ISet<REVISION_PROGRAMME> REVISION_PROGRAMMES { get; set; }

    public virtual long? ID_BAR { get; set; }
    public virtual long? ID_SYSTEME_HYDRAULIQUE { get; set; }
    public virtual long BAR_ID_ORGANISATION { get; set; }
    public virtual DateTime DATE_PROGRAMME { get; set; }
    public virtual long SYS_ID_ORGANISATION { get; set; }
    public virtual long TYPE_DATA { get; set; }

    public override bool Equals(object obj)
    {
        if (obj == null)
            return false;
        var t = obj as PROGRAMME_PREVISIONNEL;
        if (t == null)
            return false;
        if (this.ID_PROGRAMME == t.ID_PROGRAMME && this.ORGANISATION.Id == 
    t.ORGANISATION.Id)
            return true;
        return false;
    }

    public override int GetHashCode()
    {
        return (this.ID_PROGRAMME + "|" + this.ORGANISATION.Id).GetHashCode();
    }
  }
 }



//

 using System;
 using System.Collections.Generic;
 using System.Text;
 using FluentNHibernate.Mapping;
 using Sample.FluentNHibernate.Domain.Objects;

 namespace Sample.FluentNHibernate.Domain.Mappings
{
public class PREVISIONMap : ClassMap<PREVISION>
{
    public PREVISIONMap()
    {
        Table("PREVISION");
        LazyLoad();

        CompositeId()
            .KeyProperty(x => x.ID_PREVISION, "ID_PREVISION")
            //.KeyReference(x => x.PROGRAMME_PREVISIONNEL, "ID_PROGRAMME", 
         "ID_ORGANISATION");
            .KeyReference(x => x.REVISION_PROGRAMME, "ID_REVISION_PROGRAMME", 
         "ID_PROGRAMME", "ID_ORGANISATION");

        Id(x => 
        x.ID_PREVISION).GeneratedBy.Sequence("S_PREVISION").Column("ID_PREVISION");

        //References(x => x.REVISION_PROGRAMME).Columns("ID_REVISION_PROGRAMME", 
        "ID_PROGRAMME", "ID_ORGANISATION").Not.Insert().Not.Update();
        References(x => x.PROGRAMME_PREVISIONNEL).Columns("ID_PROGRAMME", 
       "ID_ORGANISATION").Not.Insert().Not.Update();
        References(x => x.BARRAGE).Columns("ID_BAR", 
        "ID_ORGANISATION").Not.Insert().Not.Update();
        References(x => 
        x.ORGANISATION).Column("ID_ORGANISATION").Not.Insert().Not.Update();

        Map(x => x.BAR_ID_ORGANISATION).Column("BAR_ID_ORGANISATION");
        Map(x => x.MOIS_PREVISION).Column("MOIS_PREVISION");
        Map(x => x.ID_BAR).Column("ID_BAR");
        Map(x => x.HAUT).Column("HAUT");
        Map(x => x.VOL).Column("VOL");
        Map(x => x.CONTRAINTE).Column("CONTRAINTE");
        Map(x => x.RESERVE).Column("RESERVE");
        Map(x => x.FREQUENCE).Column("FREQUENCE");
        Map(x => x.ANNEE_TYPE).Column("ANNEE_TYPE");
        Map(x => x.VALEUR_MIN).Column("VALEUR_MIN");
        Map(x => x.EVAPORATION).Column("EVAPORATION");
        Map(x => x.FUITES).Column("FUITES");
        Map(x => x.AEP).Column("AEP");
        Map(x => x.IRRIGATION).Column("IRRIGATION");
        Map(x => x.AUTRES).Column("AUTRES");
        Map(x => x.DVTE).Column("DVTE");
        Map(x => x.DATATION_AEP).Column("DATATION_AEP");
        Map(x => x.DATATION_IRRIG).Column("DATATION_IRRIG");
        Map(x => x.VALEUR_FREQUENCE).Column("VALEUR_FREQUENCE");
        Map(x => x.VALEUR_ANNEE_TYPE).Column("VALEUR_ANNEE_TYPE");
        Map(x => x.ANNEE_MIN).Column("ANNEE_MIN");
        Map(x => x.TE).Column("TE");
      }
    }
 }


 //

 using System;
 using System.Collections.Generic;
 using System.Text;
 using FluentNHibernate.Mapping;
 using Sample.FluentNHibernate.Domain.Objects;

  namespace Sample.FluentNHibernate.Domain.Mappings
 {
 public class REVISION_PROGRAMMEMap : ClassMap<REVISION_PROGRAMME>
 {

    public REVISION_PROGRAMMEMap()
    {
        Table("REVISION_PROGRAMME");
        LazyLoad();

        CompositeId()
            .KeyProperty(x => x.ID_REVISION_PROGRAMME, "ID_REVISION_PROGRAMME")
            .KeyReference(x => x.PROGRAMME_PREVISIONNEL, "ID_PROGRAMME", 
    "ID_ORGANISATION");

        Id(x => 
    x.ID_REVISION_PROGRAMME).GeneratedBy.Sequence("S_REVISION_PROGRAMME")
   .Column("ID_REVISION_PROGRAMME");

        References(x =>     
     x.ORGANISATION).Column("ID_ORGANISATION").Not.Insert().Not.Update();

        Map(x => x.DATE_REVISION).Column("DATE_REVISION");

        HasMany(x => x.PREVISIONS)
            .KeyColumns.Add("ID_REVISION_PROGRAMME", "ID_PROGRAMME", "ID_ORGANISATION")
            .Inverse()
            .Cascade.Delete();
       }
    }
  }


 //

 using System;
 using System.Collections.Generic;
 using System.Text;
 using FluentNHibernate.Mapping;
 using Sample.FluentNHibernate.Domain.Objects;

 namespace Sample.FluentNHibernate.Domain.Mappings
{
  public class PROGRAMME_PREVISIONNELMap : ClassMap<PROGRAMME_PREVISIONNEL>
  {
    public PROGRAMME_PREVISIONNELMap()
    {
        Table("PROGRAMME_PREVISIONNEL");
        LazyLoad();

        CompositeId()
            .KeyProperty(x => x.ID_PROGRAMME, "ID_PROGRAMME")
            .KeyReference(x => x.ORGANISATION, "ID_ORGANISATION");

        Id(x => 
    x.ID_PROGRAMME).GeneratedBy.Sequence("S_PROGRAMME_PREVISIONNEL")
  .Column("ID_PROGRAMME");

        References(x => x.BARRAGE).Columns("ID_BAR",    
   "ID_ORGANISATION").Not.Insert().Not.Update();
        References(x => x.SYSTEME_HYDRAULIQUE).Columns("ID_SYSTEME_HYDRAULIQUE",   
  "ID_ORGANISATION").Not.Insert().Not.Update();

        Map(x => x.BAR_ID_ORGANISATION).Column("BAR_ID_ORGANISATION");
        Map(x => x.ID_BAR).Column("ID_BAR");
        Map(x => x.ID_SYSTEME_HYDRAULIQUE).Column("ID_SYSTEME_HYDRAULIQUE");
        Map(x => x.DATE_PROGRAMME).Column("DATE_PROGRAMME");
        Map(x => x.SYS_ID_ORGANISATION).Column("SYS_ID_ORGANISATION");
        Map(x => x.TYPE_DATA).Column("TYPE_DATA");

        HasMany(x => x.FREQUENCE_APPORTS)
            .KeyColumns.Add("ID_PROGRAMME", "ID_ORGANISATION")
            .Inverse()
            .Cascade.Delete();
        HasMany(x => x.REVISION_PROGRAMMES)
            .KeyColumns.Add("ID_PROGRAMME", "ID_ORGANISATION")
            .Inverse()
            .Cascade.Delete();
      }
     }
   }



 //code to retrive the collection PREVISION 



  IList<PREVISION> previsions =    
  repositoryPrev.RetrieveListByFourColumn("ORGANISATION.Id", id_org, 
  "PROGRAMME_PREVISIONNEL.ID_PROGRAMME", id_prog, 
   "REVISION_PROGRAMME.ID_REVISION_PROGRAMME", revisions.ID_REVISION_PROGRAMME, 
    "BARRAGE.Id", id_bar);



   //the main method



  public JsonResult getAllPara(int id_org, int id_bar, int id_prog, int id_rev)
    {
        List<string[]> listeval = new List<string[]>();
        string[,] matrixStr = new string[24, 1];
        string[,] matrix = new string[24, 14];
        for (int i = 0; i < 24; i++)
        {
            for (int j = 0; j < 14; j++)
            {
                matrix[i, j] = "";
            }
        }

        // revisions
        FNHSessionManager<REVISION_PROGRAMME> sessionManagerRev = new 
  FNHSessionManager<REVISION_PROGRAMME>
  (FNHSessionManager<REVISION_PROGRAMME>.DatabaseType.Oracle);
        FNHRepository<REVISION_PROGRAMME> repositoryRev = new 
  FNHRepository<REVISION_PROGRAMME>(sessionManagerRev);
        REVISION_PROGRAMME revisions = 
  repositoryRev.RetrieveByTreeColumn("PROGRAMME_PREVISIONNEL.ID_PROGRAMME", id_prog, 
  "ID_REVISION_PROGRAMME", (long)id_rev, "ORGANISATION.Id", id_org);

        // previsions
        FNHSessionManager<PREVISION> sessionManagerPrev = new 
   FNHSessionManager<PREVISION>(FNHSessionManager<PREVISION>.DatabaseType.Oracle);
        FNHRepository<PREVISION> repositoryPrev = new FNHRepository<PREVISION>
   (sessionManagerPrev);

        // retenue
        int id_retenue;
        FNHSessionManager<object> sessionManager1 = new FNHSessionManager<object>
 (FNHSessionManager<object>.DatabaseType.Oracle);
        NHibernate.ISession session = sessionManager1.Session;
        var sql = "select id_retenue from retenue where ID_BAR = " + id_bar + " and 
 ID_ORGANISATION = " + id_org;
        if (session.CreateSQLQuery(sql).UniqueResult() == null)
        { id_retenue = -1; }
        else
        { id_retenue = Convert.ToInt32(session.CreateSQLQuery(sql).UniqueResult()); }

        FNHSessionManager<RETENUE_AB> sessionManagerRet = new 
  FNHSessionManager<RETENUE_AB>(FNHSessionManager<RETENUE_AB>.DatabaseType.Oracle);
        FNHRepository<RETENUE_AB> repositoryRSet = new FNHRepository<RETENUE_AB>
  (sessionManagerRet);
        RETENUE_AB retenue = new RETENUE_AB();
        if (id_retenue != -1)
        {
            retenue = repositoryRSet.RetrieveListByTreeColumn("ORGANISATION.Id", id_org, 
  "BARRAGE.Id", id_bar, "Id", id_retenue).First();
        }
        else retenue = null;

        if (revisions != null)
        {

            IList<PREVISION> previsions = 
  repositoryPrev.RetrieveListByFourColumn("ORGANISATION.Id", id_org, 
  "PROGRAMME_PREVISIONNEL.ID_PROGRAMME", id_prog, 
  "REVISION_PROGRAMME.ID_REVISION_PROGRAMME", revisions.ID_REVISION_PROGRAMME, 
  "BARRAGE.Id", id_bar);

            DateTime date = revisions.DATE_REVISION;
            int mois_rev = date.Month;

            if (mois_rev > 9)
            {
                column = mois_rev - 9 + 1;
            }
            else if (mois_rev < 9)
            {
                column = mois_rev + 4;
            }
            else { column = 1; }


            if (retenue != null)
            {
                date_proche_bath = get_date_bath_proche(retenue.Id, id_org, date);

                foreach (var item in previsions)
                {
                    long mois = item.MOIS_PREVISION;
                    switch (mois)
                    {
                        case 01:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 5, 
    id_org, id_bar, date_proche_bath, mois);
                            break;
                        case 02:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 6, 
    id_org, id_bar, date_proche_bath, mois);
                            break;
                        case 03:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 7, 
   id_org, id_bar, date_proche_bath, mois);
                            break;
                        case 04:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 8, 
  id_org, id_bar, date_proche_bath, mois);
                            break;
                        case 05:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 9, 
  id_org, id_bar, date_proche_bath, mois);
                            break;
                        case 06:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 10, 
  id_org, id_bar, date_proche_bath, mois);
                            break;
                        case 07:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 11,    
  id_org, id_bar, date_proche_bath, mois);
                            break;
                        case 08:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 12, 
  id_org, id_bar, date_proche_bath, mois);
                            break;
                        case 09:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 1, 
  id_org, id_bar, date_proche_bath, mois);
                            break;
                        case 10:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 2, 
  id_org, id_bar, date_proche_bath, mois);
                            break;
                        case 11:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 3, 
   id_org, id_bar, date_proche_bath, mois);
                            break;
                        case 12:
                            matrix = MethodeStatistiqueCalcul.remplirCol(item, 4, 
   id_org, id_bar, date_proche_bath, mois);
                            break;
                        default:
                            matrix = null;
                            break;
                    }
                }

            }
        }

        // test
        FNHSessionManager<COURBE_ALERTE> sessionManager = new 
     FNHSessionManager<COURBE_ALERTE> 

     (FNHSessionManager<COURBE_ALERTE>.DatabaseType.Oracle);
        FNHRepository<COURBE_ALERTE> repository = new FNHRepository<COURBE_ALERTE>
     (sessionManager);
        IList<COURBE_ALERTE> courbeAlerte = 
     repository.RetrieveListByTwoColumn("ORGANISATION.Id", id_org, "BARRAGE.Id", 
     id_bar);
        if (courbeAlerte.Count != 0)
        {
            foreach (var item in courbeAlerte)
            {
                if (item.MOIS >= 9 && item.MOIS <= 12)
                {
                    matrix[22, item.MOIS - 9 + 1] = item.COURBE_SUP.ToString();
                    matrix[23, item.MOIS - 9 + 1] = item.COURBE_INF.ToString();
                }
                else
                {
                    matrix[22, item.MOIS + 3 + 1] = item.COURBE_SUP.ToString();
                    matrix[23, item.MOIS + 3 + 1] = item.COURBE_INF.ToString();
                }
            }
        }
        // fin test

        matrix[0, 13] = matrix[0, column];
        matrix[1, 13] = matrix[1, column];
        matrix[2, 13] = matrix[2, column];
        matrix[3, 13] = matrix[3, column];
        matrix[4, 13] = matrix[4, column];

        matrix[5, 13] = MethodeStatistiqueCalcul.Total_Ligne(5);
        matrix[10, 13] = MethodeStatistiqueCalcul.Total_Ligne(10);
        matrix[11, 13] = MethodeStatistiqueCalcul.Total_Ligne(11);
        matrix[12, 13] = MethodeStatistiqueCalcul.Total_Ligne(12);
        matrix[13, 13] = MethodeStatistiqueCalcul.Total_Ligne(13);
        matrix[14, 13] = MethodeStatistiqueCalcul.Total_Ligne(14);
        matrix[15, 13] = MethodeStatistiqueCalcul.Total_Ligne(15);
        matrix[16, 13] = MethodeStatistiqueCalcul.Total_Ligne(16);
        matrix[17, 13] = MethodeStatistiqueCalcul.Total_Ligne(17);
        matrix[18, 13] = MethodeStatistiqueCalcul.Total_Ligne(18);
        matrix[19, 13] = matrix[19, 12];
        matrix[20, 13] = matrix[20, 12];

        if (matrix[13, 13].ToString() != "" && matrix[18, 13].ToString() != "" && 
        matrix[18, 13].ToString() != "0")
        {
            matrix[21, 13] = Math.Round((Shared.convstr(matrix[13, 13]) / 
        Shared.convstr(matrix[18, 13])) * 100, 2).ToString();
        }
        // les noms 
        matrixStr[0, 0] = "Hauteur (m)";
        matrixStr[1, 0] = "Volume (Mm3)";
        matrixStr[2, 0] = "Cote contrainte (mNGM)";
        matrixStr[3, 0] = "Réserve utile (Mm3)";

        matrixStr[4, 0] = "Fréquence (Hrz)";
        matrixStr[5, 0] = "Apports freq";
        matrixStr[6, 0] = "Année type";
        matrixStr[7, 0] = "Apports type";
        matrixStr[8, 0] = "Année min";
        matrixStr[9, 0] = "Apports min";

        matrixStr[10, 0] = "Evaporation";
        matrixStr[11, 0] = "Fuites";

        matrixStr[12, 0] = "AEP";
        matrixStr[13, 0] = "Irrigation";
        matrixStr[14, 0] = "Turbinage Exclusif";
        matrixStr[15, 0] = "Déversé+Vidangé";
        matrixStr[16, 0] = "Autres Restit";

        matrixStr[17, 0] = "Dotation AEP";
        matrixStr[18, 0] = "Dotation Irrig";

        matrixStr[19, 0] = "V(m+1)";
        matrixStr[20, 0] = "Vu(m+1)";

        matrixStr[21, 0] = "Taux de satisfaction (%)";
        matrixStr[22, 0] = "Courbe d'alerte sup";
        matrixStr[23, 0] = "Courbe d'alerte inf";

        for (int i = 0; i < 24; i++)
        {
            string[] temp = new string[14];
            for (int j = 0; j < 14; j++)
            {
                if (j == 0)
                {
                    temp[0] = matrixStr[i, j];
                }
                else
                {
                    temp[j] = matrix[i, j];
                }
            }
            listeval.Add(temp);
        }

        var jsonData = new
        {
            rows =
            (from freq in listeval

             select new
            {
                cell = freq
            }).ToArray()
        };

        sessionManagerRev.Dispose();
        sessionManagerPrev.Dispose();
        sessionManager1.Dispose();
        sessionManagerRet.Dispose();
        sessionManager.Dispose();

        return Json(jsonData, JsonRequestBehavior.AllowGet);

    }

只有在表格预览不为空时才会出现问题,当它为空时没有问题

1 个答案:

答案 0 :(得分:1)

您的代码没有任何问题,.net运行时只是完成了一些线程。他们可以从UI做一些多线程。没什么好担心的。除了你的代码(异步处理,内存管理等)之外还有更多的东西,有些东西只是在后台处理。 'code 0'表示他们成功的地方。