This commit is contained in:
mmrbnjd
2024-03-30 15:10:36 +03:30
parent f4588f3426
commit a9e3afdea4
60 changed files with 1752 additions and 70 deletions

View File

@@ -0,0 +1,16 @@
namespace Back.Common.ViewModels
{
public class PagingDto<T>
{
public PagingDto(int RowCount, int pageCount, List<T> list)
{
this.RowCount = RowCount;
this.list = list;
PageCount = pageCount;
}
public int RowCount { get; set; }
public int PageCount { get; set; }
public List<T> list { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
namespace Back.Common.Enums
{
public enum CustomerType:int
{
[Display(Name = "حقیقی")]
genuine = 1,
[Display(Name = "حقوقی")]
legal = 2,
[Display(Name = "مشارکت مدنی")]
CivilPartnership = 3,
[Display(Name = "اتباع عیر ایرانی")]
NonIranianNationals = 4
}
}

View File

@@ -0,0 +1,25 @@
using System.ComponentModel.DataAnnotations;
namespace Back.Common.Enums
{
public enum InvoiceType:int
{
[Display(Name = "پیشنهاد قیمت")]
Bidding=10,
//[Display(Name = "فاکتور")]
//Factor=11,
//[Display(Name = "قطعی")]
//Final=12,
[Display(Name = "لغو")]
CANCEL = 0,
[Display(Name = "فروش")]
Sale=1,
[Display(Name = "ابطالی")]
Cancellation=3,
[Display(Name = "اصلاحی")]
Repair=2,
[Display(Name = "برگشت از فروش")]
BackFrmSale = 4
}
}

View File

@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
namespace Back.Common.Enums
{
public enum SentStatus
{
[Display(Name = "ارسال شده")]
Send,
[Display(Name = "موفق")]
Successful,
[Display(Name = "ناموفق")]
Unsuccessful,
[Display(Name = "در حال پردازش")]
pending,
[Display(Name = "نامشخص")]
Unknown,
[Display(Name = "یافت نشده")]
NOT_FOUND
}
}

View File

@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace Back.Common.Enums
{
public enum SideType
{
[Display(Name = "مشتری")]
Customer,
[Display(Name = "کارشناس")]
Expert
}
}

View File

@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace Back.Common.Enums
{
public enum StatusOrder
{
[Display(Name = "ساخته شده")]
Create,
[Display(Name = "پرداخت شده")]
Paid,
[Display(Name = "انصراف داده شده")]
Cancel
}
}

View File

@@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
using static Back.Common.ExclusiveAttribute;
namespace Back.Common.Enums
{
public enum StatusTicket
{
[Color("00FF23")]
[Display(Name = "فرد ناشناس")]
unknownPerson,
[Color("8844A3")]
[Display(Name = "در انتظار بررسی")]
Awaitingreview,
[Color("2CAFE8")]
[Display(Name = "خوانده شده/ در حال بررسی")]
Read_Checking,
[Color("4AB621")]
[Display(Name = "پاسخ داده شده")]
hasbeenanswered,
[Color("37363E")]
[Display(Name = "پاِیان")]
End,
[Color("D24249")]
[Display(Name = "انصراف")]
optout,
}
}

View File

@@ -0,0 +1,13 @@
namespace Back.Common
{
public class ExclusiveAttribute
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Class,
AllowMultiple = false)]
public class ColorAttribute : Attribute
{
public string _ColorHex;
public ColorAttribute(string ColorHex) => _ColorHex = ColorHex;
}
}
}

View File

@@ -0,0 +1,93 @@
using Microsoft.EntityFrameworkCore;
using static Back.Common.ExclusiveAttribute;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Globalization;
using System.Reflection;
using System.Security.Cryptography;
using Back.Common.ViewModels;
namespace Back.Common
{
public static class ExtentionMethods
{
public static string GetEnumDisplayName(this Enum enumType)
{
return enumType.GetType().GetMember(enumType.ToString())
.First()
.GetCustomAttribute<DisplayAttribute>()
.Name;
}
public static string GetEnumHexColor(this Enum enumType)
{
return enumType.GetType().GetMember(enumType.ToString())
.First()
.GetCustomAttribute<ColorAttribute>()
._ColorHex;
}
public static string encrypted(this string txt)
{
HashAlgorithm hash = new MD5CryptoServiceProvider();
var bytes = System.Text.Encoding.UTF8.GetBytes(txt);
var hashedBytes = hash.ComputeHash(bytes);
string res = BitConverter.ToString(hashedBytes).Replace("-", string.Empty);
return res;
}
public static string ConvertMiladiToShamsi(this DateTime date)
{
PersianCalendar PersianCal = new PersianCalendar();
return PersianCal.GetYear(date).ToString("0000") +
PersianCal.GetMonth(date).ToString("00") +
PersianCal.GetDayOfMonth(date).ToString("00");
}
public static string ShamciToFormatShamci(this string str)
{
if (string.IsNullOrEmpty(str)) return "";
return str.Substring(0, 4) + "/" + str.Substring(4, 2) + "/" + str.Substring(6, 2);
}
public static DateTime ToMiladi(this string value)
{
PersianCalendar p = new PersianCalendar();
return p.ToDateTime(Convert.ToInt32(value.Substring(0, 4)), Convert.ToInt32(value.Substring(4, 2)), Convert.ToInt32(value.Substring(6, 2)), 0, 0, 0, 0);
}
public static async Task<PagingDto<T>> Paging<T>(this IQueryable<T> values, int pageId, int take)
{
if (/*values.Count()<1000 && */pageId == 0 && take == 0)
{
return new PagingDto<T>(values.Count(), 1, await values.ToListAsync());
}
else
{
int skip = (pageId - 1) * take;
int rowCount = values.Count();
int PageCount = rowCount % take == 0 ? rowCount / take : rowCount / take + 1;
return new PagingDto<T>(rowCount, PageCount, await values.Skip(skip).Take(take).ToListAsync());
}
}
public static System.Linq.Expressions.Expression<Func<TEntity, bool>> GetFunc<TEntity>(string Fild, string Value)
{
Type type = typeof(TEntity);
// System.Linq.Expressions.Expression<Func<TEntity, bool>> convert = s => type.GetProperty(Fild) != null && s.GetType().GetProperty(Fild).GetValue(s) == Value;
return Entity => type.GetProperty(Fild) != null && Entity.GetType().GetProperty(Fild).GetValue(Entity) == Value;
}
public static DataTable ConvertStringBase64toDataTable(this string value, string SheetName = null)
{
//try
//{
// MemoryStream stream1 = new MemoryStream(Convert.FromBase64String(value));
// WorkBook workbook = WorkBook.Load(stream1);
// WorkSheet sheet = SheetName == null ? workbook.DefaultWorkSheet : workbook.GetWorkSheet(SheetName);
// return sheet.ToDataTable(true);
//}
//catch (Exception)
//{
return new DataTable();
// }
}
}
}