Example #1
0
 public void Delete(T entity)
 {
     NHibernateSession.Delete(entity);
 }
Example #2
0
 public Poligonal GetByIndex(int index)
 {
     return(NHibernateSession.CreateQuery("from Poligonal p where p.Index = :index").SetParameter("index", index).UniqueResult <Poligonal>());
 }
Example #3
0
        public Poligonal GetByCMapId(int mapid, int polid)
        {
            var list = NHibernateSession.CreateQuery("from Poligonal p where p.MapId = :mapid and p.PolId = :polid").SetParameter("mapid", mapid).SetParameter("polid", polid).List <Poligonal>();

            return((list.Count > 0) ? list[0] : null);
        }
Example #4
0
        public IList <Direccion> GetDireccion(string[] tokensCalle, int altura, string[] tokensEsquina, string[] tokensPartido, string[] tokensProvincia, double lat, double lon)
        {
            var    flag  = tokensPartido != null && tokensPartido.Length > 0;
            var    flag2 = tokensProvincia != null && tokensProvincia.Length > 0;
            var    flag3 = !flag && !flag2 && lat < 1.7976931348623157E+308 && lon < 1.7976931348623157E+308;
            double latitud;
            double latitud2;
            double longitud;
            double longitud2;

            if (flag3)
            {
                latitud   = lat - 0.6;
                latitud2  = lat + 0.6;
                longitud  = lon - 0.6;
                longitud2 = lon + 0.6;
            }
            else
            {
                latitud2 = (latitud = (longitud = (longitud2 = 0.0)));
            }
            var list = new List <Direccion>();

            if (altura > 0)
            {
                var alturaQueryBuilder = QueryBuilder.CreateAlturaQueryBuilder(altura).AddCalle(tokensCalle, 3);
                if (flag2)
                {
                    alturaQueryBuilder = alturaQueryBuilder.AddProvincia(tokensProvincia, 3);
                }
                if (flag3)
                {
                    alturaQueryBuilder = alturaQueryBuilder.AddLatitud(latitud, latitud2);
                    alturaQueryBuilder = alturaQueryBuilder.AddLongitud(longitud, longitud2);
                }
                var list2 = NHibernateSession.CreateQuery(alturaQueryBuilder.GetQuery()).List <Altura>();
                foreach (var current in list2)
                {
                    list.Add(new Direccion(current, altura));
                }
            }
            else
            {
                var cruceQueryBuilder = QueryBuilder.CreateCruceQueryBuilder().AddCalle(tokensCalle, 3).AddEsquina(tokensEsquina, 3);
                if (flag2)
                {
                    cruceQueryBuilder = cruceQueryBuilder.AddProvincia(tokensProvincia, 3);
                }
                if (flag3)
                {
                    cruceQueryBuilder = cruceQueryBuilder.AddLatitud(latitud, latitud2);
                    cruceQueryBuilder = cruceQueryBuilder.AddLongitud(longitud, longitud2);
                }
                var list3 = NHibernateSession.CreateQuery(cruceQueryBuilder.GetQuery()).List <Cruce>();
                foreach (var current2 in list3)
                {
                    list.Add(new Direccion(current2));
                }
            }
            return(list);
        }
