public static string ToStringDateTime12P(this PersianDateTime DT) { //return DT.ToString("yyyy/MM/dd hh:mm tt").Replace("AM", "ق.ظ").Replace("PM", "ب.ظ"); string hh = DT.ToString("HH"); string tt = Convert.ToInt32(hh) < 12 ? "ق.ظ" : "ب.ظ"; return(DT.ToString("yyyy/M/d h:mm " + tt)); }
public string Convert(ResolutionContext context) { var dateTime = context.SourceValue; if (dateTime == null) { return(string.Empty); } var persianDateTime = new PersianDateTime((DateTime)dateTime); return(_fullDateTime ? $"{persianDateTime.ToString("d MMMM yyyy HH:mm")} ({RemainingDateTime.Calculate((DateTime) dateTime)})" : $"{persianDateTime.ToString(PersianDateTimeFormat.ShortDateShortTime)}, ({RemainingDateTime.Calculate((DateTime) dateTime)})"); }
public List <LatestNewsModel> Popular_filler() { ///////popular news List <LatestNewsModel> Popular = new List <LatestNewsModel>(); DataTable popular_dt = db.Select( "SELECT top 5 [Post_tbl].Id,[Categories_tbl].name,[Post_tbl].[Title],[Post_tbl].[Date],[Post_tbl].[ImagePath],[Post_tbl].[ImageValue] FROM[Post_tbl] INNER JOIN [Categories_tbl] ON [Post_tbl].Id=[Categories_tbl].PostId order by(SELECT count(*) FROM [Comment_tbl]WHERE PostId=[Post_tbl].[Id]) DESC,Date DESC"); for (int i = 0; i < popular_dt.Rows.Count; i++) { DateTime date = dateTimeStamp.GetDateTime_fromUnix(popular_dt.Rows[i]["Date"].ToString()); PersianDateTime persianDateTime = new PersianDateTime(date); var Late = new LatestNewsModel() { Id = Convert.ToInt32(popular_dt.Rows[i]["Id"]), title = popular_dt.Rows[i]["Title"].ToString(), date = persianDateTime.ToString(), ImagePath = popular_dt.Rows[i]["ImagePath"].ToString(), Category = popular_dt.Rows[i]["name"].ToString() }; Popular.Add(Late); } //////// popular end return(Popular); }
public List <LatestNewsModel> LatestNewsModels_filler() { ///////latest news List <LatestNewsModel> latest = new List <LatestNewsModel>(); DataTable latest_dt = db.Select( "SELECT top 5 [Post_tbl].Id,[Categories_tbl].name,[Post_tbl].[Title],[Post_tbl].[Date],[Post_tbl].[ImagePath],[Post_tbl].[ImageValue] FROM[Post_tbl] INNER JOIN [Categories_tbl] ON [Post_tbl].Id=[Categories_tbl].PostId order by([Post_tbl].Date)DESC"); for (int i = 0; i < latest_dt.Rows.Count; i++) { DateTime date = dateTimeStamp.GetDateTime_fromUnix(latest_dt.Rows[i]["Date"].ToString()); PersianDateTime persianDateTime = new PersianDateTime(date); var Late = new LatestNewsModel() { Id = Convert.ToInt32(latest_dt.Rows[i]["Id"]), title = latest_dt.Rows[i]["Title"].ToString(), date = persianDateTime.ToString(), ImagePath = latest_dt.Rows[i]["ImagePath"].ToString(), Category = latest_dt.Rows[i]["name"].ToString() }; latest.Add(Late); } //////// latest end return(latest); }
public List <LatestNewsModel> Search_filler(string s_text) { ///////Search news List <LatestNewsModel> search = new List <LatestNewsModel>(); DataTable search_dt = db.Select( "SELECT top 6 [Post_tbl].Id,[Categories_tbl].name,[Post_tbl].[Title],[Post_tbl].[Date],[Post_tbl].[ImagePath],[Post_tbl].[ImageValue] FROM[Post_tbl] INNER JOIN [Categories_tbl] ON [Post_tbl].Id=[Categories_tbl].PostId WHERE [Post_tbl].Title like N'%" + s_text + "%' OR [Post_tbl].Text like N'%" + s_text + "%' order by([Post_tbl].weight) DESC,Date DESC"); for (int i = 0; i < search_dt.Rows.Count; i++) { DateTime date = dateTimeStamp.GetDateTime_fromUnix(search_dt.Rows[i]["Date"].ToString()); PersianDateTime persianDateTime = new PersianDateTime(date); var S = new LatestNewsModel() { Id = Convert.ToInt32(search_dt.Rows[i]["Id"]), title = search_dt.Rows[i]["Title"].ToString(), date = persianDateTime.ToString(), ImagePath = search_dt.Rows[i]["ImagePath"].ToString(), Category = search_dt.Rows[i]["name"].ToString() }; search.Add(S); } //////// Search end return(search); }
public JsonResult InsertInvoicePurchase(string UserBizCode, string TotalPrice) { var DbUser = _context.Tbl_User.SingleOrDefault(u => u.BIZCode == UserBizCode); PersianDateTime now = PersianDateTime.Now; var ShamsiDate = now.ToString(); DateTime MiladiDate = DateTime.Now; var Invoice = new Tbl_Invoices { UserID = DbUser.Id, SellerID = Convert.ToInt32(Session["UserId"]), DateTime = ShamsiDate, InvoiceStatesID = 1, Description = "خرید از فروشگاه سیرجان" }; var Purchase = new Tbl_SirjanPurchase { UserId = DbUser.Id, PurchaseId = 1, Price = TotalPrice, DateTime = ShamsiDate, MiladiDate = MiladiDate, Description = "خرید از فروشگاه سیرجان" }; _context.Tbl_Invoices.Add(Invoice); _context.SaveChanges(); _context.Tbl_SirjanPurchase.Add(Purchase); _context.SaveChanges(); int LastInvoiceId = _context.Database.SqlQuery <int>(@"select top 1 Id from Tbl_Invoices order by Id desc").FirstOrDefault <int>(); return(Json(LastInvoiceId.ToString(), JsonRequestBehavior.AllowGet)); }
public ActionResult test() { DateTime date = Convert.ToDateTime("2020-02-20 12:01:11.300"); PersianDateTime persianDateTime = new PersianDateTime(date); return(Content(persianDateTime.ToString())); }
public string ConvertMiladiToShamsi(DateTime datetime) { PersianDateTime persianDateTime = new PersianDateTime(datetime); return(persianDateTime.ToString("yyyy/MM/dd")); //return persianDateTime.ToString("dddd d MMMM yyyy"); }
public string Convert(ResolutionContext context) { var dateTime = context.SourceValue; if (dateTime == null) { return(string.Empty); } var persianDateTime = new PersianDateTime((DateTime)dateTime); return(_fullDateTime ? string.Format("{0},{1}", persianDateTime.ToString("dddd d MMMM yyyy ساعت hh:mm:ss tt"), RemainingDateTime.Calculate((DateTime)dateTime)) : string.Format("{0},{1}", persianDateTime.ToString(PersianDateTimeFormat.ShortDateShortTime), RemainingDateTime.Calculate((DateTime)dateTime))); }
public static DayVM GetVM(Day day) { var vm = new DayVM(); vm.DayId = day.DayId; vm.PersonnelId = day.PersonnelId; persianDateTime = new PersianDateTime(day.Date); vm.DayName = persianDateTime.ToString("dddd d MMMM yyyy"); vm.DayShortName = persianDateTime.ToString("dddd d"); vm.TimeType = day.TimeType; vm.TimeTypeName = EnumName.GetWorkTimeType(day.TimeType); vm.Spans = AttendanceSpanVM.GetVMs(day.AttendanceSpans.ToList()); // vm.Duration = new DurationVM(); foreach (var sp in vm.Spans) { if (sp.TimeType == WorkTimeType.AtWork) { vm.Duration.DurationOfWorkSecends += sp.DurationSecends; } if (sp.TimeType == WorkTimeType.LeaveWork) { vm.Duration.DurationOfLeaveSecends += sp.DurationSecends; } if (sp.TimeType == WorkTimeType.Mission) { vm.Duration.DurationOfMisiionSecends += sp.DurationSecends; } if (sp.TimeType == WorkTimeType.OverTime) { vm.Duration.DurationOfOverTimeSecends += sp.DurationSecends; } } vm.Duration.DurationOfWork = Environment.Convert.TimeSpanToReadableString(TimeSpan.FromSeconds(vm.Duration.DurationOfWorkSecends)); vm.Duration.DurationOfLeave = Environment.Convert.TimeSpanToReadableString(TimeSpan.FromSeconds(vm.Duration.DurationOfLeaveSecends)); vm.Duration.DurationOfMisiion = Environment.Convert.TimeSpanToReadableString(TimeSpan.FromSeconds(vm.Duration.DurationOfMisiionSecends)); vm.Duration.DurationOfOverTime = Environment.Convert.TimeSpanToReadableString(TimeSpan.FromSeconds(vm.Duration.DurationOfOverTimeSecends)); // return(vm); }
public string ConvertMiladiToShamsi(DateTime date, string Format) { PersianDateTime persianDateTime = new PersianDateTime(date); //return persianDateTime.ToString("dddd d MMMM yyyy ساعت hh:mm:ss tt"); //return persianDateTime.ToString("dddd d MMMM yyyy"); return(persianDateTime.ToString(Format)); }
protected override string ResolveCore(DateTime?source) { if (source == null) { return(string.Empty); } var persianDateTime = new PersianDateTime(source.Value); return(persianDateTime.ToString(_format)); }
private async void lpr_OnCarReceived(object source, KarabinEmbeddedLPR.CarReceivedEventArgs e) { var plateNumber = e.GetPlate(); System.Console.WriteLine("ShomarehPelak:" + plateNumber); if (_websocket != null) { await SendPlateNumber(plateNumber); } var data = e.GetData(); string[] words = data.Split('_', '~'); var date = words[1]; // _logger.LogInformation("date:"+ date); var CameraCode = words[2]; // _logger.LogInformation("CameraCode:"+ CameraCode); var UpdateCount = words[4]; // _logger.LogInformation("Updatecount:"+ UpdateCount); // foreach (var word in words) // { // System.Console.WriteLine($"<{word}>"); // } // _logger.LogInformation("data:"+data); // var persianDateTime = new PersianDateTime(DateTime.Now); // _logger.LogInformation("farsiDate:"+ persianDateTime); DateTime dt = DateTime.ParseExact(date, "yyyy-M-d-H-m-s", CultureInfo.InvariantCulture); System.Console.WriteLine(dt); PersianDateTime persianDate = new PersianDateTime(dt); System.Console.WriteLine("FINALL DATE:" + persianDate); _plateReaderDb.Create(new Plate() { plateNumber = plateNumber, date = persianDate.ToString(), CameraCode = CameraCode, UpdateCount = UpdateCount }); }
public void DebuggingMethod() { var x3 = DateTime.UtcNow.AddDays(-1365).GetDiffrenceToNow(); var d1 = new PersianDateTime(1397, 5, 31); var d2 = new PersianDateTime(1397, 6, 8); var d3 = new PersianDateTime(1399, 6, 7); var d4 = new PersianDateTime(1410, 10, 24); var str = d1.ToString("YYYY/mm/dd"); d1 = new PersianDateTime(1397, 6, 31); str = d1.ToString("yyyy/MM/dd h:mm tt"); str = d1.ToString("dddd, dd MMMM yyyy"); str = d1.ToString("dddd, dd MMMM yyyy HH:mm"); str = d1.ToString("yyyy/MM/dd HH:mm"); str = d1.ToString("yyyy/MM/dd HH:mm:ss"); var dn = PersianDateExtensions.GenerateYearlyCalender(1375); var item = d1.DateMetaDatas; DateTime date = DateTime.Now; var dt2 = new PersianDateTime("1399/11/29"); var y1 = dt2.GetHijriDate(); var y = DateTime.UtcNow.GetHijriDate(); var x = DateTime.UtcNow.GetDiffrenceToNow(); var x1 = DateTime.UtcNow.AddDays(-10).GetDiffrenceToNow(); var x2 = DateTime.UtcNow.AddDays(-100).GetDiffrenceToNow(); //var x3 = PersianDateTime.GetDiffrenceToNow(DateTime.UtcNow.AddDays(-1365)); var x4 = DateTime.UtcNow.AddDays(365).GetDiffrenceToNow(); var x5 = DateTime.UtcNow.AddDays(10).GetDiffrenceToNow(); var x6 = DateTime.UtcNow.AddDays(100).GetDiffrenceToNow(); var x7 = DateTime.Now.GetDiffrenceToNow(); var x9 = new PersianDateTime(1397, 1, 1); //var y7 = y6.AddWeeks(5); //var y8 = y7.AddYears(-5); //var y9 = y8.AddMonths(18); //var n = y8.ToLongStringHMS(); //var n1 = y7.ToLongStringYMD(); //var n2 = x4.ToLongStringYMDHM(); //var n3 = x3.ToLongStringYMDHMS(); }
public JsonResult InsertInvoice() { PersianDateTime now = PersianDateTime.Now; var DateTime = now.ToString(); var Invoice = new Tbl_Invoices { UserID = 1007, SellerID = 1008, DateTime = DateTime, InvoiceStatesID = 1, Description = "خرید از فروشگاه تهران" }; _context.Tbl_Invoices.Add(Invoice); _context.SaveChanges(); int LastInvoiceId = _context.Database.SqlQuery <int>(@"select top 1 Id from Tbl_Invoices order by Id desc").FirstOrDefault <int>(); return(Json(LastInvoiceId, JsonRequestBehavior.AllowGet)); }
public List <ProductModel> productModels_List(string Query) { PDBC db = new PDBC("PandaMarketCMS", true); db.Connect(); DataTable dt = db.Select(Query); List <ProductModel> list = new List <ProductModel>(); for (int i = 0; i < dt.Rows.Count; i++) { DateTime date = Convert.ToDateTime(dt.Rows[i]["DateCreated"]); PersianDateTime persianDateTime = new PersianDateTime(date); var model = new ProductModel() { Num = i + 1, Id = Convert.ToInt32(dt.Rows[i]["id_MProduct"]), Title = dt.Rows[i]["Title"].ToString(), Description = dt.Rows[i]["Description"].ToString(), AddBy = dt.Rows[i]["AddBy"].ToString(), MainPrice = dt.Rows[i]["price"].ToString(), Category = dt.Rows[i]["SubCat"].ToString() + "_" + dt.Rows[i]["MainCat"].ToString() + "_" + dt.Rows[i]["type"].ToString(), Date = persianDateTime.ToString(), PicPath = AppendServername(dt.Rows[i]["pic"].ToString()) }; if (dt.Rows[i]["IS_AVAILABEL"].ToString() == "1") { model.disabled = false; } else { model.disabled = true; } if (dt.Rows[i]["ISDELETE"].ToString() == "1") { model.deleted = true; } else { model.deleted = false; } list.Add(model); } return(list); }
private void _btnLogin_Click(object sender, RoutedEventArgs e) { User us = new User() { Username = _txtUsername.Text.Trim() , Password = _txtPassword.Password.ToString().Trim() }; try { var query = db.Users.Single(x => x.Username == us.Username && x.Password == us.Password); if (query != null) { User user = (User)query; if (user.Type == _cmbType.Text && user.Type == "مدیر") { user.Type = "مدیر"; Main win = new Main(user); win.Show(); this.Close(); } else if (user.Type == _cmbType.Text && user.Type == "کاربر") { user.Type = "کاربر"; PersianDateTime pdt = PersianDateTime.Now; query.LastEntry = pdt.ToString(); db.SaveChanges(); MainUser win = new MainUser(user); win.Show(); this.Close(); } else { MessageBox.Show(".نام کاربری یا رمز عبور اشتباه است", "پیغام", MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (Exception) { MessageBox.Show(".نام کاربری یا رمز عبور اشتباه است", "پیغام", MessageBoxButton.OK, MessageBoxImage.Error); } }
public ActionResult AddArticle(AddNewArticleGetViewModel model) { if (ModelState.IsValid) { var persiandate = new PersianDateTime(DateTime.Now); string UserId = userManager.GetUserId(HttpContext.User); Article article = new Article { Title = model.Title, Abstract = model.Abstract, Body = model.Body, PublishDate = persiandate.ToString(), Status = ArticleStatus.PrePublish, CategoryId = model.SelectedCat, Likes = 0, ViewCount = 0, AspNetUsersId = int.Parse(UserId) }; string FileName = ""; if ((model?.Image?.Length > 0) && ((model?.Image?.ContentType == "image/jpeg") || (model?.Image?.ContentType == "image/jpg"))) { FileName = uploadFileRepository.UplaodFile(model.Image, "\\Images\\"); article.Image = @"~/images/" + FileName; } if ((model?.Video?.Length > 0) && (model?.Video?.ContentType == "video/mp4")) { FileName = uploadFileRepository.UplaodFile(model.Video, "\\Video\\"); article.Video = @"~/video/" + FileName; } if ((model?.PDF?.Length > 0) && (model?.PDF?.ContentType == "application/pdf")) { FileName = uploadFileRepository.UplaodFile(model.PDF, "\\Pdf\\"); article.PDF = @"~/pdf/" + FileName; } articleRepository.Add(article); return(RedirectToAction(nameof(ListArticle))); } else { return(RedirectToAction(nameof(ListArticle))); } }
public ActionResult AddInvoice(int id) { if (Session["UserId"] != null) { int LastInvoiceId = (_context.Database.SqlQuery <int>(@"select top 1 Id from Tbl_Invoices order by Id desc").FirstOrDefault <int>()) + 1; ViewBag.InvoiceId = LastInvoiceId; PersianDateTime now = PersianDateTime.Now; var DateTime = now.ToString("dddd d MMMM yyyy ساعت hh:mm:ss tt"); ViewBag.DateTime = DateTime; var DbUser = _context.Tbl_User.SingleOrDefault(u => u.BIZCode == id.ToString()); ViewBag.Name = DbUser.Name; return(View()); } else { return(RedirectToAction("Login", "Home")); } }
public static AttendanceSpanVM GetVM(AttendanceSpan span) { var vm = new AttendanceSpanVM(); vm.AttendanceSpanId = span.AttendanceSpanId; vm.TimeType = span.TimeType; vm.TimeTypeName = EnumName.GetWorkTimeType(span.TimeType); perDtStart = new PersianDateTime(span.StartAttendanceTime.DateTime); vm.StartTime = perDtStart.ToString("hh:mm:ss tt"); if (span.EndAttendanceTime != null) { perDtEnd = new PersianDateTime(span.EndAttendanceTime.DateTime); vm.EndTime = perDtEnd.ToString("hh:mm:ss tt"); TimeSpan sp = span.EndAttendanceTime.DateTime.Subtract(span.StartAttendanceTime.DateTime); vm.DurationSecends = System.Convert.ToInt64(sp.TotalSeconds); vm.Duration = Environment.Convert.TimeSpanToReadableString(sp); } return(vm); }
public JsonResult InsertUserBalance(string UserId, string BalancePrice, string Temp) { PersianDateTime now = PersianDateTime.Now; var DateTime = now.ToString(); var Purchase = new Tbl_SirjanPurchase { }; if (Temp == "Increase") { Purchase = new Tbl_SirjanPurchase { UserId = Convert.ToInt32(UserId), PurchaseId = 3, Price = BalancePrice, DateTime = DateTime, Description = "افزایش سهام کاربر" }; } else if (Temp == "Decrease") { Purchase = new Tbl_SirjanPurchase { UserId = Convert.ToInt32(UserId), PurchaseId = 4, Price = BalancePrice, DateTime = DateTime, Description = "کاهش سهام کاربر" }; } _context.Tbl_SirjanPurchase.Add(Purchase); _context.SaveChanges(); return(Json("Successful", JsonRequestBehavior.AllowGet)); }
public static string ConvertMiladiToShamsi(this DateTime?date, string format) { PersianDateTime persianDateTime = new PersianDateTime(date); return(persianDateTime.ToString(format)); }
public string ConvertMiladiToShamsi(DateTime Date, string Format) { PersianDateTime persianDateTime = new PersianDateTime(Date); return(persianDateTime.ToString(Format)); }
public static string ToStandardString(this PersianDateTime dateTime) { return(dateTime.ToString("yyyy-MM-dd HH:mm:ss")); }
public static string ConvertGeorgianToPersian(this DateTime?date, string format) { PersianDateTime persianDateTime = new PersianDateTime(date); return(persianDateTime.ToString(format)); }
public string MiladiToShamsi(DateTime date) { PersianDateTime persianDateTime = new PersianDateTime(date); return(persianDateTime.ToString("dd/MMMM/yyyy")); }
public static async Task RunBot() { var bot = new TelegramBot(Token) { WebProxy = new System.Net.WebProxy("127.0.0.1:6661") }; var me = await bot.MakeRequestAsync(new GetMe()); Console.WriteLine("usename is {0}", me.Username); long offset = 0; int whilecount = 0; while (true) { whilecount++; var updates = await bot.MakeRequestAsync(new GetUpdates() { Offset = offset }); Console.WriteLine("----------------------------------------"); try { foreach (var update in updates) { offset = update.UpdateId + 1; var text = update.Message.Text; Console.WriteLine(update.Message.From.FirstName + " and ID is : " + update.Message.Chat.Id + " : " + text); if (text == "/start") { var req = new SendMessage(update.Message.Chat.Id, "چی میخوای؟"); await bot.MakeRequestAsync(req); continue; } else if (text.Contains("گمشو") && update.Message.From.Username == "infeXno") { var req = new SendMessage(update.Message.Chat.Id, "دیگه دوستتون ندارم :("); await bot.MakeRequestAsync(req); var leave = new LeaveChat(update.Message.Chat.Id); await bot.MakeRequestAsync(leave); } else if (text == "job is") { string xxx = Convert.ToString(job); var req = new SendMessage(update.Message.Chat.Id, "job value is : " + xxx); await bot.MakeRequestAsync(req); continue; } else if (text.Contains("دلار")) { if (update.Message.From.Username != "infeXno") { WebClient n = new WebClient(); var json = n.DownloadString("http://www.tgju.org/?act=sanarateservice&client=tgju&noview&type=json"); Arz a1 = JsonConvert.DeserializeObject<Arz>(json); string dollar = a1.sana_buy_usd.price; string toman = dollar.Remove(6); string nocomma = toman.Replace(",", ""); var req = new SendMessage(update.Message.Chat.Id, "الان قیمت هر دلار " +nocomma + " تومن هستش"); req.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(req); } else { WebClient n = new WebClient(); var json = n.DownloadString("http://www.tgju.org/?act=sanarateservice&client=tgju&noview&type=json"); Arz a1 = JsonConvert.DeserializeObject<Arz>(json); string dollar = a1.sana_buy_usd.price; string toman = dollar.Remove(6); string nocomma = toman.Replace(",", ""); var req = new SendMessage(update.Message.Chat.Id, "ددی الان قیمت هر دلار " + nocomma + " تومن هستش ^^♥"); req.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(req); } continue; } else if (text.Contains("چندمه") || text.Contains("تاریخ") || text.Contains("time") || text.Contains("ساعت چنده")) { PersianDateTime time = PersianDateTime.Now; string h = time.Hour.ToString(); string m = time.Minute.ToString(); string s = time.Second.ToString(); string hms = (h + ":" + m + ":" + s); string date = time.ToString("dddd d MMMM yyyy ساعت "); string t = (date + hms); if (update.Message.From.Username != "infeXno") { var req = new SendMessage(update.Message.Chat.Id, t); req.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(req); } else { var req = new SendMessage(update.Message.Chat.Id, "ددی امروز " + t + " هستش ♥ "); req.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(req); } continue; } else if (text == "/hava" || text == "/hava@petshibot") { string s = "با این دستور میتونم وضعیت آب و هوا رو بهت بگم این شکلی میتونی استفاده کنی : \n /hava 'نام شهر'"; var req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); continue; } else if (text.Contains("/hava")) { string s1 = text; char[] ch = new char[] { ' ' }; string[] result; result = s1.Split(ch, 2); string location = result[1]; WebClient n = new WebClient(); var json = n.DownloadString("http://api.apixu.com/v1/current.json?key=1c5183723cba412ab6a102839182910&q=" + location); weather w1 = JsonConvert.DeserializeObject<weather>(json); string temp = Convert.ToString(Convert.ToInt32(w1.current.temp_c)); string stat = w1.current.condition.text; switch (w1.current.condition.code) { case 1000: string s = "امروز اونجا " + temp + " درجست و هوا صاف هستش ^^"; var req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; case 1003: s = "امروز اونجا " + temp + " درجست و هوا نیمه ابری هستش ^^"; req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; case 1006: s = "امروز اونجا " + temp + " درجست و هوا ابری هستش ^^"; req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; case 1009: s = "امروز اونجا " + temp + " درجست و هوا کاملا ابری هستش ^^"; req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; case 1030: s = "امروز اونجا " + temp + " درجست و هوا مرطوبه ^^"; req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; case 1135: s = "امروز اونجا " + temp + " درجست و هوا مه آلود هستش ^^"; req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; case 1183: s = "امروز اونجا " + temp + " درجست و یکم بارون میاد ^^"; req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; case 1186: s = "امروز اونجا " + temp + " درجست و بعضی وقتا بارون میاد ^^"; req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; case 1189: s = "امروز اونجا " + temp + " درجست و یه مقدار بارون داریم ^^"; req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; case 1192: s = "امروز اونجا " + temp + " درجست و بارون زیادی داریم ^^"; req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; case 1195: s = "امروز اونجا " + temp + " درجست و بارون زیادی داریم ^^"; req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; default: s = "امروز اونجا " + temp + "درجست و " +stat + " هستش"; req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); break; } continue; } else if (text == "/mani" || text == "/mani@petshibot") { string s = "با این دستور میتونم معنی هر کلمه ای رو بهت بگم ^^ این شکلی میتونی استفاده کنی : \n /mani 'کلمه'"; var req = new SendMessage(update.Message.Chat.Id, s); req.ReplyToMessageId = (update.Message.MessageId); await bot.MakeRequestAsync(req); continue; } else if (text.Contains("/mani")) { string s1 = text; char[] ch = new char[] { ' ' }; string[] result; result = s1.Split(ch, 2); string kalame = result[1]; WebClient n = new WebClient(); var json = n.DownloadString("http://api.urbandictionary.com/v0/define?term=" + kalame); mani m1 = JsonConvert.DeserializeObject<mani>(json); if (m1.list.Length > 0) { string man = m1.list[0].definition + "\n\n Examples : \n" + m1.list[0].example; string edit = man.Replace("[", ""); string edit1 = edit.Replace("]", ""); string edit2 = edit1.Replace("’", ""); var req = new SendMessage(update.Message.Chat.Id, edit2); req.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(req); } else { string man = "معنی این کلمه رو نتونستم پیدا کنم :("; var req = new SendMessage(update.Message.Chat.Id, man); req.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(req); } continue; } /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////SEND MY MESSAGE COMMAND PART///////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// ///////SEND MESSAGE FROM COMMAND CENTER///////// else if (update.Message.From.Username == "infeXno" && update.Message.Chat.Id == -224286003) { string s1 = text; char[] ch = new char[] { ' ' }; string[] result; result = s1.Split(ch, 2); long target = Convert.ToInt64(result[0]); string str = result[1]; var req = new SendMessage(target, str); //my messages goes here ! await bot.MakeRequestAsync(req); continue; } //////////////////////////PRIVATE PART///////////////////////////// //////////////////////////PRIVATE PART///////////////////////////// //////////////////////////PRIVATE PART///////////////////////////// //////////////////////////PRIVATE PART///////////////////////////// //////////////////////////PRIVATE PART///////////////////////////// //////////////////////////PRIVATE PART///////////////////////////// //////////////////////////PRIVATE PART///////////////////////////// //////////////////////////PRIVATE PART///////////////////////////// //////////////////////////PRIVATE PART///////////////////////////// //////////////////////////PRIVATE PART///////////////////////////// //////////////////////////PRIVATE PART///////////////////////////// //recieve privates //and answer them else if (update.Message.Chat.Type == "private") { var req = new SendMessage(-224286003, update.Message.Chat.Id + ""); await bot.MakeRequestAsync(req); var forw = new ForwardMessage(-224286003, update.Message.Chat.Id, update.Message.MessageId); await bot.MakeRequestAsync(forw); //////////////////////KNOWN PEOPLE////////////////////// ////////////////REGULAR GROUP SETTINGS////////////////////// ////////////////REGULAR GROUP SETTINGS////////////////////// ////////////////REGULAR GROUP SETTINGS////////////////////// ////////////////REGULAR GROUP SETTINGS////////////////////// ////////////////REGULAR GROUP SETTINGS////////////////////// ////////////////REGULAR GROUP SETTINGS////////////////////// ////////////////REGULAR GROUP SETTINGS////////////////////// else if (update.Message.Chat.Type == "supergroup" || update.Message.Chat.Type == "group") { if (update.Message.From.Id == 226349493) /////this is ME { if (text.Contains("دختر") || text.Contains("ربات")) { string[] asd = new string[] { " یس ددی", "ددیم ♥", " ♥:))" }; Random rnd = new Random(); int rand = rnd.Next(0, 2); var jvb = new SendMessage(update.Message.Chat.Id, asd[rand]); jvb.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(jvb); } else if (text.Contains("/off")) { var req = new SendMessage(update.Message.Chat.Id, "ربات خاموش شد."); await bot.MakeRequestAsync(req); job = 0; } else if (text.Contains("/on")) { var req = new SendMessage(update.Message.Chat.Id, "اماده خدمت :)"); await bot.MakeRequestAsync(req); job = 1; } else if (update.Message.ReplyToMessage.From.Id == 373634438) { string[] asd = new string[] { "لاو یو ددی", ":* بوچ بوچ", "^^", "+__+" }; Random rnd = new Random(); int rand = rnd.Next(0, 3); var jvb = new SendMessage(update.Message.Chat.Id, asd[rand]); jvb.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(jvb); } else if (update.Message.ReplyToMessage.From.Id == 373634438 && text.Contains("salam") || text.Contains("سلم") || text.Contains("سلام") || text.Contains("slm")) { string[] asd = new string[] { " های ددی", " سلام ددیمون", " :))", "سلام ددی ♥ :))" }; Random rnd = new Random(); int rand = rnd.Next(0, 3); var req = new SendMessage(update.Message.Chat.Id, asd[rand]); req.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(req); } } else if (text.Contains("ربات")) { string[] asd = new string[] { "؟؟", "چیه ", " بله" }; Random rnd = new Random(); int rand = rnd.Next(0, 2); var jvb = new SendMessage(update.Message.Chat.Id, asd[rand]); jvb.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(jvb); } else if (update.Message.From.Username != "infeXno" && text.Contains("خوب") || text.Contains("بد") || text.Contains("اره")) { if (update.Message.ReplyToMessage.From.Id == 373634438) { string[] asd = new string[] { " خوبه", " خدارو شکر", " :))" }; Random rnd = new Random(); int rand = rnd.Next(0, 5); if (rand <= 2) { var jvb = new SendMessage(update.Message.Chat.Id, asd[rand]); jvb.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(jvb); } } } else if (update.Message.ReplyToMessage.From.Id == 373634438 && text.Contains("salam") || text.Contains("سلم") || text.Contains("سلام") || text.Contains("slm")) { string[] asd = new string[] { " سلام", " سلام :))", "های" }; Random rnd = new Random(); int rand = rnd.Next(0, 2); var req = new SendMessage(update.Message.Chat.Id, asd[rand]); req.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(req); continue; } } } } catch (WebException) { foreach (var update in updates) { var req = new SendMessage(update.Message.Chat.Id, "پیدا نکردم :("); req.ReplyToMessageId = update.Message.MessageId; await bot.MakeRequestAsync(req); } } catch (Exception) { continue; } } }
public static string ToTimeString(this PersianDateTime dt) { return(dt.ToString("hh:mm:ss")); }
private string CombineDates(PersianDateTime persianDate) => $"{persianDate.ToString("yyyy/MM/dd")} - {persianDate.HijriDate.Year}/{persianDate.HijriDate.Month}/{persianDate.HijriDate.Day}";
public static string ToDateString(this PersianDateTime dt) { return(dt.ToString("yyyy/MM/dd")); }