当前位置: 首页>>代码示例>>C#>>正文


C# ActivityContext类代码示例

本文整理汇总了C#中ActivityContext的典型用法代码示例。如果您正苦于以下问题:C# ActivityContext类的具体用法?C# ActivityContext怎么用?C# ActivityContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ActivityContext类属于命名空间,在下文中一共展示了ActivityContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetLocation

 public override Location GetLocation(ActivityContext context)
 {
     Location location;
     if (context == null)
     {
         throw FxTrace.Exception.ArgumentNull("context");
     }
     this.ThrowIfNotInTree();
     if (!context.AllowChainedEnvironmentAccess)
     {
         if (this.IsPublic || !object.ReferenceEquals(this.Owner, context.Activity))
         {
             throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.VariableOnlyAccessibleAtScopeOfDeclaration(context.Activity, this.Owner)));
         }
         if (!context.Environment.TryGetLocation(base.Id, out location))
         {
             throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.VariableDoesNotExist(this.Name)));
         }
         return location;
     }
     if (!context.Environment.TryGetLocation(base.Id, this.Owner, out location))
     {
         throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.VariableDoesNotExist(this.Name)));
     }
     return location;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:Variable.cs

示例2: UserIsApproved

 private bool UserIsApproved(ActivityContext context) {
     // checking if user is in an accepted role
     var workContext = _workContextAccessor.GetContext();
     var user = workContext.CurrentUser;
     if (user == null) return false;
     return user.As<UserPart>().RegistrationStatus == UserStatus.Approved;
 }
开发者ID:RasterImage,项目名称:Orchard,代码行数:7,代码来源:UserIsApprovedActivity.cs

示例3: Execute

        public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) {
            var userName = activityContext.GetState<string>("UserName");
            var email = activityContext.GetState<string>("Email");
            var password = activityContext.GetState<string>("Password");
            var approved = activityContext.GetState<bool>("Approved");

            if (String.IsNullOrWhiteSpace(userName) || String.IsNullOrWhiteSpace(email)) {
                yield return T("InvalidUserNameOrEmail");
                yield break;
            }

            if (String.IsNullOrWhiteSpace(password)) {
                yield return T("InvalidPassword");
                yield break;
            }

            if (!_userService.VerifyUserUnicity(userName, email)) {
                yield return T("UserNameOrEmailNotUnique");
                yield break;
            }

            var user = _membershipService.CreateUser(
                new CreateUserParams(
                    userName,
                    password,
                    email,
                    isApproved: approved,
                    passwordQuestion: null,
                    passwordAnswer: null));

            workflowContext.Content = user;

            yield return T("Done");
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:34,代码来源:CreateUserActivity.cs

示例4: Execute

        public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) {
            var body = activityContext.GetState<string>("Body");
            var subject = activityContext.GetState<string>("Subject");
            var recipients = activityContext.GetState<string>("Recipients");
            var replyTo = activityContext.GetState<string>("ReplyTo");
            var bcc = activityContext.GetState<string>("Bcc");
            var cc = activityContext.GetState<string>("CC");

            var parameters = new Dictionary<string, object> {
                {"Subject", subject},
                {"Body", body},
                {"Recipients", recipients},
                {"ReplyTo", replyTo},
                {"Bcc", bcc},
                {"CC", cc}
            };

            var queued = activityContext.GetState<bool>("Queued");

            if (!queued) {
                _messageService.Send(SmtpMessageChannel.MessageType, parameters);
            }
            else {
                var priority = activityContext.GetState<int>("Priority");
                _jobsQueueService.Enqueue("IMessageService.Send", new { type = SmtpMessageChannel.MessageType, parameters = parameters }, priority);
            }

            yield return T("Done");
        }
开发者ID:Higea,项目名称:Orchard,代码行数:29,代码来源:EmailActivity.cs

示例5: OnActivityExecuted

        public override void OnActivityExecuted(WorkflowContext workflowContext, ActivityContext activityContext) {

            // for blocking activities only
            if (!activityContext.Activity.IsEvent) {
                return;
            }

            // activity records pointing to the executed activity
            var inboundActivities = workflowContext.GetInboundTransitions(activityContext.Record);


            // if a direct target of a Branch Activity is executed, then suppress all other direct waiting activities
            var parentBranchActivities = inboundActivities
                .Where(x => x.SourceActivityRecord.Name == this.Name)
                .Select(x => x.SourceActivityRecord)
                .ToList();

            if (parentBranchActivities.Any()) {
                foreach (var parentBranch in parentBranchActivities) {
                    // remove all other waiting activities after the parent branch

                    var siblings = workflowContext.GetOutboundTransitions(parentBranch).Select(x => x.DestinationActivityRecord).ToList();
                    var awaitings = workflowContext.Record.AwaitingActivities.Where(x => siblings.Contains(x.ActivityRecord));
                    foreach (var awaiting in awaitings) {
                        workflowContext.Record.AwaitingActivities.Remove(awaiting);
                    }
                }
            }
        }
开发者ID:RasterImage,项目名称:Orchard,代码行数:29,代码来源:ExclusiveBranchActivity.cs

示例6: Execute

        public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) {
            if (UserIsApproved(activityContext)) {
                yield return T("Yes");
            }

            yield return T("No");
        }
开发者ID:RasterImage,项目名称:Orchard,代码行数:7,代码来源:UserIsApprovedActivity.cs