Example #5
0
 public long GetCountSinPalabras()
 {
     return((long)NHibernateSession.CreateQuery("select count(*) from Poligonal p where size(p.Palabras) = 0").UniqueResult());
 }
        public override IPageOfList <WayBillReconciliation> GetByFilter(ParameterFilter filter)
        {
            //--对账日期 --收寄日期 --运单号  --提单号  --重量 --客户名称 --邮政邮资  --邮政邮件处理费 --客户运费  --客户操作费 --成本状态--收入状态--运费毛利 --操作费毛利
            string column = @"a.ReconcileDate as ReconcileDate,
b.ID AS ID,
a.ID AS IsInputCost,
a.PostingTime AS PostingTime, 
b.ExpressNo AS ExpressNo,  
b.LoadBillNO AS LoadBillNum, 
a.Weight AS Weight,       
c.Cus_Name AS CusName,		 
(CASE WHEN a.ExpressNo IS NULL THEN b.PreExpressFee ELSE a.WayBillFee END) AS WayBillFee,  
(CASE WHEN a.ExpressNo IS NULL THEN b.PreOperateFee ELSE a.ProcessingFee END) AS ProcessingFee,
b.ExpressFee AS ExpressFee,  
b.OperateFee AS OperateFee, 
a.PayStatus AS CostStatus,    
b.PayStatus AS InComeStatus,  
b.ExpressFee-a.WayBillFee AS WayBillProfit,
CASE IFNULL(d.IsAddMonthPayOff,0) WHEN 0 THEN '待添加到月结表' ELSE '已添加月结表' END AS Statement ";
            string sql    = @" FROM WayBillInCome b 
INNER JOIN LoadBillInCome d ON b.LoadBillID=d.ID
LEFT JOIN CustomerInfo c ON d.CustomerID=c.ID
LEFT JOIN WayBillCost a ON a.ExpressNo=b.ExpressNo
LEFT JOIN ExpressNoExceptionDetail e ON a.ID=e.WayBillCostID
where 1=1 AND e.ID is NULL";

            if (filter.HasQueryString)
            {
                sql = filter.ToHql();
            }
            else
            {
                sql += filter.ToHql();
            }

            var paras = filter.GetParameters();
            //string strSQL = "select COUNT(b.ID) as Count" + sql;
            string strSQL     = @"select COUNT(a.ID) as Count,SUM(a.Weight) as TotalWeight,SUM(a.WayBillFee) as TotalWayBillFee,SUM(a.ProcessingFee) as TotalProcessingFee,
            SUM(b.ExpressFee) as TotalExpressFee,SUM(b.OperateFee) as TotalOperateFee,SUM(b.ExpressFee-a.WayBillFee) AS TotalWayBillProfit" + sql;
            var    countQuery = NHibernateSession.CreateSQLQuery(strSQL);
            var    query      = NHibernateSession.CreateSQLQuery(string.Format("select {0} {1} {2} ", column, sql, filter.GetOrderString()));

            foreach (var key in paras.Keys)
            {
                countQuery.SetParameter(key, paras[key]);
                query.SetParameter(key, paras[key]);
            }

            int pageIndex = filter.PageIndex;
            int pageSize  = filter.PageSize;
            var Count     = countQuery.List <object[]>()[0];
            //long totalCounts = Count;

            decimal totalWeight        = Count[1] == null ? 0m : decimal.Parse(Count[1].ToString()); //总重量
            decimal totalWayBillFee    = Count[2] == null ? 0m : decimal.Parse(Count[2].ToString()); //总运费
            decimal totalProcessingFee = Count[3] == null ? 0m : decimal.Parse(Count[3].ToString());
            decimal totalExpressFee    = Count[4] == null ? 0m : decimal.Parse(Count[4].ToString());
            decimal totalOperateFee    = Count[5] == null ? 0m : decimal.Parse(Count[5].ToString());
            decimal totalWayBillProfit = Count[6] == null ? 0m : decimal.Parse(Count[6].ToString());

            StatModel model = new StatModel
            {
                TotalWeight        = totalWeight,
                TotalWayBillFee    = totalWayBillFee,
                TotalProcessingFee = totalProcessingFee,
                TotalExpressFee    = totalExpressFee,
                TotalOperateFee    = totalOperateFee,
                TotalWayBillProfit = totalWayBillProfit
            };
            //StatModel model = new StatModel();
            var list = query.SetResultTransformer(NHibernate.Transform.Transformers.AliasToBean(typeof(WayBillReconciliation))).SetFirstResult(pageIndex * pageSize).SetMaxResults(pageSize).List <WayBillReconciliation>().ToList();

            return(new WRPageOfList <WayBillReconciliation>(list, pageIndex, pageSize, Convert.ToInt32(Count[0]), model));
        }
Example #7
0
 protected virtual bool DeleteEntity(TEntity entity)
 {
     NHibernateSession.Delete(entity);
     return(true);
 }
Example #8
0
 public IList <ResolutionKind> GetNotActiveResolutionKind()
 {
     return(NHibernateSession.QueryOver <ResolutionKind>()
            .Where(x => x.IsActive == 0)
            .List <ResolutionKind>());
 }
Example #9
0
 public void BeforeSendReply(ref Message reply, object correlationState)
 {
     NHibernateSession.CloseAllSessions();
 }
        public ActionResult <IEnumerable <MyObject> > Get()
        {
            var session = NHibernateSession.OpenSession();

            return(session.QueryOver <MyObject>().List().ToList());
        }
        public ActionResult <MyObject> Get(string code)
        {
            var session = NHibernateSession.OpenSession();

            return(session.QueryOver <MyObject>().Where(mo => mo.Code == code).List().FirstOrDefault());
        }
Example #12
0
 public T FindById(IdT id)
 {
     return(NHibernateSession.Get <T>(id));
 }
Example #13
0
 protected ICriteria CreateCriteria()
 {
     return(NHibernateSession.CreateCriteria(typeof(T)));
 }
Example #14
0
 public int GetTotalRecordCount()
 {
     return(NHibernateSession.CreateCriteria(typeof(T))
            .SetProjection(Projections.RowCount())
            .UniqueResult <int>());
 }
