Esempio n. 1
0
        public static bool CanAccessTo(Task task, Guid userId)
        {
            if (IsAdministrator(userId) || task.ResponsibleID == userId ||
                (task.ContactID == 0 && task.EntityID == 0) || task.CreateBy == userId)
            {
                return(true);
            }

            using (var scope = DIHelper.Resolve())
            {
                var daoFactory = scope.Resolve <DaoFactory>();
                if (task.ContactID > 0)
                {
                    var contactObj = daoFactory.ContactDao.GetByID(task.ContactID);
                    if (contactObj != null)
                    {
                        return(CanAccessTo(contactObj, userId));
                    }
                }

                if (task.EntityType == EntityType.Case)
                {
                    var caseObj = daoFactory.CasesDao.GetByID(task.EntityID);
                    if (caseObj != null)
                    {
                        return(CanAccessTo(caseObj, userId));
                    }
                }

                if (task.EntityType == EntityType.Opportunity)
                {
                    var dealObj = daoFactory.DealDao.GetByID(task.EntityID);
                    if (dealObj != null)
                    {
                        return(CanAccessTo(dealObj, userId));
                    }
                }

                return(false);
            }
        }
Esempio n. 2
0
        public static bool CanAccessTo(RelationshipEvent relationshipEvent, Guid userId)
        {
            if (IsAdministrator(userId))
            {
                return(true);
            }

            using (var scope = DIHelper.Resolve())
            {
                var daoFactory = scope.Resolve <DaoFactory>();

                if (relationshipEvent.ContactID > 0)
                {
                    var contactObj = daoFactory.ContactDao.GetByID(relationshipEvent.ContactID);
                    if (contactObj != null)
                    {
                        return(CanAccessTo(contactObj, userId));
                    }
                }

                if (relationshipEvent.EntityType == EntityType.Case)
                {
                    var caseObj = daoFactory.CasesDao.GetByID(relationshipEvent.EntityID);
                    if (caseObj != null)
                    {
                        return(CanAccessTo(caseObj, userId));
                    }
                }

                if (relationshipEvent.EntityType == EntityType.Opportunity)
                {
                    var dealObj = daoFactory.DealDao.GetByID(relationshipEvent.EntityID);
                    if (dealObj != null)
                    {
                        return(CanAccessTo(dealObj, userId));
                    }
                }

                return(false);
            }
        }
Esempio n. 3
0
        private static void SaveAdditionalInfoAction(QueueItem queueItem)
        {
            try
            {
                CoreContext.TenantManager.SetCurrentTenant(queueItem.TenantID);
                using (var scope = DIHelper.Resolve())
                {
                    var daoFactory = scope.Resolve <DaoFactory>();
                    var voipEngine = new VoipEngine(daoFactory);
                    var dao        = daoFactory.VoipDao;

                    var call = dao.GetCall(queueItem.CallID);

                    GetPriceAndDuration(call);

                    if (call.ChildCalls.Any())
                    {
                        call.ChildCalls.ForEach(r =>
                        {
                            GetPriceAndDuration(r);
                            voipEngine.SaveOrUpdateCall(r);
                        });
                    }

                    call = voipEngine.SaveOrUpdateCall(call);

                    if (!string.IsNullOrEmpty(call.VoipRecord.Id))
                    {
                        call.VoipRecord = VoipDao.GetProvider().GetRecord(call.Id, call.VoipRecord.Id);
                        voipEngine.SaveOrUpdateCall(call);
                    }

                    SecurityContext.AuthenticateMe(call.AnsweredBy);
                    AddHistoryToCallContact(call, daoFactory);
                }
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("ASC").ErrorFormat("SaveAdditionalInfo {0}, {1}", ex, ex.StackTrace);
            }
        }
        public static DIHelper AddFilesControllerHelperService(this DIHelper services)
        {
            services.TryAddScoped <FilesControllerHelper <string> >();
            services.TryAddScoped <FilesControllerHelper <int> >();

            return(services
                   .AddEasyBibHelperService()
                   .AddWordpressTokenService()
                   .AddWordpressHelperService()
                   .AddFolderContentWrapperHelperService()
                   .AddFileUploaderService()
                   .AddFileShareParamsService()
                   .AddFileShareWrapperService()
                   .AddFileOperationWraperHelperService()
                   .AddFileWrapperHelperService()
                   .AddFolderWrapperHelperService()
                   .AddConsumerFactoryService()
                   .AddDocumentServiceConnectorService()
                   .AddCommonLinkUtilityService()
                   .AddMessageServiceService()
                   .AddThirdpartyConfigurationService()
                   .AddCoreBaseSettingsService()
                   .AddWebItemSecurity()
                   .AddUserManagerService()
                   .AddEntryManagerService()
                   .AddTenantManagerService()
                   .AddSecurityContextService()
                   .AddDocumentServiceHelperService()
                   .AddFilesLinkUtilityService()
                   .AddApiContextService()
                   .AddFileStorageService()
                   .AddGlobalFolderHelperService()
                   .AddFilesSettingsHelperService()
                   .AddBoxLoginProviderService()
                   .AddDropboxLoginProviderService()
                   .AddOneDriveLoginProviderService()
                   .AddGoogleLoginProviderService()
                   .AddChunkedUploadSessionHelperService()
                   .AddProductEntryPointService()
                   );
        }