示例7: CanExecute

        public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) {
            try {

                var state = activityContext.GetState<string>("CustomForms");

                // "" means 'any'
                if (String.IsNullOrEmpty(state)) {
                    return true;
                }

                var content = workflowContext.Tokens["CustomForm"] as ContentItem;

                if (content == null) {
                    return false;
                }

                var contentManager = content.ContentManager;
                var identities = state.Split(',').Select(x => new ContentIdentity(x));
                var customForms = identities.Select(contentManager.ResolveIdentity);

                return customForms.Any(x => x == content);

            }
            catch {
                return false;
            }
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:27,代码来源:FormSubmittedActivity.cs

示例8: Execute

        public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext)
        {
            var user = workflowContext.Content.As<IUserRoles>();

            // if the current workflow subject is not a user, use current user
            if (user == null) {
                user = _workContextAccessor.GetContext().CurrentUser.As<IUserRoles>();
            }

            var roles = GetRoles(activityContext);

            if (user != null) {
                foreach (var role in roles) {
                    if (!user.Roles.Contains(role)) {
                        var roleRecord = _roleService.GetRoleByName(role);
                        if (roleRecord != null) {
                            _repository.Create(new UserRolesPartRecord {UserId = user.Id, Role = roleRecord});
                        }
                        else {
                            Logger.Debug("Role not found: {0}", role);
                        }
                    }
                }
            }

            yield return T("Done");
        }
开发者ID:Timbioz,项目名称:SciGitAzure,代码行数:27,代码来源:AssignRoleActivity.cs

示例9: CanExecute

        public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext)
        {
            try {

                var contentTypesState = activityContext.GetState<string>("ContentTypes");

                // "" means 'any'
                if (String.IsNullOrEmpty(contentTypesState)) {
                    return true;
                }

                string[] contentTypes = contentTypesState.Split(',');

                var content = workflowContext.Content;

                if (content == null) {
                    return false;
                }

                return contentTypes.Any(contentType => content.ContentItem.TypeDefinition.Name == contentType);
            }
            catch {
                return false;
            }
        }
开发者ID:Timbioz,项目名称:SciGitAzure,代码行数:25,代码来源:ContentActivity.cs

示例10: Execute

        public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext)
        {
            var part = workflowContext.Content.As<WXMsgPart>();
            var apiUrl = activityContext.GetState<string>("api_url");
            var apiToken = activityContext.GetState<string>("api_token");
            var timestamp = HttpContext.Current.Request.QueryString["timestamp"];
            var nonce = HttpContext.Current.Request.QueryString["nonce"];

            string[] arr = { apiToken, timestamp, nonce };
            Array.Sort(arr);     //字典排序
            string tmpStr = string.Join("", arr);
            var signature = _winXinService.GetSHA1(tmpStr);
            signature = signature.ToLower();

            var client = new System.Net.WebClient();
            client.Encoding = System.Text.Encoding.UTF8;
            var url = string.Format("{0}?timestamp={1}&nonce={2}&signature={3}"
                    , apiUrl, timestamp, nonce, signature);
            string postData = part.XML;
            //using (var stream = HttpContext.Current.Request.InputStream)
            //{
            //    var reader = new StreamReader(stream);
            //    postData = reader.ReadToEnd();
            //}

            string result = null;
            try
            {
                result = client.UploadString(url, postData);
            }
            catch (System.Net.WebException ex)
            {
                string msg = null;
                using (var stream = ex.Response.GetResponseStream())
                {
                    var reader = new StreamReader(stream);
                    msg = reader.ReadToEnd();
                }
                Logger.Warning(ex, ex.Message);
            }
            catch (Exception ex)
            {
                var innerEx = ex;
                while (innerEx.InnerException != null)
                    innerEx = innerEx.InnerException;
                Logger.Warning(ex, innerEx.Message);
            }

            if (result == null)
            {
                yield return T("Error");
            }
            else
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(result);
                HttpContext.Current.Response.End();
                yield return T("Success");
            }
        }
开发者ID:ccccccmd,项目名称:Orchard.WeChat,代码行数:60,代码来源:WeiXinDispatchActivity.cs

示例11: GetPossibleOutcomes

 public override IEnumerable<LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) {
     return new[] {
         T("InvalidUserNameOrEmail"),
         T("InvalidPassword"),
         T("UserNameOrEmailNotUnique"),
         T("Done")
     };
 }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:8,代码来源:CreateUserActivity.cs

示例12: Get

 public object Get(ActivityContext context)
 {
     if (context == null)
     {
         throw FxTrace.Exception.ArgumentNull("context");
     }
     return context.GetValue<object>((LocationReference) this);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:Variable.cs

示例13: GetBranches

        private IEnumerable<string> GetBranches(ActivityContext context) {
            var branches = context.GetState<string>("Branches");

            if (String.IsNullOrEmpty(branches)) {
                return Enumerable.Empty<string>();
            }

            return branches.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList();
        }
开发者ID:anycall,项目名称:Orchard,代码行数:9,代码来源:BranchActivity.cs

示例14: Execute

        public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) {
            var notification = activityContext.GetState<string>("Notification");
            var message = activityContext.GetState<string>("Message");

            var notificationType = (NotifyType)Enum.Parse(typeof(NotifyType), notification);
            _notifier.Add(notificationType, T(message));

            yield return T("Done");
        }
开发者ID:bigfont,项目名称:CertifiedOverheadCrane,代码行数:9,代码来源:NotificationActivity.cs

示例15: Execute

        public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) {
            var key = activityContext.GetState<string>("Key");
            var message = activityContext.GetState<string>("ErrorMessage");
            var updater = (IUpdateModel) workflowContext.Tokens["Updater"];

            updater.AddModelError(key, T(message));

            return new[] { T("Done") };
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:9,代码来源:AddModelErrorActivity.cs


注:本文中的ActivityContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。