Пример #1
0
        public IList GetByHQL(string hql, ArrayList lists)
        {
            try
            {
                ISession session = HibernateUtil.OpenSession();
                IQuery   query   = session.CreateQuery(hql);

                for (int i = 0; i < lists.Count; i++)
                {
                    query.SetParameter(i, lists[i]);
                }

                return(query.List());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                HibernateUtil.CloseSession();
            }

            return(null);
        }
Пример #2
0
 public FirstSetupRepo()
 {
     this.session             = HibernateUtil.OpenSession(false);
     this.userRepo            = new UserRepository(session);
     this.projectRepo         = new ProjectRepository(session);
     this.certificateTypeRepo = new InspectorCertificateTypeRepository(session);
     this.seemTypeRepo        = new SeamTypeRepository(session);
     this.permissionRepo      = new PermissionRepository(session);
     this.roleRepo            = new RoleRepository(session);
     this.categoryRepo        = new CategoryRepository(session);
     this.jointOperationRepo  = new JointOperationRepository(session);
     this.pipeTestsRepo       = new PipeTestRepository(session);
     this.sizeTypeRepo        = new MillPipeSizeTypeRepository(session);
     this.plateManRepo        = new PlateManufacturerRepository(session);
     this.heatRepo            = new HeatRepository(session);
     this.plateRepo           = new PlateRepository(session);
     this.purchaseRepo        = new PurchaseOrderRepository(session);
     this.railRepo            = new RailcarRepository(session);
     this.pipeRepo            = new PipeRepository(session);
     this.inspectorRepo       = new InspectorRepository(session);
     this.pipeTestResultRepo  = new PipeTestResultRepository(session);
     this.welderRepo          = new WelderRepository(session);
     componentTypeRepo        = new ComponentTypeRepository(session);
     componentRepo            = new ComponentRepository(session);
     releaseRepo            = new ReleaseNoteRepository(session);
     this.cannedMessageRepo = new CannedMessageRepository(session);
 }
Пример #3
0
 public ActionResult Index()
 {
     using (ISession session = HibernateUtil.OpenSession())
     {
         ViewData["employees"] = session.QueryOver <Employee>().List();
     }
     return(View("Home"));
 }
Пример #4
0
        public static void LogOptimize()
        {
            string connectionString            = ConfigurationManager.ConnectionStrings["PrismDatabase"].ConnectionString;
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString);
            string database = builder.InitialCatalog;
            string logName  = database + "_log";

            string query = string.Format(@"checkpoint; DBCC SHRINKFILE ({0});", logName);

            using (var session = HibernateUtil.OpenSession(false))
            {
                session.CreateSQLQuery(query).ExecuteUpdate();
            }
        }
Пример #5
0
        public ActionResult AddEmployee([Bind()] Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { Result = "fail", Errors = CollectErrors() }));
            }

            using (ISession session = HibernateUtil.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    session.SaveOrUpdate(employee);
                    transaction.Commit();
                }
                session.Close();
            }
            return(Json(new { Result = "ok", Id = employee.Id }));
        }
Пример #6
0
        public ActionResult RemoveEmployee()
        {
            string id = Request.Params["Id"];

            try
            {
                using (var session = HibernateUtil.OpenSession())
                {
                    using (var transaction = session.BeginTransaction())
                    {
                        session.Delete(string.Format("from {0} where id = {1}", typeof(Employee), Convert.ToInt32(id)));
                        transaction.Commit();
                    }
                    session.Close();
                }
                return(Json(new { Result = "ok" }));
            }
            catch (FormatException e)
            {
                return(Json(new { Result = "fail" }));
            }
        }