Esempio n. 5
0
        public static DIHelper AddDocumentServiceHelperService(this DIHelper services)
        {
            if (services.TryAddScoped <DocumentServiceHelper>())
            {
                return(services
                       .AddDaoFactoryService()
                       .AddFileShareLinkService()
                       .AddUserManagerService()
                       .AddAuthContextService()
                       .AddFileSecurityService()
                       .AddSetupInfo()
                       .AddLockerManagerService()
                       .AddFileUtilityService()
                       .AddMachinePseudoKeysService()
                       .AddGlobalService()
                       .AddDocumentServiceConnectorService()
                       .AddConfigurationService());
            }

            return(services);
        }
Esempio n. 6
0
        public static DIHelper AddUserManagerWrapperService(this DIHelper services)
        {
            if (services.TryAddScoped <UserManagerWrapper>())
            {
                return(services
                       .AddIPSecurityService()
                       .AddTenantUtilService()
                       .AddCustomNamingPeopleService()
                       .AddSettingsManagerService()
                       .AddStudioNotifyServiceService()
                       .AddUserManagerService()
                       .AddSecurityContextService()
                       .AddAuthContextService()
                       .AddMessageServiceService()
                       .AddDisplayUserSettingsService()
                       .AddCoreBaseSettingsService()
                       .AddUserFormatter());
            }

            return(services);
        }
Esempio n. 7
0
        public static DIHelper AddTenantService(this DIHelper services)
        {
            if (services.TryAddScoped <DbTenantService>())
            {
                services.TryAddScoped <ITenantService, CachedTenantService>();

                services.TryAddScoped <IConfigureOptions <DbTenantService>, ConfigureDbTenantService>();
                services.TryAddScoped <IConfigureOptions <CachedTenantService>, ConfigureCachedTenantService>();

                services.TryAddSingleton(typeof(ICacheNotify <>), typeof(KafkaCache <>));
                services.TryAddSingleton <TenantDomainValidator>();
                services.TryAddSingleton <TimeZoneConverter>();
                services.TryAddSingleton <TenantServiceCache>();

                return(services
                       .AddCoreBaseSettingsService()
                       .AddTenantDbContextService());
            }

            return(services);
        }
