مطالب
آموزش مهندسی نرم افزار و UML - جلسه سوم

جلسه سوم :

در جلسه قبل به بررسی مشکلات تولید و توسعه سیستم‌های اطلاعاتی یا همان بسته‌های نرم افزاری پرداختیم در این جلسه به راهکاری که IT  برای فایق آمدن بر این مشکلات پیش روی ما قرار داده یا همان متدولوژی می‌پردازیم.

متدولوژی چیست ؟

          متدولوژی در واقع مجموعه ای از روش‌ها ، اصول و قواعدی است که برای قانونمند کردن تولید و توسعه نرم افزار ارائه می‌شود؛می توان گفت متدولوژی فرمولی جهت ساخت نرم افزار می‌باشد یا به عبارت دیگر متدولوژی چرخه حیات نرم افزار را مشخص می‌کند.

-چرخه حیات تولید وتوسعه نرم افزار یا SDLC(System Development Life Cycle)

مراحلی را که در طی تولید و توسعه نرم افزار سپری می‌شوند را SDLC می‌گویند.

انواع SDLC

1.     چرخه حیات سیستم‌های قدیمی یا TLC

2.     چرخه حیات سیستم‌های شی گرا یا OODLC

TLC(Traditional Life Cycle)-

در گذشته به دلیل اینکه اکثر برنامه‌ها بصورت فرآیندگرا یا Process Oriented نوشته می‌شدند از روش TLC  استفاده می‌شد . در روش‌های فرآیند گرا تمرکز اصلی بر روی فعالیت‌های سیستم بود در این روش بیشتر از نمودارهای ERD و DFD استفاده می‌شد .

البته اینا اضافه کنم که هنوز هم در بعضی از شرکت‌ها از این روش استفاده می‌شه هر چند که خودشونم نمی‌دونند یکی از دلایل اصلی هم فقر سواد شرکت‌های کار فرما می‌باشد . در ادامه به بررسی یکی از مدل‌های معروف TLC  یعنی مدل آبشاری می‌پردازیم.

-مدل آبشاری یا Water Fall  :

مدل آبشاری هر چند مدلی قدیمی می‌باشد اما مبنای اساسی مدل‌های شی گرا می‌باشد.

فازهای مختلف مدل آبشاری :

1.     مهندسی سیستم یا System Engineering

معرفی نیازمندی‌های کلی و مشخص نمودن کلیات سیستم به صورت سخت افزاری و نرم افزاری و تعاریف اصلی سیستم به طور مثال در پروژه وب سایت از Asp  استفاده کنیم یا Php 

2.     آنالیز نیازمندی‌ها یا Requirement Analysis

در این فاز به نیازمندی‌های کاربران می‌پردازیم یعنی در این فاز ما با چه یا What می‌پردازیم 

3.     طراحی یا Design

در این فاز ما به دنبال چگونه یا Who می‌رویم یعنی اینکه سیستم چگونه در جهت بر آوردن نیازمندی‌ها گام بردارد. 

4.     ساخت یا Construction

در این فاز آنچه را که در فاز طراحی مطرح کردیم به کد تبدیل می‌کنیم 

5.     تست Testing

در این مرحله سیستم از لحاظ کمی و کیفی تست میشوند. 

6.     نصب یا Installation

7.     نگهداری یا Maintenance

این فاز طولانی‌ترین و پرهزینه‌ترین قسمت چرخه عمر یک نرم افزار

معایب مدل آبشاری :

1.     مدل آبشاری تکرار بین فاز‌ها را در نظر نمی‌گیرد و خروجی هر فاز را قطعی در نظر می‌گیرد که اگر مثلا در فاز طراحی باشیم و یک نیازمندی در نظر گرفته نشده باشد این مدل هیچ راهکاری را برای در ج این نیازمندی در سیستم ارائه نمی‌دهد بعد‌ها برای رفع این مشکل مدل آبشاری با تکرار (Water Fall with Iteration)  معرفی گردید.

2.     دراین روش هر فاز هنگامی آغاز می‌شود که فاز قبل از خودش به پایان رسیده باشد که این امر مانع از Overlap  یا به اشتراک گذاری بین فازها می‌شد.

3.     سیستم‌های محاوره ای نیستند و در برابر تغییرات مقاوم نمی‌باشند.

