1

リストに保存している受信者のリストを提供するカスタム ワークフロー アクティビティを作成しようとしています。しかし、ワークフローをデプロイして開始すると、何も起こらず、ログ メッセージも来ません。そのため、コードをデバッグしようとしましたが、ブレークポイントが設定されておらず、「ブレークポイントは現在ヒットしません。このドキュメントにはシンボルが読み込まれていません。」というエラーが表示されます。誰でもこの問題に対処するのを手伝ってくれませんか。

以下は、このアクティビティを作成する際に従った手順です。1. ワークフロー アクティビティ ライブラリを作成しました。(私のコードファイルが添付されていることを確認してください)

  1. .dll を GAC に追加
  2. web.config および WSS.actions ファイルを更新しました。
  3. デザイナーでアクションが表示されるようになったので、デザイナーを使用してワークフローを作成しました。
  4. アイテムのワークフローを手動で開始しました。

ここでは何も起こっておらず、エラーさえありません。さらに情報が必要な場合はお知らせください。

以下のコードを見つけてください。

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using System.Diagnostics;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;

namespace CustomWorkflowActivityLibrary
{
    public partial class CustomWorkflowActivity: SequenceActivity
    {
        SPList _list;
        private EventLog _log;
        SPFieldUserValueCollection objUserFieldValueCol;
        string semailsettingKeyword1;
        string semailsettingKeyword2;
        public CustomWorkflowActivity()
        {
            InitializeComponent();
        }

        public static DependencyProperty __ContextProperty = DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(CustomWorkflowActivity));
        [DescriptionAttribute("__Context")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]

        public WorkflowContext __Context
        {
            get { return ((WorkflowContext)(base.GetValue(CustomWorkflowActivity.__ContextProperty))); }
            set { base.SetValue(CustomWorkflowActivity.__ContextProperty, value); }
        }
        public static DependencyProperty ListIdProperty = DependencyProperty.Register("ListId", typeof(string), typeof(CustomWorkflowActivity));
        [DescriptionAttribute("ListId")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string ListId
        {
            get { return ((string)(base.GetValue(CustomWorkflowActivity.ListIdProperty))); }
            set { base.SetValue(CustomWorkflowActivity.ListIdProperty, value); }
        }
        public static DependencyProperty ListItemProperty = DependencyProperty.Register("ListItem", typeof(int), typeof(CustomWorkflowActivity));
        [DescriptionAttribute("ListItem")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public int ListItem
        {
            get { return ((int)(base.GetValue(CustomWorkflowActivity.ListItemProperty))); }
            set { base.SetValue(CustomWorkflowActivity.ListItemProperty, value); }
        }
        private void codeActivity1_ExecuteCode(object sender, EventArgs e)
        {
        }
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            _log = new EventLog("Add Description");
            _log.Source = "Share Point Workflows";
            try
            {
                //Execute method as a elevated method                 
                SPSecurity.CodeToRunElevated elevatedExecuteMethod = new SPSecurity.CodeToRunElevated(ExecuteMethod);
                SPSecurity.RunWithElevatedPrivileges(elevatedExecuteMethod);
            }
            catch (Exception ex)
            {
                _log.WriteEntry("Error" + ex.Message.ToString(), EventLogEntryType.Error);
            }
            return ActivityExecutionStatus.Closed;
        }
        private void ExecuteMethod()
        {
            try
            {
                //retrieveing the Site object       
                SPSite _site = new SPSite(__Context.Site.Url);
                //retrieveing the Web object                 
                SPWeb _web = (SPWeb)(__Context.Web);
                //retrieveing the list object                 
                _list = _web.Lists[new Guid(this.ListId)];
                //retrieveing the list item object              
                SPListItem _listItem = _list.GetItemById(this.ListItem);
                _site.AllowUnsafeUpdates = true;
                _web.AllowUnsafeUpdates = true;
                string semailsubject = _listItem["E-Mail Subject"].ToString();
                string semailfrom = _listItem["emailfrom"].ToString();
                _log = new EventLog("get vendor info");
                _log.WriteEntry("semailsubject");
                _log.WriteEntry("semailfrom");

                /* _listItem.Update();
                 _list.Update();
                 _site.AllowUnsafeUpdates = false;
                 _web.AllowUnsafeUpdates = false;*/
                using (SPSite mysite = new SPSite("http://dlglobaltest.dl.com/Admin/IT/Application%20Development%20Group/LibraryEmailDistribution"))
                {
                    using (SPWeb myweb = mysite.OpenWeb())
                    {
                        SPList settingsList = myweb.Lists["EmailDistributionSettings"];
                        SPQuery oQuery = new SPQuery();
                        oQuery.Query = "<Where><Eq><FieldRef Name='Sender' /><Value Type='Text'>" + semailfrom + "</Value></Eq></Where>";
                        SPListItemCollection ColListItems = settingsList.GetItems(oQuery);
                        foreach (SPListItem oListItem in ColListItems)
                        {
                            semailsettingKeyword1 = oListItem["Keyword1"].ToString();
                            semailsettingKeyword2 = oListItem["Keyword2"].ToString();
                            //SPFieldUserValue objUserFieldValue = new SPFieldUserValue(myweb, oListItem["Recipients"].ToString());

                            if ((semailsubject.Contains(semailsettingKeyword1)) || (semailsubject.Contains(semailsettingKeyword2)))
                            {
                                objUserFieldValueCol = new SPFieldUserValueCollection(myweb, oListItem["Recipients"].ToString());
                                _log = new EventLog(objUserFieldValueCol.ToString());

                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            { }
        }
    }
}

Web.Config:

<authorizedType Assembly="CustomWorkflowActivityLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a95e146fc1062337" Namespace="CustomWorkflowActivityLibrary" TypeName="*" Authorized="True" />

WSS.アクション:

<Action Name="Get Recipients" 
            ClassName="CustomWorkflowActivityLibrary.CustomWorkflowActivity"
            Assembly="CustomWorkflowActivityLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a95e146fc1062337" 
            AppliesTo="all" Category="Custom">
            <RuleDesigner Sentence="Get Recipients for %1 "> 
           <FieldBind Field="ListId,ListItem" Text="this list" Id="1" DesignerType="ChooseListItem" />
        </RuleDesigner>   
         <Parameters> 
        <Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext" Direction="In" /> 
        <Parameter Name="ListId" Type="System.String, mscorlib" Direction="In" /> 
        <Parameter Name="ListItem" Type="System.Int32, mscorlib" Direction="In" /> 
            </Parameters> 

    </Action>

ありがとう、

4

2 に答える 2

0

これが役立つかどうかはわかりませんが、コードの次の行をこれから変更してみてください。

SPSecurity.RunWithElevatedPrivileges(elevatedExecuteMethod); 

これに:

SPSecurity.RunWithElevatedPrivileges(delegate(){
    ExecuteMethod();
}); 
于 2011-01-30T15:18:37.243 に答える
0

別のショットインザダークリプライ:

継承しているクラス ( http://msdn.microsoft.com/en-us/library/ms173149(v=VS.80).aspx ) を SequenceActivity から Activity に変更してみてください (SequenceActivity は CompositeActivity から継承し、それ自体はから継承します)アクティビティ: http://msdn.microsoft.com/en-us/library/system.workflow.activities.sequenceactivity(v=VS.90).aspxを参照してください。

それでもうまくいかない場合は、コンストラクターを完全に削除してみてください。基本 (Sequence)Activity コンストラクターを使用できるはずです (クラスを実装するのではなく継承しているため)

それが役立つことを願っています...

于 2011-06-23T19:40:11.507 に答える