コード例 #1
0
        public UnitOfWorkManager(ICHCContext context)
        {
            // http://stackoverflow.com/questions/3552000/entity-framework-code-only-error-the-model-backing-the-context-has-changed-sinc
            Database.SetInitializer <CHCContext>(null);

            _context = context as CHCContext;
        }
コード例 #2
0
        public override void HandleAutoTask()
        {
            LogManager.Instance.Write("Start CompanyOrder Handler ******************************************************");

            using (var cache = new EntityCache <CompanyOrder, CHCContext>(p => p.Locked == true && p.IsBuildCompleted == false))
            {
                while (true)
                {
                    LogManager.Instance.Write(cache.Results.Count().ToString());

                    var importExportService = new ImportExportService();
                    var companyOrderService = new CompanyOrderService(null, importExportService, null, null);
                    if (cache.Results.Count() > 0)
                    {
                        foreach (var order in cache.Results)
                        {
                            companyOrderService.ExportCompanyOrderForms(ConfigurationManager.AppSettings["CHCWebRootPath"], order);

                            using (var context = new CHCContext())
                            {
                                var entity = context.CompanyOrder.SingleOrDefault(e => e.Id == order.Id);
                                entity.Locked           = true;
                                entity.IsBuildCompleted = true;
                                context.SaveChanges();
                            }
                        }
                    }

                    Thread.Sleep(5000);
                }
            }
        }
コード例 #3
0
ファイル: UnitOfWork.cs プロジェクト: junlu3/CMS
        /// <summary>
        /// Constructor
        /// </summary>
        public UnitOfWork(CHCContext context)
        {
            _context = context;

            // In order to make calls that are overidden in the caching ef-wrapper, we need to use
            // transactions from the connection, rather than TransactionScope.
            // This results in our call e.g. to commit() being intercepted
            // by the wrapper so the cache can be adjusted.
            // This won't work with the dbcontext because it handles the connection itself, so we must use the underlying ObjectContext.
            // http://blogs.msdn.com/b/diego/archive/2012/01/26/exception-from-dbcontext-api-entityconnection-can-only-be-constructed-with-a-closed-dbconnection.aspx
            _objectContext = ((IObjectContextAdapter)_context).ObjectContext;

            if (_objectContext.Connection.State != ConnectionState.Open)
            {
                _objectContext.Connection.Open();
                _transaction = _objectContext.Connection.BeginTransaction();
            }
        }
コード例 #4
0
        public override void HandleAutoTask()
        {
            LogManager.Instance.Write("Start Email Handler ******************************************************");

            var emailAccount = new EmailAccount()
            {
                Email                 = ConfigurationManager.AppSettings["EmailAccount"],
                DisplayName           = ConfigurationManager.AppSettings["EmailDisplayName"],
                Host                  = ConfigurationManager.AppSettings["EmailHost"],
                Port                  = int.Parse(ConfigurationManager.AppSettings["EmailPort"]),
                Username              = ConfigurationManager.AppSettings["EmailUsername"],
                Password              = ConfigurationManager.AppSettings["EmailPassword"],
                EnableSsl             = bool.Parse(ConfigurationManager.AppSettings["EmailEnableSsl"]),
                UseDefaultCredentials = bool.Parse(ConfigurationManager.AppSettings["EmailUseDefaultCredentials"]),
            };

            using (var cache = new EntityCache <Email, CHCContext>(p => !p.SentDate.HasValue))
            {
                while (true)
                {
                    LogManager.Instance.Write(cache.Results.Count().ToString());

                    if (cache.Results.Count() > 0)
                    {
                        foreach (var email in cache.Results)
                        {
                            var bcc = String.IsNullOrWhiteSpace(email.Bcc)
                                        ? null
                                        : email.Bcc.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                            var cc = String.IsNullOrWhiteSpace(email.CC)
                                        ? null
                                        : email.CC.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                            try
                            {
                                EmailHelper.SendEmail(emailAccount, email.Subject, email.Body, emailAccount.Email, emailAccount.DisplayName, email.To, email.ToName,
                                                      email.ReplyTo, email.ReplyToName, bcc, cc, email.AttachmentFilePath, email.AttachmentFileName);

                                using (var context = new CHCContext())
                                {
                                    var entity = context.Email.SingleOrDefault(e => e.Id == email.Id);
                                    entity.SentTries++;
                                    entity.SentDate = DateTime.Now;
                                    context.SaveChanges();
                                }
                            }
                            catch (Exception ex)
                            {
                                LogManager.Instance.Write(ex.ToString());
                                using (var context = new CHCContext())
                                {
                                    var entity = context.Email.SingleOrDefault(e => e.Id == email.Id);
                                    entity.SentTries++;
                                    context.SaveChanges();
                                }
                            }
                        }
                    }

                    Thread.Sleep(5000);
                }
            }
        }
コード例 #5
0
ファイル: EmailRepository.cs プロジェクト: junlu3/CMS
 public EmailRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #6
0
 public MenuItemRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #7
0
 public MSDS_CompositionRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #8
0
ファイル: CompanyOrderRepository.cs プロジェクト: junlu3/CMS
 public CompanyOrderRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #9
0
 public MSDS_Substance_ExposureLimitRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #10
0
 public HealthResultRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #11
0
 public EmployeeBaseInfoRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #12
0
 public HospitalCalendarRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #13
0
 public CompanyOrder_Employee_MappingRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #14
0
ファイル: MembershipRepository.cs プロジェクト: junlu3/CMS
 public MembershipRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #15
0
 public MSDS_WorkStationRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #16
0
ファイル: MSDS_CustomerRepository.cs プロジェクト: junlu3/CMS
 public MSDS_CustomerRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #17
0
 public MSDS_H_StatementRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #18
0
 public CompanyEmployeeRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #19
0
 public MembershipUser_Company_MappingRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #20
0
 public PermissionRecordRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #21
0
ファイル: CategoryRepository.cs プロジェクト: junlu3/CMS
 public CategoryRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #22
0
 public MSDS_HazardousSubstancesRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #23
0
 public MembershipUser_EmailTaskType_MappingRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #24
0
 public PermissionRecord_MembershipRole_MappingRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #25
0
 public MSDS_SpecificationRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #26
0
 public FunctionRecordRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #27
0
ファイル: MSDS_WorkShopRepository.cs プロジェクト: junlu3/CMS
 public MSDS_WorkShopRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #28
0
 public MembershipUser_MembershipRole_MappingRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }
コード例 #29
0
 public AutoTaskRepository(ICHCContext context)
 {
     this._context = context as CHCContext;
 }
コード例 #30
0
 public EmployeeWorkHistoryRepository(ICHCContext context)
 {
     _context = context as CHCContext;
 }