Exemplo n.º 1
0
        public bool TryContains(string value, out IForwardService forwardService)
        {
            var array = Dictionary.ToArray();

            if (array.Any(_keyPair => value.Equals(_keyPair.Key)))
            {
                var type = array.FirstOrDefault(_keyPair => Regex.IsMatch(value, _keyPair.Key)).Value;

                forwardService = (IForwardService)UnitWork.Instance.ServiceProvider.GetRequiredService(type);

                return(true);
            }

            forwardService = null;
            return(false);
        }
        public EmailService(IMailboxConfiguration mailboxConfiguration, 
                            IForwardService forwardService,
                            IEmailProvider emailProvider, 
                            IEmailRepository emailRepository, 
                            IReferenceGenerator referenceGenerator, 
                            IEmailServiceSettings emailServiceSettings)
        {
            Check.If(mailboxConfiguration).IsNotNull();
            Check.If(forwardService).IsNotNull();
            Check.If(emailProvider).IsNotNull();
            Check.If(emailRepository).IsNotNull();
            Check.If(referenceGenerator).IsNotNull();
            Check.If(emailServiceSettings).IsNotNull();

            _mailboxConfiguration = mailboxConfiguration;
            _forwardService = forwardService;
            _emailProvider = emailProvider;
            _emailRepository = emailRepository;
            _referenceGenerator = referenceGenerator;
            _emailServiceSettings = emailServiceSettings;
        }
Exemplo n.º 3
0
        public static async Task  Process(IForwardService service, HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var result = await service.ForwardAysnc(context);

            if (result.Status == 0 || result.Status == 200)
            {
                context.Response.ContentType = "application/json";
                await context.Response.WriteAsync(result.Data);
            }
            else if (result.Status == 404)
            {
                context.Response.StatusCode = 404;
                await context.Response.WriteAsync(result.Message ?? "Service not found!");
            }
            else
            {
                context.Response.StatusCode = 500;
                await context.Response.WriteAsync(result.Message ?? "Server Internal Error!");
            }
        }
        public void Setup()
        {
            _mockRule1 = new Mock<IForwardingRule>();
            _mockRule2 = new Mock<IForwardingRule>();
            _mockRule3 = new Mock<IForwardingRule>();
            _mockForwardingRuleFactory = new Mock<IForwardingRuleFactory>();

            _mockForwardingRuleFactory.Setup(x => x.GetRules())
                .Returns(new List<IForwardingRule> {_mockRule1.Object, _mockRule2.Object, _mockRule3.Object});

            _forwardService = new ForwardService(_mockForwardingRuleFactory.Object);
        }
 public ForwardServiceSubscribe(IForwardService forwardService, Func <object, object> func)
 {
     ForwardService = forwardService;
     Func           = func;
 }
Exemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        i18n = new i18nHelper();
        this.Title = i18n.GetMessage("m261") + " @ " + i18n.GetMessage("m9");
        this.forwardSend.Text = i18n.GetMessage("m78");
        currentUser = WebUtility.GetCurrentKBUser();
        subjectid = currentUser.SubjectId;
        documentService = factory.GetDocumentService();
        categoryService = factory.GetCategoryService();
        ratingService = factory.GetRatingService();
        auditTrailService = factory.GetAuditTrailService();
        wfService = factory.GetWorkflowService();
        hitService = factory.GetHitService();
        documentClassService = factory.GetDocumentClassService();
        subscribeService = WebUtility.Repository.GetSubscribeService();
        docId = WebUtility.GetIntegerParameter("documentId");
        folderId = WebUtility.GetIntegerParameter("folderId", -1);
        ver = WebUtility.GetIntegerParameter("ver", 0);
        latestVersionNumber = buildVersionInfo();
        currentUserOutputConfig = WebUtility.GetUserOutputConfig(currentUser.SubjectId);
        attachMode = currentUserOutputConfig.AttachMode;
        showUsedTags = ConfigurationManager.AppSettings["ShowUsedTags"] != null ? ConfigurationManager.AppSettings["ShowUsedTags"] : "false";
        tagsAutoComplete = ConfigurationManager.AppSettings["TagsAutoComplete"] != null ? ConfigurationManager.AppSettings["TagsAutoComplete"] : "false";
        tagsSuggestListLen = ConfigurationManager.AppSettings["TagsSuggestListLen"] != null ? ConfigurationManager.AppSettings["TagsSuggestListLen"] : "10";
        subscriptionConfirm = Convert.ToBoolean(ConfigurationManager.AppSettings["SubscriptionConfirm"] != null ? ConfigurationManager.AppSettings["SubscriptionConfirm"].ToString() : "true");
        autoSubscription = Convert.ToBoolean(ConfigurationManager.AppSettings["AutoSubscription"] != null ? ConfigurationManager.AppSettings["AutoSubscription"].ToString() : "true");
        allowSendToNoPrivilegeUser = Convert.ToBoolean(ConfigurationManager.AppSettings["AllowSendToNoPrivilegeUser"] != null ? ConfigurationManager.AppSettings["AllowSendToNoPrivilegeUser"].ToString() : "true");
        TagMaxLength = ConfigurationManager.AppSettings["TagMaxLength"] != null ? ConfigurationManager.AppSettings["TagMaxLength"] : "30";
        IsSafari = (Request.Browser.Browser.ToLower().Equals("applemac-safari") && !Request.UserAgent.ToLower().Contains("chrome"));
        userHadSubscribeResource = subscribeService.UserHadSubscribedResource(currentUser.SubjectId, (int)currentUser.SubjectType, docId, (int)SubscribeRecord.ResourceType.Document);
        mailService = WebUtility.Repository.GetMailService();
        kbuserService = WebUtility.Repository.GetKBUserService();
        folderService = WebUtility.Repository.GetFolderService();
        forwardService = WebUtility.Repository.GetForwardService();
        if (ver == 0)
        {
            doc = documentService.GetDocument(currentUser, docId);
            ver = latestVersionNumber;
        }
        else
        {
            doc = documentService.GetDocument(currentUser, docId, ver);
        }
        readVersion.Text = ver.ToString();
        latestVersion.Text = latestVersionNumber.ToString();
        if (ver != latestVersionNumber)
        {
            Panel1.Visible = false;
        }
        if (folderId == -1)
        {
            FolderInfo f = documentService.GetParentFolders(currentUser, docId)[0];
            folderId = f.FolderId;
        }

        buildCategoriesList();
        buildDocumentView();

        #region For teamKube Xml Render
        if (IsACLiteSubjectProvider)
        {
            renderSpecXml = RenderSpecificXML(currentUser, doc.DocumentId, ver);
        }
        #endregion

        if(!doc.DocumentClass.ClassName.Trim().ToLower().Equals("filesystem"))
        {
            buildFileList();
        }

        buildRatingSummary();
        buildAuditTrailInfo();
        createHitInfo();
        buildRelatedTagList(20);
        buildRelatedDocumentList();
        checkWorkflowInvolved();
        isDiffDocClass = IsDiffDocumentClass();
        strDiffDocClass = String.Format(i18n.GetMessage("m801"), doc.DocumentClass.ClassName, i18n.GetMessage("m802"), i18n.GetMessage("m803"));

        isBuiltinDocumentClass = (doc.DocumentClass.IsBuiltIn == true) ? "true" : "false";
    }