Example #15
0
 public override Host SaveOrUpdate(Host entity)
 {
     NHibernateSession.CurrentFor(SessionFactoryAttribute.GetKeyFrom(new HostRepository())).Save(entity);
     return(entity);
 }
    public static List <Usuario> GetMonitor(
        int a1, //Id operador
        int a2, //Id operador
        int b1, //Semaforo
        int b2, //Semaforo
        int c1, //Actividad
        int c2, //Actividad
        int d1, //TipoDeOperador
        int d2, //TipoDeOperador
        int e1, //Grupo
        int e2, //Grupo
        String nombre
        )
    {
        List <Usuario> usuarios = null;
        List <Usuario> nuevos   = new List <Usuario>();

        using (ISession session = NHibernateSession.openSession())
        {
            try
            {
                //monitor = session.QueryOver<Monitor>().Where(x =>x.Id >a1).List().ToList();
                usuarios = session.QueryOver <Usuario>().
                           Where(x => x.nombre.IsLike(nombre, MatchMode.Anywhere)). //Filtra de acuerdo al nombre, hace referencia a un LIKE
                           Where(x => x.Id > a1).                                   //IdOperador
                           And(x => x.Id < a2).                                     //IdOperador
                           And(x => x.Group_Id > e1).
                           And(x => x.Group_Id < e2).
                           And(x => x.Driver_Type_Id > d1).
                           And(x => x.Driver_Type_Id < d2).
                           And(x => x.activo == 1).//esActivo
                           OrderBy(x => x.nombre).Asc.
                           List().ToList();
                /**Obtiene a los usuarios que esten entre un rango**/
                foreach (var usuario in usuarios)
                {
                    IList <Monitor> m = session.QueryOver <Monitor>().
                                        Where(x => x.Usuario_Id == usuario.Id).
                                        And(x => x.Actividad_Actual_Id > c1).
                                        And(x => x.Actividad_Actual_Id < c2).
                                        //And(x => x.Actividad_Actual_Id!=3).
                                        And(x => x.Color_Id > b1).
                                        And(x => x.Color_Id < b2)
                                        .List().ToList();
                    if (m.Count() != 0)
                    {
                        var a = m.First();
                        usuario.monitor = a; //.First();

                        switch (usuario.monitor.Actividad_Actual_Id)
                        {
                        case (int)StatusActividad.ACTIVO:
                            usuario.monitor.actividad = "Activo";
                            break;

                        case (int)StatusActividad.INACTIVO:
                            usuario.monitor.actividad = "Inactivo";
                            break;

                        case (int)StatusActividad.DESCANSO:
                            usuario.monitor.actividad = "Descanso";
                            break;

                        case (int)StatusActividad.SUENO:
                            usuario.monitor.actividad = "Sueño";
                            break;
                        }

                        nuevos.Add(usuario);
                    }
                }
            }
            catch (Exception e)
            {
                nuevos = null;
            }
            finally
            {
                session.Close();
            }

            return(nuevos);
        }
    }
Example #17
0
        public void HibernateConnectionTest()
        {
            ISession session = NHibernateSession.OpenSessionNoServer();

            Assert.IsNotNull(session);
        }
Example #18
0
        public void CanGenerateDatabaseSchema()
        {
            var session = NHibernateSession.GetDefaultSessionFactory().OpenSession();

            new SchemaExport(configuration).Execute(true, false, false, session.Connection, null);
        }
Example #19
0
 private void UpdateEntity(TEntity entity)
 {
     NHibernateSession.Update(entity);
     NHibernateSession.Flush();
 }
Example #20
0
 protected virtual void UpdateEntity(TEntity entity)
 {
     NHibernateSession.Update(entity);
     NHibernateSession.Flush();
 }
Example #21
0
 public void SelectQueryWorks()
 {
     NHibernateSession.CreateCriteria(typeof(TEntity)).SetMaxResults(5).List();
 }
Example #22
0
 protected override IQueryOver <PECMailLog, PECMailLog> CreateQueryOver()
 {
     return(NHibernateSession.QueryOver <PECMailLog>());
 }
Example #23
0
 public IList <Poligonal> GetSinCruceOAltura(int idMapa)
 {
     return(NHibernateSession.CreateQuery("from Poligonal p where (size(p.Cruces) = 0 or size(p.Alturas) = 0) and p.MapId = :idMapa").SetParameter("idMapa", idMapa).List <Poligonal>());
 }
 public virtual void TearDown()
 {
     NHibernateSession.CloseAllSessions();
     NHibernateSession.Reset();
 }
Example #25
0
 public IList <Poligonal> GetSinPalabras()
 {
     return(NHibernateSession.CreateQuery("from Poligonal p where size(p.Palabras) = 0").List <Poligonal>());
 }
