public string FormatDateTime(Object obj) { string Result = ""; try { if (obj != null) { DateTime CurDT = Convert.ToDateTime(obj); DateTimeMethods dtm = new DateTimeMethods(); Result = Tools.ChageEnc(dtm.GetPersianDate(CurDT)); string strCurrentMin = CurDT.Minute.ToString(); if (strCurrentMin.Length == 1) { strCurrentMin = "0" + strCurrentMin; } Result += " ساعت: " + Tools.ChageEnc(CurDT.Hour + ":" + strCurrentMin); } return(Result); } catch { return(""); } }
public string PersianDate(Object obj) { try { if (obj != null) { DateTimeMethods dtm = new DateTimeMethods(); DateTime objDate = Convert.ToDateTime(obj); //return Tools.ChangeEnc(objDate.ToShortTimeString().Replace("AM", "").Replace("PM", "") + " - " + dtm.GetPersianDate(objDate)); if (_timeFormat == TimeFormats.PerfectTime) { return(Tools.ChangeEnc(objDate.ToString("H:mm:ss") + " - " + dtm.GetPersianDate(objDate))); } else { return(Tools.GetPrettyPersianDate2(objDate)); } } else { return(""); } } catch { return(""); } }
public void StringToDateTime_NotADateTime_ReturnsNull() { string Input = "7837:68 8ml"; DateTime?Result = DateTimeMethods.StringToDatetime(Input); Assert.IsNull(Result); }
public void StringToDateTime_InvalidDate_ReturnsNull() { string Input = "30:02:2019 8pm"; DateTime?Result = DateTimeMethods.StringToDatetime(Input); Assert.IsNull(Result); }
protected void Page_Load(object sender, EventArgs e) { //HtmlGenericControl script = new HtmlGenericControl("script"); //script.Attributes.Add("src", this.ResolveClientUrl("~/Admin/Scripts/farsi.js")); //script.Attributes.Add("type", "text/javascript"); //Page.Header.Controls.Add(script); if (!Page.IsPostBack) { int Code = 0; string strCode = Request["Code"]; Int32.TryParse(strCode, out Code); BOLNews NewsBOL = new BOLNews(); News CurNews = ((IBaseBOL <News>)NewsBOL).GetDetails(Code); if (CurNews != null) { NewsCode = Code.ToString(); ViewState["Code"] = CurNews.Code; lblSuTitr.Text = CurNews.SoTitr; Page.Title = lblTitle.Text = CurNews.Title; DateTimeMethods dtm = new DateTimeMethods(); string strDateTime = ""; string strCurrentMin = CurNews.NewsDate.Minute.ToString(); strDateTime += Tools.ChageEnc(dtm.GetPersianLongDate(CurNews.NewsDate)); strDateTime += " ساعت: " + Tools.ChageEnc(CurNews.NewsDate.Hour + ":" + strCurrentMin); lblDate.Text = strDateTime; lblNewsCode.Text = " کد : " + Tools.ChageEnc(CurNews.Code.ToString()); if (!string.IsNullOrEmpty(CurNews.PicFile1)) { hplImage.ImageUrl = CurNews.PicFile1; hplImage.NavigateUrl = CurNews.PicFile1; } else { hplImage.ImageUrl = "~/images/Nopic.gif"; } string Abstract = CurNews.Abstract; Abstract = Abstract.Replace("style=", "style1="); Abstract = Abstract.Replace("<br />", "</p><p>"); //NewBody = NewBody.Replace("<div", "<p"); ltrNewsBody.Text = Tools.FormatText(Abstract); BOLComments CommentsBOL = new BOLComments(); int CommentCount = CommentsBOL.GetCommentCount(CurNews.Code); lblAbstract.Text = Tools.FormatText(CurNews.Abstract); } } }
public async Task set_timezones([Remainder] string input = null) { using (var database = new GuildDB()) { // log command execution CommandMethods.LogExecution(logger, "set timezones", Context); // indicate that the bot is working on the command await Context.Channel.TriggerTypingAsync(); var language = statecollection.GetLanguage(Context.Guild, database); // make sure that the user has the right permissions if (!PermissionHelper.UserHasPermission(Context.User as SocketGuildUser, PermissionHelper.Admin, database)) { await Context.Channel.SendMessageAsync(language.GetString("command.nopermission")); return; } await Context.Channel.SendMessageAsync(language.GetString("command.set.timezones.wait")); // find all the current roles in the guild IEnumerable <SocketRole> present = from role in Context.Guild.Roles where DateTimeMethods.IsTimezone(role.Name) select role; // add all the timezones that are not present already foreach (string t in DateTimeMethods.Timezones()) { if (!present.Any(x => x.Name == t)) { var role = await Context.Guild.CreateRoleAsync(t, isHoisted : false, permissions : constants.RolePermissions); await role.ModifyAsync(x => { x.Mentionable = false; }); } } // update the roles of the timezones that áre present foreach (SocketRole sr in present) { await sr.ModifyAsync((x) => { x.Permissions = constants.RolePermissions; x.Mentionable = false; }); } // return success to the user await Context.Channel.TriggerTypingAsync(); await Context.Channel.SendMessageAsync(statecollection.GetLanguage(Context.Guild, database).GetString("command.set.timezones.done")); } }
public void StringToTime_InvalidInput_ReturnsNull() { // Arrange string Input = "6om"; // Act TimeSpan?Result = DateTimeMethods.StringToTime(Input, true); // Assert Assert.IsNull(Result); }
public void StringToTime_NoTimeInAString_ReturnsNull() { // Arrange string Input = "Our event starts at $7sm today"; // Act TimeSpan?Result = DateTimeMethods.StringToTime(Input); // Assert Assert.IsNull(Result); }
public void StringToTime_TimeInAString_ReturnsCorrectTime() { // Arrange string Input = "Our event starts at $7am tomorrow."; // Act TimeSpan?Result = DateTimeMethods.StringToTime(Input); // Assert TimeSpan Expected = new TimeSpan(7, 0, 0); Assert.IsNotNull(Result); Assert.AreEqual(Result, Expected); }
public void StringToDateTime_ValidInput_ReturnsCorrectDateTime() { // Arrange string Input = "23:07:1998 8pm"; // Act DateTime?Result = DateTimeMethods.StringToDatetime(Input); // Assert DateTime Expected = new DateTime(1998, 7, 23, 20, 0, 0); Assert.IsNotNull(Result); Assert.AreEqual(Expected, Result); }
private IEnumerable <TimedMessage> TimedMessagesFromEvent(EventAndNotifications ev) { foreach (var en in ev.Notifications) { yield return(new TimedMessage { Date = en.Date, Keyword = en.ResponseKeyword, Context = new SentenceContext() .Add("title", ev.Event.Name) .Add("time", DateTimeMethods.TimeSpanToString(ev.Event.Date - en.Date)), }); } }
public void StringToTime_ValidInput_ReturnsCorrectTime() { // Arrange string Input = "8:30pm"; // Act TimeSpan?Result = DateTimeMethods.StringToTime(Input, true); // Assert TimeSpan Expected = new TimeSpan(20, 30, 0); Assert.IsNotNull(Result); Assert.AreEqual(Result.Value, Expected); }
public async Task AnalyseTime(SocketCommandContext Context) { using (var database = new GuildDB()) { // first make sure that the user has the correct permissions if (!PermissionHelper.UserHasPermission(Context.User as SocketGuildUser, PermissionHelper.Member, database)) { return; } DateTime now = DateTime.UtcNow; // check if the text contains a time indication TimeSpan?FoundTime = DateTimeMethods.StringToTime(Context.Message.Content); if (!FoundTime.HasValue) { return; } // check if the user has a timezone applied TimeZoneInfo tz = DateTimeMethods.UserToTimezone(Context.User); if (tz == null) { return; } // indicate that the bot is working on the answer await Context.Channel.TriggerTypingAsync(); var language = statecollection.GetLanguage(Context.Guild, database); // find the desired date time in the local time DateTime dt = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0) + FoundTime.Value; // print the table to the chat string result = DateTimeMethods.TimetableToString(DateTimeMethods.LocalTimeToTimetable(dt, tz, Context.Guild)); await Context.Channel.SendMessageAsync(language.GetString("scan.time.found")); await Context.Channel.TriggerTypingAsync(); await Context.Channel.SendMessageAsync(result); return; } }
public string FormatDate(Object obj) { string Result = ""; try { if (obj != null) { DateTime CurDT = Convert.ToDateTime(obj); DateTimeMethods dtm = new DateTimeMethods(); Result = Tools.ChageEnc(dtm.GetPersianLongDate(CurDT)); } return(Result); } catch { return(""); } }
public string ShowDate(Object obj) { string Result = ""; try { if (obj != null) { DateTime dtCommentDate = Convert.ToDateTime(obj); DateTimeMethods dtm = new DateTimeMethods(); Result = dtm.GetPersianDate(dtCommentDate); Result = Tools.ChangeEnc(Result); } return(Result); } catch { return(""); } }
public async Task RestoreApplication(SocketGuild guild, GuildDB database) { // check if this guild has applications ApplicationTB application = GetApplicationEntry(guild, database); if (application == null) { logger.Log(new LogMessage(LogSeverity.Info, "State", $"'{guild.Name}' currently has no application.")); return; } // make sure that there is not an already active notifier // (This could happen, because GuildAvailable gets called when Betty loses connection with discord) CancellationTokenSource t = GetApplicationToken(guild); if (t != null) { if (!t.IsCancellationRequested) { // if it's still active, there is no need to restore the application logger.Log(new LogMessage(LogSeverity.Warning, "State", $"Found an active notifier for application.")); return; } else { // if it's not active, then there is something wrong with the code, but then a new notifier can be created still logger.Log(new LogMessage(LogSeverity.Error, "State", $"Found a notifier, but cancellation was requested. This should never happen!!")); } } // create notifier SocketTextChannel channel = GetApplicationChannel(guild, database, application); IInviteMetadata invite = await GetApplicationInvite(guild, database, application, channel); var token = notifier.CreateWaiterTask(guild, channel, messages: DateTimeMethods.BuildMessageList(constants.ApplicationNotifications, application.Deadline, "Application selection"), action: async(db) => { await ExpireAppLink(invite); }); SetApplicationToken(guild, database, token); }
public string PersianDate(Object obj) { try { if (obj != null) { DateTimeMethods dtm = new DateTimeMethods(); DateTime objDate = Convert.ToDateTime(obj); return(Tools.ChangeEnc(objDate.ToShortTimeString().Replace("AM", "").Replace("PM", "") + " - " + dtm.GetPersianDate(objDate))); } else { return(""); } } catch { return(""); } }
public bool Plan(SocketGuild guild, GuildDB database, string name, DateTime date, SocketTextChannel channel = null, bool doNotifications = true, TimeSpan[] notifications = null) { // generate database data var ev = StoreEventInDatabase(guild, database, name, date, channel, doNotifications, notifications); // create notifier for this event var token = notifier.CreateWaiterTask(guild, null, messages: DateTimeMethods.BuildMessageList(constants.EventNotifications, ev.Event.Date, ev.Event.Name), action: (db) => { Cancel(ev.Event, db); }); // store cancellation token if (!notifiercollection.TryAdd(ev.Event.EventId, token)) { // log failure and report back logger.Log(new LogMessage(LogSeverity.Error, "Agenda", "Attempted to store cancellation token for event, but failed")); return(false); } return(true); }
public async Task unset_timezones([Remainder] string input = null) { using (var database = new GuildDB()) { // log command execution CommandMethods.LogExecution(logger, "unset timezones", Context); // indicate that the bot is working on the command await Context.Channel.TriggerTypingAsync(); var language = statecollection.GetLanguage(Context.Guild, database); // make sure that the user has the right permissions if (!PermissionHelper.UserHasPermission(Context.User as SocketGuildUser, PermissionHelper.Owner, database)) { await Context.Channel.SendMessageAsync(language.GetString("command.nopermission")); return; } await Context.Channel.SendMessageAsync(language.GetString("command.unset.timezones.wait")); // find all the current roles in the guild IEnumerable <KeyValuePair <string, ulong> > roles = Context.Guild.Roles.Select(r => new KeyValuePair <string, ulong>(r.Name, r.Id)); // delete all the roles that are timezones foreach (var t in roles) { if (DateTimeMethods.IsTimezone(t.Key)) { await Context.Guild.GetRole(t.Value).DeleteAsync(); } } await Context.Channel.TriggerTypingAsync(); await Context.Channel.SendMessageAsync(language.GetString("command.unset.timezones.done")); } }
public ISensorsDatabase GetDatabase(DateTime time) { long ticks = time.Ticks; lock (_accessLock) { var correspondingItem = _sensorsDatabases.FirstOrDefault(i => i.DatabaseMinTicks <= ticks && i.DatabaseMaxTicks >= ticks); if (correspondingItem != null) { return(correspondingItem); } DateTime minDateTime = DateTimeMethods.GetMinDateTime(time); DateTime maxDateTime = DateTimeMethods.GetMaxDateTime(time); string newDatabaseName = CreateSensorsDatabaseName(minDateTime, maxDateTime); ISensorsDatabase newDatabase = LevelDBManager.GetSensorDatabaseInstance( _databaseSettings.GetPathToMonitoringDatabase(newDatabaseName), minDateTime, maxDateTime); _sensorsDatabases.Add(newDatabase); Task.Run(() => _environmentDatabase.AddMonitoringDatabaseToList(newDatabaseName)); return(newDatabase); } }
protected void Page_Load(object sender, EventArgs e) { #region Tab Pages if (!NewMode) { ShowDetails(); } else { RadMultiPage1.SelectedIndex = 0; tsMultiMedias.Tabs[0].Selected = true; } #endregion BOLClass = new BOLMultiMedias(); lblSysName.Text = BOLClass.PageLable; if ((Code == null) && (!NewMode)) { return; } if (!Page.IsPostBack) { #region Fill Combo cboHCPicTypeCode.DataSource = new BOLHardCode().GetHCDataTable("HCPicTypes"); #endregion if (!NewMode) { LoadData((int)Code); BOLMultiMedias MultiMediasBOL = new BOLMultiMedias(); MultiMedias CurRecord = ((IBaseBOL <MultiMedias>)MultiMediasBOL).GetDetails((int)Code); DateTimeMethods dtm = new DateTimeMethods(); lblCreateDateVal.Text = dtm.GetPersianDate((DateTime)CurRecord.CreateDate); } } }
private void CheckRequestStatus(string strAuthority) { try { int UserCode = 0; int BankCode = 1; BOLUserTransactions UserTransactionsBOL = new BOLUserTransactions(1); vUserTransactions CurTransaction = UserTransactionsBOL.GetTransByAuthority(strAuthority); if (CurTransaction != null) { if (CurTransaction.HCTransStatusCode == 2) { msgMessage.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Warning; msgMessage.Text = "این تراکنش قبلا تایید شده است."; return; } //byte Status = 1; //Ranjbaran.ParsianBankWS.EShopService ParsianService = new Ranjbaran.ParsianBankWS.EShopService(); //ParsianService.PinPaymentEnquiry(ConfigurationManager.AppSettings["ParsianPin"], Convert.ToInt64(strAuthority), ref Status); ir.shaparak.pec1.ConfirmService ConfirmClass = new ir.shaparak.pec1.ConfirmService(); ClientConfirmRequestData CCR = new ClientConfirmRequestData(); CCR.Token = Convert.ToInt64(strAuthority); CCR.LoginAccount = ConfigurationManager.AppSettings["ParsianPin"]; ClientConfirmResponseData ClientResponse = ConfirmClass.ConfirmPayment(CCR); if (ClientResponse.Status == 0) { string errMessage = ""; UserTransactionsBOL.ChangeStatus(CurTransaction.Code, 2); int UserTransactionCode = UserTransactionsBOL.Insert(CurTransaction.UserCode, DateTime.Now, 2, 1, "", -1 * (int)CurTransaction.Amount, 1, BankCode, "", 0, out errMessage, ClientResponse.CardNumberMasked, ClientResponse.RRN); Response.Write(errMessage); lblTotalAmount.Text = CurTransaction.Amount.ToString(); lblPaymentStatus.Text = "پرداخت شده"; DateTimeMethods dtm = new DateTimeMethods(); msgMessage.MessageTextMode = AKP.Web.Controls.Common.MessageMode.OK; msgMessage.Text = "پرداخت با موفقیت انجام شد."; ViewState["TransactionCode"] = CurTransaction.Code; ltrMessage.Text = "آقای/خانم " + CurTransaction.FirstName + " " + CurTransaction.LastName + " خرید شما انجام پذیرفت. شماره پیگیری:" + CurTransaction.Code + " تاریخ:" + CurTransaction.ChrgDate + "<br /> با تشکر از شما <br />انتشارات اثبات"; return; } else { msgMessage.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; msgMessage.Text = "مشترک گرامی، پرداخت الکترونیک شما با موفقیت انجام نشد، این مشکل معمولاً در مواردی رخ میدهد که شما در صفحه بانک پرداخت را تایید نمیکنید، در حساب خود به اندازه کافی موجودی ندارید، مشکلی در برقرار ارتباط با بانک بوجود آمده و ... در هر صورت جای نگرانی وجود ندارد، چرا که هیچ وجهی از حساب شما کسر نشده است.. کد خطا:" + ClientResponse.Status; } } } catch (Exception ex) { msgMessage.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; msgMessage.Text += "بروز خطا : " + ex.Message + "<BR>"; return; } }
public async Task StartApplications([Remainder] string input = null) { using (var database = new GuildDB()) { // log command execution CommandMethods.LogExecution(logger, "application start", Context); // indicate that the bot is working on the command await Context.Channel.TriggerTypingAsync(); GuildTB dbentry = statecollection.GetGuildEntry(Context.Guild, database); var language = statecollection.GetLanguage(Context.Guild, database, dbentry); // make sure that the user has the right permissions if (!PermissionHelper.UserHasPermission(Context.User as SocketGuildUser, PermissionHelper.Admin, database)) { await Context.Channel.SendMessageAsync(language.GetString("command.nopermission")); return; } // allow only 1 application per guild if (statecollection.GetApplicationEntry(Context.Guild, database) != null) { await Context.Channel.SendMessageAsync(language.GetString("command.appstart.isactive")); return; } // command must have input if (input == null) { await Context.Channel.SendMessageAsync(language.GetString("command.appstart.empty")); return; } // user must have a timezone TimeZoneInfo usertimezone = DateTimeMethods.UserToTimezone(Context.User); if (usertimezone == null) { await Context.Channel.SendMessageAsync(language.GetString("command.appstart.notimezone")); return; } // given deadline must be in proper format DateTime?localdeadline = DateTimeMethods.StringToDatetime(input); if (!localdeadline.HasValue) { await Context.Channel.SendMessageAsync(language.GetString("command.appstart.error")); return; } DateTime utcdeadline = TimeZoneInfo.ConvertTimeToUtc(localdeadline.Value, usertimezone); // deadline must be in the future if (utcdeadline < DateTime.UtcNow) { await Context.Channel.SendMessageAsync(language.GetString("command.appstart.past")); return; } // creation must succeed IInviteMetadata invite = await statecollection.StartApplication(Context.Guild, database, utcdeadline, dbentry); if (invite == null) { await Context.Channel.SendMessageAsync(language.GetString("command.appstart.error")); return; } // return success to the user await Context.Channel.SendMessageAsync(language.GetString("command.appstart.success", new SentenceContext() .Add("url", invite.Url))); } }
protected void Page_Load(object sender, EventArgs e) { try { int Code; string strCode = Request["Code"]; Int32.TryParse(strCode, out Code); if (Code != 0) { BOLNews NewsBOL = new BOLNews(); //PageTools1.ItemCode = Code; //PageTools1.HCEntityCode = 1; vNewsDetail CurNews = NewsBOL.GetNewsByCode(Code); if (CurNews == null) { msgText.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; msgText.Text = "No news found."; pnlShowNews.Visible = false; return; } strNewsCode = CurNews.Code.ToString(); Tools.SetLink("lnkCanonical", "https://www.khabardaan.ir/" + "/News/" + CurNews.Code + ".html"); Tools.SetMeta("keywords", CurNews.Title); Tools.SetMeta("description", CurNews.Title); Tools.SetMeta("twittercard", CurNews.Title); Tools.SetMeta("twittertitle", CurNews.Title); Tools.SetMeta("twitterdescription", CurNews.Title); Tools.SetMeta("ogtitle", CurNews.Title); Tools.SetMeta("ogurl", "https://www.khabardaan.ir/" + "/News/" + CurNews.Code + "_" + Tools.ReplaceSpaceWithUnderline(CurNews.Title) + ".html"); Tools.SetMeta("twitterimagesrc", ""); if (!string.IsNullOrEmpty(CurNews.PicName)) { Tools.SetMeta("ogimage", "https://static.parset.com/Files/News/" + CurNews.PicName); } Tools.SetMeta("ogdescription", CurNews.Title); //NewsBOL.UpdateViewCount(Code); lblViewTitle.Text = CurNews.Title; Page.Title = CurNews.Title + " - خبردان"; ReqUtils Utils = new ReqUtils(); string FullStory = CurNews.Contents; FullStory = Utils.RemoveTags(FullStory); FullStory = Tools.FormatString(FullStory); FullStory = Tools.ShowBriefText(FullStory, 3000) + "..."; FullStory = FullStory.Replace("<img ", "<img class=\"img-responsive\" "); //if (FullStory.IndexOf("<br />") == -1) //{ // if(FullStory.IndexOf("<img ") == -1) // lblViewContents.Text = GenParagraph(FullStory); // else // lblViewContents.Text = CorrectEnters(FullStory); //} //else // lblViewContents.Text = FullStory; DataTable dtNewsImages = new Converter <NewsImages>().ToDataTable(NewsBOL.GetNewsImages(CurNews.Code)); lblViewContents.Text = GenParagraph(FullStory, dtNewsImages); DateTimeMethods dtm = new DateTimeMethods(); lblViewNewsDate.Text = Tools.ChangeEnc(dtm.GetPersianDate((DateTime)CurNews.NewsDate)); if (!string.IsNullOrEmpty(CurNews.PicName)) { imgPicName.ImageUrl = CurNews.ImgUrl;// "https://www.khabardaan.ir/Files/News/" + CurNews.PicName; imgPicName.ToolTip = CurNews.Title; } else { pnlPic.Visible = false; } RelatedNews1.NewsCode = Code.ToString(); KeywordList1.NewsCode = Code.ToString(); lblViewCount.Text = Tools.ChangeEnc(NewsBOL.GetVisitCount(CurNews.Code)); hplViewResourceName.Text = CurNews.Name; hplMoreFull.NavigateUrl = hplViewResourceName.NavigateUrl = CurNews.Url; //"https://www.khabardaan.ir/N" + CurNews.Code + "_" + Tools.ReplaceSpaceWithUnderline(CurNews.Title) + ".html"; lblViewCode.Text = CurNews.Code.ToString(); string strNewsHour = CurNews.NewsDate.Value.Hour.ToString(); if (strNewsHour.Length == 1) { strNewsHour = "0" + strNewsHour; } string strNewsMinute = CurNews.NewsDate.Value.Minute.ToString(); if (strNewsMinute.Length == 1) { strNewsMinute = "0" + strNewsMinute; } lblViewNewsTime.Text = Tools.ChangeEnc(strNewsHour + ":" + strNewsMinute); News3Col1.LoadPicNews(); //rptNewsImages.DataSource = NewsBOL.GetNewsImages(CurNews.Code); //rptNewsImages.DataBind(); //rptImages.DataSource = NewsBOL.GetSmallRelatedNews(CurNews.Code, 20, 1); //rptImages.DataBind(); //int CatCode = (int)CurNews.CatCode; //switch (CatCode) //{ // case 1: // { // lblCatTitle.Text = "اجتماعي "; // break; // } // case 2: // { // lblCatTitle.Text = "اقتصادي"; // break; // } // case 3: // { // lblCatTitle.Text = "سياسي"; // break; // } // case 4: // { // lblCatTitle.Text = "ورزشي"; // break; // } // case 5: // { // lblCatTitle.Text = "علمي"; // break; // } // case 6: // { // lblCatTitle.Text = "فرهنگي"; // break; // } // case 7: // { // lblCatTitle.Text = "ادب و هنر"; // break; // } // case 8: // { // lblCatTitle.Text = "بينالملل"; // break; // } // case 9: // { // lblCatTitle.Text = "حوادث"; // break; // } // default: // break; //} //lblCatTitle.Text = "آخرین خبرهای " + lblCatTitle.Text ; //NewsList1.ShowPager = false; //NewsList1.ShowNewsByCatCode((int)CurNews.CatCode, null); if (Request.UserAgent == "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" || Request.UserAgent == "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" || Request.UserAgent == "msnbot/2.0b (+http://search.msn.com/msnbot.htm)._" || Request.UserAgent == "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" || Request.UserAgent == "Mozilla/5.0 (en-us) AppleWebKit/525.13 (KHTML, like Gecko; Google Web Preview) Version/3.1 Safari/525.13" || Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.3.3; http://www.majestic12.co.uk/bot.php?+)" || Request.UserAgent == "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)" || Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.4.3; http://www.majestic12.co.uk/bot.php?+)" || Request.UserAgent == "Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)" ) { } else { NewsBOL.IncrementVisitCount(Code); } //if (FullStory.Length < 100) //{ // Response.Redirect(CurNews.Url); // return; //} //SmallAdsList1.ShowAdsByNewsCode(Code); //dtlRelatedPicNews.DataSource = NewsBOL.GetRelatedPicNews(Code); //dtlRelatedPicNews.DataBind(); //ProductsDataContext pdc = new ProductsDataContext(); //vRandPayeganGood CurRandBanner = pdc.vRandPayeganGoods.SingleOrDefault(); //if (CurRandBanner != null) //{ // hplPBanner.ImageUrl = CurRandBanner.strHBannerURL.Trim(); // hplPBanner.NavigateUrl = "http://forosh.biz/Detail.aspx?q=" + CurRandBanner.strGoodCode.Trim() + "&s=9144"; //} //CurRandBanner = pdc.vRandPayeganGoods.SingleOrDefault(); //if (CurRandBanner != null) //{ // hplPBanner2.ImageUrl = CurRandBanner.strHBannerURL.Trim(); // hplPBanner2.NavigateUrl = "http://forosh.biz/Detail.aspx?q=" + CurRandBanner.strGoodCode.Trim() + "&s=9144"; //} } } catch (Exception err) { BOLErrorLogs ErrorLogsBOL = new BOLErrorLogs(); ErrorLogsBOL.Insert(err.Message, DateTime.Now, Request.Url.AbsolutePath, "ShowNews::Load"); } }
protected void Page_Load(object sender, EventArgs e) { try { //TextNewsList2.ShowLatestTextNews(100); int Code; string strCode = Request["Code"]; Int32.TryParse(strCode, out Code); if (Code != 0) { BOLNews NewsBOL = new BOLNews(); //PageTools1.ItemCode = Code; //PageTools1.HCEntityCode = 1; vNewsDetail CurNews = NewsBOL.GetNewsByCode(Code); if (CurNews == null) { msgText.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; msgText.Text = "خبری با این کد یافت نشد."; //pnlShowNews.Visible = false; return; } Response.Redirect("~/N" + CurNews.Code + "_" + Tools.ReplaceSpaceWithUnderline(CurNews.Title) + ".html", false); return; NewsUrl = CurNews.Url; //NewsBOL.UpdateViewCount(Code); Page.Title = CurNews.Title; string FullStory = Tools.FormatString(CurNews.Contents); HtmlMeta metaTitle = (HtmlMeta)Page.Master.FindControl("title"); metaTitle.Attributes["content"] = CurNews.Title; HtmlMeta metaURL = (HtmlMeta)Page.Master.FindControl("url"); metaURL.Attributes["content"] = "https://www.khabardaan.ir/news/" + CurNews.Code + ".htm"; HtmlMeta metaKeywords = (HtmlMeta)Page.Master.FindControl("keywords"); metaKeywords.Attributes["content"] = ""; HtmlMeta metaDescription = (HtmlMeta)Page.Master.FindControl("description"); string BriefStory = Tools.ShowBriefText(FullStory, 400); ReqUtils Utils = new ReqUtils(); BriefStory = Utils.RemoveTags(BriefStory); metaDescription.Attributes["content"] = BriefStory; if (!string.IsNullOrEmpty(CurNews.PicName)) { HtmlMeta metaImage = (HtmlMeta)Page.Master.FindControl("image"); metaImage.Attributes["content"] = "https://www.khabardaan.ir/Files/News/" + CurNews.PicName; } DateTimeMethods dtm = new DateTimeMethods(); //lblViewTitle.Text = CurNews.Title; //lblViewNewsDate.Text = Tools.ChangeEnc(dtm.GetPersianLongDate((DateTime)CurNews.NewsDate)); //RelatedNews1.NewsCode = Code.ToString(); //KeywordList1.NewsCode = Code.ToString(); //lblViewCount.Text = NewsBOL.GetVisitCount(CurNews.Code);// Tools.ChangeEnc(CurNews.ViewCount.ToString()); //hplResourceName.Text = "جدید ترین خبرهای " + CurNews.Name; //hplResourceName.NavigateUrl = "~/News/Resources/" + CurNews.ResouseSiteCode + ".htm"; //hplCatName.Text = "جدید ترین خبرهای " + CurNews.CatName; //hplCatName.NavigateUrl = "~/News/NewsByCatCode.aspx?Code=" + CurNews.CatCode; //hplRelatedNews.NavigateUrl = "~/News/RelatedNews.aspx?Code=" + CurNews.Code; //hplViewResourceName.NavigateUrl = CurNews.Url; //lblViewCode.Text = CurNews.Code.ToString(); //lblViewNewsTime.Text = Tools.ChangeEnc(CurNews.NewsDate.Value.Hour + ":" + CurNews.NewsDate.Value.Minute); //ShareFaceBook.NavigateUrl = "~/ShareLink.aspx?Media=facebook&LinkUrl=" + Server.UrlEncode("https://www.khabardaan.ir/News/ShowNews.aspx?Code=" + CurNews.Code) + "&LinkTitle=" + Server.UrlEncode(CurNews.Title); //ShareDigg.NavigateUrl = "~/ShareLink.aspx?Media=digg&LinkUrl=" + Server.UrlEncode("https://www.khabardaan.ir/News/ShowNews.aspx?Code=" + CurNews.Code) + "&LinkTitle=" + Server.UrlEncode(CurNews.Title); //ShareTwitter.NavigateUrl = "~/ShareLink.aspx?Media=twitter&LinkUrl=" + Server.UrlEncode("https://www.khabardaan.ir/News/ShowNews.aspx?Code=" + CurNews.Code) + "&LinkTitle=" + Server.UrlEncode(CurNews.Title); //rptResourceNewsList.DataSource = NewsBOL.GetLatestNewsByResourceCode((int)CurNews.ResouseSiteCode, 4, 1); //rptResourceNewsList.DataBind(); //rptMostVisitedNews.DataSource = NewsBOL.GetMostVisitedTextNews(5, 1, 100); //rptMostVisitedNews.DataBind(); //rptCatNews.DataSource = NewsBOL.GetNewsByCatCode((int)CurNews.CatCode, 4, 1); //rptCatNews.DataBind(); //rptRelatedNews.DataSource = NewsBOL.GetRelatedNews((int)CurNews.Code, 4, 1); //rptRelatedNews.DataBind(); //if (rptRelatedNews.Items.Count == 0) // pnlRelatedNews.Visible = false; BOLNewsKeywords NewsKeywordsBOL = new BOLNewsKeywords(CurNews.Code); //rptKeywords.DataSource = NewsKeywordsBOL.GetTopKeywords(CurNews.Code, 3); //rptKeywords.DataBind(); if (Request.UserAgent == "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" || Request.UserAgent == "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" || Request.UserAgent == "msnbot/2.0b (+http://search.msn.com/msnbot.htm)._" || Request.UserAgent == "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" || Request.UserAgent == "Mozilla/5.0 (en-us) AppleWebKit/525.13 (KHTML, like Gecko; Google Web Preview) Version/3.1 Safari/525.13" || Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.3.3; http://www.majestic12.co.uk/bot.php?+)" || Request.UserAgent == "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)" || Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.4.3; http://www.majestic12.co.uk/bot.php?+)" || Request.UserAgent == "Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)" ) { } else { NewsBOL.IncrementVisitCount(Code); } if (FullStory.Length < 100) { Response.Redirect(CurNews.Url); return; } } } catch (Exception err) { BOLErrorLogs ErrorLogsBOL = new BOLErrorLogs(); ErrorLogsBOL.Insert(err.Message, DateTime.Now, Request.Url.AbsolutePath, "ShowExternalNews::Load"); } }
public async Task ConvertTime([Remainder] string input = null) { using (var database = new GuildDB()) { // log command execution CommandMethods.LogExecution(logger, "time", Context); // indicate that the bot is working on the command await Context.Channel.TriggerTypingAsync(); StringConverter language = statecollection.GetLanguage(Context.Guild, database); // make sure that the user has the right permissions if (!PermissionHelper.UserHasPermission(Context.User as SocketGuildUser, PermissionHelper.Member, database)) { await Context.Channel.SendMessageAsync(language.GetString("command.nopermission")); return; } TimeZoneInfo sourcetz; DateTime time; if (input != null) { // parse the input Match m = timerx.Match(input); if (!m.Success) { await Context.Channel.SendMessageAsync(language.GetString("command.time.error")); return; } // find out which timezone is desired GroupCollection g = m.Groups; TimeLocale tl; if (g["locale"].Success) { if (!Enum.TryParse <TimeLocale>(g["locale"].Value, true, out tl)) { await Context.Channel.SendMessageAsync(language.GetString("command.time.error")); return; } } else { tl = TimeLocale.local; } // find the desired timezone info if (tl == TimeLocale.local) { sourcetz = DateTimeMethods.UserToTimezone(Context.User); if (sourcetz == null) { await Context.Channel.SendMessageAsync(language.GetString("command.time.notimezone")); return; } } else { sourcetz = TimeZoneInfo.Utc; } // find the time time = TimeZoneInfo.ConvertTime(DateTime.Now, sourcetz); TimeSpan?ts = DateTimeMethods.StringToTime(g["time"].Value, true); if (!ts.HasValue) { // signal error if not await Context.Channel.SendMessageAsync(language.GetString("command.time.error")); return; } time = new DateTime(time.Year, time.Month, time.Day, 0, 0, 0, time.Kind) + ts.Value; } else { sourcetz = TimeZoneInfo.Utc; time = DateTime.UtcNow; } // construct a timetable and present it to the user string result = DateTimeMethods.TimetableToString(DateTimeMethods.LocalTimeToTimetable(time, sourcetz, Context.Guild)); await Context.Channel.SendMessageAsync(language.GetString("present")); await Context.Channel.TriggerTypingAsync(); await Context.Channel.SendMessageAsync(result); } }
public void IsTimeZone_NoTimezone_ReturnsFalse() { Assert.IsFalse(DateTimeMethods.IsTimezone("Central Easter Island GMT Time")); }
public void IsTimezone_Timezone_ReturnsTrue() { Assert.IsTrue(DateTimeMethods.IsTimezone("Central European Standard Time")); }
protected void Page_Load(object sender, EventArgs e) { try { //TextNewsList2.ShowLatestTextNews(100); int Code; string strCode = Request["Code"]; Int32.TryParse(strCode, out Code); if (Code != 0) { BOLNews NewsBOL = new BOLNews(); //PageTools1.ItemCode = Code; //PageTools1.HCEntityCode = 1; vNewsDetail CurNews = NewsBOL.GetNewsByCode(Code); if (CurNews == null) { msgText.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; msgText.Text = "No news found"; //pnlShowNews.Visible = false; return; } NewsUrl = CurNews.Url; if (!NewsUrl.StartsWith("http://")) { NewsUrl = "http://" + NewsUrl; } NewsUrl = NewsUrl.Replace("http://https://", "https://"); Response.Redirect(NewsUrl); Response.End(); return; //NewsBOL.UpdateViewCount(Code); Page.Title = CurNews.Title; string FullStory = Tools.FormatString(CurNews.Contents); HtmlMeta metaTitle = (HtmlMeta)Page.Master.FindControl("title"); metaTitle.Attributes["content"] = CurNews.Title.Trim(); HtmlMeta metaURL = (HtmlMeta)Page.Master.FindControl("url"); metaURL.Attributes["content"] = "https://www.khabardaan.ir/N" + CurNews.Code + "_" + Tools.ReplaceSpaceWithUnderline(CurNews.Title) + ".html"; HtmlMeta metaKeywords = (HtmlMeta)Page.Master.FindControl("keywords"); metaKeywords.Attributes["content"] = ""; HtmlMeta metaDescription = (HtmlMeta)Page.Master.FindControl("description"); string BriefStory = Tools.ShowBriefText(FullStory, 1100); ReqUtils Utils = new ReqUtils(); BriefStory = Utils.RemoveTags(BriefStory); metaDescription.Attributes["content"] = BriefStory; if (!string.IsNullOrEmpty(CurNews.PicName)) { HtmlMeta metaImage = (HtmlMeta)Page.Master.FindControl("image"); metaImage.Attributes["content"] = "https://www.khabardaan.ir/Files/News/" + CurNews.PicName; } DateTimeMethods dtm = new DateTimeMethods(); if (Request.UserAgent == "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" || Request.UserAgent == "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" || Request.UserAgent == "msnbot/2.0b (+http://search.msn.com/msnbot.htm)._" || Request.UserAgent == "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" || Request.UserAgent == "Mozilla/5.0 (en-us) AppleWebKit/525.13 (KHTML, like Gecko; Google Web Preview) Version/3.1 Safari/525.13" || Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.3.3; http://www.majestic12.co.uk/bot.php?+)" || Request.UserAgent == "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)" || Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.4.3; http://www.majestic12.co.uk/bot.php?+)" || Request.UserAgent == "Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)" ) { } else { NewsBOL.IncrementVisitCount(Code); } //if (FullStory.Length < 100) //{ // Response.Redirect(CurNews.Url); // return; //} } } catch (Exception err) { //Response.Write(err.Message); } }
protected void Page_Load(object sender, EventArgs e) { #region Load Scripts HtmlGenericControl scriptJQuery = new HtmlGenericControl("script"); scriptJQuery.Attributes.Add("src", this.ResolveClientUrl("~/Scripts/jquery-1.11.3.min.js")); scriptJQuery.Attributes.Add("type", "text/javascript"); Page.Header.Controls.Add(scriptJQuery); HtmlGenericControl scriptBootstrap = new HtmlGenericControl("script"); scriptBootstrap.Attributes.Add("src", this.ResolveClientUrl("~/Scripts/bootstrap.minv4.js")); scriptBootstrap.Attributes.Add("type", "text/javascript"); Page.Header.Controls.Add(scriptBootstrap); HtmlGenericControl scriptjssor = new HtmlGenericControl("script"); scriptjssor.Attributes.Add("src", this.ResolveClientUrl("~/Scripts/jssor.slider-27.1.0.min.js")); scriptjssor.Attributes.Add("type", "text/javascript"); Page.Header.Controls.Add(scriptjssor); HtmlGenericControl script = new HtmlGenericControl("script"); script.Attributes.Add("src", this.ResolveClientUrl("~/Scripts/main.js")); script.Attributes.Add("type", "text/javascript"); Page.Header.Controls.Add(script); HtmlGenericControl scripthoverIntent = new HtmlGenericControl("script"); scripthoverIntent.Attributes.Add("src", this.ResolveClientUrl("~/Scripts/hoverIntent.js")); scripthoverIntent.Attributes.Add("type", "text/javascript"); Page.Header.Controls.Add(scripthoverIntent); HtmlGenericControl scriptFarsi = new HtmlGenericControl("script"); scriptFarsi.Attributes.Add("src", this.ResolveClientUrl("~/Scripts/farsi.js")); scriptFarsi.Attributes.Add("type", "text/javascript"); Page.Header.Controls.Add(scriptFarsi); #endregion //BOLNews NewsBOL = new BOLNews(); //rptNewsTicker.DataSource = NewsBOL.GetLatestTelexNews(10); //rptNewsTicker.DataBind(); //if (rptNewsTicker.Items.Count == 0) // pnlTickNews.Visible = false; if (Session["UserCode"] != null) { pnlLoggedUser.Visible = true; pnlUserLogin.Visible = false; if (Session["UserFullName"] != null) { lblUserInfo.Text = Session["UserFullName"].ToString(); } } DateTimeMethods dtm = new DateTimeMethods(); DateTime IranDate = DateTime.Now; ltrPersianDate.Text = Tools.ChangeEnc(dtm.GetPersianLongDate(DateTime.Now)); lblTime.Text = Tools.ChangeEnc(DateTime.Now.Hour + ":" + DateTime.Now.Minute); //BOLSpeeches SpeechesBOL = new BOLSpeeches(); //Ranjbaran.Old_App_Code.DAL.vSpeeches LatestSpeech = SpeechesBOL.GetLatest(); //if (LatestSpeech != null) // ltrTodayWord.Text = Tools.FormatString(LatestSpeech.Title); }