مزایای مدل‌های آبشاری

1.     واگذاری هر فاز به یک تیم مشخص

2.     پیشرفت پروژه بیشتر به چشم می‌خورد.

 در جلسه آینده به بررسی مدل‌های شی گرا خواهیم پرداخت.

 

مطالب
ایجاد بارکد به همراه یک متن
در این مقاله یک بارکد را به همراه یک متن در پایین آن، مشابه تصویر زیر ایجاد میکنیم. سورس کامل این مطلب در این آدرس قرار دارد. جهت تست بارکد از این آدرس استفاده کنید.

- طول عکس خروجی نهایی 250 پیکسل است.

- فونت متن 10 پیکسل هست و عرض هر خط 17 پیکسل.

- حداکثر تعداد خطِ نمایش متن، 3 خط است و اگر متن برای نمایش، به 3 خط بیشتر نیاز داشت، اضافه‌ی متن را به صورت 3 نقطه نمایش میدهیم (مثل عکس بالا).

- عرض بارکد 50 پیکسل است.

- فاصله بین بارکد و متن 5 پیکسل است.

public static class BarcodeHelper
{
    public static string GenerateBarcodeWithText(string input, string textBelow)
    {
        // barcode: 50 pixels
        // margin: top 5 pixels
        // height of each text line is 17 pixels
        // text: maximum 3 lines
        // each 30 letters is: 1 line

        var eachLineHeight = 17;

        var eachLineLetters = 30;

        var maximumLines = 3;

        var maximumTextHeight = eachLineHeight * maximumLines;

        var resultWidth = 250;

        var barcodeHeight = 50;

        var textY = barcodeHeight + 5;

        // each 30 letters is: 1 line for example input length is 150 letters and for show 100 letters we need (150 / 30) 5 lines
        // each line is 17 pixels and text height will be (17 * 5) 102 pixels
        var textHeight = (textBelow.Length / eachLineLetters) * eachLineHeight;

        // if height of text be greater than (eachLineHeight * maximumLines) we use maximum text height (eachLineHeight * maximumLines)
        textHeight = textHeight > maximumTextHeight ? maximumTextHeight : textHeight;

        // if text height be less than 1 line we set 1 line height (17 pixels) to the text height
        // text height minimum is equal 1 linle (17 pixels)
        textHeight = textHeight < eachLineHeight ? eachLineHeight : textHeight;

        var resultHeight = textY + textHeight;
    }
}


چون ما از Bitmap و Image استفاده میکنیم، پس به پکیچ System.Drawing.Common نیاز داریم:

<ItemGroup>
    <PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>

اولین کاری که انجام میدهیم، یک Bitmap را ایجاد میکنیم و بعد یک مستطیل را به اندازه‌ی خود Bitmap ایجاد میکنیم و با کلاس Graphics، به نارنجی، رنگش میکنیم و داخل Bitmap میریزیم و در نهایت عکس ایجاد شده را در حافظه‌ی رم ذخیره میکنیم.

- Bitmap فضایی را در اختیار ما قرار میدهد که داخلش هر چیزی را ترسیم کنیم.

- Graphics به ما کمک میکند که عملیات گرافیکی را نظیر رنگ آمیزی، ترسیم عکس و ... روی یک شیء انجام دهیم.

- MemoryStream برای ذخیره سازی موقت در حافظه‌ی رم به کار میاد؛ عکس ایجاد شده‌ی تا این لحظه را که یک مستطیل نارنجی رنگ هست، در داخل رم ذخیره میکنیم.

#region MainBitmap

var mainBitmap = new Bitmap(resultWidth, resultHeight);
using var rectangleGraphics = Graphics.FromImage(mainBitmap);
{
    var rectangle = new Rectangle(0, 0, resultWidth, resultHeight);
    rectangleGraphics.FillRectangle(Brushes.OrangeRed, rectangle);
}

using var rectangleStream = new MemoryStream();
{
    mainBitmap.Save(rectangleStream, ImageFormat.Png);
}

#endregion

خروجی تا این لحظه:

حالا باید بارکد را ایجاد کنیم و عکس خروجی بارکد را داخل این مستطیل بریزیم؛ برای اینکار از کتابخانه BarcodeLib استفاده میکنیم:

private static Bitmap GenerateBarcodeImage(string input, int width, int height)
{
    var barcodeInstance = new Barcode();
    var barcodeImage = barcodeInstance.Encode(BarcodeLib.TYPE.CODE39, input, Color.Black,
        Color.OrangeRed, width, height);
    using var barcodeStream = new MemoryStream();
    {
        barcodeImage.Save(barcodeStream, ImageFormat.Png);
    }
    return (Bitmap)Image.FromStream(barcodeStream);
}

و الان این عکس بارکد را داخل مستطیل اصلی میریزیم و هر دو را Merge میکنیم:

#region Barcode

var barcodeImage = GenerateBarcodeImage(input, resultWidth, barcodeHeight);

#endregion

#region MergedRectangleAndBarcode

var newMainBitmap = (Bitmap)Image.FromStream(rectangleStream);
var newBarcodeBitmap = barcodeImage;
using var newRectangleGraphics = Graphics.FromImage(newMainBitmap);
{
    newRectangleGraphics.DrawImage(newBarcodeBitmap, 0, 0);
}

using var mergedRectangleAndBarcodeStream = new MemoryStream();
{
    newMainBitmap.Save(mergedRectangleAndBarcodeStream, ImageFormat.Png);
}

#endregion

خروجی تا این لحظه :

حالا باید 5 پیکسل از پایین بارکد فاصله بگیریم و متن را بنویسیم.

برای اینکار از یک مستطیل کمک میگیریم. یعنی یک مستطیل بدون هیچ رنگ و Border ـی را پایین این بارکد ایجاد میکنیم، چرا؟ دلیل این است که میخواهیم متن‌مان را به صورت وسط چین، از راست و چپ، و وسط از بالا و پایین قرار بدیم و برای اینکار میگیم این نسبت وسط چین بودن از راست و چپ، وسط بودن از بالا و پایین را از مستطیل پایین بارکد کمک بگیر، خلاصه‌اش می‌شود اینکه از مستطیلِ پایینِ بارکد برای وسط چین بودن متن از راست و چپ و وسط بودن از بالا و پایین استفاده میکنیم.

#region WriteText

var barcodeBitmap = (Bitmap)Image.FromStream(mergedRectangleAndBarcodeStream);
using var graphics = Graphics.FromImage(barcodeBitmap);
{
    using var font = new Font("Tahoma", 10);
    {
        var rect = new Rectangle(0, textY, resultWidth, textHeight);
        var sf = new StringFormat();
        sf.Alignment = StringAlignment.Center;
        sf.Trimming = StringTrimming.EllipsisCharacter;
        sf.FormatFlags = StringFormatFlags.DirectionRightToLeft;
        sf.LineAlignment = StringAlignment.Center;
        graphics.DrawString(textBelow, font, Brushes.Black, rect, sf);
        //graphics.DrawRectangle(Pens.Green, rect);
    }
}

using var finalStream = new MemoryStream();
{
    barcodeBitmap.Save(finalStream, ImageFormat.Png);
}

#endregion

graphics.DrawString می‌گوید textBelow را با font تاهوما و با رنگ سیاه، داخل rect (مستطیل) و با این تنظیماتِ متن بریز.

Alignment متن را وسط چین می‌کند (این وسط چین شدن نسبت به مستطیل پایین بارکد است که هیچ رنگ و Border ـی ندارد) .

LineAlignment متن را از بالا و پایین میارد وسط (این وسط شدن نسبت به مستطیل پایین بارکد است که هیچ رنگ و Border ـی ندارد).

EllipsisCharacter اگر متن طولانی باشد، اضافه متن را به صورت سه نقطه نمایش می‌دهد.

DirectionRightToLeft متن را RTL می‌کند.

خروجی نهایی:

عکس نهایی به صورت Stream ذخیره شده‌است، آن‌را به فرمت Base64 تبدیل میکنیم و برگشت میزنیم.

return Convert.ToBase64String(finalStream.ToArray());

برای نمایش یک آرایه بایتی که به فرمت Base64 تبدیل شده، به این روش عمل میکنیم:

<img src="data:image/png;base64, @BarcodeHelper.GenerateBarcodeWithText("barcode text", "below text")" />