Example #26
0
        public void CalculateFullForecast(int week, int year, IList <Product> productlist, bool clean)
        {
            int prodcont = 0;

            if (productlist.Count < 1)
            {
                productlist = ControllerManager.Product.GetProductList();
            }

            List <TransactionHistoryWeekly> fullhistory    = ControllerManager.TransactionHistoryWeekly.GetInfo(week, year, 20);
            List <ProductStatisticWeekly>   fullstatistics = ControllerManager.ProductStatisticWeekly.GetStatistics();
            List <PurchaseOrderItem>        fullpoil       = Grundfos.ScalaConnector.ControllerManager.PurchaseOrderItem.GetFullArrivalPO(Config.CurrentDate);

            if (clean)
            {
                IQuery q = NHibernateSession.GetNamedQuery("sp_forecast_clean");
                q.SetInt32("Week", week);
                q.SetInt32("Year", year);
                q.UniqueResult();
            }
            foreach (Product p in productlist)
            {
                prodcont++;
                List <TransactionHistoryWeekly> history = fullhistory.FindAll(delegate(TransactionHistoryWeekly record)
                {
                    if (record.ProductID != p)
                    {
                        return(false);
                    }
                    return(true);
                });

                ProductStatisticWeekly statistics = fullstatistics.Find(delegate(ProductStatisticWeekly record)
                {
                    if (record.Product != p)
                    {
                        return(false);
                    }
                    return(true);
                });

                List <PurchaseOrderItem> poil = fullpoil.FindAll(delegate(PurchaseOrderItem record)
                {
                    if (record.Product.Id == p.ProductCode)
                    {
                        return(true);
                    }
                    return(false);
                });

                if (history.Count < 20)
                {
                    List <TransactionHistoryWeekly> temphistory = new List <TransactionHistoryWeekly>();

                    int initialweek = 0;
                    int initialyear = 0;
                    if (week < 20)
                    {
                        initialweek = week - 20 + 54;
                        initialyear = year - 1;
                    }
                    else
                    {
                        initialweek = week - 20;
                    }
                    for (int cont = 1; cont <= 20; cont++)
                    {
                        TransactionHistoryWeekly tempTHW = history.Find(delegate(TransactionHistoryWeekly record)
                        {
                            if ((record.Week == initialweek) &&
                                (record.Year == initialyear))
                            {
                                return(true);
                            }
                            return(false);
                        });
                        if (tempTHW == null)
                        {
                            tempTHW                = new TransactionHistoryWeekly(0, p);
                            tempTHW.Week           = initialweek;
                            tempTHW.Year           = initialyear;
                            tempTHW.Stock          = 0;
                            tempTHW.PurchaseOrders = 0;
                            tempTHW.Purchase       = 0;
                            tempTHW.Sale           = 0;
                        }


                        temphistory.Add(tempTHW);

                        if (initialweek < 53)
                        {
                            initialweek++;
                        }
                        else
                        {
                            initialweek = 1;
                            initialyear++;
                        }
                    }
                    CalculateForecast(p, week, year, temphistory, statistics, poil);
                }
                else
                {
                    CalculateForecast(p, week, year, history, statistics, poil);
                }

                if (Convert.ToDouble(prodcont) % 1000 == 0)
                {
                    NHibernateSession.Flush();
                    ControllerManager.Log.Add("Forecast Processor", ExecutionStatus.Running, "Forecast: " + prodcont + " productos procesados");
                }
            }

            NHibernateSession.Flush();
            ControllerManager.Log.Add("Forecast Processor", ExecutionStatus.Running, "Forecast: " + prodcont + " productos procesados");
        }
Example #27
0
 public IList <Poligonal> GetByIdMapa(int idMapa)
 {
     return(NHibernateSession.CreateQuery("from Poligonal p where p.MapId = :idMapa").SetParameter("idMapa", idMapa).List <Poligonal>());
 }
Example #28
0
 public ISession OpenSession()
 {
     return(NHibernateSession.OpenSession(_environment));
 }
Example #29
0
 public IList <Poligonal> GetEnPartidoYProvincia(string[] tokens, int partido, int provincia, int altura)
 {
     return(NHibernateSession.CreateQuery(QueryBuilder.CreatePoligonalQueryBuilder().AddCalle(tokens, 3).AddPartido(partido).AddProvincia(provincia).AddAltura(altura).GetQuery()).List <Poligonal>());
 }
Example #30
0
 /// <summary>
 /// For entities with automatatically generated IDs, such as identity, SaveOrUpdate may
 /// be called when saving a new entity.  SaveOrUpdate can also be called to update any
 /// entity, even if its ID is assigned.
 /// </summary>
 public T SaveOrUpdate(T entity)
 {
     NHibernateSession.SaveOrUpdate(entity);
     return(entity);
 }