當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。