実行する曜日で条件分岐したい

ご相談です。

ジョブを実行したい曜日(土曜、日曜、火曜or水曜)が3日あります。

それぞれの曜日で実行フローを変更したいのですが、条件分岐などを使って曜日ごとで実行フローを選択することは可能でしょうか。

例えば
土曜日 ⇒ Aフロー
日曜日 ⇒ Bフロー
火or水曜日 ⇒ Cフロー

ジョブを3つ作成することも考えましたが、1つのジョブで作成したいです。

Hi @n.prettytake

Yes, you can using flow chart, switch etc

image

Expression

System.DateTime.Now.DayOfWeek.ToString()

But I don’t recommed using this approach. If you need to run the job in others day for any reason it will run the branch related to the day

It is better you add an argument in main workflow that says which flow to execute then you configure 3 trigger each one passing the correct value

This way, if you need run the flow A manually, whatever the day, you can run the job passing this argument

1 Like

こんにちは

他のアプローチとして以下のようにすると条件分岐無しで、動的に異なる処理を呼び出せます。

dict = New Dictionary(Of String,String)From{{"Sunday","A.xaml"},{"Saturday","B.xaml"},{"Tuesday","C.xaml"},{"Wednesday","C.xaml"}}

としておいて

dict(DateTime.Now.DayOfWeek.ToString)

をワークフロー呼び出しアクティビティで呼び出します。

20231128-3-2

20231128-4

なお23.4までのWindowsプロジェクトではうまく動作しませんのでご注意ください。

1 Like

@Yoichi just to mentioned, I love see your solutions

It is a valuable source of knowledge

1 Like

dictの変数の型は何になりますでしょうか。

stringではエラーが発生してしまいます。

Dictionary<string,string>になります
以下サンプルです。

Sample20231128-1.zip (7.1 KB)

教えていただいて申し訳ないのですが、

条件分岐(else if)での作り方も教えていただけますと幸いです。

以下になります。

(Invoke Workflowにしていますが、そのまま処理を記述してもOKです)

以下Sequence.xaml参照ください
Sample20231128-1 (2).zip (10.1 KB)

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.