Esempio n. 1
0
        /*    protected void Application_Stop()
         *  {
         *                  StopTasks();
         * //            SqlDependency.Stop(GetSpecialistWebConnectionString());
         *
         *  }*/

        protected virtual void InitializeContainer()
        {
            if (Container == null)
            {
                Container = new UnityContainer();

                UnityRegistrator.RegisterControls(Container,
                                                  typeof(HomeController).Assembly);
                UnityRegistrator.RegisterServices(Container);
                Container
                .RegisterType <ISimplePageVMService, SimplePageVMService>()
                .RegisterInstance(typeof(IMetaDataProvider), MetaDataProvider)
                .RegisterType <IAnnounceService, AnnounceService>()
                .RegisterType <ISectionVMService, SectionVMService>()
                .RegisterType <ICourseVMService, CourseVMService>();
                Container.Configure <Interception>()
                .SetDefaultInterceptorFor <CourseVMService>(
                    new VirtualMethodInterceptor())
                .SetDefaultInterceptorFor <SuperJobService>(
                    new VirtualMethodInterceptor());


                ValidatorRegistrator.Register(Container);

                ControllerBuilder.Current.
                SetControllerFactory(typeof(UnityControllerFactory));
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var container = new UnityContainer();

            UnityRegistrator.RegisterServices(container);

            var service      = container.Resolve <MailListService>();
            var mailTemplate = service.GetTemplate();

            using (var client = new SmtpClient()) {
                foreach (var email in
                         "[email protected],[email protected]".Split(','))
                {
                    service.Send(client, mailTemplate.V1, email);
                }
            }
            service = container.Resolve <MailListService>();
            Console.WriteLine("current = " + service.CurrentUser.GetValueOrDefault());
            Console.WriteLine(service.CurrentUser.HasValue
                                ? "Продолжить рассылку?" : "Рассылать?");
            Console.ReadKey();
            Console.WriteLine(service.GetSendedPercent().GetValueOrDefault()
                              .ToString("n2") + "%");
            service.SendForAll();
            Console.WriteLine("done");
            Console.ReadKey();
        }
Esempio n. 3
0
 public SiteSupportService()
 {
     InitializeComponent();
     UnityRegistrator.RegisterServices(_container);
     _container
     .RegisterType <IContextProvider, CmsContextProvider>()
     .RegisterType <IResponseLogicService, ResponseLogicService>()
     ;
 }
Esempio n. 4
0
        public static void Register(HttpConfiguration config)
        {
            config.EnableCors();
            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            //DI
            var connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            config.DependencyResolver = UnityRegistrator.RegisterRepository <Department, DepartmentRepository>(connectionString);
        }
Esempio n. 5
0
        protected virtual void InitializeContainer()
        {
            if (Container == null)
            {
                Container = new UnityContainer();
                UnityRegistrator.RegisterControls(Container,
                                                  typeof(HomeController).Assembly);
                UnityRegistrator.RegisterServices(Container);
                Container
                .RegisterType <IRepository <SiteObjectType>, SiteObjectTypeRepository>()
                .RegisterType <IRepository <PaymentType>, PaymentTypeRepository>()
                .RegisterType <IRepository <NewsType>, InMemoryRepository <NewsType> >()
                .RegisterType <IRepository <OrderCustomerType>, InMemoryRepository <OrderCustomerType> >()
                .RegisterType <IRepository <TestStatus>, NamedIdRepository <TestStatus> >()
                .RegisterType <IRepository <ResponseRating>, InMemoryRepository <ResponseRating> >()
                .RegisterType <IRepository <MarketingActionType>, InMemoryRepository <MarketingActionType> >()
                .RegisterType <IRepository <RawQuestionnaireType>,
                               InMemoryRepository <RawQuestionnaireType> >()
                .RegisterType <IRepository <CenterVacancyType>,
                               InMemoryRepository <CenterVacancyType> >()
                .RegisterType <IRepository <Order>, OrderService>()
                .RegisterType <IRepository <OrderDetail>, OrderDetailService>()
                .RegisterInstance(typeof(IMetaDataProvider), MetaDataProvider)
                .RegisterType <IContextProvider, ContextProvider>()
                .RegisterType <IResponseLogicService, ResponseLogicService>();

                Container.Configure <Interception>()
                .SetDefaultInterceptorFor <PaymentTypeRepository>(
                    new VirtualMethodInterceptor());


                ControllerBuilder.Current.
                SetControllerFactory(typeof(CmsControllerFactory));
                ControllerBuilder.Current.DefaultNamespaces.Add(Const.Common.ControllerNamespace);
            }
        }
Esempio n. 6
0
        public string Get()
        {
            var context = new SpecialistDataContext();
            var groups  = context.Groups.PlannedAndNotBegin()
                          .Where(g => g.DateBeg > new DateTime(2011, 1, 1))
                          .Select(g => new { g.Course_TC, Date = g.DateBeg.Value, g.Course.Name }).ToList();
            var orgs   = _.List(PriceTypes.Corporate, PriceTypes.CorporateBusinessClass);
            var prices = context.PriceViews.Where(x => orgs.Contains(x.PriceType_TC) &&
                                                  x.Track_TC == null).Select(x =>
                                                                             new { x.Course_TC, x.PriceType_TC, x.Price }).ToList();
            var courses = prices.Select(x => x.Course_TC).Distinct();
            Func <string, string, string> getPrice = (courseTC, priceTypeTC) =>
                                                     prices.FirstOrDefault(p => p.Course_TC == courseTC &&
                                                                           p.PriceType_TC == priceTypeTC).GetOrDefault(x => (decimal?)x.Price)
                                                     .NotNullString("n0");

            groups =
                (from g in groups
                 group g by new { g.Course_TC, Week = GetWeekNumber(g.Date) }
                 into gr
                 select gr.First()).ToList();
            groups = groups.Where(g => courses.Contains(g.Course_TC)).ToList();
            var resultGroups = groups.GroupBy(x => x.Course_TC)
                               .Select(x => new {
                Course_TC = x.Key,
                x.First().Name,
                Dates = x.OrderBy(z => z.Date).Select(z => z.Date.ToString("dd.MM")).JoinWith(" ")
            })
                               .ToList();


            var webcontext   = new SpecialistWebDataContext();
            var rootSections = webcontext.Sections.Where(s => s.IsMain)
                               .ByWebOrder().IsActive().ToList();
            var unity = new UnityContainer();

            UnityRegistrator.RegisterServices(unity);
            var courseService      = unity.Resolve <ICourseService>();
            var sectionWithCourses =
                rootSections.Select(s => new { Section = s, CourseTCs =
                                                   courseService.GetCourseTCListForSections(
                                                       _.List(s.Section_ID)) });

            /*var allSectionCourses = sectionWithCourses
             *      .SelectMany(x => x.CourseTCs).Distinct().ToList();
             * var notInList = resultGroups.Where(g => !allSectionCourses.Contains(g.Course_TC)).ToList();*/
            var groupBySections = sectionWithCourses.Select(s =>
                                                            Grouping.New(s.Section,
                                                                         resultGroups.Where(c => s.CourseTCs.Contains(c.Course_TC))))
                                  .Where(s => s.Any()).ToList();


            return(table[tr[
                             th["Название курса"],
                             th["Цена ОРГ"],
                             th["Цена ОРГБ"],
                             th["Расписание"]],
                         groupBySections.Select(s => H.l(tr[td[s.Key.Name].Colspan(4)],
                                                         s.OrderBy(x => x.Name).Select(g => tr[td[g.Name],
                                                                                               td[getPrice(g.Course_TC, PriceTypes.Corporate)],
                                                                                               td[getPrice(g.Course_TC, PriceTypes.CorporateBusinessClass)],
                                                                                               td[g.Dates]])))].ToString());
        }