last module update ...

This commit is contained in:
2026-11-11 15:48:11 +03:30
parent 81beb177fd
commit ee6ae89001
13 changed files with 23231 additions and 1 deletions
+3
View File
@@ -60,6 +60,9 @@
[submodule "Modules/xAiService"]
path = Modules/xAiService
url = https://git.saherelm.ir/saherelm/xAiService.git
[submodule "Modules/xBotService"]
path = Modules/xBotService
url = https://git.saherelm.ir/saherelm/xBotService.git
#
# xFramework Modules ...
+683
View File
@@ -0,0 +1,683 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>راهنمای جامع ساخت بات بله با C# | پیاده‌سازی سیستم نوتیفیکیشن</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
:root {
--primary: #1a365d;
--primary-light: #2c5282;
--accent: #c9a961;
--accent-dark: #a8893f;
--bg: #faf9f6;
--card-bg: #ffffff;
--text: #1a202c;
--text-muted: #4a5568;
--border: #e2e8f0;
--success: #38a169;
--danger: #e53e3e;
--warning: #dd6b20;
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Vazirmatn', Tahoma, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.9;
font-size: 15px;
padding: 30px 15px;
}
.document-container {
max-width: 950px;
margin: 0 auto;
background: var(--card-bg);
box-shadow: var(--shadow);
border-radius: 12px;
overflow: hidden;
}
.document-header {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
color: white;
padding: 50px 40px 40px;
position: relative;
border-bottom: 4px solid var(--accent);
}
.document-header::before {
content: '';
position: absolute;
top: 0; right: 0;
width: 200px; height: 200px;
background: radial-gradient(circle, rgba(201,169,97,0.15) 0%, transparent 70%);
border-radius: 50%;
transform: translate(50%, -50%);
}
.header-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
position: relative;
z-index: 1;
}
.company-badge {
display: flex;
align-items: center;
gap: 12px;
}
.company-logo {
width: 60px; height: 60px;
background: var(--accent);
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
color: white;
font-size: 14px;
}
.doc-meta {
text-align: left;
font-size: 12px;
opacity: 0.9;
}
.doc-meta div { margin-bottom: 3px; }
.document-title {
text-align: center;
position: relative;
z-index: 1;
padding: 20px 0;
}
.document-title .label {
display: inline-block;
background: rgba(201,169,97,0.2);
color: var(--accent);
padding: 4px 16px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
margin-bottom: 15px;
border: 1px solid rgba(201,169,97,0.4);
}
.document-title h1 {
font-size: 28px;
font-weight: 800;
margin-bottom: 10px;
letter-spacing: -0.5px;
}
.document-title h2 {
font-size: 16px;
font-weight: 400;
opacity: 0.9;
}
.document-body {
padding: 40px;
}
.intro-text {
background: linear-gradient(to left, #f7fafc, #edf2f7);
border-right: 4px solid var(--accent);
padding: 20px 25px;
border-radius: 8px;
margin-bottom: 35px;
font-size: 14px;
color: var(--text-muted);
}
.section {
margin-bottom: 40px;
page-break-inside: avoid;
}
.section-header {
display: flex;
align-items: center;
gap: 15px;
padding-bottom: 12px;
border-bottom: 2px solid var(--border);
margin-bottom: 20px;
}
.section-number {
width: 50px; height: 50px;
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
font-size: 20px;
flex-shrink: 0;
box-shadow: 0 4px 10px rgba(26,54,93,0.2);
}
.section-title { flex: 1; }
.section-title h3 {
font-size: 19px;
font-weight: 700;
color: var(--primary);
margin-bottom: 2px;
}
.section-title .subtitle {
font-size: 12px;
color: var(--text-muted);
}
.section-content {
padding-right: 10px;
}
.section-content p {
margin-bottom: 12px;
text-align: justify;
text-indent: 20px;
}
.section-content p.no-indent { text-indent: 0; }
.highlight-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #f6e05e;
border-right: 4px solid var(--accent);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.highlight-box strong { color: var(--accent-dark); }
.info-box {
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
border: 1px solid #90cdf4;
border-right: 4px solid var(--primary-light);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.success-box {
background: linear-gradient(to left, #f0fff4, #e6fffa);
border: 1px solid #9ae6b4;
border-right: 4px solid var(--success);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.warning-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #fbd38d;
border-right: 4px solid var(--warning);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.styled-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
background: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.styled-table thead {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
}
.styled-table th {
padding: 14px 16px;
text-align: right;
font-weight: 600;
font-size: 13px;
}
.styled-table td {
padding: 13px 16px;
border-bottom: 1px solid var(--border);
font-size: 13px;
}
.styled-table tbody tr:last-child td { border-bottom: none; }
.styled-table tbody tr:nth-child(even) { background: #f8fafc; }
.styled-table .highlight-row {
background: #fffaf0 !important;
font-weight: 600;
}
.code-block {
background: #1a202c;
color: #e2e8f0;
padding: 20px;
border-radius: 8px;
font-family: 'Consolas', 'Monaco', monospace;
font-size: 13px;
direction: ltr;
text-align: left;
overflow-x: auto;
margin: 20px 0;
border-right: 4px solid var(--accent);
}
.code-block .keyword { color: #569cd6; }
.code-block .string { color: #ce9178; }
.code-block .comment { color: #6a9955; }
.code-block .type { color: #4ec9b0; }
.comparison-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin: 25px 0;
}
.comparison-card {
background: #f8fafc;
border: 2px solid var(--border);
border-radius: 10px;
padding: 20px;
position: relative;
}
.comparison-card.recommended {
border-color: var(--success);
background: linear-gradient(to left, #f0fff4, #e6fffa);
}
.comparison-card .card-badge {
position: absolute;
top: -10px;
right: 20px;
background: var(--success);
color: white;
padding: 3px 12px;
border-radius: 15px;
font-size: 11px;
font-weight: 600;
}
.comparison-card h4 {
font-size: 16px;
font-weight: 700;
color: var(--primary);
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 2px solid var(--border);
}
.comparison-card.recommended h4 { border-bottom-color: var(--success); }
.comparison-card ul { list-style: none; padding: 0; }
.comparison-card ul li {
padding: 8px 0;
border-bottom: 1px solid var(--border);
font-size: 13px;
display: flex;
justify-content: space-between;
}
.comparison-card ul li:last-child { border-bottom: none; }
.comparison-card ul li .value { font-weight: 600; color: var(--primary); }
.stats-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 15px;
margin: 25px 0;
}
.stat-card {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
padding: 20px;
border-radius: 10px;
text-align: center;
box-shadow: 0 4px 12px rgba(26,54,93,0.2);
}
.stat-card .stat-value {
font-size: 24px;
font-weight: 800;
margin-bottom: 5px;
color: var(--accent);
line-height: 1.3;
}
.stat-card .stat-label { font-size: 12px; opacity: 0.9; }
.conclusion-box {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
padding: 30px;
border-radius: 12px;
margin: 30px 0;
text-align: center;
box-shadow: 0 8px 20px rgba(26,54,93,0.3);
}
.conclusion-box h3 {
font-size: 22px;
font-weight: 800;
margin-bottom: 15px;
color: var(--accent);
}
.conclusion-box p {
font-size: 14px;
line-height: 1.8;
text-indent: 0 !important;
margin-bottom: 15px;
}
.conclusion-box .highlight {
background: rgba(201,169,97,0.2);
padding: 15px 20px;
border-radius: 8px;
margin-top: 20px;
border: 1px solid rgba(201,169,97,0.4);
}
.document-footer {
background: var(--primary);
color: white;
padding: 25px 40px;
text-align: center;
font-size: 12px;
margin-top: 40px;
}
.document-footer .footer-brand {
font-weight: 700;
color: var(--accent);
margin-bottom: 5px;
font-size: 14px;
}
.footer-divider {
width: 60px;
height: 2px;
background: var(--accent);
margin: 10px auto;
}
.page-info {
text-align: center;
padding: 15px;
font-size: 11px;
color: var(--text-muted);
border-top: 1px solid var(--border);
margin-top: 30px;
}
@media print {
body { background: white; padding: 0; }
.document-container { box-shadow: none; border-radius: 0; }
.section { page-break-inside: avoid; }
}
@media (max-width: 768px) {
.document-body { padding: 25px 20px; }
.document-header { padding: 30px 20px; }
.comparison-grid { grid-template-columns: 1fr; }
.stats-grid { grid-template-columns: 1fr; }
.header-top { flex-direction: column; gap: 15px; }
.doc-meta { text-align: center; }
}
</style>
</head>
<body>
<div class="document-container">
<header class="document-header">
<div class="header-top">
<div class="company-badge">
<div class="company-logo">RPK</div>
</div>
<div class="doc-meta">
<div>شماره مستند: TECH-1405-002</div>
<div>نسخه: ۱.۰</div>
<div>تاریخ تهیه: آبان ۱۴۰۵</div>
<div>طبقه‌بندی: داخلی / فنی</div>
</div>
</div>
<div class="document-title">
<span class="label">TECHNICAL GUIDE</span>
<h1>راهنمای جامع ساخت بات بله با C#</h1>
<h2>پیاده‌سازی گام‌به‌گام سیستم ارسال نوتیفیکیشن به کاربران</h2>
</div>
</header>
<div class="document-body">
<div class="intro-text">
<strong>مدیر انتشار و تیم توسعه محترم،</strong><br>
این مستند فنی، راهنمای کامل و گام‌به‌گام طراحی و پیاده‌سازی یک سرویس نوتیفیکیشن مبتنی بر پیام‌رسان بله با استفاده از زبان C# و فریم‌ورک .NET 8 را ارائه می‌دهد. هدف، ایجاد یک زیرساخت پایدار، مقیاس‌پذیر و قابل یکپارچه‌سازی با چرخه انتشار نرم‌افزار است.
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۱</div>
<div class="section-title">
<h3>خلاصه اجرایی و انتخاب مسیر</h3>
<div class="subtitle">Executive Summary & Path Selection</div>
</div>
</div>
<div class="section-content">
<p>پیام‌رسان بله دو مسیر مجزا برای ارسال پیام ارائه می‌دهد. انتخاب مسیر صحیح، کلید موفقیت سناریوی «ارسال نوتیف به هر کاربر در هر زمان» است.</p>
<div class="comparison-grid">
<div class="comparison-card">
<h4>مسیر اول: Bot API استاندارد</h4>
<ul>
<li><span>آدرس پایه</span> <span class="value">tapi.bale.ai</span></li>
<li><span>هدف‌گیری</span> <span class="value">فقط Chat ID (کاربر باید بات را استارت کرده باشد)</span></li>
<li><span>هزینه</span> <span class="value">رایگان</span></li>
<li><span>مناسب برای</span> <span class="value" style="color: var(--warning);">تعامل دوطرفه و ربات‌های خدماتی</span></li>
</ul>
</div>
<div class="comparison-card recommended">
<span class="card-badge">پیشنهاد ما ✓</span>
<h4>مسیر دوم: سرویس سفیر (Safir)</h4>
<ul>
<li><span>آدرس پایه</span> <span class="value">safir.bale.ai</span></li>
<li><span>هدف‌گیری</span> <span class="value">شماره موبایل (حتی بدون استارت بات)</span></li>
<li><span>هزینه</span> <span class="value">به ازای هر پیام (نیاز به شارژ اعتبار)</span></li>
<li><span>مناسب برای</span> <span class="value" style="color: var(--success);">ارسال نوتیفیکیشن، اعلان و OTP</span></li>
</ul>
</div>
</div>
<div class="highlight-box">
<strong>نتیجه کلیدی:</strong> برای سناریوی درخواستی شما (ارسال نوتیف به هر کاربر در هر زمان)، <strong>سرویس سفیر</strong> تنها گزینه عملیاتی است، زیرا وابستگی به `chat_id` و شروع گفتگو توسط کاربر را حذف می‌کند.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۲</div>
<div class="section-title">
<h3>گام اول: معماری و ساختار پروژه</h3>
<div class="subtitle">Architecture & Project Structure</div>
</div>
</div>
<div class="section-content">
<p>برای حفظ اصول Clean Architecture و قابلیت تست‌پذیری، پروژه به سه لایه اصلی تقسیم می‌شود:</p>
<div class="code-block">
<span class="comment">// ساختار پیشنهادی حل (Solution)</span>
BaleNotifier/
├── BaleNotifier.sln
├── src/
│ ├── BaleNotifier.Core/ <span class="comment">// مدل‌ها (Models) و اینترفیس‌ها (Interfaces)</span>
│ ├── BaleNotifier.Services/ <span class="comment">// پیاده‌سازی سرویس‌های HTTP و منطق کسب‌وکار</span>
│ └── BaleNotifier.Worker/ <span class="comment">// Background Service برای Polling یا Console App</span>
└── tests/
└── BaleNotifier.Tests/ <span class="comment">// تست‌های واحد (Unit Tests)</span>
</div>
<div class="info-box">
<strong>💡 تنظیمات پیکربندی (appsettings.json):</strong>
مقادیر `BotToken` و `ApiAccessKey` (دریافتی از پنل کسب‌وکار بله) باید در این فایل یا Azure Key Vault ذخیره شوند.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۳</div>
<div class="section-title">
<h3>گام دوم: پیاده‌سازی مدل‌ها و سرویس سفیر</h3>
<div class="subtitle">Models & Safir Service Implementation</div>
</div>
</div>
<div class="section-content">
<p>سرویس سفیر نیازمند ارسال درخواست‌های JSON با هدر احراز هویت خاص است. مدل‌های زیر ساختار داده‌ای را تضمین می‌کنند:</p>
<div class="code-block">
<span class="keyword">public class</span> <span class="type">SafirSendRequest</span>
{
<span class="keyword">public string</span> RequestId { <span class="keyword">get</span>; <span class="keyword">set</span>; } = Guid.NewGuid().ToString(<span class="string">"N"</span>);
<span class="keyword">public long</span> BotId { <span class="keyword">get</span>; <span class="keyword">set</span>; }
<span class="keyword">public string</span> PhoneNumber { <span class="keyword">get</span>; <span class="keyword">set</span>; } = <span class="keyword">default!</span>;
<span class="keyword">public</span> <span class="type">SafirMessageData</span> MessageData { <span class="keyword">get</span>; <span class="keyword">set</span>; } = <span class="keyword">default!</span>;
}
<span class="keyword">public class</span> <span class="type">SafirMessageData</span>
{
<span class="keyword">public</span> <span class="type">SafirMessage</span>? Message { <span class="keyword">get</span>; <span class="keyword">set</span>; }
<span class="keyword">public bool</span>? IsSecure { <span class="keyword">get</span>; <span class="keyword">set</span>; } <span class="comment">// برای ارسال پیام رمزدار</span>
}
</div>
<p>پیاده‌سازی سرویس اصلی با استفاده از `HttpClient` و تزریق وابستگی (DI):</p>
<div class="code-block">
<span class="keyword">public class</span> <span class="type">SafirService</span> : <span class="type">ISafirService</span>
{
<span class="keyword">private readonly</span> <span class="type">HttpClient</span> _http;
<span class="keyword">private readonly</span> <span class="type">long</span> _botId;
<span class="keyword">public</span> <span class="type">SafirService</span>(<span class="type">HttpClient</span> http, <span class="type">IConfiguration</span> config)
{
_http = http;
_http.BaseAddress = <span class="keyword">new</span> <span class="type">Uri</span>(config[<span class="string">"Bale:Safir:BaseUrl"</span>]!);
_http.DefaultRequestHeaders.Add(<span class="string">"api-access-key"</span>, config[<span class="string">"Bale:Safir:ApiAccessKey"</span>]!);
_botId = <span class="keyword">long</span>.Parse(config[<span class="string">"Bale:Safir:BotId"</span>]!);
}
<span class="keyword">public async</span> <span class="type">Task</span>&lt;<span class="type">SafirSendResponse</span>?&gt; <span class="type">SendTextNotificationAsync</span>(<span class="keyword">string</span> phone, <span class="keyword">string</span> text)
{
<span class="keyword">var</span> request = <span class="keyword">new</span> <span class="type">SafirSendRequest</span>
{
BotId = _botId,
PhoneNumber = <span class="type">NormalizePhoneNumber</span>(phone),
MessageData = <span class="keyword">new</span> <span class="type">SafirMessageData</span> { Message = <span class="keyword">new</span> <span class="type">SafirMessage</span> { Text = text } }
};
<span class="keyword">var</span> response = <span class="keyword">await</span> _http.PostAsJsonAsync(<span class="string">"/api/v3/send_message"</span>, request);
<span class="keyword">return await</span> response.Content.ReadFromJsonAsync&lt;<span class="type">SafirSendResponse</span>&gt;();
}
<span class="comment">// متد NormalizePhoneNumber برای اطمینان از فرمت 989123456789</span>
}
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۴</div>
<div class="section-title">
<h3>گام سوم: مدیریت ارسال انبوه و Idempotency</h3>
<div class="subtitle">Bulk Management & Idempotency</div>
</div>
</div>
<div class="section-content">
<p>در محیط عملیاتی (Production)، ارسال نوتیفیکیشن باید در برابر خطاهای شبکه و تلاش‌های تکراری (Retry) مقاوم باشد.</p>
<div class="success-box">
<strong>✓ مکانیزم Idempotency:</strong> فیلد `request_id` در درخواست سفیر، از ارسال تکراری پیام در صورتی که درخواست به دلیل خطای شبکه دوباره ارسال شود، جلوگیری می‌کند.
</div>
<div class="warning-box">
<strong>⚠️ مدیریت Rate Limit:</strong> سرویس بله دارای محدودیت نرخ ارسال است. در صورت ارسال انبوه، حتماً بین درخواست‌ها تأخیر (Delay) ایجاد کنید یا از صف‌های پیام (مانند Azure Service Bus یا RabbitMQ) با الگوی Consumer Rate Limiting استفاده نمایید.
</div>
<div class="code-block">
<span class="keyword">public async</span> <span class="type">Task</span> <span class="type">BroadcastAsync</span>(<span class="type">IEnumerable</span>&lt;<span class="keyword">string</span>&gt; phones, <span class="keyword">string</span> text)
{
<span class="keyword">foreach</span> (<span class="keyword">var</span> phone <span class="keyword">in</span> phones)
{
<span class="keyword">await</span> _safir.SendTextNotificationAsync(phone, text);
<span class="keyword">await</span> <span class="type">Task</span>.Delay(200); <span class="comment">// جلوگیری از خطای RateLimitExceeded (کد 3)</span>
}
}
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۵</div>
<div class="section-title">
<h3>گام چهارم: یکپارچه‌سازی با چرخه انتشار</h3>
<div class="subtitle">Integration with Release Pipeline</div>
</div>
</div>
<div class="section-content">
<p>به عنوان مدیر انتشار، می‌توانید این سرویس را در نقاط مختلف چرخه ۷ مرحله‌ای انتشار (از ثبت درخواست تا استقرار آبی) فراخوانی کنید. نمونه استفاده در یک سرویس اعلان انتشار:</p>
<div class="code-block">
<span class="keyword">public class</span> <span class="type">ReleaseNotifier</span>
{
<span class="keyword">private readonly</span> <span class="type">INotificationService</span> _notifier;
<span class="keyword">public</span> <span class="type">ReleaseNotifier</span>(<span class="type">INotificationService</span> notifier) => _notifier = notifier;
<span class="keyword">public async</span> <span class="type">Task</span> <span class="type">OnReleaseDeployed</span>(<span class="keyword">string</span> version, <span class="type">IEnumerable</span>&lt;<span class="keyword">string</span>&gt; stakeholderPhones)
{
<span class="keyword">var</span> message = $<span class="string">"✅ نسخه <b>{version}</b> با موفقیت در محیط عملیاتی آبی مستقر شد."</span>;
<span class="keyword">await</span> _notifier.BroadcastAsync(stakeholderPhones, message);
}
}
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۶</div>
<div class="section-title">
<h3>مدیریت خطاها و نکات امنیتی</h3>
<div class="subtitle">Error Handling & Security Notes</div>
</div>
</div>
<div class="section-content">
<p>پاسخ سرویس سفیر شامل آرایه‌ای از `error_data` است. پایش این کدها برای عیب‌یابی عملیاتی حیاتی است:</p>
<table class="styled-table">
<thead>
<tr>
<th>کد خطا</th>
<th>نام خطا</th>
<th>توضیح و راه‌حل</th>
</tr>
</thead>
<tbody>
<tr>
<td>3</td>
<td>RateLimitExceeded</td>
<td>بیش از حد مجاز پیام ارسال شده. افزایش Delay بین درخواست‌ها.</td>
</tr>
<tr>
<td>8</td>
<td>InvalidPhone</td>
<td>فرمت شماره اشتباه است. اطمینان از حذف '0' اول و شروع با '98'.</td>
</tr>
<tr>
<td>17</td>
<td>NotBaleUser</td>
<td>کاربر با این شماره، حساب کاربری بله ندارد. حذف از لیست ارسال.</td>
</tr>
<tr>
<td>20</td>
<td>PaymentRequired</td>
<td>اعتبار پنل سفیر به پایان رسیده است. نیاز به شارژ حساب.</td>
</tr>
</tbody>
</table>
<div class="info-box">
<strong>🔒 نکته امنیتی:</strong> هرگز `ApiAccessKey` و `BotToken` را در مخزن کد (Git Repository) کامیت نکنید. از Azure Key Vault یا GitHub Secrets برای تزریق این مقادیر در زمان اجرا استفاده نمایید.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۷</div>
<div class="section-title">
<h3>جمع‌بندی نهایی و گام بعدی</h3>
<div class="subtitle">Final Summary & Next Steps</div>
</div>
</div>
<div class="section-content">
<div class="conclusion-box">
<h3>🎯 مسیر پیشنهادی</h3>
<p>برای دستیابی به هدف «ارسال نوتیف به هر کاربر در هر زمان»، پیاده‌سازی سرویس <strong>Safir</strong> با الگوی <strong>Background Worker</strong> و مدیریت صف، پایدارترین و حرفه‌ای‌ترین راه‌حل در اکوسیستم .NET است.</p>
<div class="highlight">
<strong>💎 ارزش فنی ارائه‌شده:</strong><br>
استقلال از Chat ID + مدیریت خودکار خطاها + یکپارچه‌سازی روان با چرخه انتشار + رعایت اصول Clean Architecture
</div>
</div>
<div class="info-box">
<strong>📞 گام بعدی:</strong> در صورت تأیید این معماری، می‌توانم ریپازیتوری پایه (Boilerplate) شامل تمامی مدل‌ها، سرویس‌ها و تست‌های واحد را آماده و در اختیار تیم توسعه قرار دهم.
</div>
</div>
</div>
<div class="page-info">
این مستند فنی محرمانه بوده و صرفاً جهت استفاده داخلی تیم توسعه و مدیریت انتشار شرکت رایان پرداز کاوش تهیه شده است.
</div>
</div>
<footer class="document-footer">
<div class="footer-brand">طراحی و تدوین: هادی خزاعی اصل | مدیر انتشار</div>
<div class="footer-divider"></div>
<div>تاریخ تهیه: آبان ۱۴۰۵ &nbsp;|&nbsp; نسخه: ۱.۰ &nbsp;|&nbsp; طبقه‌بندی: داخلی / فنی</div>
</footer>
</div>
</body>
</html>
+683
View File
@@ -0,0 +1,683 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>راهنمای جامع ساخت بات بله با C# | پیاده‌سازی سیستم نوتیفیکیشن</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
:root {
--primary: #1a365d;
--primary-light: #2c5282;
--accent: #c9a961;
--accent-dark: #a8893f;
--bg: #faf9f6;
--card-bg: #ffffff;
--text: #1a202c;
--text-muted: #4a5568;
--border: #e2e8f0;
--success: #38a169;
--danger: #e53e3e;
--warning: #dd6b20;
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Vazirmatn', Tahoma, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.9;
font-size: 15px;
padding: 30px 15px;
}
.document-container {
max-width: 950px;
margin: 0 auto;
background: var(--card-bg);
box-shadow: var(--shadow);
border-radius: 12px;
overflow: hidden;
}
.document-header {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
color: white;
padding: 50px 40px 40px;
position: relative;
border-bottom: 4px solid var(--accent);
}
.document-header::before {
content: '';
position: absolute;
top: 0; right: 0;
width: 200px; height: 200px;
background: radial-gradient(circle, rgba(201,169,97,0.15) 0%, transparent 70%);
border-radius: 50%;
transform: translate(50%, -50%);
}
.header-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
position: relative;
z-index: 1;
}
.company-badge {
display: flex;
align-items: center;
gap: 12px;
}
.company-logo {
width: 60px; height: 60px;
background: var(--accent);
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
color: white;
font-size: 14px;
}
.doc-meta {
text-align: left;
font-size: 12px;
opacity: 0.9;
}
.doc-meta div { margin-bottom: 3px; }
.document-title {
text-align: center;
position: relative;
z-index: 1;
padding: 20px 0;
}
.document-title .label {
display: inline-block;
background: rgba(201,169,97,0.2);
color: var(--accent);
padding: 4px 16px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
margin-bottom: 15px;
border: 1px solid rgba(201,169,97,0.4);
}
.document-title h1 {
font-size: 28px;
font-weight: 800;
margin-bottom: 10px;
letter-spacing: -0.5px;
}
.document-title h2 {
font-size: 16px;
font-weight: 400;
opacity: 0.9;
}
.document-body {
padding: 40px;
}
.intro-text {
background: linear-gradient(to left, #f7fafc, #edf2f7);
border-right: 4px solid var(--accent);
padding: 20px 25px;
border-radius: 8px;
margin-bottom: 35px;
font-size: 14px;
color: var(--text-muted);
}
.section {
margin-bottom: 40px;
page-break-inside: avoid;
}
.section-header {
display: flex;
align-items: center;
gap: 15px;
padding-bottom: 12px;
border-bottom: 2px solid var(--border);
margin-bottom: 20px;
}
.section-number {
width: 50px; height: 50px;
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
font-size: 20px;
flex-shrink: 0;
box-shadow: 0 4px 10px rgba(26,54,93,0.2);
}
.section-title { flex: 1; }
.section-title h3 {
font-size: 19px;
font-weight: 700;
color: var(--primary);
margin-bottom: 2px;
}
.section-title .subtitle {
font-size: 12px;
color: var(--text-muted);
}
.section-content {
padding-right: 10px;
}
.section-content p {
margin-bottom: 12px;
text-align: justify;
text-indent: 20px;
}
.section-content p.no-indent { text-indent: 0; }
.highlight-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #f6e05e;
border-right: 4px solid var(--accent);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.highlight-box strong { color: var(--accent-dark); }
.info-box {
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
border: 1px solid #90cdf4;
border-right: 4px solid var(--primary-light);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.success-box {
background: linear-gradient(to left, #f0fff4, #e6fffa);
border: 1px solid #9ae6b4;
border-right: 4px solid var(--success);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.warning-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #fbd38d;
border-right: 4px solid var(--warning);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.styled-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
background: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.styled-table thead {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
}
.styled-table th {
padding: 14px 16px;
text-align: right;
font-weight: 600;
font-size: 13px;
}
.styled-table td {
padding: 13px 16px;
border-bottom: 1px solid var(--border);
font-size: 13px;
}
.styled-table tbody tr:last-child td { border-bottom: none; }
.styled-table tbody tr:nth-child(even) { background: #f8fafc; }
.styled-table .highlight-row {
background: #fffaf0 !important;
font-weight: 600;
}
.code-block {
background: #1a202c;
color: #e2e8f0;
padding: 20px;
border-radius: 8px;
font-family: 'Consolas', 'Monaco', monospace;
font-size: 13px;
direction: ltr;
text-align: left;
overflow-x: auto;
margin: 20px 0;
border-right: 4px solid var(--accent);
}
.code-block .keyword { color: #569cd6; }
.code-block .string { color: #ce9178; }
.code-block .comment { color: #6a9955; }
.code-block .type { color: #4ec9b0; }
.comparison-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin: 25px 0;
}
.comparison-card {
background: #f8fafc;
border: 2px solid var(--border);
border-radius: 10px;
padding: 20px;
position: relative;
}
.comparison-card.recommended {
border-color: var(--success);
background: linear-gradient(to left, #f0fff4, #e6fffa);
}
.comparison-card .card-badge {
position: absolute;
top: -10px;
right: 20px;
background: var(--success);
color: white;
padding: 3px 12px;
border-radius: 15px;
font-size: 11px;
font-weight: 600;
}
.comparison-card h4 {
font-size: 16px;
font-weight: 700;
color: var(--primary);
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 2px solid var(--border);
}
.comparison-card.recommended h4 { border-bottom-color: var(--success); }
.comparison-card ul { list-style: none; padding: 0; }
.comparison-card ul li {
padding: 8px 0;
border-bottom: 1px solid var(--border);
font-size: 13px;
display: flex;
justify-content: space-between;
}
.comparison-card ul li:last-child { border-bottom: none; }
.comparison-card ul li .value { font-weight: 600; color: var(--primary); }
.stats-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 15px;
margin: 25px 0;
}
.stat-card {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
padding: 20px;
border-radius: 10px;
text-align: center;
box-shadow: 0 4px 12px rgba(26,54,93,0.2);
}
.stat-card .stat-value {
font-size: 24px;
font-weight: 800;
margin-bottom: 5px;
color: var(--accent);
line-height: 1.3;
}
.stat-card .stat-label { font-size: 12px; opacity: 0.9; }
.conclusion-box {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
padding: 30px;
border-radius: 12px;
margin: 30px 0;
text-align: center;
box-shadow: 0 8px 20px rgba(26,54,93,0.3);
}
.conclusion-box h3 {
font-size: 22px;
font-weight: 800;
margin-bottom: 15px;
color: var(--accent);
}
.conclusion-box p {
font-size: 14px;
line-height: 1.8;
text-indent: 0 !important;
margin-bottom: 15px;
}
.conclusion-box .highlight {
background: rgba(201,169,97,0.2);
padding: 15px 20px;
border-radius: 8px;
margin-top: 20px;
border: 1px solid rgba(201,169,97,0.4);
}
.document-footer {
background: var(--primary);
color: white;
padding: 25px 40px;
text-align: center;
font-size: 12px;
margin-top: 40px;
}
.document-footer .footer-brand {
font-weight: 700;
color: var(--accent);
margin-bottom: 5px;
font-size: 14px;
}
.footer-divider {
width: 60px;
height: 2px;
background: var(--accent);
margin: 10px auto;
}
.page-info {
text-align: center;
padding: 15px;
font-size: 11px;
color: var(--text-muted);
border-top: 1px solid var(--border);
margin-top: 30px;
}
@media print {
body { background: white; padding: 0; }
.document-container { box-shadow: none; border-radius: 0; }
.section { page-break-inside: avoid; }
}
@media (max-width: 768px) {
.document-body { padding: 25px 20px; }
.document-header { padding: 30px 20px; }
.comparison-grid { grid-template-columns: 1fr; }
.stats-grid { grid-template-columns: 1fr; }
.header-top { flex-direction: column; gap: 15px; }
.doc-meta { text-align: center; }
}
</style>
</head>
<body>
<div class="document-container">
<header class="document-header">
<div class="header-top">
<div class="company-badge">
<div class="company-logo">RPK</div>
</div>
<div class="doc-meta">
<div>شماره مستند: TECH-1405-002</div>
<div>نسخه: ۱.۰</div>
<div>تاریخ تهیه: آبان ۱۴۰۵</div>
<div>طبقه‌بندی: داخلی / فنی</div>
</div>
</div>
<div class="document-title">
<span class="label">TECHNICAL GUIDE</span>
<h1>راهنمای جامع ساخت بات بله با C#</h1>
<h2>پیاده‌سازی گام‌به‌گام سیستم ارسال نوتیفیکیشن به کاربران</h2>
</div>
</header>
<div class="document-body">
<div class="intro-text">
<strong>مدیر انتشار و تیم توسعه محترم،</strong><br>
این مستند فنی، راهنمای کامل و گام‌به‌گام طراحی و پیاده‌سازی یک سرویس نوتیفیکیشن مبتنی بر پیام‌رسان بله با استفاده از زبان C# و فریم‌ورک .NET 8 را ارائه می‌دهد. هدف، ایجاد یک زیرساخت پایدار، مقیاس‌پذیر و قابل یکپارچه‌سازی با چرخه انتشار نرم‌افزار است.
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۱</div>
<div class="section-title">
<h3>خلاصه اجرایی و انتخاب مسیر</h3>
<div class="subtitle">Executive Summary & Path Selection</div>
</div>
</div>
<div class="section-content">
<p>پیام‌رسان بله دو مسیر مجزا برای ارسال پیام ارائه می‌دهد. انتخاب مسیر صحیح، کلید موفقیت سناریوی «ارسال نوتیف به هر کاربر در هر زمان» است.</p>
<div class="comparison-grid">
<div class="comparison-card">
<h4>مسیر اول: Bot API استاندارد</h4>
<ul>
<li><span>آدرس پایه</span> <span class="value">tapi.bale.ai</span></li>
<li><span>هدف‌گیری</span> <span class="value">فقط Chat ID (کاربر باید بات را استارت کرده باشد)</span></li>
<li><span>هزینه</span> <span class="value">رایگان</span></li>
<li><span>مناسب برای</span> <span class="value" style="color: var(--warning);">تعامل دوطرفه و ربات‌های خدماتی</span></li>
</ul>
</div>
<div class="comparison-card recommended">
<span class="card-badge">پیشنهاد ما ✓</span>
<h4>مسیر دوم: سرویس سفیر (Safir)</h4>
<ul>
<li><span>آدرس پایه</span> <span class="value">safir.bale.ai</span></li>
<li><span>هدف‌گیری</span> <span class="value">شماره موبایل (حتی بدون استارت بات)</span></li>
<li><span>هزینه</span> <span class="value">به ازای هر پیام (نیاز به شارژ اعتبار)</span></li>
<li><span>مناسب برای</span> <span class="value" style="color: var(--success);">ارسال نوتیفیکیشن، اعلان و OTP</span></li>
</ul>
</div>
</div>
<div class="highlight-box">
<strong>نتیجه کلیدی:</strong> برای سناریوی درخواستی شما (ارسال نوتیف به هر کاربر در هر زمان)، <strong>سرویس سفیر</strong> تنها گزینه عملیاتی است، زیرا وابستگی به `chat_id` و شروع گفتگو توسط کاربر را حذف می‌کند.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۲</div>
<div class="section-title">
<h3>گام اول: معماری و ساختار پروژه</h3>
<div class="subtitle">Architecture & Project Structure</div>
</div>
</div>
<div class="section-content">
<p>برای حفظ اصول Clean Architecture و قابلیت تست‌پذیری، پروژه به سه لایه اصلی تقسیم می‌شود:</p>
<div class="code-block">
<span class="comment">// ساختار پیشنهادی حل (Solution)</span>
BaleNotifier/
├── BaleNotifier.sln
├── src/
│ ├── BaleNotifier.Core/ <span class="comment">// مدل‌ها (Models) و اینترفیس‌ها (Interfaces)</span>
│ ├── BaleNotifier.Services/ <span class="comment">// پیاده‌سازی سرویس‌های HTTP و منطق کسب‌وکار</span>
│ └── BaleNotifier.Worker/ <span class="comment">// Background Service برای Polling یا Console App</span>
└── tests/
└── BaleNotifier.Tests/ <span class="comment">// تست‌های واحد (Unit Tests)</span>
</div>
<div class="info-box">
<strong>💡 تنظیمات پیکربندی (appsettings.json):</strong>
مقادیر `BotToken` و `ApiAccessKey` (دریافتی از پنل کسب‌وکار بله) باید در این فایل یا Azure Key Vault ذخیره شوند.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۳</div>
<div class="section-title">
<h3>گام دوم: پیاده‌سازی مدل‌ها و سرویس سفیر</h3>
<div class="subtitle">Models & Safir Service Implementation</div>
</div>
</div>
<div class="section-content">
<p>سرویس سفیر نیازمند ارسال درخواست‌های JSON با هدر احراز هویت خاص است. مدل‌های زیر ساختار داده‌ای را تضمین می‌کنند:</p>
<div class="code-block">
<span class="keyword">public class</span> <span class="type">SafirSendRequest</span>
{
<span class="keyword">public string</span> RequestId { <span class="keyword">get</span>; <span class="keyword">set</span>; } = Guid.NewGuid().ToString(<span class="string">"N"</span>);
<span class="keyword">public long</span> BotId { <span class="keyword">get</span>; <span class="keyword">set</span>; }
<span class="keyword">public string</span> PhoneNumber { <span class="keyword">get</span>; <span class="keyword">set</span>; } = <span class="keyword">default!</span>;
<span class="keyword">public</span> <span class="type">SafirMessageData</span> MessageData { <span class="keyword">get</span>; <span class="keyword">set</span>; } = <span class="keyword">default!</span>;
}
<span class="keyword">public class</span> <span class="type">SafirMessageData</span>
{
<span class="keyword">public</span> <span class="type">SafirMessage</span>? Message { <span class="keyword">get</span>; <span class="keyword">set</span>; }
<span class="keyword">public bool</span>? IsSecure { <span class="keyword">get</span>; <span class="keyword">set</span>; } <span class="comment">// برای ارسال پیام رمزدار</span>
}
</div>
<p>پیاده‌سازی سرویس اصلی با استفاده از `HttpClient` و تزریق وابستگی (DI):</p>
<div class="code-block">
<span class="keyword">public class</span> <span class="type">SafirService</span> : <span class="type">ISafirService</span>
{
<span class="keyword">private readonly</span> <span class="type">HttpClient</span> _http;
<span class="keyword">private readonly</span> <span class="type">long</span> _botId;
<span class="keyword">public</span> <span class="type">SafirService</span>(<span class="type">HttpClient</span> http, <span class="type">IConfiguration</span> config)
{
_http = http;
_http.BaseAddress = <span class="keyword">new</span> <span class="type">Uri</span>(config[<span class="string">"Bale:Safir:BaseUrl"</span>]!);
_http.DefaultRequestHeaders.Add(<span class="string">"api-access-key"</span>, config[<span class="string">"Bale:Safir:ApiAccessKey"</span>]!);
_botId = <span class="keyword">long</span>.Parse(config[<span class="string">"Bale:Safir:BotId"</span>]!);
}
<span class="keyword">public async</span> <span class="type">Task</span>&lt;<span class="type">SafirSendResponse</span>?&gt; <span class="type">SendTextNotificationAsync</span>(<span class="keyword">string</span> phone, <span class="keyword">string</span> text)
{
<span class="keyword">var</span> request = <span class="keyword">new</span> <span class="type">SafirSendRequest</span>
{
BotId = _botId,
PhoneNumber = <span class="type">NormalizePhoneNumber</span>(phone),
MessageData = <span class="keyword">new</span> <span class="type">SafirMessageData</span> { Message = <span class="keyword">new</span> <span class="type">SafirMessage</span> { Text = text } }
};
<span class="keyword">var</span> response = <span class="keyword">await</span> _http.PostAsJsonAsync(<span class="string">"/api/v3/send_message"</span>, request);
<span class="keyword">return await</span> response.Content.ReadFromJsonAsync&lt;<span class="type">SafirSendResponse</span>&gt;();
}
<span class="comment">// متد NormalizePhoneNumber برای اطمینان از فرمت 989123456789</span>
}
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۴</div>
<div class="section-title">
<h3>گام سوم: مدیریت ارسال انبوه و Idempotency</h3>
<div class="subtitle">Bulk Management & Idempotency</div>
</div>
</div>
<div class="section-content">
<p>در محیط عملیاتی (Production)، ارسال نوتیفیکیشن باید در برابر خطاهای شبکه و تلاش‌های تکراری (Retry) مقاوم باشد.</p>
<div class="success-box">
<strong>✓ مکانیزم Idempotency:</strong> فیلد `request_id` در درخواست سفیر، از ارسال تکراری پیام در صورتی که درخواست به دلیل خطای شبکه دوباره ارسال شود، جلوگیری می‌کند.
</div>
<div class="warning-box">
<strong>⚠️ مدیریت Rate Limit:</strong> سرویس بله دارای محدودیت نرخ ارسال است. در صورت ارسال انبوه، حتماً بین درخواست‌ها تأخیر (Delay) ایجاد کنید یا از صف‌های پیام (مانند Azure Service Bus یا RabbitMQ) با الگوی Consumer Rate Limiting استفاده نمایید.
</div>
<div class="code-block">
<span class="keyword">public async</span> <span class="type">Task</span> <span class="type">BroadcastAsync</span>(<span class="type">IEnumerable</span>&lt;<span class="keyword">string</span>&gt; phones, <span class="keyword">string</span> text)
{
<span class="keyword">foreach</span> (<span class="keyword">var</span> phone <span class="keyword">in</span> phones)
{
<span class="keyword">await</span> _safir.SendTextNotificationAsync(phone, text);
<span class="keyword">await</span> <span class="type">Task</span>.Delay(200); <span class="comment">// جلوگیری از خطای RateLimitExceeded (کد 3)</span>
}
}
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۵</div>
<div class="section-title">
<h3>گام چهارم: یکپارچه‌سازی با چرخه انتشار</h3>
<div class="subtitle">Integration with Release Pipeline</div>
</div>
</div>
<div class="section-content">
<p>به عنوان مدیر انتشار، می‌توانید این سرویس را در نقاط مختلف چرخه ۷ مرحله‌ای انتشار (از ثبت درخواست تا استقرار آبی) فراخوانی کنید. نمونه استفاده در یک سرویس اعلان انتشار:</p>
<div class="code-block">
<span class="keyword">public class</span> <span class="type">ReleaseNotifier</span>
{
<span class="keyword">private readonly</span> <span class="type">INotificationService</span> _notifier;
<span class="keyword">public</span> <span class="type">ReleaseNotifier</span>(<span class="type">INotificationService</span> notifier) => _notifier = notifier;
<span class="keyword">public async</span> <span class="type">Task</span> <span class="type">OnReleaseDeployed</span>(<span class="keyword">string</span> version, <span class="type">IEnumerable</span>&lt;<span class="keyword">string</span>&gt; stakeholderPhones)
{
<span class="keyword">var</span> message = $<span class="string">"✅ نسخه <b>{version}</b> با موفقیت در محیط عملیاتی آبی مستقر شد."</span>;
<span class="keyword">await</span> _notifier.BroadcastAsync(stakeholderPhones, message);
}
}
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۶</div>
<div class="section-title">
<h3>مدیریت خطاها و نکات امنیتی</h3>
<div class="subtitle">Error Handling & Security Notes</div>
</div>
</div>
<div class="section-content">
<p>پاسخ سرویس سفیر شامل آرایه‌ای از `error_data` است. پایش این کدها برای عیب‌یابی عملیاتی حیاتی است:</p>
<table class="styled-table">
<thead>
<tr>
<th>کد خطا</th>
<th>نام خطا</th>
<th>توضیح و راه‌حل</th>
</tr>
</thead>
<tbody>
<tr>
<td>3</td>
<td>RateLimitExceeded</td>
<td>بیش از حد مجاز پیام ارسال شده. افزایش Delay بین درخواست‌ها.</td>
</tr>
<tr>
<td>8</td>
<td>InvalidPhone</td>
<td>فرمت شماره اشتباه است. اطمینان از حذف '0' اول و شروع با '98'.</td>
</tr>
<tr>
<td>17</td>
<td>NotBaleUser</td>
<td>کاربر با این شماره، حساب کاربری بله ندارد. حذف از لیست ارسال.</td>
</tr>
<tr>
<td>20</td>
<td>PaymentRequired</td>
<td>اعتبار پنل سفیر به پایان رسیده است. نیاز به شارژ حساب.</td>
</tr>
</tbody>
</table>
<div class="info-box">
<strong>🔒 نکته امنیتی:</strong> هرگز `ApiAccessKey` و `BotToken` را در مخزن کد (Git Repository) کامیت نکنید. از Azure Key Vault یا GitHub Secrets برای تزریق این مقادیر در زمان اجرا استفاده نمایید.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۷</div>
<div class="section-title">
<h3>جمع‌بندی نهایی و گام بعدی</h3>
<div class="subtitle">Final Summary & Next Steps</div>
</div>
</div>
<div class="section-content">
<div class="conclusion-box">
<h3>🎯 مسیر پیشنهادی</h3>
<p>برای دستیابی به هدف «ارسال نوتیف به هر کاربر در هر زمان»، پیاده‌سازی سرویس <strong>Safir</strong> با الگوی <strong>Background Worker</strong> و مدیریت صف، پایدارترین و حرفه‌ای‌ترین راه‌حل در اکوسیستم .NET است.</p>
<div class="highlight">
<strong>💎 ارزش فنی ارائه‌شده:</strong><br>
استقلال از Chat ID + مدیریت خودکار خطاها + یکپارچه‌سازی روان با چرخه انتشار + رعایت اصول Clean Architecture
</div>
</div>
<div class="info-box">
<strong>📞 گام بعدی:</strong> در صورت تأیید این معماری، می‌توانم ریپازیتوری پایه (Boilerplate) شامل تمامی مدل‌ها، سرویس‌ها و تست‌های واحد را آماده و در اختیار تیم توسعه قرار دهم.
</div>
</div>
</div>
<div class="page-info">
این مستند فنی محرمانه بوده و صرفاً جهت استفاده داخلی تیم توسعه و مدیریت انتشار شرکت رایان پرداز کاوش تهیه شده است.
</div>
</div>
<footer class="document-footer">
<div class="footer-brand">طراحی و تدوین: هادی خزاعی اصل | مدیر انتشار</div>
<div class="footer-divider"></div>
<div>تاریخ تهیه: آبان ۱۴۰۵ &nbsp;|&nbsp; نسخه: ۱.۰ &nbsp;|&nbsp; طبقه‌بندی: داخلی / فنی</div>
</footer>
</div>
</body>
</html>
+673
View File
@@ -0,0 +1,673 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>راهنمای جامع ساخت بات بله با C# | پیاده‌سازی Bot API</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
:root {
--primary: #1a365d;
--primary-light: #2c5282;
--accent: #c9a961;
--accent-dark: #a8893f;
--bg: #faf9f6;
--card-bg: #ffffff;
--text: #1a202c;
--text-muted: #4a5568;
--border: #e2e8f0;
--success: #38a169;
--danger: #e53e3e;
--warning: #dd6b20;
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Vazirmatn', Tahoma, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.9;
font-size: 15px;
padding: 30px 15px;
}
.document-container {
max-width: 950px;
margin: 0 auto;
background: var(--card-bg);
box-shadow: var(--shadow);
border-radius: 12px;
overflow: hidden;
}
.document-header {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
color: white;
padding: 50px 40px 40px;
position: relative;
border-bottom: 4px solid var(--accent);
}
.document-header::before {
content: '';
position: absolute;
top: 0; right: 0;
width: 200px; height: 200px;
background: radial-gradient(circle, rgba(201,169,97,0.15) 0%, transparent 70%);
border-radius: 50%;
transform: translate(50%, -50%);
}
.header-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
position: relative;
z-index: 1;
}
.company-badge {
display: flex;
align-items: center;
gap: 12px;
}
.company-logo {
width: 60px; height: 60px;
background: var(--accent);
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
color: white;
font-size: 14px;
}
.doc-meta {
text-align: left;
font-size: 12px;
opacity: 0.9;
}
.doc-meta div { margin-bottom: 3px; }
.document-title {
text-align: center;
position: relative;
z-index: 1;
padding: 20px 0;
}
.document-title .label {
display: inline-block;
background: rgba(201,169,97,0.2);
color: var(--accent);
padding: 4px 16px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
margin-bottom: 15px;
border: 1px solid rgba(201,169,97,0.4);
}
.document-title h1 {
font-size: 28px;
font-weight: 800;
margin-bottom: 10px;
letter-spacing: -0.5px;
}
.document-title h2 {
font-size: 16px;
font-weight: 400;
opacity: 0.9;
}
.document-body {
padding: 40px;
}
.intro-text {
background: linear-gradient(to left, #f7fafc, #edf2f7);
border-right: 4px solid var(--accent);
padding: 20px 25px;
border-radius: 8px;
margin-bottom: 35px;
font-size: 14px;
color: var(--text-muted);
}
.section {
margin-bottom: 40px;
page-break-inside: avoid;
}
.section-header {
display: flex;
align-items: center;
gap: 15px;
padding-bottom: 12px;
border-bottom: 2px solid var(--border);
margin-bottom: 20px;
}
.section-number {
width: 50px; height: 50px;
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
font-size: 20px;
flex-shrink: 0;
box-shadow: 0 4px 10px rgba(26,54,93,0.2);
}
.section-title { flex: 1; }
.section-title h3 {
font-size: 19px;
font-weight: 700;
color: var(--primary);
margin-bottom: 2px;
}
.section-title .subtitle {
font-size: 12px;
color: var(--text-muted);
}
.section-content {
padding-right: 10px;
}
.section-content p {
margin-bottom: 12px;
text-align: justify;
text-indent: 20px;
}
.section-content p.no-indent { text-indent: 0; }
.highlight-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #f6e05e;
border-right: 4px solid var(--accent);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.highlight-box strong { color: var(--accent-dark); }
.info-box {
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
border: 1px solid #90cdf4;
border-right: 4px solid var(--primary-light);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.success-box {
background: linear-gradient(to left, #f0fff4, #e6fffa);
border: 1px solid #9ae6b4;
border-right: 4px solid var(--success);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.warning-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #fbd38d;
border-right: 4px solid var(--warning);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.styled-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
background: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.styled-table thead {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
}
.styled-table th {
padding: 14px 16px;
text-align: right;
font-weight: 600;
font-size: 13px;
}
.styled-table td {
padding: 13px 16px;
border-bottom: 1px solid var(--border);
font-size: 13px;
}
.styled-table tbody tr:last-child td { border-bottom: none; }
.styled-table tbody tr:nth-child(even) { background: #f8fafc; }
.styled-table .highlight-row {
background: #fffaf0 !important;
font-weight: 600;
}
.code-block {
background: #1a202c;
color: #e2e8f0;
padding: 20px;
border-radius: 8px;
font-family: 'Consolas', 'Monaco', monospace;
font-size: 13px;
direction: ltr;
text-align: left;
overflow-x: auto;
margin: 20px 0;
border-right: 4px solid var(--accent);
}
.code-block .keyword { color: #569cd6; }
.code-block .string { color: #ce9178; }
.code-block .comment { color: #6a9955; }
.code-block .type { color: #4ec9b0; }
.comparison-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin: 25px 0;
}
.comparison-card {
background: #f8fafc;
border: 2px solid var(--border);
border-radius: 10px;
padding: 20px;
position: relative;
}
.comparison-card.recommended {
border-color: var(--success);
background: linear-gradient(to left, #f0fff4, #e6fffa);
}
.comparison-card .card-badge {
position: absolute;
top: -10px;
right: 20px;
background: var(--success);
color: white;
padding: 3px 12px;
border-radius: 15px;
font-size: 11px;
font-weight: 600;
}
.comparison-card h4 {
font-size: 16px;
font-weight: 700;
color: var(--primary);
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 2px solid var(--border);
}
.comparison-card.recommended h4 { border-bottom-color: var(--success); }
.comparison-card ul { list-style: none; padding: 0; }
.comparison-card ul li {
padding: 8px 0;
border-bottom: 1px solid var(--border);
font-size: 13px;
display: flex;
justify-content: space-between;
}
.comparison-card ul li:last-child { border-bottom: none; }
.comparison-card ul li .value { font-weight: 600; color: var(--primary); }
.stats-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 15px;
margin: 25px 0;
}
.stat-card {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
padding: 20px;
border-radius: 10px;
text-align: center;
box-shadow: 0 4px 12px rgba(26,54,93,0.2);
}
.stat-card .stat-value {
font-size: 24px;
font-weight: 800;
margin-bottom: 5px;
color: var(--accent);
line-height: 1.3;
}
.stat-card .stat-label { font-size: 12px; opacity: 0.9; }
.conclusion-box {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
padding: 30px;
border-radius: 12px;
margin: 30px 0;
text-align: center;
box-shadow: 0 8px 20px rgba(26,54,93,0.3);
}
.conclusion-box h3 {
font-size: 22px;
font-weight: 800;
margin-bottom: 15px;
color: var(--accent);
}
.conclusion-box p {
font-size: 14px;
line-height: 1.8;
text-indent: 0 !important;
margin-bottom: 15px;
}
.conclusion-box .highlight {
background: rgba(201,169,97,0.2);
padding: 15px 20px;
border-radius: 8px;
margin-top: 20px;
border: 1px solid rgba(201,169,97,0.4);
}
.document-footer {
background: var(--primary);
color: white;
padding: 25px 40px;
text-align: center;
font-size: 12px;
margin-top: 40px;
}
.document-footer .footer-brand {
font-weight: 700;
color: var(--accent);
margin-bottom: 5px;
font-size: 14px;
}
.footer-divider {
width: 60px;
height: 2px;
background: var(--accent);
margin: 10px auto;
}
.page-info {
text-align: center;
padding: 15px;
font-size: 11px;
color: var(--text-muted);
border-top: 1px solid var(--border);
margin-top: 30px;
}
@media print {
body { background: white; padding: 0; }
.document-container { box-shadow: none; border-radius: 0; }
.section { page-break-inside: avoid; }
}
@media (max-width: 768px) {
.document-body { padding: 25px 20px; }
.document-header { padding: 30px 20px; }
.comparison-grid { grid-template-columns: 1fr; }
.stats-grid { grid-template-columns: 1fr; }
.header-top { flex-direction: column; gap: 15px; }
.doc-meta { text-align: center; }
}
</style>
</head>
<body>
<div class="document-container">
<header class="document-header">
<div class="header-top">
<div class="company-badge">
<div class="company-logo">RPK</div>
</div>
<div class="doc-meta">
<div>شماره مستند: TECH-1405-003</div>
<div>نسخه: ۱.۰</div>
<div>تاریخ تهیه: آبان ۱۴۰۵</div>
<div>طبقه‌بندی: داخلی / فنی</div>
</div>
</div>
<div class="document-title">
<span class="label">TECHNICAL GUIDE</span>
<h1>راهنمای جامع ساخت بات بله با C#</h1>
<h2>پیاده‌سازی گام‌به‌گام سرویس نوتیفیکیشن مبتنی بر Bot API</h2>
</div>
</header>
<div class="document-body">
<div class="intro-text">
<strong>مدیر انتشار و تیم توسعه محترم،</strong><br>
این مستند فنی، راهنمای کامل و گام‌به‌گام طراحی و پیاده‌سازی یک سرویس نوتیفیکیشن مبتنی بر <strong>Bot API استاندارد بله</strong> با استفاده از زبان C# و فریم‌ورک .NET 8 را ارائه می‌دهد. این روش برای سناریوهایی که کاربران قبلاً با بات تعامل داشته‌اند (Chat ID ذخیره شده است) ایده‌آل و کاملاً رایگان می‌باشد.
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۱</div>
<div class="section-title">
<h3>خلاصه اجرایی و پیش‌نیازها</h3>
<div class="subtitle">Executive Summary & Prerequisites</div>
</div>
</div>
<div class="section-content">
<p>در این روش، ارتباط با سرورهای بله از طریق آدرس پایه <code>tapi.bale.ai</code> برقرار می‌شود. کلید موفقیت در این سناریو، داشتن <code>Chat ID</code> منحصربه‌فرد هر کاربر است که تنها پس از شروع گفتگو توسط کاربر در اختیار بات قرار می‌گیرد.</p>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-value">رایگان<br>بودن کامل</div>
<div class="stat-label">بدون نیاز به شارژ اعتبار یا پنل سفیر</div>
</div>
<div class="stat-card">
<div class="stat-value">تعامل<br>دوطرفه</div>
<div class="stat-label">امکان دریافت پاسخ و دکمه‌های شیشه‌ای</div>
</div>
<div class="stat-card">
<div class="stat-value">سرعت<br>بالا</div>
<div class="stat-label">ارتباط مستقیم HTTP بدون واسطه</div>
</div>
</div>
<div class="highlight-box">
<strong>نتیجه کلیدی:</strong> برای استفاده از این روش، ابتدا باید مکانیزمی برای جذب کاربر و ذخیره <code>Chat ID</code> او در دیتابیس سازمان پیاده‌سازی شود. پس از آن، ارسال نوتیفیکیشن در هر زمان ممکن خواهد بود.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۲</div>
<div class="section-title">
<h3>گام اول: دریافت توکن و ساختار پروژه</h3>
<div class="subtitle">Token Generation & Project Structure</div>
</div>
</div>
<div class="section-content">
<p>برای شروع، باید با مراجعه به بازوی پدر (<code>@botfather</code>) در پیام‌رسان بله، یک بات جدید ایجاد کرده و توکن احراز هویت (Token) را دریافت نمایید. ساختار پیشنهادی پروژه بر اساس اصول Clean Architecture به شرح زیر است:</p>
<div class="code-block">
<span class="comment">// ساختار پیشنهادی حل (Solution)</span>
BaleNotifier/
├── BaleNotifier.sln
├── src/
│ ├── BaleNotifier.Core/ <span class="comment">// مدل‌ها (Models) و اینترفیس‌ها (Interfaces)</span>
│ ├── BaleNotifier.Services/ <span class="comment">// پیاده‌سازی سرویس‌های HTTP و منطق کسب‌وکار</span>
│ └── BaleNotifier.Worker/ <span class="comment">// Background Service برای Polling مداوم</span>
└── tests/
└── BaleNotifier.Tests/ <span class="comment">// تست‌های واحد (Unit Tests)</span>
</div>
<div class="info-box">
<strong>💡 تنظیمات پیکربندی (appsettings.json):</strong>
مقدار <code>BotToken</code> دریافتی از بات‌فادر باید در این فایل یا Azure Key Vault ذخیره شود.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۳</div>
<div class="section-title">
<h3>گام دوم: پیاده‌سازی سرویس Bot API</h3>
<div class="subtitle">Bot API Service Implementation</div>
</div>
</div>
<div class="section-content">
<p>سرویس اصلی مسئولیت برقراری ارتباط با متدهای مختلف API بله را بر عهده دارد. پیاده‌سازی این سرویس با استفاده از <code>HttpClient</code> و تزریق وابستگی (DI) انجام می‌شود:</p>
<div class="code-block">
<span class="keyword">public class</span> <span class="type">BaleBotService</span> : <span class="type">IBaleBotService</span>
{
<span class="keyword">private readonly</span> <span class="type">HttpClient</span> _http;
<span class="keyword">private readonly</span> <span class="keyword">string</span> _botToken;
<span class="keyword">public</span> <span class="type">BaleBotService</span>(<span class="type">HttpClient</span> http, <span class="type">IConfiguration</span> config)
{
_http = http;
_http.BaseAddress = <span class="keyword">new</span> <span class="type">Uri</span>(config[<span class="string">"Bale:BotApiBaseUrl"</span>]!);
_botToken = config[<span class="string">"Bale:BotToken"</span>]!;
}
<span class="keyword">public async</span> <span class="type">Task</span>&lt;<span class="keyword">bool</span>&gt; <span class="type">SendTextMessageAsync</span>(<span class="keyword">long</span> chatId, <span class="keyword">string</span> text)
{
<span class="keyword">var</span> payload = <span class="keyword">new</span> { chat_id = chatId, text, parse_mode = <span class="string">"HTML"</span> };
<span class="keyword">var</span> response = <span class="keyword">await</span> _http.PostAsJsonAsync($<span class="string">"/bot{_botToken}/sendMessage"</span>, payload);
<span class="keyword">var</span> result = <span class="keyword">await</span> response.Content.ReadFromJsonAsync&lt;<span class="type">BaleResponse</span>&lt;<span class="type">BaleMessage</span>&gt;&gt;();
<span class="keyword">return</span> result?.Ok == <span class="keyword">true</span>;
}
<span class="keyword">public async</span> <span class="type">Task</span>&lt;<span class="type">IReadOnlyList</span>&lt;<span class="type">BaleUpdate</span>&gt;&gt; <span class="type">GetUpdatesAsync</span>(<span class="keyword">long</span> offset = 0)
{
<span class="keyword">var</span> url = $<span class="string">"/bot{_botToken}/getUpdates?offset={offset}&timeout=30"</span>;
<span class="keyword">var</span> response = <span class="keyword">await</span> _http.GetFromJsonAsync&lt;<span class="type">BaleResponse</span>&lt;<span class="type">List</span>&lt;<span class="type">BaleUpdate</span>&gt;&gt;&gt;(url);
<span class="keyword">return</span> response?.Ok == <span class="keyword">true</span> && response.Result != <span class="keyword">null</span>
? response.Result.AsReadOnly()
: Array.Empty&lt;<span class="type">BaleUpdate</span>&gt;();
}
}
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۴</div>
<div class="section-title">
<h3>گام سوم: مدیریت Polling و ذخیره Chat ID</h3>
<div class="subtitle">Polling Management & Chat ID Storage</div>
</div>
</div>
<div class="section-content">
<p>برای دریافت پیام‌های ارسالی کاربران و استخراج <code>Chat ID</code>، از یک <code>BackgroundService</code> استفاده می‌کنیم که به صورت مداوم سرور بله را بررسی می‌کند (Long Polling).</p>
<div class="code-block">
<span class="keyword">public class</span> <span class="type">BotPollingWorker</span> : <span class="type">BackgroundService</span>
{
<span class="keyword">private readonly</span> <span class="type">IBaleBotService</span> _bot;
<span class="keyword">private long</span> _offset;
<span class="keyword">protected override async</span> <span class="type">Task</span> <span class="type">ExecuteAsync</span>(<span class="type">CancellationToken</span> ct)
{
<span class="keyword">while</span> (!ct.IsCancellationRequested)
{
<span class="keyword">var</span> updates = <span class="keyword">await</span> _bot.GetUpdatesAsync(_offset);
<span class="keyword">foreach</span> (<span class="keyword">var</span> update <span class="keyword">in</span> updates)
{
_offset = update.UpdateId + 1;
<span class="keyword">if</span> (update.Message?.Text?.Trim() == <span class="string">"/start"</span>)
<span class="keyword">await</span> SubscribeUserAsync(update); <span class="comment">// ذخیره Chat ID در دیتابیس</span>
}
<span class="keyword">await</span> <span class="type">Task</span>.Delay(1000, ct);
}
}
}
</div>
<div class="success-box">
<strong>✓ نکته مهم:</strong> حتماً مقدار <code>offset</code> را پس از هر بار دریافت آپدیت‌ها به‌روز کنید تا از پردازش تکراری پیام‌ها جلوگیری شود.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۵</div>
<div class="section-title">
<h3>گام چهارم: یکپارچه‌سازی با چرخه انتشار</h3>
<div class="subtitle">Integration with Release Pipeline</div>
</div>
</div>
<div class="section-content">
<p>پس از ذخیره <code>Chat ID</code> ذی‌نفعان در دیتابیس، می‌توانید در هر مرحله از چرخه ۷ مرحله‌ای انتشار، نوتیفیکیشن ارسال کنید. نمونه استفاده در یک سرویس اعلان:</p>
<div class="code-block">
<span class="keyword">public class</span> <span class="type">ReleaseNotifier</span>
{
<span class="keyword">private readonly</span> <span class="type">IBaleBotService</span> _bot;
<span class="keyword">private readonly</span> <span class="type">IUserRepository</span> _repo;
<span class="keyword">public async</span> <span class="type">Task</span> <span class="type">OnReleaseDeployed</span>(<span class="keyword">string</span> version)
{
<span class="keyword">var</span> users = <span class="keyword">await</span> _repo.GetSubscribedUsersAsync();
<span class="keyword">var</span> message = $<span class="string">"✅ نسخه <b>{version}</b> با موفقیت در محیط عملیاتی آبی مستقر شد."</span>;
<span class="keyword">foreach</span> (<span class="keyword">var</span> user <span class="keyword">in</span> users)
<span class="keyword">await</span> _bot.SendTextMessageAsync(user.ChatId, message);
}
}
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۶</div>
<div class="section-title">
<h3>مدیریت خطاها و نکات امنیتی</h3>
<div class="subtitle">Error Handling & Security Notes</div>
</div>
</div>
<div class="section-content">
<p>پاسخ‌های API بله شامل فیلد <code>ok</code> و در صورت خطا، <code>error_code</code> هستند. پایش این کدها برای عیب‌یابی حیاتی است:</p>
<table class="styled-table">
<thead>
<tr>
<th>کد خطا</th>
<th>نام خطا</th>
<th>توضیح و راه‌حل</th>
</tr>
</thead>
<tbody>
<tr>
<td>400</td>
<td>Bad Request</td>
<td>فرمت درخواست اشتباه است (مثلاً Chat ID نامعتبر).</td>
</tr>
<tr>
<td>401</td>
<td>Unauthorized</td>
<td>توکن بات اشتباه یا منقضی شده است.</td>
</tr>
<tr>
<td>403</td>
<td>Forbidden</td>
<td>بات اجازه ارسال پیام به آن کاربر خاص را ندارد (کاربر بات را بلاک کرده است).</td>
</tr>
<tr>
<td>429</td>
<td>Too Many Requests</td>
<td>محدودیت نرخ ارسال (Rate Limit). افزایش Delay بین درخواست‌ها.</td>
</tr>
</tbody>
</table>
<div class="info-box">
<strong>🔒 نکته امنیتی:</strong> هرگز <code>BotToken</code> را در مخزن کد (Git Repository) کامیت نکنید. از Azure Key Vault یا GitHub Secrets برای تزریق این مقادیر در زمان اجرا استفاده نمایید.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۷</div>
<div class="section-title">
<h3>جمع‌بندی نهایی و گام بعدی</h3>
<div class="subtitle">Final Summary & Next Steps</div>
</div>
</div>
<div class="section-content">
<div class="conclusion-box">
<h3>🎯 مسیر پیشنهادی</h3>
<p>برای دستیابی به هدف «ارسال نوتیف به کاربران ثبت‌نام کرده»، پیاده‌سازی سرویس <strong>Bot API</strong> با الگوی <strong>Polling</strong> و ذخیره‌سازی <code>Chat ID</code>، پایدارترین و حرفه‌ای‌ترین راه‌حل رایگان در اکوسیستم .NET است.</p>
<div class="highlight">
<strong>💎 ارزش فنی ارائه‌شده:</strong><br>
هزینه صفر + تعامل دوطرفه + مدیریت خودکار خطاها + یکپارچه‌سازی روان با چرخه انتشار
</div>
</div>
<div class="info-box">
<strong>📞 گام بعدی:</strong> در صورت تأیید این معماری، می‌توانم ریپازیتوری پایه (Boilerplate) شامل تمامی مدل‌ها، سرویس‌ها و تست‌های واحد را آماده و در اختیار تیم توسعه قرار دهم.
</div>
</div>
</div>
<div class="page-info">
این مستند فنی محرمانه بوده و صرفاً جهت استفاده داخلی تیم توسعه و مدیریت انتشار شرکت رایان پرداز کاوش تهیه شده است.
</div>
</div>
<footer class="document-footer">
<div class="footer-brand">طراحی و تدوین: هادی خزاعی اصل | مدیر انتشار</div>
<div class="footer-divider"></div>
<div>تاریخ تهیه: آبان ۱۴۰۵ &nbsp;|&nbsp; نسخه: ۱.۰ &nbsp;|&nbsp; طبقه‌بندی: داخلی / فنی</div>
</footer>
</div>
</body>
</html>
@@ -0,0 +1,789 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>پیاده‌سازی ماژول xBotService | مستندات فنی و سورس کد</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
:root {
--primary: #1a365d;
--primary-light: #2c5282;
--accent: #c9a961;
--accent-dark: #a8893f;
--bg: #faf9f6;
--card-bg: #ffffff;
--text: #1a202c;
--text-muted: #4a5568;
--border: #e2e8f0;
--success: #38a169;
--code-bg: #2d3748;
--code-text: #e2e8f0;
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Vazirmatn', Tahoma, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.9;
font-size: 15px;
padding: 30px 15px;
}
.document-container {
max-width: 1100px;
margin: 0 auto;
background: var(--card-bg);
box-shadow: var(--shadow);
border-radius: 12px;
overflow: hidden;
}
.document-header {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
color: white;
padding: 50px 40px 40px;
position: relative;
border-bottom: 4px solid var(--accent);
}
.header-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
}
.doc-meta {
text-align: left;
font-size: 12px;
opacity: 0.9;
}
.document-title h1 {
font-size: 28px;
font-weight: 800;
margin-bottom: 10px;
}
.document-title h2 {
font-size: 16px;
font-weight: 400;
opacity: 0.9;
}
.document-body {
padding: 40px;
}
.section {
margin-bottom: 50px;
page-break-inside: avoid;
}
.section-header {
display: flex;
align-items: center;
gap: 15px;
padding-bottom: 12px;
border-bottom: 2px solid var(--border);
margin-bottom: 25px;
}
.section-number {
width: 50px; height: 50px;
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
font-size: 20px;
flex-shrink: 0;
}
.section-title h3 {
font-size: 20px;
font-weight: 700;
color: var(--primary);
}
.code-block {
background: var(--code-bg);
color: var(--code-text);
border-radius: 8px;
padding: 20px;
overflow-x: auto;
font-family: 'Consolas', 'Monaco', monospace;
font-size: 13px;
line-height: 1.6;
margin-top: 15px;
border: 1px solid var(--border);
direction: ltr;
text-align: left;
}
.file-path {
color: var(--accent);
font-weight: 600;
margin-bottom: 10px;
display: block;
font-family: 'Consolas', monospace;
font-size: 12px;
}
.info-box {
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
border: 1px solid #90cdf4;
border-right: 4px solid var(--primary-light);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.success-box {
background: linear-gradient(to left, #f0fff4, #e6fffa);
border: 1px solid #9ae6b4;
border-right: 4px solid var(--success);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.document-footer {
background: var(--primary);
color: white;
padding: 25px 40px;
text-align: center;
font-size: 12px;
margin-top: 40px;
}
.footer-brand {
font-weight: 700;
color: var(--accent);
margin-bottom: 5px;
font-size: 14px;
}
@media print {
body { background: white; padding: 0; }
.document-container { box-shadow: none; }
.code-block { white-space: pre-wrap; }
}
</style>
</head>
<body>
<div class="document-container">
<header class="document-header">
<div class="header-top">
<div class="doc-meta">
<div>پروژه: xDashboard</div>
<div>ماژول: xBotService</div>
<div>تاریخ: ۱۴۰۵/۰۸/۲۰</div>
<div>تهیه کننده: هادی خزاعی اصل</div>
</div>
</div>
<div class="document-title">
<h1>مستندات فنی و پیاده‌سازی xBotService</h1>
<h2>بر اساس الگوی استاندارد xTagService و زیرساخت xDataService</h2>
</div>
</header>
<div class="document-body">
<div class="info-box">
<strong>تحلیل معماری:</strong><br>
با بررسی دقیق <code>xTagService</code>، الگوی حاکم بر سیستم شامل موارد زیر است:
<ul style="padding-right: 20px; margin-top: 10px;">
<li>استفاده از <strong>XBaseIntIDEntity</strong> برای موجودیت‌ها.</li>
<li>پیکربندی جداگانه EF در کلاس‌های <strong>Configuration</strong>.</li>
<li>استفاده از <strong>XRepositoryDescriptor</strong> برای ثبت سرویس‌ها در DI.</li>
<li>پشتیبانی کامل از <strong>GraphQL</strong> و <strong>SignalR Hubs</strong>.</li>
<li>جداسازی لایه‌های Dto و Entity با استفاده از AutoMapper.</li>
</ul>
کدهای زیر تمامی شکاف‌های موجود در <code>xBotService</code> را پر کرده و آن را به یک ماژول کامل تبدیل می‌کنند.
</div>
<!-- Section 1: Models & Configurations -->
<div class="section">
<div class="section-header">
<div class="section-number">۱</div>
<div class="section-title">
<h3>مدل‌ها و پیکربندی دیتابیس (Models & Configurations)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/Models/Entities/XBotUser.cs</span>
<div class="code-block">
using xModels.Base;
namespace xBotService.Models.Entities
{
/// <summary>
/// Bot User / System User Relation ...
/// </summary>
public class XBotUser : XBaseIntIDEntity
{
/// <summary>
/// User Id ...
/// </summary>
public string UserId { get; set; }
/// <summary>
/// Chat Bot User Name ...
/// </summary>
public string BotUserName { get; set; }
}
}
</div>
<span class="file-path">Modules/xBotService/Models/Dtos/XBotUserDto.cs</span>
<div class="code-block">
using xModels.Dtos;
namespace xBotService.Models.Dtos
{
/// <summary>
/// Bot User / System User Relation Dto ...
/// </summary>
public class XBotUserDto : XBaseIntIDEntityDto
{
/// <summary>
/// User Id ...
/// </summary>
public string UserId { get; set; }
/// <summary>
/// Chat Bot User Name ...
/// </summary>
public string BotUserName { get; set; }
}
}
</div>
<span class="file-path">Modules/xBotService/Configurations/Entities/XBotUserEntityConfiguration.cs</span>
<div class="code-block">
using xDataService.Providers;
using xBotService.Models.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace xBotService.Configurations.Entities
{
public class XBotUserEntityConfiguration : XBaseEntityTypeConfiguration<XBotUser, int>
{
public override void Configure(EntityTypeBuilder<XBotUser> builder)
{
builder.ToTable("BotUsers");
// Example Indexes
builder.HasIndex(x => x.UserId);
builder.HasIndex(x => x.BotUserName);
}
}
}
</div>
</div>
<!-- Section 2: Constants & Interfaces -->
<div class="section">
<div class="section-header">
<div class="section-number">۲</div>
<div class="section-title">
<h3>ثابت‌ها و اینترفیس‌ها (Constants & Interfaces)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/Constants/XBotServiceConstants.cs</span>
<div class="code-block">
namespace xBotService.Constants
{
public struct XBotServiceConstants
{
public const string XBotServiceDILogTag = "XBotService";
// Table Mapping
public const string XBotUserTable = "BotUsers";
// GraphQL Mappings
public const string XBotUserSingleName = "botUser";
public const string XBotUserCollectionName = "botUsers";
// Hubs
public const string XBotUserDtoHub = "botUserDto";
public const string XBotUserEntityHub = "botUserEntity";
// Helper Method Names
public const string GetXBotUserEFRepositoryDescriptor = "GetXBotUserEFRepositoryDescriptor";
}
}
</div>
<span class="file-path">Modules/xBotService/Interfaces/Entities/IXBotUserRepository.cs</span>
<div class="code-block">
using xDataService.Interfaces;
using xBotService.Models.Entities;
namespace xBotService.Interfaces.Entities
{
public interface IXBotUserRepository : IXBaseRepository<XBotUser, int>
{
}
}
</div>
<span class="file-path">Modules/xBotService/Interfaces/Entities/IXBotUserKeyGenerator.cs</span>
<div class="code-block">
using xDataService.Interfaces;
using xBotService.Models.Entities;
namespace xBotService.Interfaces.Entities
{
public interface IXBotUserKeyGenerator : IXKeyGenerator<XBotUser, int>
{
}
}
</div>
<span class="file-path">Modules/xBotService/Interfaces/Entities/IXBotUserRepositoryEvents.cs</span>
<div class="code-block">
using xDataService.Interfaces;
using xBotService.Models.Entities;
namespace xBotService.Interfaces.Entities
{
public interface IXBotUserRepositoryEvents : IXBaseRepositoryEvents<XBotUser>
{
}
}
</div>
<span class="file-path">Modules/xBotService/Interfaces/Dtos/IXBotUserRepositoryService.cs</span>
<div class="code-block">
using xDataService.Interfaces;
using xBotService.Models.Dtos;
using xBotService.Models.Entities;
namespace xBotService.Interfaces.Dtos
{
public interface IXBotUserRepositoryService : IXBaseRepositoryService<XBotUser, XBotUserDto, int>
{
}
}
</div>
</div>
<!-- Section 3: Providers (Implementation) -->
<div class="section">
<div class="section-header">
<div class="section-number">۳</div>
<div class="section-title">
<h3>پیاده‌سازی ارائه‌دهندگان (Providers Implementation)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/Providers/Entities/XBotUserEFRepository.cs</span>
<div class="code-block">
using xDataService.Db;
using xDataService.Providers;
using xDataService.Interfaces;
using xDataService.Configuration;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.Entities
{
public class XBotUserEFRepository<TContext> : XBaseEFRepository<XBotUser, int, TContext>, IXBotUserRepository
where TContext : XDbContext
{
public XBotUserEFRepository(
IXUnitOfWorks<TContext> unitOfWorks,
XDataServiceConfiguration configuration,
IXBotUserKeyGenerator keyGenerator = null,
IXBotUserRepositoryEvents baseRepositoryEvents = null
) : base(unitOfWorks, configuration, keyGenerator, baseRepositoryEvents)
{
}
}
}
</div>
<span class="file-path">Modules/xBotService/Providers/Entities/XBotUserKeyGenerator.cs</span>
<div class="code-block">
using xDataService.Providers;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.Entities
{
public class XBotUserKeyGenerator : XIntKeyGenerator<XBotUser>, IXBotUserKeyGenerator
{
}
}
</div>
<span class="file-path">Modules/xBotService/Providers/Entities/XBotUserRepositoryEvents.cs</span>
<div class="code-block">
using xDataService.Providers;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.Entities
{
public class XBotUserRepositoryEvents : XBaseRepositoryEvents<XBotUser>, IXBotUserRepositoryEvents
{
}
}
</div>
<span class="file-path">Modules/xBotService/Providers/Dtos/XBotUserRepositoryService.cs</span>
<div class="code-block">
using AutoMapper;
using xDataService.Providers;
using xBotService.Models.Dtos;
using System.Collections.Generic;
using xBotService.Interfaces.Dtos;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.Dtos
{
public class XBotUserRepositoryService : XBaseRepositoryService<XBotUser, XBotUserDto, int>, IXBotUserRepositoryService
{
public XBotUserRepositoryService(
IXBotUserRepository repository,
IEnumerable<Profile> mapperProfiles = null
) : base(repository, mapperProfiles)
{
}
}
}
</div>
</div>
<!-- Section 4: GraphQL Support -->
<div class="section">
<div class="section-header">
<div class="section-number">۴</div>
<div class="section-title">
<h3>پشتیبانی گراف‌کیو‌ال (GraphQL Support)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/Providers/GraphQL/XBotUserGraphType.cs</span>
<div class="code-block">
using xDataService.GraphQL;
using xBotService.Models.Entities;
namespace xBotService.Providers.GraphQL
{
public class XBotUserGraphType : XBaseGraphObjectType<XBotUser, int>
{
public XBotUserGraphType() : base()
{
Field(x => x.UserId);
Field(x => x.BotUserName);
}
}
}
</div>
<span class="file-path">Modules/xBotService/Providers/GraphQL/XBotUserGraphQLTypeHelper.cs</span>
<div class="code-block">
using xDataService.GraphQL;
using xBotService.Constants;
using xDataService.Configuration;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.GraphQL
{
public class XBotUserGraphQLTypeHelper : XBaseGraphQLTypeHelper<XBotUser, int>, IXBotUserGraphQLTypeHelper
{
public XBotUserGraphQLTypeHelper(XDataServiceConfiguration configuration)
: base(configuration)
{
}
public override string GetInQueryCollectionName()
{
return XBotServiceConstants.XBotUserCollectionName;
}
public override string GetInQuerySingleName()
{
return XBotServiceConstants.XBotUserSingleName;
}
}
}
</div>
<span class="file-path">Modules/xBotService/Providers/GraphQL/XBotUserGraphQuery.cs</span>
<div class="code-block">
using GraphQL.Types;
using xDataService.GraphQL;
using xDataService.Configuration;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.GraphQL
{
public class XBotUserGraphQuery : XBaseGraphQLQuery<XBotUser, int, XBotUserGraphType, IntGraphType>
{
public XBotUserGraphQuery(
XDataServiceConfiguration configuration,
IXBotUserRepository repository,
IXBotUserGraphQLTypeHelper helper
) : base(configuration, repository, helper)
{
}
}
}
</div>
<span class="file-path">Modules/xBotService/Providers/GraphQL/XBotUserGraphSchema.cs</span>
<div class="code-block">
using System;
using GraphQL.Types;
namespace xBotService.Providers.GraphQL
{
public class XBotUserGraphSchema : Schema
{
public XBotUserGraphSchema(IServiceProvider services) : base(services)
{
Query = (XBotUserGraphQuery)services.GetService(typeof(XBotUserGraphQuery));
}
}
}
</div>
</div>
<!-- Section 5: DI Helper Extension -->
<div class="section">
<div class="section-header">
<div class="section-number">۵</div>
<div class="section-title">
<h3>ثبت وابستگی‌ها (Dependency Injection)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/DI/XDIHelperExtension.cs</span>
<div class="code-block">
using System;
using xDataService.Db;
using xDataService.DI;
using xCommons.Extensions;
using xDataService.Models;
using xBotService.Helpers;
using xExceptions.Constants;
using xBotService.Constants;
using xBotService.Providers;
using xDataService.Constants;
using xBotService.Interfaces;
using xBotService.Providers.Dtos;
using xBotService.Interfaces.Dtos;
using Microsoft.AspNetCore.Builder;
using xBotService.Providers.Entities;
using xBotService.Interfaces.Entities;
using Microsoft.Extensions.DependencyInjection;
namespace xBotService.DI
{
public static class XDIHelperExtension
{
/// <summary>
/// Register XBotService
/// </summary>
public static void AddXBotService(
this IServiceCollection services,
XRepositoryType repositoryType,
ServiceLifetime lifeTime = ServiceLifetime.Scoped
)
{
AddBotService(
contextType: null,
services: services,
lifeTime: lifeTime,
repositoryType: repositoryType
);
}
/// <summary>
/// Register XBotService with Context
/// </summary>
public static void AddXBotService<TContext>(
this IServiceCollection services,
XRepositoryType repositoryType,
ServiceLifetime lifeTime = ServiceLifetime.Scoped
) where TContext : XDbContext
{
AddBotService(
services: services,
lifeTime: lifeTime,
contextType: typeof(TContext),
repositoryType: repositoryType
);
}
/// <summary>
/// Use XBotService Middleware
/// </summary>
public static void UseXBotService(
this IApplicationBuilder app,
bool isDevelopmentEnvironment = false
)
{
// Using XBot Repository Descriptor
if (!descriptor.IsNull())
{
app.UseXRepository(
descriptor: descriptor,
isDevelopmentEnvironment: isDevelopmentEnvironment
);
}
}
// Private Implementation
private static XRepositoryDescriptor descriptor = null;
private static string XLogTag = XBotServiceConstants.XBotServiceDILogTag;
private static void Log(string message)
{
Console.WriteLine($"{XLogTag} => {message}");
}
private static void AddBotService(
IServiceCollection services,
XRepositoryType repositoryType,
Type contextType = null,
ServiceLifetime lifeTime = ServiceLifetime.Scoped
)
{
var exception = XException.InvalidArgs.ToException();
// Validate Services
if (services.IsNull())
{
Log("Service Registration failed, services not provided ...");
throw exception;
}
// Validate Repository Type
var isRepositoryTypeValid =
(repositoryType == XRepositoryType.EF && !contextType.IsNull()) ||
((repositoryType == XRepositoryType.Mongo || repositoryType == XRepositoryType.InMemory) && contextType.IsNull());
if (!isRepositoryTypeValid)
{
Log("Service Registration failed, Invalid Repository Type and Context Type ...");
throw exception;
}
// Make Instance of Repository Descriptor
switch (repositoryType)
{
case XRepositoryType.EF:
descriptor = typeof(XBotServiceHelper)
.InvokeGenericMethod<XRepositoryDescriptor>(
args: null,
runtimeType: contextType,
methodName: XBotServiceConstants.GetXBotUserEFRepositoryDescriptor
);
break;
case XRepositoryType.Mongo:
// descriptor = XBotServiceHelper.GetXBotUserMongoRepositoryDescriptor();
Log("MongoDB support not implemented yet for XBotService.");
break;
case XRepositoryType.InMemory:
// descriptor = XBotServiceHelper.GetXBotUserInMemoryRepositoryDescriptor();
Log("InMemory support not implemented yet for XBotService.");
break;
}
// Register XBotUser Repository Descriptor
if (!descriptor.IsNull())
{
services.AddXRepository(lifeTime: lifeTime, descriptor: descriptor);
}
// Register Dto Services
services.Add(new ServiceDescriptor(typeof(IXBotUserRepositoryService), typeof(XBotUserRepositoryService), lifeTime));
Log("XBotService Registration Succeed ...");
}
}
}
</div>
</div>
<!-- Section 6: Helpers -->
<div class="section">
<div class="section-header">
<div class="section-number">۶</div>
<div class="section-title">
<h3>کمک‌کننده‌های توصیف‌گر (Descriptor Helpers)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/Helpers/XBotServiceHelper.cs</span>
<div class="code-block">
using GraphQL.Types;
using xDataService.Db;
using xDataService.Models;
using xDataService.Providers;
using xBotService.Models.Entities;
using xBotService.Providers.GraphQL;
using xBotService.Providers.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Helpers
{
public static class XBotServiceHelper
{
// EF Repository Descriptor Provider
public static XEFRepositoryDescriptor<
XBotUser,
int,
IXBotUserKeyGenerator,
XBotUserKeyGenerator,
IXBotUserRepositoryEvents,
XBotUserRepositoryEvents,
XBotUserGraphType,
IntGraphType,
XBotUserGraphQuery,
IXBotUserGraphQLTypeHelper,
XBotUserGraphQLTypeHelper,
XBotUserGraphSchema,
IXBotUserRepository,
XBotUserEFRepository<TContext>,
TContext
> GetXBotUserEFRepositoryDescriptor<TContext>()
where TContext : XDbContext
{
var result = new XEFRepositoryDescriptor<
XBotUser,
int,
IXBotUserKeyGenerator,
XBotUserKeyGenerator,
IXBotUserRepositoryEvents,
XBotUserRepositoryEvents,
XBotUserGraphType,
IntGraphType,
XBotUserGraphQuery,
IXBotUserGraphQLTypeHelper,
XBotUserGraphQLTypeHelper,
XBotUserGraphSchema,
IXBotUserRepository,
XBotUserEFRepository<TContext>,
TContext
>();
return result;
}
}
}
</div>
</div>
<div class="success-box">
<strong>نتیجه‌گیری:</strong><br>
با افزودن فایل‌های فوق، ماژول <code>xBotService</code> اکنون دارای چرخه حیات کامل (CRUD)، پشتیبانی از GraphQL، Event Handling و قابلیت تزریق وابستگی خودکار مطابق با استانداردهای <code>xDataService</code> است. این ساختار امکان توسعه سریع‌تر و نگهداری آسان‌تر را فراهم می‌آورد.
</div>
</div>
<footer class="document-footer">
<div class="footer-brand">طراحی و توسعه: هادی خزاعی اصل</div>
<div>شرکت رایان پرداز کاوش &nbsp;|&nbsp; واحد معماری نرم‌افزار</div>
</footer>
</div>
</body>
</html>
@@ -0,0 +1,754 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>پیاده‌سازی ماژول xBotService | مستندات فنی و سورس کد</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
:root {
--primary: #1a365d;
--primary-light: #2c5282;
--accent: #c9a961;
--accent-dark: #a8893f;
--bg: #faf9f6;
--card-bg: #ffffff;
--text: #1a202c;
--text-muted: #4a5568;
--border: #e2e8f0;
--success: #38a169;
--code-bg: #2d3748;
--code-text: #e2e8f0;
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Vazirmatn', Tahoma, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.9;
font-size: 15px;
padding: 30px 15px;
}
.document-container {
max-width: 1100px;
margin: 0 auto;
background: var(--card-bg);
box-shadow: var(--shadow);
border-radius: 12px;
overflow: hidden;
}
.document-header {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
color: white;
padding: 50px 40px 40px;
position: relative;
border-bottom: 4px solid var(--accent);
}
.header-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
}
.doc-meta {
text-align: left;
font-size: 12px;
opacity: 0.9;
}
.document-title h1 {
font-size: 28px;
font-weight: 800;
margin-bottom: 10px;
}
.document-title h2 {
font-size: 16px;
font-weight: 400;
opacity: 0.9;
}
.document-body {
padding: 40px;
}
.section {
margin-bottom: 50px;
page-break-inside: avoid;
}
.section-header {
display: flex;
align-items: center;
gap: 15px;
padding-bottom: 12px;
border-bottom: 2px solid var(--border);
margin-bottom: 25px;
}
.section-number {
width: 50px; height: 50px;
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
font-size: 20px;
flex-shrink: 0;
}
.section-title h3 {
font-size: 20px;
font-weight: 700;
color: var(--primary);
}
.code-block {
background: var(--code-bg);
color: var(--code-text);
border-radius: 8px;
padding: 20px;
overflow-x: auto;
font-family: 'Consolas', 'Monaco', monospace;
font-size: 13px;
line-height: 1.6;
margin-top: 15px;
border: 1px solid var(--border);
direction: ltr;
text-align: left;
white-space: pre;
}
.file-path {
color: var(--accent);
font-weight: 600;
margin-bottom: 10px;
display: block;
font-family: 'Consolas', monospace;
font-size: 12px;
}
.info-box {
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
border: 1px solid #90cdf4;
border-right: 4px solid var(--primary-light);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.success-box {
background: linear-gradient(to left, #f0fff4, #e6fffa);
border: 1px solid #9ae6b4;
border-right: 4px solid var(--success);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.document-footer {
background: var(--primary);
color: white;
padding: 25px 40px;
text-align: center;
font-size: 12px;
margin-top: 40px;
}
.footer-brand {
font-weight: 700;
color: var(--accent);
margin-bottom: 5px;
font-size: 14px;
}
@media print {
body { background: white; padding: 0; }
.document-container { box-shadow: none; }
.code-block { white-space: pre-wrap; }
}
</style>
</head>
<body>
<div class="document-container">
<header class="document-header">
<div class="header-top">
<div class="doc-meta">
<div>پروژه: xDashboard</div>
<div>ماژول: xBotService</div>
<div>تاریخ: ۱۴۰۵/۰۸/۲۰</div>
<div>تهیه کننده: هادی خزاعی اصل</div>
</div>
</div>
<div class="document-title">
<h1>مستندات فنی و پیاده‌سازی xBotService</h1>
<h2>بر اساس الگوی استاندارد xTagService و زیرساخت xDataService</h2>
</div>
</header>
<div class="document-body">
<div class="info-box">
<strong>تحلیل معماری:</strong><br>
با بررسی دقیق <code>xTagService</code>، الگوی حاکم بر سیستم شامل موارد زیر است:
<ul style="padding-right: 20px; margin-top: 10px;">
<li>استفاده از <strong>XBaseIntIDEntity</strong> برای موجودیت‌ها.</li>
<li>پیکربندی جداگانه EF در کلاس‌های <strong>Configuration</strong>.</li>
<li>استفاده از <strong>XRepositoryDescriptor</strong> برای ثبت سرویس‌ها در DI.</li>
<li>پشتیبانی کامل از <strong>GraphQL</strong> و <strong>SignalR Hubs</strong>.</li>
<li>جداسازی لایه‌های Dto و Entity با استفاده از AutoMapper.</li>
</ul>
کدهای زیر تمامی شکاف‌های موجود در <code>xBotService</code> را پر کرده و آن را به یک ماژول کامل تبدیل می‌کنند.
</div>
<!-- Section 1: Models & Configurations -->
<div class="section">
<div class="section-header">
<div class="section-number">۱</div>
<div class="section-title">
<h3>مدل‌ها و پیکربندی دیتابیس (Models & Configurations)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/Models/Entities/XBotUser.cs</span>
<div class="code-block">using xModels.Base;
namespace xBotService.Models.Entities
{
/// &lt;summary&gt;
/// Bot User / System User Relation ...
/// &lt;/summary&gt;
public class XBotUser : XBaseIntIDEntity
{
/// &lt;summary&gt;
/// User Id ...
/// &lt;/summary&gt;
public string UserId { get; set; }
/// &lt;summary&gt;
/// Chat Bot User Name ...
/// &lt;/summary&gt;
public string BotUserName { get; set; }
}
}</div>
<span class="file-path">Modules/xBotService/Models/Dtos/XBotUserDto.cs</span>
<div class="code-block">using xModels.Dtos;
namespace xBotService.Models.Dtos
{
/// &lt;summary&gt;
/// Bot User / System User Relation Dto ...
/// &lt;/summary&gt;
public class XBotUserDto : XBaseIntIDEntityDto
{
/// &lt;summary&gt;
/// User Id ...
/// &lt;/summary&gt;
public string UserId { get; set; }
/// &lt;summary&gt;
/// Chat Bot User Name ...
/// &lt;/summary&gt;
public string BotUserName { get; set; }
}
}</div>
<span class="file-path">Modules/xBotService/Configurations/Entities/XBotUserEntityConfiguration.cs</span>
<div class="code-block">using xDataService.Providers;
using xBotService.Models.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace xBotService.Configurations.Entities
{
public class XBotUserEntityConfiguration : XBaseEntityTypeConfiguration&lt;XBotUser, int&gt;
{
public override void Configure(EntityTypeBuilder&lt;XBotUser&gt; builder)
{
builder.ToTable("BotUsers");
// Example Indexes
builder.HasIndex(x =&gt; x.UserId);
builder.HasIndex(x =&gt; x.BotUserName);
}
}
}</div>
</div>
<!-- Section 2: Constants & Interfaces -->
<div class="section">
<div class="section-header">
<div class="section-number">۲</div>
<div class="section-title">
<h3>ثابت‌ها و اینترفیس‌ها (Constants & Interfaces)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/Constants/XBotServiceConstants.cs</span>
<div class="code-block">namespace xBotService.Constants
{
public struct XBotServiceConstants
{
public const string XBotServiceDILogTag = "XBotService";
// Table Mapping
public const string XBotUserTable = "BotUsers";
// GraphQL Mappings
public const string XBotUserSingleName = "botUser";
public const string XBotUserCollectionName = "botUsers";
// Hubs
public const string XBotUserDtoHub = "botUserDto";
public const string XBotUserEntityHub = "botUserEntity";
// Helper Method Names
public const string GetXBotUserEFRepositoryDescriptor = "GetXBotUserEFRepositoryDescriptor";
}
}</div>
<span class="file-path">Modules/xBotService/Interfaces/Entities/IXBotUserRepository.cs</span>
<div class="code-block">using xDataService.Interfaces;
using xBotService.Models.Entities;
namespace xBotService.Interfaces.Entities
{
public interface IXBotUserRepository : IXBaseRepository&lt;XBotUser, int&gt;
{
}
}</div>
<span class="file-path">Modules/xBotService/Interfaces/Entities/IXBotUserKeyGenerator.cs</span>
<div class="code-block">using xDataService.Interfaces;
using xBotService.Models.Entities;
namespace xBotService.Interfaces.Entities
{
public interface IXBotUserKeyGenerator : IXKeyGenerator&lt;XBotUser, int&gt;
{
}
}</div>
<span class="file-path">Modules/xBotService/Interfaces/Entities/IXBotUserRepositoryEvents.cs</span>
<div class="code-block">using xDataService.Interfaces;
using xBotService.Models.Entities;
namespace xBotService.Interfaces.Entities
{
public interface IXBotUserRepositoryEvents : IXBaseRepositoryEvents&lt;XBotUser&gt;
{
}
}</div>
<span class="file-path">Modules/xBotService/Interfaces/Dtos/IXBotUserRepositoryService.cs</span>
<div class="code-block">using xDataService.Interfaces;
using xBotService.Models.Dtos;
using xBotService.Models.Entities;
namespace xBotService.Interfaces.Dtos
{
public interface IXBotUserRepositoryService : IXBaseRepositoryService&lt;XBotUser, XBotUserDto, int&gt;
{
}
}</div>
</div>
<!-- Section 3: Providers (Implementation) -->
<div class="section">
<div class="section-header">
<div class="section-number">۳</div>
<div class="section-title">
<h3>پیاده‌سازی ارائه‌دهندگان (Providers Implementation)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/Providers/Entities/XBotUserEFRepository.cs</span>
<div class="code-block">using xDataService.Db;
using xDataService.Providers;
using xDataService.Interfaces;
using xDataService.Configuration;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.Entities
{
public class XBotUserEFRepository&lt;TContext&gt; : XBaseEFRepository&lt;XBotUser, int, TContext&gt;, IXBotUserRepository
where TContext : XDbContext
{
public XBotUserEFRepository(
IXUnitOfWorks&lt;TContext&gt; unitOfWorks,
XDataServiceConfiguration configuration,
IXBotUserKeyGenerator keyGenerator = null,
IXBotUserRepositoryEvents baseRepositoryEvents = null
) : base(unitOfWorks, configuration, keyGenerator, baseRepositoryEvents)
{
}
}
}</div>
<span class="file-path">Modules/xBotService/Providers/Entities/XBotUserKeyGenerator.cs</span>
<div class="code-block">using xDataService.Providers;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.Entities
{
public class XBotUserKeyGenerator : XIntKeyGenerator&lt;XBotUser&gt;, IXBotUserKeyGenerator
{
}
}</div>
<span class="file-path">Modules/xBotService/Providers/Entities/XBotUserRepositoryEvents.cs</span>
<div class="code-block">using xDataService.Providers;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.Entities
{
public class XBotUserRepositoryEvents : XBaseRepositoryEvents&lt;XBotUser&gt;, IXBotUserRepositoryEvents
{
}
}</div>
<span class="file-path">Modules/xBotService/Providers/Dtos/XBotUserRepositoryService.cs</span>
<div class="code-block">using AutoMapper;
using xDataService.Providers;
using xBotService.Models.Dtos;
using System.Collections.Generic;
using xBotService.Interfaces.Dtos;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.Dtos
{
public class XBotUserRepositoryService : XBaseRepositoryService&lt;XBotUser, XBotUserDto, int&gt;, IXBotUserRepositoryService
{
public XBotUserRepositoryService(
IXBotUserRepository repository,
IEnumerable&lt;Profile&gt; mapperProfiles = null
) : base(repository, mapperProfiles)
{
}
}
}</div>
</div>
<!-- Section 4: GraphQL Support -->
<div class="section">
<div class="section-header">
<div class="section-number">۴</div>
<div class="section-title">
<h3>پشتیبانی گراف‌کیو‌ال (GraphQL Support)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/Providers/GraphQL/XBotUserGraphType.cs</span>
<div class="code-block">using xDataService.GraphQL;
using xBotService.Models.Entities;
namespace xBotService.Providers.GraphQL
{
public class XBotUserGraphType : XBaseGraphObjectType&lt;XBotUser, int&gt;
{
public XBotUserGraphType() : base()
{
Field(x =&gt; x.UserId);
Field(x =&gt; x.BotUserName);
}
}
}</div>
<span class="file-path">Modules/xBotService/Providers/GraphQL/XBotUserGraphQLTypeHelper.cs</span>
<div class="code-block">using xDataService.GraphQL;
using xBotService.Constants;
using xDataService.Configuration;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.GraphQL
{
public class XBotUserGraphQLTypeHelper : XBaseGraphQLTypeHelper&lt;XBotUser, int&gt;, IXBotUserGraphQLTypeHelper
{
public XBotUserGraphQLTypeHelper(XDataServiceConfiguration configuration)
: base(configuration)
{
}
public override string GetInQueryCollectionName()
{
return XBotServiceConstants.XBotUserCollectionName;
}
public override string GetInQuerySingleName()
{
return XBotServiceConstants.XBotUserSingleName;
}
}
}</div>
<span class="file-path">Modules/xBotService/Providers/GraphQL/XBotUserGraphQuery.cs</span>
<div class="code-block">using GraphQL.Types;
using xDataService.GraphQL;
using xDataService.Configuration;
using xBotService.Models.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Providers.GraphQL
{
public class XBotUserGraphQuery : XBaseGraphQLQuery&lt;XBotUser, int, XBotUserGraphType, IntGraphType&gt;
{
public XBotUserGraphQuery(
XDataServiceConfiguration configuration,
IXBotUserRepository repository,
IXBotUserGraphQLTypeHelper helper
) : base(configuration, repository, helper)
{
}
}
}</div>
<span class="file-path">Modules/xBotService/Providers/GraphQL/XBotUserGraphSchema.cs</span>
<div class="code-block">using System;
using GraphQL.Types;
namespace xBotService.Providers.GraphQL
{
public class XBotUserGraphSchema : Schema
{
public XBotUserGraphSchema(IServiceProvider services) : base(services)
{
Query = (XBotUserGraphQuery)services.GetService(typeof(XBotUserGraphQuery));
}
}
}</div>
</div>
<!-- Section 5: DI Helper Extension -->
<div class="section">
<div class="section-header">
<div class="section-number">۵</div>
<div class="section-title">
<h3>ثبت وابستگی‌ها (Dependency Injection)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/DI/XDIHelperExtension.cs</span>
<div class="code-block">using System;
using xDataService.Db;
using xDataService.DI;
using xCommons.Extensions;
using xDataService.Models;
using xBotService.Helpers;
using xExceptions.Constants;
using xBotService.Constants;
using xBotService.Providers;
using xDataService.Constants;
using xBotService.Interfaces;
using xBotService.Providers.Dtos;
using xBotService.Interfaces.Dtos;
using Microsoft.AspNetCore.Builder;
using xBotService.Providers.Entities;
using xBotService.Interfaces.Entities;
using Microsoft.Extensions.DependencyInjection;
namespace xBotService.DI
{
public static class XDIHelperExtension
{
/// &lt;summary&gt;
/// Register XBotService
/// &lt;/summary&gt;
public static void AddXBotService(
this IServiceCollection services,
XRepositoryType repositoryType,
ServiceLifetime lifeTime = ServiceLifetime.Scoped
)
{
AddBotService(
contextType: null,
services: services,
lifeTime: lifeTime,
repositoryType: repositoryType
);
}
/// &lt;summary&gt;
/// Register XBotService with Context
/// &lt;/summary&gt;
public static void AddXBotService&lt;TContext&gt;(
this IServiceCollection services,
XRepositoryType repositoryType,
ServiceLifetime lifeTime = ServiceLifetime.Scoped
) where TContext : XDbContext
{
AddBotService(
services: services,
lifeTime: lifeTime,
contextType: typeof(TContext),
repositoryType: repositoryType
);
}
/// &lt;summary&gt;
/// Use XBotService Middleware
/// &lt;/summary&gt;
public static void UseXBotService(
this IApplicationBuilder app,
bool isDevelopmentEnvironment = false
)
{
// Using XBot Repository Descriptor
if (!descriptor.IsNull())
{
app.UseXRepository(
descriptor: descriptor,
isDevelopmentEnvironment: isDevelopmentEnvironment
);
}
}
// Private Implementation
private static XRepositoryDescriptor descriptor = null;
private static string XLogTag = XBotServiceConstants.XBotServiceDILogTag;
private static void Log(string message)
{
Console.WriteLine($"{XLogTag} =&gt; {message}");
}
private static void AddBotService(
IServiceCollection services,
XRepositoryType repositoryType,
Type contextType = null,
ServiceLifetime lifeTime = ServiceLifetime.Scoped
)
{
var exception = XException.InvalidArgs.ToException();
// Validate Services
if (services.IsNull())
{
Log("Service Registration failed, services not provided ...");
throw exception;
}
// Validate Repository Type
var isRepositoryTypeValid =
(repositoryType == XRepositoryType.EF && !contextType.IsNull()) ||
((repositoryType == XRepositoryType.Mongo || repositoryType == XRepositoryType.InMemory) && contextType.IsNull());
if (!isRepositoryTypeValid)
{
Log("Service Registration failed, Invalid Repository Type and Context Type ...");
throw exception;
}
// Make Instance of Repository Descriptor
switch (repositoryType)
{
case XRepositoryType.EF:
descriptor = typeof(XBotServiceHelper)
.InvokeGenericMethod&lt;XRepositoryDescriptor&gt;(
args: null,
runtimeType: contextType,
methodName: XBotServiceConstants.GetXBotUserEFRepositoryDescriptor
);
break;
case XRepositoryType.Mongo:
// descriptor = XBotServiceHelper.GetXBotUserMongoRepositoryDescriptor();
Log("MongoDB support not implemented yet for XBotService.");
break;
case XRepositoryType.InMemory:
// descriptor = XBotServiceHelper.GetXBotUserInMemoryRepositoryDescriptor();
Log("InMemory support not implemented yet for XBotService.");
break;
}
// Register XBotUser Repository Descriptor
if (!descriptor.IsNull())
{
services.AddXRepository(lifeTime: lifeTime, descriptor: descriptor);
}
// Register Dto Services
services.Add(new ServiceDescriptor(typeof(IXBotUserRepositoryService), typeof(XBotUserRepositoryService), lifeTime));
Log("XBotService Registration Succeed ...");
}
}
}</div>
</div>
<!-- Section 6: Helpers -->
<div class="section">
<div class="section-header">
<div class="section-number">۶</div>
<div class="section-title">
<h3>کمک‌کننده‌های توصیف‌گر (Descriptor Helpers)</h3>
</div>
</div>
<span class="file-path">Modules/xBotService/Helpers/XBotServiceHelper.cs</span>
<div class="code-block">using GraphQL.Types;
using xDataService.Db;
using xDataService.Models;
using xDataService.Providers;
using xBotService.Models.Entities;
using xBotService.Providers.GraphQL;
using xBotService.Providers.Entities;
using xBotService.Interfaces.Entities;
namespace xBotService.Helpers
{
public static class XBotServiceHelper
{
// EF Repository Descriptor Provider
public static XEFRepositoryDescriptor&lt;
XBotUser,
int,
IXBotUserKeyGenerator,
XBotUserKeyGenerator,
IXBotUserRepositoryEvents,
XBotUserRepositoryEvents,
XBotUserGraphType,
IntGraphType,
XBotUserGraphQuery,
IXBotUserGraphQLTypeHelper,
XBotUserGraphQLTypeHelper,
XBotUserGraphSchema,
IXBotUserRepository,
XBotUserEFRepository&lt;TContext&gt;,
TContext
&gt; GetXBotUserEFRepositoryDescriptor&lt;TContext&gt;()
where TContext : XDbContext
{
var result = new XEFRepositoryDescriptor&lt;
XBotUser,
int,
IXBotUserKeyGenerator,
XBotUserKeyGenerator,
IXBotUserRepositoryEvents,
XBotUserRepositoryEvents,
XBotUserGraphType,
IntGraphType,
XBotUserGraphQuery,
IXBotUserGraphQLTypeHelper,
XBotUserGraphQLTypeHelper,
XBotUserGraphSchema,
IXBotUserRepository,
XBotUserEFRepository&lt;TContext&gt;,
TContext
&gt;();
return result;
}
}
}</div>
</div>
<div class="success-box">
<strong>نتیجه‌گیری:</strong><br>
با افزودن فایل‌های فوق، ماژول <code>xBotService</code> اکنون دارای چرخه حیات کامل (CRUD)، پشتیبانی از GraphQL، Event Handling و قابلیت تزریق وابستگی خودکار مطابق با استانداردهای <code>xDataService</code> است. این ساختار امکان توسعه سریع‌تر و نگهداری آسان‌تر را فراهم می‌آورد.
</div>
</div>
<footer class="document-footer">
<div class="footer-brand">طراحی و توسعه: هادی خزاعی اصل</div>
<div>شرکت رایان پرداز کاوش &nbsp;|&nbsp; واحد معماری نرم‌افزار</div>
</footer>
</div>
</body>
</html>
@@ -0,0 +1,67 @@
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Constants\ConfigurationNodeNames.cs
namespace xBotService.Constants
{
public partial struct ConfigurationNodeNames
{
public const string BOT_SERVICE_NODE = "BotServiceConfiguration";
}
}
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Models\Dtos\XBotUserDto.cs
using xModels.Base;
using xModels.Dtos;
namespace xBotService.Models.Dtos
{
/// <summary>
/// Bot User / System User Relation ...
/// </summary>
public class XBotUserDto : XBaseIntIDEntityDto
{
/// <summary>
/// User Id ...
/// </summary>
/// <value></value>
public string UserId { get; set; }
/// <summary>
/// System Person Information ...
/// </summary>
/// <value></value>
public virtual XPersonDto User { get; set; } = null;
/// <summary>
/// Chat Bot User Name ...
/// </summary>
/// <value></value>
public string BotUserName { get; set; }
}
}
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Models\Entities\XBotUser.cs
using xModels.Base;
namespace xBotService.Models.Entities
{
/// <summary>
/// Bot User / System User Relation ...
/// </summary>
public class XBotUser : XBaseIntIDEntity
{
/// <summary>
/// User Id ...
/// </summary>
/// <value></value>
public string UserId { get; set; }
/// <summary>
/// Chat Bot User Name ...
/// </summary>
/// <value></value>
public string BotUserName { get; set; }
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Submodule Modules/xBotService added at 1e2eb030e8
+15
View File
@@ -59,6 +59,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xAiMcpServer", "xAiMcpServe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xLoggingService", "Modules\xLoggingService\xLoggingService.csproj", "{5D5DC136-9F14-45E8-887E-F49DB8DBD2AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xBotService", "Modules\xBotService\xBotService.csproj", "{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -393,6 +395,18 @@ Global
{5D5DC136-9F14-45E8-887E-F49DB8DBD2AF}.Release|x64.Build.0 = Release|Any CPU
{5D5DC136-9F14-45E8-887E-F49DB8DBD2AF}.Release|x86.ActiveCfg = Release|Any CPU
{5D5DC136-9F14-45E8-887E-F49DB8DBD2AF}.Release|x86.Build.0 = Release|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Debug|x64.ActiveCfg = Debug|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Debug|x64.Build.0 = Debug|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Debug|x86.ActiveCfg = Debug|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Debug|x86.Build.0 = Debug|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Release|Any CPU.Build.0 = Release|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Release|x64.ActiveCfg = Release|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Release|x64.Build.0 = Release|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Release|x86.ActiveCfg = Release|Any CPU
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -420,5 +434,6 @@ Global
{11FCE609-EF3F-47F6-9073-5FF86D9980BC} = {CA253913-39DE-BFD0-C9A3-4B7EC6FBDF17}
{BDD08088-B2A2-48C5-90C3-F19D7813F8C1} = {CA253913-39DE-BFD0-C9A3-4B7EC6FBDF17}
{BEFA4CA9-70B0-476D-95A3-E4D066AD48FE} = {CA253913-39DE-BFD0-C9A3-4B7EC6FBDF17}
{4E14B377-E4FB-4AD4-BD93-B2587FB01D1F} = {CA253913-39DE-BFD0-C9A3-4B7EC6FBDF17}
EndGlobalSection
EndGlobal