Esempio n. 8
0
        public HttpResponseMessage VoiceMail(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0)
        {
            try
            {
                using (var scope = DIHelper.Resolve())
                {
                    var daoFactory = scope.Resolve <DaoFactory>();
                    var voipEngine = new VoipEngine(daoFactory);
                    request.AddAdditionalFields(callerId, contactId);

                    MissCall(request, voipEngine);

                    return(GetHttpResponse(request.VoiceMail()));
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
Esempio n. 9
0
 public static DIHelper AddFileConverterService(this DIHelper services)
 {
     services.TryAddScoped <FileConverter>();
     return(services
            .AddFilesLinkUtilityService()
            .AddFileUtilityService()
            .AddDaoFactoryService()
            .AddSetupInfo()
            .AddPathProviderService()
            .AddFileSecurityService()
            .AddFileMarkerService()
            .AddTenantManagerService()
            .AddAuthContextService()
            .AddEntryManagerService()
            .AddFilesSettingsHelperService()
            .AddGlobalFolderHelperService()
            .AddFilesMessageService()
            .AddFileShareLinkService()
            .AddDocumentServiceHelperService()
            .AddDocumentServiceConnectorService());
 }
Esempio n. 10
0
        public override IEnumerable <object[]> BuildDocbuilderReport(TaskFilter filter)
        {
            filter.SortBy    = "title";
            filter.SortOrder = true;

            using (var scope = DIHelper.Resolve())
            {
                var result = scope.Resolve <EngineFactory>().ProjectEngine
                             .GetByFilter(filter)
                             .Select(r => new object[]
                {
                    r.Title, CoreContext.UserManager.GetUsers(r.Responsible).DisplayUserName(false),
                    LocalizedEnumConverter.ConvertToString(r.Status),
                    r.MilestoneCount, r.TaskCount, r.ParticipantCount
                });

                result = result.OrderBy(r => (string)r[1]);

                return(result);
            }
        }
Esempio n. 11
0
 public HttpResponseMessage Index(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0)
 {
     try
     {
         lock (LockObj)
         {
             using (var scope = DIHelper.Resolve())
             {
                 var daoFactory = scope.Resolve <DaoFactory>();
                 request.AddAdditionalFields(callerId, contactId);
                 var response = request.IsInbound ? Inbound(request, daoFactory) : Outbound(request, daoFactory);
                 return(GetHttpResponse(response));
             }
         }
     }
     catch (Exception e)
     {
         Log.Error(e);
         throw;
     }
 }
Esempio n. 12
0
        public static DIHelper AddFileSharingAceHelperService(this DIHelper services)
        {
            if (services.TryAddScoped <FileSharingAceHelper <string> >())
            {
                services.TryAddScoped <FileSharingAceHelper <int> >();

                return(services
                       .AddFileSecurityService()
                       .AddCoreBaseSettingsService()
                       .AddFileUtilityService()
                       .AddUserManagerService()
                       .AddAuthContextService()
                       .AddDocumentServiceHelperService()
                       .AddFileMarkerService()
                       .AddNotifyClientService()
                       .AddGlobalFolderHelperService()
                       .AddFileSharingHelperService());
            }

            return(services);
        }
Esempio n. 13
0
        public static DIHelper AddStudioWhatsNewNotify(this DIHelper services)
        {
            services.TryAddSingleton <StudioWhatsNewNotify>();
            services.TryAddScoped <StudioWhatsNewNotifyScope>();
            return(services
                   .AddWebItemManager()
                   .AddFeedAggregateDataProvider()

                   .AddTenantManagerService()
                   .AddPaymentManagerService()
                   .AddStudioNotifyHelperService()
                   .AddUserManagerService()
                   .AddSecurityContextService()
                   .AddAuthContextService()
                   .AddAuthManager()
                   .AddTenantUtilService()
                   .AddCommonLinkUtilityService()
                   .AddDisplayUserSettingsService()
                   .AddCoreSettingsService()
                   );
        }
Esempio n. 14
0
        public static DIHelper AddFolderDaoService(this DIHelper services)
        {
            services.TryAddScoped <IFolderDao <int>, FolderDao>();
            services.TryAddTransient <Folder <int> >();
            services.TryAddTransient <Folder <string> >();

            return(services
                   .AddFactoryIndexerService <FoldersWrapper>()
                   .AddTenantManagerService()
                   .AddUserManagerService()
                   .AddFilesDbContextService()
                   .AddTenantUtilService()
                   .AddSetupInfo()
                   .AddTenantExtraService()
                   .AddTenantStatisticsProviderService()
                   .AddCoreBaseSettingsService()
                   .AddCoreConfigurationService()
                   .AddSettingsManagerService()
                   .AddAuthContextService()
                   .AddGlobalSpaceService());
        }
Esempio n. 15
0
        public override IEnumerable <Tuple <Feed, object> > GetFeeds(FeedFilter filter)
        {
            var query = new SqlQuery("crm_case c")
                        .Select(CasesColumns().Select(c => "c." + c).ToArray())
                        .LeftOuterJoin("crm_entity_contact ec",
                                       Exp.EqColumns("ec.entity_id", "c.id")
                                       & Exp.Eq("ec.entity_type", 7)
                                       )
                        .Select("group_concat(distinct cast(ec.contact_id as char))")
                        .Where("c.tenant_id", filter.Tenant)
                        .Where(Exp.Between("c.create_on", filter.Time.From, filter.Time.To))
                        .GroupBy("c.id");

            using (var db = new DbManager(DbId))
                using (var scope = DIHelper.Resolve())
                {
                    var dao   = scope.Resolve <DaoFactory>().ContactDao;
                    var cases = db.ExecuteList(query).ConvertAll(ToCases);
                    return(cases.Select(c => new Tuple <Feed, object>(ToFeed(c, dao), c)).ToList());
                }
        }
Esempio n. 16
0
        public static DIHelper AddUserService(this DIHelper services)
        {
            if (services.TryAddScoped <EFUserService>())
            {
                services.TryAddScoped <IUserService, CachedUserService>();

                services.TryAddScoped <IConfigureOptions <EFUserService>, ConfigureEFUserService>();
                services.TryAddScoped <IConfigureOptions <CachedUserService>, ConfigureCachedUserService>();

                services.TryAddSingleton <UserServiceCache>();
                services.TryAddSingleton(typeof(ICacheNotify <>), typeof(KafkaCache <>));

                services
                .AddCoreSettingsService()
                .AddLoggerService()
                .AddUserDbContextService()
                .AddPasswordHasherService();
            }

            return(services);
        }
Esempio n. 17
0
        public async Task TestGetByName_WithValidPokemonName_ExpectPokemonWithDescription(
            Mock <IPokeApiClientWrapper> pokeApiClientWrapperMock,
            string pokemonName,
            string expectedDescription)
        {
            var pokemonSpecies = PokemonSpeciesHelper.CreatePokemonSpecies(pokemonName, expectedDescription, "en");

            SetupPokeApiClientWrapperMock(pokeApiClientWrapperMock, pokemonSpecies);
            var sutService = DIHelper.GetServices()
                             .RegisterMock(pokeApiClientWrapperMock)
                             .GetConfiguredService <IPokemonApiService>();

            // Act
            var pokemon = await sutService.GetByName(pokemonName, CancellationToken.None)
                          .ConfigureAwait(false);

            // Assert
            Assert.NotNull(pokemon);
            Assert.Equal(pokemonName, pokemon.Name);
            Assert.Equal(expectedDescription, pokemon.OriginalDescription);
        }
Esempio n. 18
0
        public async Task RunServerAsync()
        {
            OnSubMessage?.Invoke("服务启动中......", "重要");
            //第一步:创建ServerBootstrap实例
            var bootstrap = new ServerBootstrap();
            //第二步:绑定事件组
            IEventLoopGroup mainGroup = new MultithreadEventLoopGroup(1); //主工作线程组
            IEventLoopGroup workGroup = new MultithreadEventLoopGroup();  //工作线程组

            bootstrap.Group(mainGroup, workGroup);
            //第三步:绑定服务端的通道
            bootstrap.Channel <TcpServerSocketChannel>();// 设置通道模式为TcpSocket
            //第四步:配置处理器
            bootstrap.Option(ChannelOption.SoBacklog, 8192);
            bootstrap.ChildHandler(new ActionChannelInitializer <IChannel>(channel =>
            {
                IChannelPipeline pipeline = channel.Pipeline;
                pipeline.AddLast(new HttpServerCodec());
                pipeline.AddLast(new HttpObjectAggregator(65536));
                var handler = DIHelper.GetService <HttpChannelHandler>();
                if (OnException != null)
                {
                    handler.OnException += OnException;
                }
                pipeline.AddLast(handler);//注入HttpChannelHandler
            }));
            //第五步:配置主机和端口号
            var      iPAddress        = GetTrueIPAddress(); //获得真实IP地址
            var      port             = ConfigHelper.Configuration["ServerConfig:Port"];
            IChannel bootstrapChannel = await bootstrap.BindAsync(iPAddress, int.Parse(port));

            OnSubMessage?.Invoke("服务启动成功", "重要");
            OnMessage?.Invoke($"已监听http://{iPAddress}:{int.Parse(port)}");
            //第六步:停止服务
            WaitServerStop();//等待服务停止
            OnSubMessage?.Invoke("正在停止服务......", "重要");
            await bootstrapChannel.CloseAsync();

            OnSubMessage?.Invoke("服务已停止", "重要");
        }
        public override void Init()
        {
            context = new ProductContext
            {
                MasterPageFile                    = String.Concat(PathProvider.BaseVirtualPath, "Masters/BasicTemplate.Master"),
                DisabledIconFileName              = "product_disabled_logo.png",
                IconFileName                      = "product_logo.png",
                LargeIconFileName                 = "product_logolarge.png",
                SubscriptionManager               = new ProductSubscriptionManager(),
                DefaultSortOrder                  = 20,
                SpaceUsageStatManager             = new ProjectsSpaceUsageStatManager(),
                AdminOpportunities                = () => ProjectsCommonResource.ProductAdminOpportunities.Split('|').ToList(),
                UserOpportunities                 = () => ProjectsCommonResource.ProductUserOpportunities.Split('|').ToList(),
                HasComplexHierarchyOfAccessRights = true,
            };

            FileEngine.RegisterFileSecurityProvider();
            SearchHandlerManager.Registry(new SearchHandler());
            NotifyClient.RegisterSecurityInterceptor();
            ClientScriptLocalization = new ClientLocalizationResources();
            DIHelper.Register();
        }
Esempio n. 20
0
        public HttpResponseMessage Dial(TwilioVoiceRequest request, [FromUri] Guid callerId, [FromUri] int contactId = 0, [FromUri] string reject = null)
        {
            try
            {
                using (var scope = DIHelper.Resolve())
                {
                    var daoFactory = scope.Resolve <DaoFactory>();
                    var voipEngine = new VoipEngine(daoFactory);

                    request.AddAdditionalFields(callerId, contactId, reject);

                    var call = CallFromTwilioRequest(request);
                    call = voipEngine.SaveOrUpdateCall(call);

                    var parentCall = daoFactory.VoipDao.GetCall(call.ParentID);

                    if (!string.IsNullOrEmpty(request.RecordingSid))
                    {
                        if (parentCall.VoipRecord == null || string.IsNullOrEmpty(parentCall.VoipRecord.Id))
                        {
                            parentCall.VoipRecord = new VoipRecord {
                                Id = request.RecordingSid
                            };
                        }

                        daoFactory.VoipDao.SaveOrUpdateCall(parentCall);
                    }

                    voipEngine.SaveAdditionalInfo(parentCall.Id);

                    return(GetHttpResponse(request.Dial()));
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
Esempio n. 21
0
        public void TestTargetMustReturnCorrectAssembly()
        {
            // set up model
            LanguageModelAccessorMock model = new LanguageModelAccessorMock();

            // create configuration
            CecilAnalyzerConfiguration configuration = CecilAnalyzerConfiguration.CreateDefaultConfiguration(string.Empty);

            // do weaving
            IILAnalyzer     analyzer = DIHelper.CreateObject <CecilILAnalyzer>(CreateTestContainer(model, configuration));
            AssemblyElement ae       = analyzer.ExtractAllTypes(CreateFullPath("TestTarget.exe"));

            Assert.IsNotNull(ae, "Could not create an AssemblyElement.");
            Assert.IsFalse(string.IsNullOrEmpty(ae.FileName), "Filename is not set.");
            Assert.IsFalse(string.IsNullOrEmpty(ae.Name), "Assembly name is not set.");
            Assert.IsFalse(ae.Timestamp == 0, "Timestamp is not set.");

            Assert.IsTrue(ae.TypeElements.Length > 0, "TypeElements were not retrieved.");
            Assert.IsTrue(ae.TypeElements.Length == 1, "Found {0} TypeElements, expecting 1.", ae.TypeElements.Length);

            TypeElement te = ae.TypeElements[0];

            Assert.IsNotNull(te, "Could not set the TypeElement.");

            Assert.IsFalse(string.IsNullOrEmpty(te.BaseType), "BaseType has not been stored.");
            Assert.IsFalse(string.IsNullOrEmpty(te.FullName), "FullName has not been stored.");
            Assert.IsFalse(string.IsNullOrEmpty(te.Name), "Name has not been stored.");
            Assert.IsFalse(string.IsNullOrEmpty(te.Namespace), "Namespace has not been stored.");

            Assert.IsTrue(te.MethodElements.Length == 2, "Methods not stored in the TypeElement. {0} methods found", te.MethodElements.Length);

            MethodElement me = te.MethodElements[0];

            Assert.IsNotNull(me, "Could not set the methodElement");

            Assert.IsFalse(string.IsNullOrEmpty(me.Name), "Name has not been stored.");
            Assert.IsFalse(string.IsNullOrEmpty(me.ReturnType), "Returntype has not been stored.");
            Assert.IsFalse(string.IsNullOrEmpty(me.Signature), "Signature has not been stored.");
        } // TestTargetMustReturnAssembly()
Esempio n. 22
0
        public async Task TestGetTranslation_WhenRequestIsMade_ExpectHttpClientWrapperCall(
            Mock <IHttpClientWrapper> httpClientWrapper,
            Dictionary <string, string> parametersDictionary)
        {
            // Arrange
            var textToTranslate     = parametersDictionary.Values.FirstOrDefault();
            var httpResponseMessage = CreateHttpResponseMessage();

            SetupHttpClientWrapperMock(httpClientWrapper, httpResponseMessage);

            var sutService = DIHelper.GetServices()
                             .RegisterMock(httpClientWrapper)
                             .GetConfiguredService <IShakespeareTranslationService>();

            // Act
            await sutService.GetTranslation(textToTranslate, CancellationToken.None)
            .ConfigureAwait(false);

            // Assert
            httpClientWrapper
            .Verify(wrapper => wrapper.PostAsync(It.IsAny <string>(), It.IsAny <HttpContent>(), It.IsAny <CancellationToken>()), Times.Once);
        }
Esempio n. 23
0
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .UseSystemd()
        .UseWindowsService()
        .UseServiceProviderFactory(new AutofacServiceProviderFactory())
        .ConfigureAppConfiguration((hostContext, config) =>
        {
            var buided = config.Build();
            var path   = buided["pathToConf"];
            if (!Path.IsPathRooted(path))
            {
                path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path));
            }
            config.SetBasePath(path);
            var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
            config
            .AddJsonFile("appsettings.json")
            .AddEnvironmentVariables()
            .AddCommandLine(args)
            .AddInMemoryCollection(new Dictionary <string, string>
            {
                { "pathToConf", path }
            }
                                   );
        })
        .ConfigureServices((hostContext, services) =>
        {
            services.AddMemoryCache();
            var diHelper = new DIHelper(services);

            diHelper.TryAdd(typeof(ICacheNotify <>), typeof(KafkaCache <>));
            services.AddHostedService <ClearEventsServiceLauncher>();
            diHelper.TryAdd <ClearEventsServiceLauncher>();
        })
        .ConfigureContainer <ContainerBuilder>((context, builder) =>
        {
            builder.Register(context.Configuration, false, false);
        })
        .ConfigureNLogLogging();
Esempio n. 24
0
        public static DIHelper AddTagDaoService(this DIHelper services)
        {
            if (services.TryAddScoped<TagDao<string>>())
            {
                services.TryAddScoped<ITagDao<int>, TagDao<int>>();

                return services
                    .AddUserManagerService()
                    .AddFilesDbContextService()
                    .AddTenantManagerService()
                    .AddTenantUtilService()
                    .AddSetupInfo()
                    .AddTenantExtraService()
                    .AddTenantStatisticsProviderService()
                    .AddCoreBaseSettingsService()
                    .AddCoreConfigurationService()
                    .AddSettingsManagerService()
                    .AddAuthContextService();
            }

            return services;
        }
        public override IEnumerable <object[]> BuildReport(TaskFilter filter)
        {
            filter.SortBy    = "title";
            filter.SortOrder = true;

            using (var scope = DIHelper.Resolve())
            {
                var result = scope.Resolve <EngineFactory>().ProjectEngine
                             .GetByFilter(filter)
                             .Select(r => new object[]
                {
                    r.ID, r.Title, r.Responsible,
                    LocalizedEnumConverter.ConvertToString(r.Status),
                    r.MilestoneCount, r.TaskCount, r.ParticipantCount
                });

                result = AddUserInfo(result, 2);
                result = result.OrderBy(r => (string)r[1]);

                return(result);
            }
        }
        public bool CanRead(FileEntry entry, Guid userId)
        {
            if (entry.FileEntryType == FileEntryType.Folder)
            {
                return(false);
            }

            using (var scope = DIHelper.Resolve())
            {
                var daoFactory = scope.Resolve <DaoFactory>();
                var invoice    = daoFactory.InvoiceDao.GetByFileId(Convert.ToInt32(entry.ID));
                if (invoice != null)
                {
                    return(CRMSecurity.CanAccessTo(invoice, userId));
                }

                var reportFile = daoFactory.ReportDao.GetFile(Convert.ToInt32(entry.ID), userId);
                if (reportFile != null)
                {
                    return(true);
                }

                using (var tagDao = FilesIntegration.GetTagDao())
                {
                    var eventIds = tagDao.GetTags(entry.ID, FileEntryType.File, TagType.System)
                                   .Where(x => x.TagName.StartsWith("RelationshipEvent_"))
                                   .Select(x => Convert.ToInt32(x.TagName.Split(new[] { '_' })[1]))
                                   .ToList();

                    if (!eventIds.Any())
                    {
                        return(false);
                    }

                    var eventItem = daoFactory.RelationshipEventDao.GetByID(eventIds.First());
                    return(CRMSecurity.CanAccessTo(eventItem, userId));
                }
            }
        }
        public static UnityContainer RegisterComponents(IDataProtectionProvider dataProtectionProvider)
        {
            var container = new UnityContainer();

            DIHelper.RegisterComponents <HierarchicalLifetimeManager>(container);

            var settings = new JsonSerializerSettings();

#if DEBUG
            settings.Formatting = Formatting.Indented;
#else
            settings.Formatting = Formatting.None;
#endif
            settings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            var jsonSerializer = JsonSerializer.Create(settings);
            container.RegisterInstance(jsonSerializer);

            DependencyResolver.SetResolver(new MvcUnityDependencyResolver(container));
            GlobalConfiguration.Configuration.DependencyResolver = new WebApiUnityDependencyResolver(container);

            return(container);
        }
        public void Init()
        {
            WebItemManager.Instance.LoadItems();

            CoreContext.TenantManager.SetCurrentTenant(0);
            var tenant = CoreContext.TenantManager.GetCurrentTenant();

            SecurityContext.AuthenticateMe(tenant.OwnerId);

            Scope = DIHelper.Resolve(true);

            var engineFactory = Scope.Resolve <EngineFactory>();

            ProjectEngine      = engineFactory.ProjectEngine;
            ParticipantEngine  = engineFactory.ParticipantEngine;
            TaskEngine         = engineFactory.TaskEngine;
            SubtaskEngine      = engineFactory.SubtaskEngine;
            MilestoneEngine    = engineFactory.MilestoneEngine;
            MessageEngine      = engineFactory.MessageEngine;
            TimeTrackingEngine = engineFactory.TimeTrackingEngine;
            DataGenerator      = new DataGenerator();
            ProjectsReassign   = new ProjectsReassign();
        }
Esempio n. 29
0
        public static DIHelper AddFilesSpaceUsageStatManagerService(this DIHelper services)
        {
            if (services.TryAddScoped <FilesSpaceUsageStatManager>())
            {
                return(services
                       .AddTenantManagerService()
                       .AddUserManagerService()
                       .AddUserPhotoManagerService()
                       .AddDisplayUserSettingsService()
                       .AddCommonLinkUtilityService()
                       .AddFilesDbContextService()
                       .AddPathProviderService()
                       .AddFeedDbService()
                       .AddNotifyDbContext()
                       .AddDbContextService()
                       .AddResourceDbService()
                       .AddVoipDbContextService()
                       .AddMailDbContextService()
                       .AddMessagesContextService());
            }

            return(services);
        }
Esempio n. 30
0
        public static void Register(DIHelper services)
        {
            services.TryAdd <DocumentConfig <string> >();
            services.TryAdd <DocumentConfig <int> >();

            services.TryAdd <InfoConfig <string> >();
            services.TryAdd <InfoConfig <int> >();

            services.TryAdd <EditorConfiguration <string> >();
            services.TryAdd <EditorConfiguration <int> >();

            services.TryAdd <PluginsConfig>();
            services.TryAdd <EmbeddedConfig>();

            services.TryAdd <CustomizationConfig <string> >();
            services.TryAdd <CustomizationConfig <int> >();

            services.TryAdd <CustomerConfig <string> >();
            services.TryAdd <CustomerConfig <int> >();

            services.TryAdd <LogoConfig <string> >();
            services.TryAdd <LogoConfig <int> >();
        }