چون برای ایجاد بارکد از تایپ 39 استفاده کرده‌ایم و تایپ 39 فقط حروف بزرگ انگلیسی را پشتیبانی میکند، پس برای اینکه دچار خطا نشویم، میتوانیم ابتدای متدمان، از این کد استفاده کنیم:

// Type 39 doesn't support lower case letters, for prevent exception, we convert all input letters to upper case
// more details: https://www.dntips.ir/newsarchive/details/18019
input = input.ToUpperInvariant();

همچنین جهت تشخیص خودکار راست به چک بودن متن پایین بارکد، میتوان از متد ContainsFarsi در پکیج DNTPersianUtils.Core استفاده کرد:

if (textBelow.ContainsFarsi())
    sf.FormatFlags = StringFormatFlags.DirectionRightToLeft;
نظرات مطالب
نحوه اضافه کردن Auto-Complete به جستجوی لوسین در ASP.NET MVC و Web forms
یک سوال خدمت شما داشتم اینکه :

وقتی بخوایم از 2 جدول متفاوت جستجو کنیم به نظر شما اطلاعات هر جدول را جداگانه ایندکس کنیم(منظورم همان کاری که متد CreateFullTextIndex شما انجام میده) یا خیر؟
البته منظور دو جدولی که با هم رابطه دارند.


چندتا لینک در مورد لوسین:

  ممنون
اشتراک‌ها
Profiller رایگان برای ASP.NET

Prefix is a free profiler for ASP.NET applications. It's dead easy to use and it will help you find bugs in your code that you didn't even know you had. I found two in what I thought were properly working apps within an hour of downloading Prefix. 

Profiller رایگان برای ASP.NET
اشتراک‌ها
کتابخانه boba.js
Boba.js is a small, easily extensible JavaScript library that makes working with Google Analytics easier. It supports the old ga.js library as well as the new analytics.js library. It has one out of the box function, trackLinks, and makes tracking everything else child's play.  Demo
کتابخانه boba.js
اشتراک‌ها
WebAssembly برای توسعه دهنده‌های دات نت

WebAssembly, or Wasm, is on its way to becoming the next big thing in software development, allowing us to develop more reusable code across programming stacks. It will also enable the deployment of smaller packages more securely. This talk will focus on the view of a .NET developer using WebAssembly in their projects, whether client-side, server-side, or plugins.
Agenda
0:00:00 – Introduction
0:01:44 – Presentation Start
0:04:36 – Wasm on the client
0:08:27 – Wasm on the server
0:11:51 – ASP.NET Core in Wasi
0:21:41 – Wasm in the cloud
0:32:38 – Wasm for plugins
0:36:07 – Wasm plugins samples
0:49:05 – .NET 8 and the future
0:55:08 – Who’s working on this?
1:03:13 – Outro
 

WebAssembly برای توسعه دهنده‌های دات نت
اشتراک‌ها
FastEndpoints؛ جایگزینی دیگر برای Minimal APIs در دات نت 6

FastEndpoints offers a more elegant solution than the Minimal APIs and MVC Controllers with the goal of increasing developer productivity. Performance is on par with the Minimal APIs and is faster; uses less memory; and outperforms a MVC Controller by about 34k requests per second on a Ryzen 3700X desktop. 

FastEndpoints؛ جایگزینی دیگر برای Minimal APIs در دات نت 6
مطالب
عدم نمایش Ribbon برای کاربران ناشناس (Anonymous Users) در شیرپوینت
یکی از نیاز‌های مشتریان هنگام استفاده از سایت‌های تحت شیرپوینت ، عدم نمایش نوار مدیریتی بالای صفحه یا همان Ribbon برای کاربران ناشناس است .
شاید بتوان گفت که مزیت این راهکار نسبت به دیگر راه کار‌ها ، تصحیح نمایش Scroll Bar مرورگر است که ممکن است در برخی روش‌ها با مشکل مواجه شود. دلیل این امر هم این است که شیرپوینت برای افزودن Ribbon به بالای صفحه Vertical Scroll Bar را از صفحه حذف می‌کند و سپس Scroll Bar سفارشی خود را به صفحه طوری اضافه می‌کند تا نوار Ribbon همیشه در بالا‌ترین نقطه از صفحه بماند
همچنین در این روش از بارگذاری نوار هنگام بالا آمدن سایت نیز البته برای کاربران ناشناس جلوگیری می‌شود
 و اما روش :
 سایت خود را با SharePoint Designer باز کرده و از Master Page یک کپی تهیه کنید و آن را به عنوان پیش فرض سایت تعیین کنید 

