Пример #1
0
        public List<Setting> GetFilePath(Setting setting)
        {
            List<Setting> lstSetting = new List<Setting>();
            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {

                    //NHibernate.ISQLQuery nHquery = session.CreateSQLQuery("Select FilePath from setting where Module ='" + setting.Module + "'");// and FileType='" + setting.FileType + "'

                    NHibernate.IQuery nIquery=session.CreateQuery("from Setting s where s.Module = :module").SetParameter("module",setting.Module);
                    

                    foreach (Setting item in nIquery.Enumerable<Setting>())
                    {
                        try
                        {
                            lstSetting.Add(item);
                        }
                        catch (Exception ex)
                        {
                            GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                        }
                    }

                    //nHquery.Enumerable<Setting>
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }
            return lstSetting;
        }
Пример #2
0
 public ICollection<Setting> GetAllSetting(Setting setting)
 {
     ICollection<Setting> iCol = null;
     try
     {
         using (NHibernate.ISession session = SessionFactory.GetNewSession())
         {
             iCol= session.CreateCriteria(typeof(Setting)).List<Setting>();
         }
     }
     catch (Exception ex)
     {
         GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
     }
     return iCol;
 }
Пример #3
0
        public void InsertOrUpdateSetting(Setting objSetting)
        {
            try
            {
                objSettingRepository.InsertOrUpdate(objSetting);


            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }
        }
Пример #4
0
        public void DeleteAccounts(Setting setting)
        {           
            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {

                        var query = session.CreateQuery("DELETE FROM Setting  WHERE Module = :module AND FileType= :fileType");
                        query.SetParameter("module", setting.Module);
                        query.SetParameter("fileType", setting.FileType);
                       
                        int res = query.ExecuteUpdate();
                        transaction.Commit();
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }
        }
Пример #5
0
        public void Delete(Setting setting)
        {

            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        //session.Delete(acc.UserName);
                        transaction.Commit();
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }
        }
Пример #6
0
        //public void SaveOrUpdate(Setting setting)
        //{
        //    try
        //    {
        //        using (NHibernate.ISession session = SessionFactory.GetNewSession())
        //        {
        //            using (NHibernate.ITransaction transaction = session.BeginTransaction())
        //            {
        //                session.SaveOrUpdate(setting);
        //                transaction.Commit();
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
        //    }
        //} 
        #endregion

        public void Update(Setting setting)
        {
            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        session.Update(setting.FilePath, setting);
                        transaction.Commit();
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }
        }
Пример #7
0
        public void InsertOrUpdate(Setting setting)
        {
            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        List<Setting> lstSetting=GetUniqueFilePath(setting);

                        if (lstSetting.Count > 0)
                        {
                            if (!string.IsNullOrEmpty(setting.FilePath))
                            {

                                var query = session.CreateQuery("Update Setting set FilePath = :filePath where Module= :module and FileType= :fileType");
                                query.SetParameter("filePath", setting.FilePath);
                                query.SetParameter("module", setting.Module);
                                query.SetParameter("fileType", setting.FileType);

                                int res = query.ExecuteUpdate();
                                transaction.Commit();
                                //return res;
                            }
                        }
                        else
                        {
                            session.Save(setting);

                            transaction.Commit();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }
        }