Пример #7
0
        public override void Load()
        {
            #region Repository
            Bind <ISession>().ToMethod(_ => HibernateUtil.OpenSession(true));

            Bind <IReleaseNoteRepository>().To <ReleaseNoteRepository>();
            Bind <IRailcarRepository>().To <RailcarRepository>();
            Bind <IPipeRepository>().To <PipeRepository>();
            Bind <IHeatRepository>().To <HeatRepository>();
            Bind <IPlateRepository>().To <PlateRepository>();
            Bind <IAuditLogRepository>().To <AuditLogRepository>();
            Bind <IPurchaseOrderRepository>().To <PurchaseOrderRepository>();
            Bind <IWeldRepository>().To <WeldRepository>();
            Bind <IWelderRepository>().To <WelderRepository>();
            Bind <IPipeTestResultRepository>().To <PipeTestResultRepository>();
            Bind <IMillPipeSizeTypeRepository>().To <MillPipeSizeTypeRepository>();
            Bind <IPipeTestRepository>().To <PipeTestRepository>();
            Bind <IMillRepository>().To <MillRepository>();
            Bind <IJointOperationRepository>().To <JointOperationRepository>();

            Bind <ISettingsRepositories>().To <SettingsRepositories>();
            Bind <IReleaseNoteRepositories>().To <ReleaseNoteRepositories>();
            Bind <IHeatRepositories>().To <HeatRepositories>();
            Bind <IProjectRepository>().To <ProjectRepository>();
            Bind <ICategoryRepository>().To <CategoryRepository>();
            Bind <IMillReportsRepository>().To <MillReportsRepository>();
            Bind <IUserRepository>().To <UserRepository>();
            Bind <IRoleRepository>().To <RoleRepository>();
            Bind <IPermissionRepository>().To <PermissionRepository>();
            Bind <IConstructionRepository>().To <ConstructionRepository>();
            Bind <IJointRepository>().To <JointRepository>();

            Bind <IFirstSetupRepo>().To <FirstSetupRepo>();

            Bind <IComponentRepositories>().To <ComponentRepositories>();
            Bind <IComponentTypeRepository>().To <ComponentTypeRepository>();
            Bind <IComponentRepository>().To <ComponentRepository>();
            Bind <ISpoolRepository>().To <SpoolRepository>();
            Bind <ISpoolRepositories>().To <SpoolRepositories>();
            Bind <IJointTestResultRepository>().To <JointTestResultRepository>();
            Bind <IJointWeldResultRepository>().To <JointWeldResultRepository>();
            Bind <IInspectorRepository>().To <InspectorRepository>();
            Bind <IFileRepository>().To <FileRepository>();
            Bind <IInspectionTestResultRepository>().To <InspectionTestResultRepository>();
            Bind <IPartInspectionRepository>().To <PartInspectionRepository>();
            Bind <INotificationRepository>().To <NotificationRepository>();
            Bind <IPortionRepository>().To <PortionRepository>();
            Bind <IExportRepository>().To <ExportRepository>();
            Bind <IImportRepository>().To <ImportRepository>();
            Bind <IExternalFilesRepositories>().To <ExternalFilesRepositories>();
            Bind <ICannedMessageRepository>().To <CannedMessageRepository>();

            // TODO: remove TemporaryContext after binding to real context.
            Bind <Prizm.Main.Security.ISecurityContext>().To <SecurityContext>().InSingletonScope();

            #endregion

            #region ViewModel
            Bind <HeatViewModel>().ToSelf();
            Bind <PurchaseOrderViewModel>().ToSelf();
            Bind <ReleaseNoteViewModel>().ToSelf();
            Bind <MillPipeSearchViewModel>().ToSelf();
            Bind <MillPipeNewEditViewModel>().ToSelf();
            Bind <ReleaseNoteSearchViewModel>().ToSelf();
            Bind <SettingsViewModel>().ToSelf();
            Bind <MillReportsViewModel>().ToSelf();
            Bind <PrizmApplicationViewModel>().ToSelf();
            Bind <JointNewEditViewModel>().ToSelf();
            Bind <JointSearchViewModel>().ToSelf();
            Bind <PartSearchViewModel>().ToSelf();
            Bind <FirstSetupViewModel>().ToSelf();
            Bind <SpoolViewModel>().ToSelf();
            Bind <ExternalFilesViewModel>().ToSelf();
            Bind <PipeConstractionReportViewModel>().ToSelf();
            Bind <WeldDateReportViewModel>().ToSelf();
            #endregion

            #region Forms Binding
            Bind <MillPipeNewEditXtraForm>().ToSelf();
            Bind <ReleaseNoteNewEditXtraForm>().ToSelf();
            Bind <MillPipeSearchXtraForm>().ToSelf();
            Bind <MillReportsXtraForm>().ToSelf();
            Bind <ComponentNewEditXtraForm>().ToSelf();
            Bind <InspectionReportsXtraForm>().ToSelf();
            Bind <JointNewEditXtraForm>().ToSelf();
            Bind <JointSearchXtraForm>().ToSelf();
            Bind <ConstructionReportsXtraForm>().ToSelf();
            Bind <SettingsXtraForm>().ToSelf();
            Bind <ReleaseNoteSearchXtraForm>().ToSelf();
            Bind <SpoolsXtraForm>().ToSelf();
            Bind <HeatXtraForm>().ToSelf();
            Bind <PurchaseOrderXtraForm>().ToSelf();
            Bind <AuditXtraForm>().ToSelf();
            Bind <PartSearchXtraForm>().ToSelf();
            Bind <FirstSetupXtraForm>().ToSelf();
            Bind <ExternalFilesXtraForm>().ToSelf();
            Bind <ExportForm>().ToSelf();
            Bind <ImportForm>().ToSelf();
            Bind <PipeConstractionReportXtraForm>().ToSelf();
            Bind <WeldDateReportXtraForm>().ToSelf();
            #endregion

            #region Commands
            Bind <JointSearchCommand>().ToSelf();
            #endregion

            Bind <IUserNotify>().To <PrizmApplicationXtraForm>().InSingletonScope();
            Bind <AuditInterceptor>().ToSelf();

            #region Synch

            Bind <IEncryptor>().To <Encryptor>();
            Bind <IHasher>().To <Hasher>();

            #endregion
        }