سپس تگ زیر را در صفحه بیابید : 
<div id="s4-ribbonrow">
و تگ زیر را به ابتدای آن (قبل از تگ) اضافه کنید : 
<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="AddDelPrivateWebParts">
مانند تصویر زیر : 

و تگ پایانی آن : 

نکته مهم در استفاده از این تگ ، ویژگی Permissions آن است که باید با دقت و بسته به نیاز شما تعریف شود :

برخی از این موارد عبارتند از : 

EmptyMask – Has no permissions on the Web site. Not available through the user interface.

ViewListItems – View items in lists, documents in document libraries, and view Web discussion comments.

AddListItems – Add items to lists, add documents to document libraries, and add Web discussion comments.

EditListItems – Edit items in lists, edit documents in document libraries, edit Web discussion comments in documents, and customize Web Part Pages in document libraries.

DeleteListItems – Delete items from a list, documents from a document library, and Web discussion comments in documents.

ApproveItems – Approve a minor version of a list item or document.

OpenItems – View the source of documents with server-side file handlers.

ViewVersions – View past versions of a list item or document.

DeleteVersions – Delete past versions of a list item or document.

CancelCheckout – Discard or check in a document which is checked out to another user.

ManagePersonalViews – Create, change, and delete personal views of lists.

ManageLists – Create and delete lists, add or remove columns in a list, and add or remove public views of a list.

ViewFormPages – View forms, views, and application pages, and enumerate lists.

Open – Allow users to open a Web site, list, or folder to access items inside that container.

ViewPages – View pages in a Web site.

AddAndCustomizePages – Add, change, or delete HTML pages or Web Part Pages, and edit the Web site using a SharePoint Foundation–compatible editor.

ApplyThemeAndBorder – Apply a theme or borders to the entire Web site.

ApplyStyleSheets – Apply a style sheet (.css file) to the Web site.

ViewUsageData – View reports on Web site usage.

CreateSSCSite – Create a Web site using Self-Service Site Creation.

ManageSubwebs – Create subsites such as team sites, Meeting Workspace sites, and Document Workspace sites.

CreateGroups – Create a group of users that can be used anywhere within the site collection.

ManagePermissions – Create and change permission levels on the Web site and assign permissions to users and groups.

BrowseDirectories – Enumerate files and folders in a Web site using Microsoft Office SharePoint Designer 2007 and WebDAV interfaces.

BrowseUserInfo – View information about users of the Web site.

AddDelPrivateWebParts – Add or remove personal Web Parts on a Web Part Page.

UpdatePersonalWebParts – Update Web Parts to display personalized information.

ManageWeb – Grant the ability to perform all administration tasks for the Web site as well as manage content. Activate, deactivate, or edit properties of Web site scoped Features through the object model or through the user interface (UI). When granted on the root Web site of a site collection, activate, deactivate, or edit properties of site collection scoped Features through the object model. To browse to the Site Collection Features page and activate or deactivate site collection scoped Features through the UI, you must be a site collection administrator.

UseClientIntegration – Use features that launch client applications; otherwise, users must work on documents locally and upload changes.

UseRemoteAPIs – Use SOAP, WebDAV, or Microsoft Office SharePoint Designer 2007 interfaces to access the Web site.

ManageAlerts – Manage alerts for all users of the Web site.

CreateAlerts – Create e-mail alerts.

EditMyUserInfo – Allows a user to change his or her user information, such as adding a picture.

EnumeratePermissions – Enumerate permissions on the Web site, list, folder, document, or list item.

FullMask – Has all permissions on the Web site. Not available through the user interface.

حال خارج از تگ‌های SPSecurityTrimmedControl در ابتدا یا انتها ، باید تگ login را مانند زیر به آن اضافه کرد . 

و تمام : 

موفق باشید 

اشتراک‌ها
12.Visual Studio 2017 15.9 منتشر شد

Issues Fixed in 15.9.12

These are the customer-reported issues addressed in 15.9.12:

Security Advisory Notices

12.Visual Studio 2017 15.9 منتشر شد