SkyoceanHome
Home
Privacy
ダウンロード
SkyShop
Updated Information
チュートリアルコード集
References
記事編集
日付
ジャンルのカテゴリ―名
名前を選択して下さい。
Contexts
Controllers
Databases
Htmls
JavaScripts
Models
MVCTutorials
Others
Styles
Views
タイトル
内容の要旨
<div style="flex: 1 1 0%; display: flex; overflow: hidden; flex-direction: column; height: 368px; box-sizing: border-box; padding: 20px 20px 0px; color: rgb(0, 0, 0); font-family: roboto, helvetica, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;" data-pasted="true"><div style="display: flex; flex: 1 1 0%; position: relative; min-width: 0px; height: 256px; flex-direction: column;"><div tabindex="0" style="color: rgba(0, 0, 0, 0.8); padding: 0px; flex: 1 1 0%; font-size: 16px; line-height: 26px; font-weight: 400; overflow: auto; max-height: 420px;"><p data-bm="25" style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: 4px; padding: revert; -webkit-line-clamp: revert;">ASP.NET Core MVC で「今日が月の1日ならば」という条件判定は、<br><code style="border-radius: 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255);">DateTime.Today.Day == 1</code> を使えば簡単に書けます。</p><p data-bm="26" style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: 4px; padding: revert; -webkit-line-clamp: revert;">例えば、<code style="border-radius: 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255);">SomethingDo()</code> を呼び出す条件部分は以下のようになります。</p><pre data-priority="2" data-bm="27" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(245, 245, 245); border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 8px; overflow: hidden;"><div data-bm="33" style="display: flex; height: 28px; flex-direction: row; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid rgba(0, 0, 0, 0.1); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(248, 244, 241);"><h5 style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: 0px; padding: revert; font-style: normal !important; font-variant: normal !important; font-weight: 400 !important; font-stretch: 100% !important; line-height: 18px; font-family: roboto, helvetica, sans-serif !important; font-optical-sizing: auto !important; font-size-adjust: none !important; font-kerning: auto !important; font-feature-settings: normal !important; font-variation-settings: normal !important; font-language-override: normal !important; font-size: 16px; display: inline-block; color: rgb(60, 81, 180);">Csharp</h5><div style="height: 28px;"><button type="button" tabindex="" title="Copy code" style="box-sizing: border-box; margin: 0px; padding: 0px; font: 400 13px / 20px roboto, helvetica, sans-serif; background-color: rgb(217, 223, 251); border: 1px solid rgba(0, 0, 0, 0); display: grid; grid-auto-flow: column; align-items: center; cursor: pointer; color: rgb(60, 81, 180) !important; text-decoration: none !important; border-radius: 9999px; block-size: 28px; gap: 2px; padding-inline: 10px;"><div style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); padding-inline: 2px;">Copy code</div></button></div></div><code style="border-radius: 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255); display: block; white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px 16px 16px;"><span style="color: rgb(215, 58, 73);">using</span> System; <span style="color: rgb(215, 58, 73);">public</span> <span style="color: rgb(215, 58, 73);">class</span> <span style="color: rgb(111, 66, 193);">MyService</span> { <span style="color: rgb(215, 58, 73);">public</span> <span style="color: rgb(215, 58, 73);">void</span> <span style="color: rgb(111, 66, 193);">SomethingDo</span>() { <span style="color: rgb(106, 115, 125);">// 実行したい処理</span> Console.WriteLine(<span style="color: rgb(3, 47, 98);">"毎月1日の処理を実行しました。"</span>); } <span style="color: rgb(215, 58, 73);">public</span> <span style="color: rgb(215, 58, 73);">void</span> <span style="color: rgb(111, 66, 193);">CheckAndRun</span>() { <span style="color: rgb(106, 115, 125);">// 今日が月の1日かどうか判定</span> <span style="color: rgb(215, 58, 73);">if</span> (DateTime.Today.Day == <span style="color: rgb(0, 92, 197);">1</span>) { SomethingDo(); } } } </code></pre><h3 data-bm="28" style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: revert; padding: revert; display: inline-block; font: 400 20px / 22px roboto, helvetica, sans-serif;">補足</h3><ul data-bm="29" style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: revert; padding: revert;"><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;"><code style="border-radius: 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255);">DateTime.Today</code> は時刻部分を 00:00 にした日付を返します。</li><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;"><code style="border-radius: 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255);">Day</code> プロパティはその月の日にち(1〜31)を返します。</li><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;">このコードは「呼び出されたタイミングで今日が1日なら実行」するだけなので、<br>実際に毎月1日に自動実行したい場合は <strong style="font-weight: 700;">スケジューラ</strong> が必要です。</li></ul><p data-bm="30" style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: 4px; padding: revert; -webkit-line-clamp: revert;">ASP.NET Core で自動実行するには例えば:</p><ul data-bm="31" style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: revert; padding: revert;"><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;"><strong style="font-weight: 700;">IHostedService / BackgroundService</strong> を使って定期的にチェック</li><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;"><strong style="font-weight: 700;">Quartz.NET</strong> や <strong style="font-weight: 700;">Hangfire</strong> などのジョブスケジューラを利用</li><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;">OS のタスクスケジューラや cron で HTTP エンドポイントを叩く</li></ul><p data-bm="32" style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: 4px; padding: revert; -webkit-line-clamp: revert;">もしご希望なら、この「毎月1日に自動実行する」ための <strong style="font-weight: 700;">ASP.NET Core BackgroundService 実装例</strong> も作れますが、作成しますか?<br>そうすればアプリが稼働中に自動で <code style="border-radius: 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255);">SomethingDo()</code> が呼ばれます。</p></div></div></div><div style="color: rgba(0, 0, 0, 0.6); border-top: 0px; margin: 0px 20px; padding: 0px 0px 20px; height: 36px; display: flex; align-items: center; position: relative; font-family: roboto, helvetica, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div style="flex: 1 1 0%; display: flex; gap: 8px; align-items: center;"><button type="button" tabindex="-1" title="Undo" style="box-sizing: border-box; margin: 0px; padding: 0px; font: 700 13px / 20px roboto, helvetica, sans-serif; background-color: rgba(0, 0, 0, 0); border: 1px solid rgba(0, 0, 0, 0); display: grid; grid-auto-flow: column; align-items: center; cursor: not-allowed; color: rgb(60, 81, 180) !important; text-decoration: none !important; opacity: 0.3; block-size: 38px; gap: 4px; padding-inline: 0px; aspect-ratio: 1 / 1; justify-content: center; border-radius: 8px;"><div data-visually-hidden="" style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); block-size: 1px; inline-size: 1px; border: 0px; clip: rect(0px, 0px, 0px, 0px); clip-path: inset(50%); position: absolute; padding-inline: 4px;">Undo</div></button><button type="button" tabindex="-1" title="Redo" style="box-sizing: border-box; margin: 0px; padding: 0px; font: 700 13px / 20px roboto, helvetica, sans-serif; background-color: rgba(0, 0, 0, 0); border: 1px solid rgba(0, 0, 0, 0); display: grid; grid-auto-flow: column; align-items: center; cursor: not-allowed; color: rgb(60, 81, 180) !important; text-decoration: none !important; opacity: 0.3; block-size: 38px; gap: 4px; padding-inline: 0px; aspect-ratio: 1 / 1; justify-content: center; border-radius: 8px;"><div data-visually-hidden="" style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); block-size: 1px; inline-size: 1px; border: 0px; clip: rect(0px, 0px, 0px, 0px); clip-path: inset(50%); position: absolute; padding-inline: 4px;">Redo</div></button><button type="button" title="Copy" style="box-sizing: border-box; margin: 0px; padding: 0px; font: 700 13px / 20px roboto, helvetica, sans-serif; background-color: rgba(0, 0, 0, 0); border: 1px solid rgba(0, 0, 0, 0); display: grid; grid-auto-flow: column; align-items: center; cursor: pointer; color: rgb(60, 81, 180) !important; text-decoration: none !important; block-size: 38px; gap: 4px; padding-inline: 0px; aspect-ratio: 1 / 1; justify-content: center; border-radius: 8px;"><div data-visually-hidden="" style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); block-size: 1px; inline-size: 1px; border: 0px; clip: rect(0px, 0px, 0px, 0px); clip-path: inset(50%); position: absolute; padding-inline: 4px;">Copy</div></button><button type="button" title="Export" style="box-sizing: border-box; margin: 0px; padding: 0px; font: 700 13px / 20px roboto, helvetica, sans-serif; background-color: rgba(0, 0, 0, 0); border: 1px solid rgba(0, 0, 0, 0); display: grid; grid-auto-flow: column; align-items: center; cursor: pointer; color: rgb(60, 81, 180) !important; text-decoration: none !important; block-size: 38px; gap: 4px; padding-inline: 0px; aspect-ratio: 1 / 1; justify-content: center; border-radius: 8px;"><div data-visually-hidden="" style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); block-size: 1px; inline-size: 1px; border: 0px; clip: rect(0px, 0px, 0px, 0px); clip-path: inset(50%); position: absolute; padding-inline: 4px;">Export</div></button><div style="display: flex; z-index: 10; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; color: rgba(0, 0, 0, 0.6); width: 300px; min-height: 40px; max-height: 120px; position: absolute; box-sizing: border-box; bottom: 18px; border: 1px solid rgba(0, 0, 0, 0.1); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(247, 247, 247); left: 172px;"><textarea placeholder="What would you like to adjust?" rows="1" style="font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: 20px; font-family: inherit; font-optical-sizing: inherit; font-size-adjust: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; font-language-override: inherit; font-size: 14px; outline: 0px; border: 0px; padding: 0px; resize: none; overflow: hidden; flex: 1 1 auto; min-width: 0px; background: inherit; height: 20px;"></textarea><div style="display: flex; align-items: center; gap: 8px; margin-inline-start: auto;"><br></div></div><button type="button" title="Rewrite" style="box-sizing: border-box; margin: 0px; padding: 0px; font: 700 13px / 20px roboto, helvetica, sans-serif; background-color: rgb(248, 244, 241); border: 1px solid rgba(0, 0, 0, 0); display: grid; grid-auto-flow: column; align-items: center; cursor: pointer; color: rgb(60, 81, 180) !important; text-decoration: none !important; block-size: 38px; gap: 4px; padding-inline: 10px; border-radius: 8px; height: 40px;"><div style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); padding-inline: 4px;">Rewrite</div></button><fieldset style="all: unset;"><button type="button" title="Testing Tools" style="box-sizing: border-box; margin: 0px; padding: 8px 12px; font: 700 14px / 22px roboto, helvetica, sans-serif; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(248, 244, 241) !important; border: 0px; display: flex; grid-auto-flow: column; align-items: center; cursor: pointer; color: rgb(60, 81, 180); text-decoration: none !important; padding-inline: 10px; justify-content: center; gap: 4px; fill: rgb(60, 81, 180); border-radius: 8px; outline: 0px; block-size: 38px; height: 40px;"><div style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); padding-inline: 4px;">Testing Tools</div></button></fieldset><fieldset style="all: unset;"><button type="button" title="More Actions" style="box-sizing: border-box; margin: 0px; padding: 8px 12px; font: 700 14px / 22px roboto, helvetica, sans-serif; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(248, 244, 241) !important; border: 0px; display: flex; grid-auto-flow: column; align-items: center; cursor: pointer; color: rgb(60, 81, 180); text-decoration: none !important; padding-inline: 10px; justify-content: center; gap: 4px; fill: rgb(60, 81, 180); border-radius: 8px; outline: 0px; block-size: 38px; height: 40px;"><div style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); padding-inline: 4px;">More Actions</div></button></fieldset><div style="margin-left: auto;"><div style="box-sizing: border-box; margin: 0px; padding: 0px; display: grid; gap: 2px;"><div title="Try more templates" data-visually-hidden="" style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; font: 400 13px / 20px roboto, helvetica, sans-serif; color: rgba(0, 0, 0, 0.6); white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); block-size: 1px; inline-size: 1px; border: 0px; clip: rect(0px, 0px, 0px, 0px); clip-path: inset(50%); position: absolute;">Try more templates</div><div tabindex="0" title="Try more templates" style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; display: grid; grid-auto-flow: column; justify-content: space-between; align-items: center; gap: 4px; font: 400 13px / 20px roboto, helvetica, sans-serif; color: rgb(0, 0, 0); padding-block: 8px; padding-inline: 12px; border-radius: 8px; background-color: rgb(248, 244, 241); border: 0px; cursor: pointer; height: 40px;"><div style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; display: grid; grid-auto-flow: column; align-items: center; gap: 8px;"><div style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); color: rgb(60, 81, 180); font: 700 14px / 22px roboto, helvetica, sans-serif; outline: 0px;">Try more templates</div></div></div></div></div></div></div><p data-f-id="pbf" style="text-align: center; font-size: 14px; margin-top: 30px; opacity: 0.65; font-family: sans-serif;">Powered by <a href="https://www.froala.com/wysiwyg-editor?pb=1" title="Froala Editor">Froala Editor</a></p>
コピーする
添付画像
画像を変更
Back to List
//検索文:Editor内でHTMLコードをコピーさせる