Beispiel #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Page.RouteData.Values["pageId"] != null)
     {
         pageId = Page.RouteData.Values["pageId"] as string;
     }
     if (!IsPostBack)
     {
         try
         {
             if (Request.Cookies["CurrentLanguage"] != null)
             {
                 Lang = Request.Cookies["CurrentLanguage"].Value;
             }
             if (Microsoft.VisualBasic.Information.IsNumeric(pageId) == false)
             {
                 return;
             }
             DataTable dtPage = PageService.Page_GetById(pageId);
             if (dtPage.Rows.Count > 0)
             {
                 sTitleName = dtPage.Rows[0]["Name"].ToString();
                 Page.Title = sTitleName;
                 sDateTime  = DateTimeClass.ConvertDate(dtPage.Rows[0]["Image"].ToString(), "dd/MM/yyyy - HH:mm");
                 sContent   = dtPage.Rows[0]["Description"].ToString();
                 sDetail    = dtPage.Rows[0]["Detail"].ToString();
             }
         }
         catch (Exception ex)
         {
             MailSender.SendMail("", "", "Error System", ex.Message);
         }
     }
 }
Beispiel #2
0
        private static async Task <MessageSentResult> TestTime(TelegramBotAbstract sender, MessageEventArgs e)
        {
            var sentDate = await DateTimeClass.AskDateAsync(e.Message.From.Id,
                                                            e.Message.Text,
                                                            e.Message.From.LanguageCode, sender, e.Message.From.Username);

            if (sentDate.Item2 != null)
            {
                await NotifyUtil.NotifyOwners(new ExceptionNumbered(sentDate.Item2), sender, 0, sentDate.Item3);

                return(null);
            }

            var sentDate2 = sentDate.Item1.GetDate();

            var dict = new Dictionary <string, string>
            {
                { "en", DateTimeClass.DateTimeToItalianFormat(sentDate2) }
            };
            var text = new Language(dict);

            return(await SendMessage.SendMessageInPrivate(sender, e.Message.From.Id,
                                                          e.Message.From.LanguageCode, e.Message.From.Username,
                                                          text, ParseMode.Default, e.Message.MessageId));
        }
Beispiel #3
0
 protected void Update_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         Data.User obj = new Data.User();
         obj.Id       = Id;
         obj.Name     = txtName.Text;
         obj.UserName = txtUsername.Text;
         obj.Password = txtPassword.Text;
         obj.Email    = txtEmail.Text;
         obj.Phone    = txtPhone.Text;
         obj.Date     = DateTimeClass.ConvertDateTime(DateTime.Now.ToString(), "MM/dd/yy hh:mm:ss");
         obj.Admin    = chkAdmin.Checked ? "1" : "0";
         obj.Active   = "0";
         if (Insert == true)
         {
             UserService.User_Insert(obj);
         }
         else
         {
             UserService.User_Update(obj);
         }
         BindGrid();
         pnView.Visible   = true;
         pnUpdate.Visible = false;
         Insert           = false;
     }
 }
Beispiel #4
0
        protected void grdOrders_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            string    strCA = e.CommandArgument.ToString();
            DataTable dt    = new DataTable();

            dt = OrdersService.Orders_GetById(strCA);
            switch (e.CommandName)
            {
            case "Edit":
                Id = strCA;
                DataTable dtOrderDetail = OrderDetailService.OrderDetail_GetByTop("", "OrderId=" + Id, "");
                grdProducts.DataSource = dtOrderDetail;
                grdProducts.DataBind();
                lblName.Text    = dt.Rows[0]["Name"].ToString();
                lblTel.Text     = dt.Rows[0]["Tel"].ToString();
                lblEmail.Text   = dt.Rows[0]["Email"].ToString();
                lblAddress.Text = dt.Rows[0]["Address"].ToString();
                lblDetail.Text  = dt.Rows[0]["Detail"].ToString();
                PageHelper.LoadDropDownListStatusCart(drlStatus);
                txtDate.Text     = DateTimeClass.ConvertDateTime(DateTime.Now, "MM/dd/yyyy HH:mm:ss");
                pnView.Visible   = false;
                pnUpdate.Visible = true;
                break;
            }
        }
Beispiel #5
0
        public ActionResult WareHouseViews(int id)
        {
            string chuoi  = "";
            var    wh     = db.WareHouses.Where(m => m.Id == id).FirstOrDefault();
            var    userWh = db.MemberWareHouses.Where(m => m.IdWareHouse == wh.Id).ToList();

            chuoi += "<h2>Xem thông tin kho hàng</h2>";
            chuoi += "<div class=\"viewInfo\">";
            chuoi += "<div>";
            chuoi += "<p>Tên kho</p>";
            chuoi += "<p>Địa chỉ kho</p>";
            chuoi += "<p>Số điện thoại</p>";
            chuoi += "<div>Ghi chú</div>";
            chuoi += "</div>";
            chuoi += "<div>";
            chuoi += "<p>" + wh.Name + "</p>";
            chuoi += "<p>" + wh.Address + "</p>";
            chuoi += "<p>" + wh.Tel + "</p>";
            chuoi += "</div>";
            chuoi += "</div>";
            chuoi += "<div class=\"clearfix\"></div>";
            chuoi += "<div class='note'>" + wh.Description + "</div>";
            if (userWh.Count > 0)
            {
                chuoi += "<div class=\"divShowHideHistory\">";
                chuoi += "<div class=\"showHideHistory\">Xem thông tin lịch sử nhân viên quản kho</div>";
                chuoi += "<div id=\"divHistory\">";
                chuoi += "<table border=\"1\">";
                chuoi += "<tr>";
                chuoi += "<th>STT</th>";
                chuoi += "<th>Tên nhân viên</th>";
                chuoi += "<th>Ngày bắt đầu</th>";
                chuoi += "<th>Ngày kết thúc</th>";
                chuoi += "</tr>";
                var useWhId = 0;
                for (int i = 0; i < userWh.Count; i++)
                {
                    useWhId = (int)userWh[i].IdMember;
                    var user = db.Members.Where(m => m.Id == useWhId).FirstOrDefault();
                    chuoi += "<tr>";
                    chuoi += "<td>" + (i + 1) + "</td>";
                    chuoi += "<td>" + user.Name + "</td>";
                    chuoi += "<td>" + DateTimeClass.ConvertDateTimeddMMyyyy(userWh[i].SDate.ToString()) + "</td>";
                    if (userWh[i].SDate == null)
                    {
                        chuoi += "<td>Hiện vẫn đang làm</td>";
                    }
                    else
                    {
                        chuoi += "<td>" + DateTimeClass.ConvertDateTimeddMMyyyy(userWh[i].SDate.ToString()) + "</td>";
                    }
                    chuoi += "</tr>";
                }
                chuoi += "</table>";
                chuoi += "</div>";
                chuoi += "</div>";
            }
            ViewBag.View = chuoi;
            return(View());
        }
Beispiel #6
0
        protected void grdNews_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            string    strCA = e.CommandArgument.ToString();
            DataTable dt    = new DataTable();

            dt = NewsService.News_GetById(strCA);
            switch (e.CommandName)
            {
            case "Edit":
                Insert            = false;
                Id                = strCA;
                txtName.Text      = dt.Rows[0]["Name"].ToString();
                txtImage.Text     = dt.Rows[0]["Image"].ToString();
                imgImage.ImageUrl = dt.Rows[0]["Image"].ToString().Length > 0 ? dt.Rows[0]["Image"].ToString() : "";
                //txtFile.Text = dt.Rows[0]["File"].ToString();
                txtContent.Text   = dt.Rows[0]["Content"].ToString();
                fckDetail.Value   = dt.Rows[0]["Detail"].ToString();
                txtDate.Text      = DateTimeClass.ConvertDateTime(dt.Rows[0]["Date"].ToString());
                txtOrd.Text       = dt.Rows[0]["Ord"].ToString();
                chkActive.Checked = dt.Rows[0]["Active"].ToString() == "1" || dt.Rows[0]["Active"].ToString() == "True";
                LoadGroupNewsDropDownList();
                ddlGroupNews.Text = dt.Rows[0]["GroupNewsId"].ToString();
                PageHelper.LoadDropNewsPriority(ddlPriority);
                ddlPriority.SelectedValue = dt.Rows[0]["Priority"].ToString();
                chkIndex.Checked          = dt.Rows[0]["Index"].ToString() == "1";
                pnView.Visible            = false;
                pnUpdate.Visible          = true;
                break;

            case "Active":
                string strA = "";
                string str  = e.Item.Cells[2].Text;
                strA = str == "1" ? "0" : "1";
                sql.ExecuteNonQuery("Update [News] set Active=" + strA + "  Where Id='" + strCA + "'");
                BindGrid(where);
                break;

            case "Delete":
                sql.ExecuteNonQuery("Delete CommentNews where NewsID='" + strCA + "'");
                NewsService.News_Delete(strCA);
                BindGrid(where);
                break;

            case "Priority":
                string strPri = "";
                strPri = dt.Rows[0]["Priority"].ToString() == "1" ? "0" : "1";
                sql.ExecuteNonQuery("Update [News] set [Priority]=" + strPri + "  Where Id='" + strCA + "'");
                BindGrid(where);
                break;

            case "Index":
                string strIndex = "";
                strIndex = dt.Rows[0]["Index"].ToString() == "1" ? "0" : "1";
                sql.ExecuteNonQuery("Update [News] set [Index]=" + strIndex + " Where Id='" + strCA + "'");
                BindGrid(where);
                break;
            }
        }
Beispiel #7
0
 protected void AddButton_Click(object sender, EventArgs e)
 {
     ltrPass.Text = "Mật Khẩu";
     ControlClass.ResetControlValues(this);
     txtDate.Text      = DateTimeClass.ConvertDateTime(DateTime.Now, "MM/dd/yyyy");
     pnUpdate.Visible  = true;
     chkActive.Checked = true;
     pnView.Visible    = false;
 }
Beispiel #8
0
 protected void AddButton_Click(object sender, EventArgs e)
 {
     pnUpdate.Visible = true;
     ControlClass.ResetControlValues(this);
     LoadGroupNewsDropDownList();
     PageHelper.LoadDropDownListLanguage(ddlLanguage);
     txtDate.Text   = DateTimeClass.ConvertDateTime(DateTime.Now, "dd/MM/yyyy hh:mm:ss tt");
     pnView.Visible = false;
     Insert         = true;
 }
Beispiel #9
0
        public void DateTime_works()
        {
            var obj = new DateTimeClass();

            obj.Since = new DateTime(2020, 1, 1);

            var result = Serializer.Serialize(obj);

            Assert(() => result == @"{ Since = 2020-01-01T00:00:00.0000000, Other = 0001-01-01T00:00:00.0000000 }");
        }
Beispiel #10
0
        public void TestCurrent()
        {
            // ARRANGE
            IDateTime dateTime = new DateTimeClass();

            // ACT
            DateTime now1   = DateTime.Now;
            DateTime actual = dateTime.Current;
            DateTime now2   = DateTime.Now;

            // ASSERT
            Assert.IsTrue(now1.CompareTo(actual) <= 0);
            Assert.IsTrue(now2.CompareTo(actual) >= 0);
        }
        private void LoadMaxDay()
        {
            this.cboDay.Items.Clear();
            int year  = int.Parse(this.cboYear.Text);
            int month = int.Parse(this.cboMonth.Text);
            int max   = DateTimeClass.GetMonthMaxDay(year, month);

            this.cboDay.Items.Add("全部");
            for (int d = 1; d <= max; d++)
            {
                this.cboDay.Items.Add(d.ToString());
            }
            this.cboDay.SelectedIndex = 0;
        }
Beispiel #12
0
        private void ChangeUser()
        {
            pnView.Visible   = false;
            pnUpdate.Visible = true;
            txtPass.Visible  = false;
            ddlAdmin.Enabled = false;
            txtId.Text       = Request.Cookies["IdUser"].Value;
            List <Data.User> listE = UserBUS.User_GetById(txtId.Text);

            txtImage.Text          = listE[0].Image;
            txtDate.Text           = DateTimeClass.ConvertDateTime(listE[0].DateCreate, "MM/dd/yyyy");
            txtName.Text           = listE[0].Name;
            txtUsername.Text       = listE[0].Username;
            ddlAdmin.SelectedValue = listE[0].Admin;
            chkActive.Checked      = listE[0].Active == "1" || listE[0].Active == "True";
        }
        private void LoadInf()
        {
            string id  = Request.QueryString["idS"].ToString();
            var    dt1 = new DataTable();

            dt1 = BookingService.Booking_Sum(id);
            //int daco = Int32.Parse(dt1.Rows[0]["tickets"].ToString());
            var dt = new DataTable();

            dt = ShowTimesService.ShowTimes_GetById(id);
            lblNameCinema.Text  = dt.Rows[0]["NameCi"].ToString();
            Imagethumb.ImageUrl = dt.Rows[0]["PictureBig"].ToString();
            lblAddress.Text     = dt.Rows[0]["Address"].ToString();
            lblFilm.Text        = dt.Rows[0]["NameF"].ToString();
            lblSeats.Text       = dt.Rows[0]["Seats"].ToString() + " (total)";
            //int tong = Int32.Parse(dt.Rows[0]["Seats"].ToString());
            lblDuration.Text = dt.Rows[0]["Duration"].ToString() + " minutes";
            lblShowtime.Text = DateTimeClass.ConvertDateTime(dt.Rows[0]["ShowTime"].ToString(), "dd/MM/yyyy");
            lblTime.Text     = DateTimeClass.ConvertTime(dt.Rows[0]["Time"].ToString());
            lblPrice.Text    = StringClass.FormatNumber(dt.Rows[0]["Price"].ToString());
            double price  = Convert.ToDouble(dt.Rows[0]["Price"].ToString());
            double number = Convert.ToDouble(txtNumber.Text);
            string str    = (price * number).ToString();

            lblTotal.Text = StringClass.FormatNumber(str);
            //string str2 = (tong - daco).ToString();
            //lblNumbertickets.Text = str2 + " (empty)";
            lblNumbertickets.Text = dt1.Rows[0]["tickets"].ToString();
            if (dt1.Rows[0]["tickets"].ToString() == dt.Rows[0]["Seats"].ToString())
            {
                lblMessage.Text    = "Not tickets";
                txtNumber.ReadOnly = true;
                lblOrder.Enabled   = false;
            }
            //if (dt1.Rows[0]["tickets"].ToString() == "")
            //{
            //    lblNumbertickets.Text = "0";
            //}
            else
            {
                lblMessage.Text    = "";
                txtNumber.ReadOnly = false;
                lblOrder.Enabled   = true;
            }
        }
Beispiel #14
0
        protected void grdAdmin_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            string strCa = e.CommandArgument.ToString();

            if (e.CommandName == "Edit")
            {
                DataTable dt = AdminService.Admin_GetById(strCa);
                txtId.Value      = dt.Rows[0]["AdmId"].ToString();
                txtUsername.Text = dt.Rows[0]["Username"].ToString();
                txtFullName.Text = dt.Rows[0]["FullName"].ToString();
                txtBod.Text      = DateTimeClass.ConvertDateTime(dt.Rows[0]["Bod"].ToString(), "MM/dd/yyyy");
                txtAddress.Text  = dt.Rows[0]["Address"].ToString();
                txtPhone.Text    = dt.Rows[0]["Phone"].ToString();
                txtEmail.Text    = dt.Rows[0]["Email"].ToString();
                pnUpdate.Visible = true;
                pnView.Visible   = false;
            }
        }
Beispiel #15
0
        protected void grdUser_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            string strCA = e.CommandArgument.ToString();

            switch (e.CommandName)
            {
            case "Edit":
                txtPass.Text    = "";
                txtPass.Visible = false;
                List <Data.User> ListE = UserBUS.User_GetById(strCA);
                txtId.Text             = strCA;
                txtImage.Text          = ListE[0].Image.Length > 0 ? ListE[0].Image: "";
                txtDate.Text           = DateTimeClass.ConvertDateTime(ListE[0].DateCreate, "MM/dd/yyyy");
                txtName.Text           = ListE[0].Name;
                txtUsername.Text       = ListE[0].Username;
                ddlAdmin.SelectedValue = ListE[0].Admin;
                chkActive.Checked      = ListE[0].Active == "1" || ListE[0].Active == "True";
                pnView.Visible         = false;
                pnUpdate.Visible       = true;
                break;

            case "Active":
                string strA = "";
                string str  = e.Item.Cells[2].Text;
                strA = str == "1" ? "0" : "1";
                SqlDataProvider sql = new SqlDataProvider();
                sql.ExecuteNonQuery("Update Users set Active=" + strA + "  Where Id='" + strCA + "'");
                BindGrid();
                break;

            case "Delete":
                UserBUS.User_Delete(strCA);
                BindGrid();
                break;

            case "Pass":
                Response.Redirect("/Admins/UpdatePass.aspx?Id=" + strCA + "");
                BindGrid();
                break;

            case "Role":
                break;
            }
        }
        private static ValueWithException <DateTime?> GetLastUpdateLinkTimeFromJson(JProperty r3)
        {
            ;
            var r4 = r3.First;

            ;
            if (r4 is JValue r5)
            {
                ;
                if (r5.Value == null)
                {
                    return(null);
                }

                return(DateTimeClass.GetFromString(r5.Value.ToString()));
            }

            return(new ValueWithException <DateTime?>(null, new JsonDateTimeNotFound()));
        }
Beispiel #17
0
        protected void grdNews_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            string    strCA = e.CommandArgument.ToString();
            DataTable dt    = new DataTable();

            dt = NewsService.News_GetById(strCA);
            switch (e.CommandName)
            {
            case "Edit":
                Insert            = false;
                Id                = strCA;
                txtName.Text      = dt.Rows[0]["Name"].ToString();
                txtFile.Text      = dt.Rows[0]["File"].ToString();
                txtSoHieu.Text    = dt.Rows[0]["Content"].ToString();
                fckDetail.Value   = dt.Rows[0]["Detail"].ToString();
                txtDate.Text      = DateTimeClass.ConvertDateTime(dt.Rows[0]["Date"].ToString());
                txtPublic.Text    = DateTimeClass.ConvertDateTime(dt.Rows[0]["LinkDemo"].ToString());
                txtOrd.Text       = dt.Rows[0]["Ord"].ToString();
                chkActive.Checked = dt.Rows[0]["Active"].ToString() == "1" || dt.Rows[0]["Active"].ToString() == "True";
                LoadGroupNewsDropDownList();
                PageHelper.LoadDropDownListLanguage(ddlLanguage);
                ddlLanguage.SelectedValue = dt.Rows[0]["Language"].ToString();
                ddlGroupNews.Text         = dt.Rows[0]["GroupNewsId"].ToString();
                pnView.Visible            = false;
                pnUpdate.Visible          = true;
                break;

            case "Active":
                string strA = "";
                string str  = e.Item.Cells[2].Text;
                strA = str == "1" ? "0" : "1";
                sql.ExecuteNonQuery("Update [News] set Active=" + strA + "  Where Id='" + strCA + "'");
                BindGrid(where);
                break;

            case "Delete":
                sql.ExecuteNonQuery("Delete CommentNews where NewsID='" + strCA + "'");
                NewsService.News_Delete(strCA);
                BindGrid(where);
                break;
            }
        }
Beispiel #18
0
        private static ValueWithException <DateTime?> GetDateTime(string[] target)
        {
            if (target == null)
            {
                return(null);
            }
            if (target.Length < 3)
            {
                return(null);
            }

            var s = "";

            for (var i = 2; i < target.Length; i++)
            {
                s += target[i] + " ";
            }

            s = s.Trim();
            return(DateTimeClass.GetFromString(s));
        }
Beispiel #19
0
 protected void btnSend_Click(object sender, EventArgs e)
 {
     Data.Contact obj = new Data.Contact();
     obj.Name     = txtHoTen.Text;
     obj.Company  = txtAddress.Text;
     obj.Email    = txtEmail.Text;
     obj.Phone    = txtPhone.Text;
     obj.Website  = string.Empty;
     obj.Title    = txtTitle.Text;
     obj.Detail   = txtDetail.Text;
     obj.Date     = DateTimeClass.ConvertDateTime(DateTime.Now.ToLongDateString(), "MM/dd/yyyy HH:mm:ss");
     obj.Language = "vi";
     ContactService.Contact_Insert(obj);
     #region [SendMail]
     try
     {
         string strchuoi = "Họ tên: " + txtHoTen.Text.Trim() + "\n<br />";
         strchuoi += "E-mail: " + txtEmail.Text.Trim() + "\n<br />";
         strchuoi += "Điện thoại: " + txtPhone.Text.Trim() + "\n<br />";
         strchuoi += "Địa chỉ: " + txtAddress.Text.Trim() + "\n<br />";
         strchuoi += "Nội dung: " + txtDetail.Text.Trim() + "\n";
         MailSender.SendMail("", "", txtTitle.Text.Trim(), strchuoi);
         WebMsgBox.Show("Bạn đã gửi thành công!");
     }
     catch (Exception ex)
     {
         WebMsgBox.Show("Bạn đã gửi thất bại! Vui lòng thử lại lần nữa!");
     }
     finally
     {
         txtTitle.Text   = string.Empty;
         txtAddress.Text = string.Empty;
         txtHoTen.Text   = string.Empty;
         txtEmail.Text   = string.Empty;
         txtDetail.Text  = string.Empty;
         txtPhone.Text   = string.Empty;
     }
     #endregion
 }
Beispiel #20
0
 protected void Update_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         Data.News obj = new Data.News();
         obj.Id           = Id;
         obj.Name         = txtName.Text;
         obj.Image        = txtImage.Text;
         obj.File         = "";
         obj.Content      = txtContent.Text;
         obj.Detail       = fckDetail.Value;
         obj.Date         = DateTimeClass.ConvertDateTime(txtDate.Text, "MM/dd/yyyy HH:mm:ss");
         obj.Index        = "0";
         obj.Ord          = txtOrd.Text != "" ? txtOrd.Text : "1";
         obj.Active       = chkActive.Checked ? "1" : "0";
         obj.Position     = ddlPosition.SelectedValue;
         obj.GroupNewsId  = ddlGroupNews.SelectedValue;
         obj.GroupTagNews = StringClass.NameToTag(ddlGroupNews.SelectedItem.Text);
         obj.Description  = "";
         obj.Keyword      = "";
         obj.Views        = "0";
         obj.LinkDemo     = "";
         obj.Language     = ddlLanguage.SelectedValue;
         if (Insert == true)
         {
             NewsService.News_Insert(obj);
         }
         else
         {
             NewsService.News_Update(obj);
         }
         BindGrid(where);
         pnView.Visible   = true;
         pnUpdate.Visible = false;
         Insert           = false;
     }
 }
Beispiel #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.RouteData.Values["Id"] != null)
            {
                id = Page.RouteData.Values["Id"] as string;
            }
            if (Microsoft.VisualBasic.Information.IsNumeric(id) == false)
            {
                return;
            }
            if (Request.Cookies["CurrentLanguage"] != null)
            {
                Lang = Request.Cookies["CurrentLanguage"].Value;
            }
            if (!IsPostBack)
            {
                try
                {
                    DataTable dtNews = NewsService.News_GetById(id);
                    if (dtNews.Rows.Count > 0)
                    {
                        Label lblName = (Label)Master.FindControl("lblName");
                        sTitleName = dtNews.Rows[0]["Name"].ToString();
                        Page.Title = sTitleName;
                        sContent   = dtNews.Rows[0]["Content"].ToString();
                        sDetail    = dtNews.Rows[0]["Detail"].ToString();
                        sDateTime  = DateTimeClass.ConvertDate(dtNews.Rows[0]["Date"].ToString(), "dd/MM/yyyy - HH:mm");

                        DataTable dtG = GroupNewsService.GroupNews_GetById(dtNews.Rows[0]["GroupNewsId"].ToString());
                        if (dtG.Rows.Count > 0)
                        {
                            groupName = dtG.Rows[0]["Name"].ToString();
                            if (lblName != null)
                            {
                                lblName.Text = groupName;
                            }
                        }
                        DataTable dtLastNews = NewsService.News_GetByTop("10", "Id <> " + id + "  AND GroupNewsId IN (Select Id from GroupNews where Active=1 AND [Index]=0) AND Active = 1 AND Language='" + Lang + "'", "Date Desc");
                        dtLastNews = PageHelper.ModifyData(dtLastNews, Consts.CON_TIN_TUC);
                        DataTable dtLeft = dtLastNews.Clone();
                        for (int i = 0; i < dtLastNews.Rows.Count; i++)
                        {
                            DataRow dr = dtLastNews.Rows[i];
                            if (i < 5)
                            {
                                dtLeft.Rows.Add(dr.ItemArray);
                                dr.Delete();
                                dtLastNews.AcceptChanges();
                            }
                            else
                            {
                                break;
                            }
                        }
                        rptLeft.DataSource = dtLeft;
                        rptLeft.DataBind();
                        rptRight.DataSource = dtLastNews;
                        rptRight.DataBind();
                    }
                }
                catch (Exception ex)
                {
                    MailSender.SendMail("", "", "Error System", ex.Message);
                }
            }
        }
        public static async Task CommandDispatcherMethod(TelegramBotAbstract sender, MessageEventArgs e)
        {
            var cmdLines = e.Message.Text.Split(' ');
            var cmd      = cmdLines[0];

            switch (cmd)
            {
            case "/start":
            {
                await Start(sender, e);

                return;
            }

            case "/force_check_invite_links":
            {
                if (GlobalVariables.Creators.Contains(e.Message.Chat.Id))
                {
                    _ = ForceCheckInviteLinksAsync(sender, e);
                }
                else
                {
                    await DefaultCommand(sender, e);
                }
                return;
            }

            case "/contact":
            {
                await ContactUs(sender, e);

                return;
            }

            case "/help":
            {
                await Help(sender, e);

                return;
            }

            case "/banAll":
            {
                if (GlobalVariables.Creators.Contains(e.Message.From.Id))
                {
                    _ = BanAllAsync(sender, e, cmdLines, e.Message.From.LanguageCode, e.Message.From.Username);
                }
                else
                {
                    await DefaultCommand(sender, e);
                }
                return;
            }

            case "/ban":
            {
                _ = BanUserAsync(sender, e, cmdLines);
                return;
            }

            case "/unbanAll":
            {
                if (GlobalVariables.Creators.Contains(e.Message.From.Id))
                {
                    _ = UnbanAllAsync(sender, e, cmdLines[1]);
                }
                else
                {
                    await DefaultCommand(sender, e);
                }
                return;
            }

            case "/getGroups":
            {
                if (GlobalVariables.Creators.Contains(e.Message.From.Id) && e.Message.Chat.Type == ChatType.Private)
                {
                    string username = null;
                    if (!string.IsNullOrEmpty(e.Message.From.Username))
                    {
                        username = e.Message.From.Username;
                    }
                    _ = GetAllGroups(e.Message.From.Id, username, sender, e.Message.From.LanguageCode);
                    return;
                }

                await DefaultCommand(sender, e);

                return;
            }

            case "/time":
            {
                var lang = new Language(new Dictionary <string, string>
                    {
                        { "", DateTimeClass.NowAsStringAmericanFormat() }
                    });
                await SendMessage.SendMessageInPrivate(sender, e, lang);

                return;
            }

            case "/assoc_send":
            {
                _ = Assoc.Assoc_SendAsync(sender, e);
                return;
            }

            default:
            {
                await DefaultCommand(sender, e);

                return;
            }
            }
        }
Beispiel #23
0
        private void createOneDateTimeUserControl()
        {
            DateTimeUserControl dateTimeUserControl;

            dateTimeUserControl = new DateTimeUserControl();
            //
            // dateTimeUserControl1
            //
            //dateTimeUserControl.CultureInfo = new System.Globalization.CultureInfo("fr-FR");
            // resources.ApplyResources(dateTimeUserControl1, "dateTimeUserControl1");
            dateTimeUserControl.Name = string.Concat("dateTimeUserControl", dateTimeUserControl.InstanceNumber.ToString());
            //dateTimeUserControl1.TimeZoneInfo = ((System.TimeZoneInfo)(resources.GetObject("dateTimeUserControl1.TimeZoneInfo")));
            //dateTimeUserControl.Load += new System.EventHandler(this.dateTimeUserControl1_Load);
            this.flowLayoutPanel1.Controls.Add(dateTimeUserControl);
            DateTimeClass _dt = new DateTimeClass();

            _dt.TimeZone = TimeZoneInfo.Local;
            dateTimeUserControl.DataSource        = _dt;
            dateTimeUserControl.DuplicateControl += DuplicateControl;

            dateTimeUserControl.SendMessageToSerialPort += DateTimeUserControl1_SendMessageToSerialPort;

            int     numoutput = 1;
            Boolean trouve    = true;

            while (trouve)
            {
                trouve = false;
                for (int i = 0; i < listDateTimeUserControl.Count; i++)
                {
                    if (((IDuplicable)listDateTimeUserControl[i]).Num_Output == numoutput)
                    {
                        trouve     = true;
                        numoutput += 1;
                        break;
                    }
                }
            }

            dateTimeUserControl.Num_Output = numoutput;

            dateTimeUserControl.OutputPath = Application.StartupPath;


            listDateTimeUserControl.Add(dateTimeUserControl);

            for (int i = 0; i < listDateTimeUserControl.Count; i++)
            {
                if (i == 0)
                {
                    ((IDuplicable)listDateTimeUserControl[i]).IsFirst = true;
                }
                else
                {
                    ((IDuplicable)listDateTimeUserControl[i]).IsFirst = false;
                }

                if (i == listDateTimeUserControl.Count - 1)
                {
                    ((IDuplicable)listDateTimeUserControl[i]).IsLast = true;
                }
                else
                {
                    ((IDuplicable)listDateTimeUserControl[i]).IsLast = false;
                }
            }
        }
Beispiel #24
0
 protected void btnDelivery_Click(object sender, EventArgs e)
 {
     try
     {
         if (Page.IsValid)
         {
             if (string.IsNullOrEmpty(fname.Value.Trim()))
             {
                 lblName.Visible = true;
                 fname.Focus();
                 return;
             }
             else
             {
                 lblName.Visible = false;
             }
             if (string.IsNullOrEmpty(email.Value.Trim()))
             {
                 lblEmail.Visible = true;
                 email.Focus();
                 return;
             }
             else
             {
                 lblEmail.Visible = false;
             }
             if (string.IsNullOrEmpty(adr.Value.Trim()))
             {
                 lblTel.Visible = true;
                 adr.Focus();
                 return;
             }
             else
             {
                 lblTel.Visible = false;
             }
             if (string.IsNullOrEmpty(city.Value.Trim()))
             {
                 lblAddress.Visible = true;
                 city.Focus();
                 return;
             }
             else
             {
                 lblAddress.Visible = false;
             }
             Hashtable htData = new Hashtable();
             for (int i = 0; i < rptCart.Items.Count; i++)
             {
                 RepeaterItem item        = rptCart.Items[i];
                 TextBox      txtquantity = (TextBox)item.FindControl("txtquantity");
                 DropDownList ddlSize     = (DropDownList)item.FindControl("ddlSize");
                 HiddenField  hfId        = (HiddenField)item.FindControl("hfId");
                 htData.Add(hfId.Value.Trim(), txtquantity.Text.Trim() + "," + ddlSize.SelectedValue);
             }
             Orders order = new Orders();
             order.Id        = Id;
             order.Name      = StringClass.SqlInjection(fname.Value.Trim());
             order.Email     = StringClass.SqlInjection(email.Value.Trim());
             order.Tel       = StringClass.SqlInjection(adr.Value.Trim());
             order.Address   = StringClass.SqlInjection(city.Value.Trim());
             order.OrderId   = orderId;
             order.OrderDate = DateTimeClass.ConvertDateTime(DateTime.Now, "dd/MM/yyyy HH:mm:ss");
             if (rdoChuyenkhoan.Checked)
             {
                 order.PaymentMethod = "0";
             }
             else
             {
                 order.PaymentMethod = "1";
             }
             order.Price        = totalPrice;
             order.Status       = "1";
             order.Detail       = StringClass.SqlInjection(content.Value.Trim());
             order.DeliveryDate = "";
             OrdersService.PurchaseProduct(order, htData);
             lblMsg.Text          = "Cảm ơn bạn đã mua sản phẩm của chúng tôi. Chúng tôi sẽ giao hàng trong thời gian sớm nhất.";
             shoppingcart.Visible = false;
             rptCart.Visible      = false;
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
     }
 }
Beispiel #25
0
        /// <summary>
        /// Every conversation turn for our LUIS Bot will call this method.
        /// There are no dialogs used, the sample only uses "single turn" processing,
        /// meaning a single request and response, with no stateful conversation.
        /// </summary>
        /// <param name="turnContext">A <see cref="ITurnContext"/> containing all the data needed
        /// for processing this conversation turn. </param>
        /// <param name="cancellationToken">(Optional) A <see cref="CancellationToken"/> that can be used by other objects
        /// or threads to receive notice of cancellation.</param>
        /// <returns>A <see cref="Task"/> that represents the work queued to execute.</returns>
        public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (turnContext.Activity.Type == ActivityTypes.Message)
            {
                // Check LUIS model
                var recognizerResult = await _services.LuisServices[LuisKey].RecognizeAsync(turnContext, cancellationToken);

                var topIntent = recognizerResult?.GetTopScoringIntent();
                if (topIntent != null && topIntent.HasValue && topIntent.Value.intent != "None")
                {
                    await turnContext.SendActivityAsync($"==>LUIS Top Scoring Intent: {topIntent.Value.intent}, Score: {topIntent.Value.score}\n");

                    //var listOfEntities = recognizerResult?.Entities.First["$instance"]["DayName"]["text"];
                    //var listOfEntities = recognizerResult?.Entities.First.ToString();
                    //var listOfEntities = recognizerResult?.Entities.First.ToString();

                    //dynamic data = JsonConvert.DeserializeObject(recognizerResult?.Entities.Last);
                    var listOfEntities = recognizerResult?.Entities.Last.ToString();

                    //dynamic dyn = JsonConvert.DeserializeObject(listOfEntities);
                    //foreach (var obj in dyn.DayName)
                    //{
                    //    for
                    //};


                    var stringEntities = recognizerResult?.Entities.ToString();
                    await turnContext.SendActivityAsync($"Entities: {stringEntities} \n");


                    //
                    //var customEntityData = CustomEntityData.FromJson(jsonString);
                    var customEntityData = CustomEntityData.FromJson(stringEntities);
                    var sundayWord       = customEntityData.DayName[0][0].ToString();
                    await turnContext.SendActivityAsync($"Entities: {sundayWord} \n");

                    var dateTimeClass  = DateTimeClass.FromJson(stringEntities);
                    var dateTimeString = dateTimeClass.Datetime[0].Timex[0].ToString();
                    await turnContext.SendActivityAsync($"Entities: {dateTimeString} \n");

                    var dateAndTimeClass        = DateAndTimeClass.FromJson(stringEntities);
                    var dateAndTimeClassTheDate = dateTimeClass.Datetime[0].Timex[0].ToString();
                    var dateAndTimeClassTheTime = dateTimeClass.Datetime[1].Timex[0].ToString();
                    await turnContext.SendActivityAsync($"Entities: {dateAndTimeClassTheDate} and {dateAndTimeClassTheTime} \n");

                    var dateAndDateTimeClass        = DateAndDateTimeClass.FromJson(stringEntities);
                    var dateAndDateTimeClassTheDate = dateAndDateTimeClass.Datetime[0].Timex[0].ToString();

                    var dateAndDateTimeClassTheDateTime = dateAndDateTimeClass.Datetime[1].Timex[0].ToString();

                    //var input = "2018-10-28";
                    ////var input = "2018-10-28T4";
                    //var format = "yyyy-MM-dd";
                    ////var format = "yyyy-MM-ddThh:mm:ss";



                    //DateTime parsed;
                    //string parsedString;
                    //                    if (DateTime.TryParseExact(input, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    ////if (DateTime.TryParse(dateAndDateTimeClassTheDateTime, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))


                    ////if (DateTime.TryParse(input, CultureInfo.InvariantCulture , DateTimeStyles.None, out parsed))
                    //{
                    //    parsedString = parsed.ToString();
                    //    // Do whatever you want with "parsed"
                    //    await turnContext.SendActivityAsync($"Parsed: {parsedString} \n");
                    //}

                    //WORKS
                    //var input = "2012-05-28 11:35:00Z";
                    //var format = "yyyy-MM-dd HH:mm:ssZ";
                    //if (DateTime.TryParseExact(input, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))


                    var input = "2018-10-28T11:35:00";
                    //var format = "yyyy-MM-dd";
                    var format = "yyyy-MM-ddThh:mm:ss";

                    DateTime parsed;
                    string   parsedString;

                    try
                    {
                        await turnContext.SendActivityAsync($"Input: {input} Format: {format} \n");

                        DateTime.TryParseExact(input, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed);
                    }
                    catch (Exception ex)
                    {
                        await turnContext.SendActivityAsync($"Parsed: {ex.ToString()} \n");
                    }

                    //if (DateTime.TryParse(dateAndDateTimeClassTheDateTime, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))


                    //if (DateTime.TryParse(input, CultureInfo.InvariantCulture , DateTimeStyles.None, out parsed))


                    var input1  = "2018-10-28T11:35:00";
                    var format1 = "yyyy-MM-ddThh:mm:ss";

                    if (DateTime.TryParseExact(input1, format1, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        // Do whatever you want with "parsed"
                        await turnContext.SendActivityAsync($"Parsed 1: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input1} Format: {format1} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 1: Input: {input1} Format: {format1} \n");
                    }

                    var input2  = "2018-10-28T11:35:00";
                    var format2 = "yyyy-MM-ddTHH:mm:ss";

                    if (DateTime.TryParseExact(input2, format2, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        // Do whatever you want with "parsed"
                        await turnContext.SendActivityAsync($"Parsed 2: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input2} Format: {format2} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 2: Input: {input2} Format: {format2} \n");
                    }

                    var input3  = "2018-10-28T04:35:00";
                    var format3 = "yyyy-MM-ddThh:mm:ss";

                    if (DateTime.TryParseExact(input3, format3, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        // Do whatever you want with "parsed"
                        await turnContext.SendActivityAsync($"Parsed 3: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input3} Format: {format3} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 3: Input: {input3} Format: {format3} \n");
                    }

                    var input4  = "2018-10-28T04:35:00";
                    var format4 = "yyyy-MM-ddTHH:mm:ss";

                    if (DateTime.TryParseExact(input4, format4, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        // Do whatever you want with "parsed"
                        await turnContext.SendActivityAsync($"Parsed 4: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input4} Format: {format4} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 4: Input: {input4} Format: {format4} \n");
                    }


                    var input5  = "2018-10-28T4:35:00";
                    var format5 = "yyyy-MM-ddTh:mm:ss";

                    if (DateTime.TryParseExact(input5, format5, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        // Do whatever you want with "parsed"
                        await turnContext.SendActivityAsync($"Parsed 5: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input5} Format: {format5} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 5: Input: {input5} Format: {format5} \n");
                    }

                    var input6  = "2018-10-28T4:35:00";
                    var format6 = "yyyy-MM-ddTH:mm:ss";

                    if (DateTime.TryParseExact(input6, format6, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        // Do whatever you want with "parsed"
                        await turnContext.SendActivityAsync($"Parsed 6: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input6} Format: {format6} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 6: Input: {input6} Format: {format6} \n");
                    }


                    //THIS DOES NOT WORK
                    var input7  = "2018-10-28T4:35:00";
                    var format7 = "yyyy-MM-ddThh:mm:ss";

                    if (DateTime.TryParseExact(input7, format7, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        //THIS DOES NOT WORK
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 7: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input7} Format: {format7} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 7: Input: {input7} Format: {format7} \n");
                    }


                    //THIS DOES NOT WORK
                    var input8  = "2018-10-28T4:35:00";
                    var format8 = "yyyy-MM-ddTHH:mm:ss";

                    if (DateTime.TryParseExact(input8, format8, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        //THIS DOES NOT WORK
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 8: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input8} Format: {format8} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 8: Input: {input8} Format: {format8} \n");
                    }

                    var input9  = "2018-10-28T11:35:00";
                    var format9 = "yyyy-MM-ddTh:mm:ss";

                    if (DateTime.TryParseExact(input9, format9, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        // Do whatever you want with "parsed"
                        await turnContext.SendActivityAsync($"Parsed 9: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input9} Format: {format9} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 9: Input: {input9} Format: {format9} \n");
                    }

                    var input10  = "2018-10-28T11:35:00";
                    var format10 = "yyyy-MM-ddTH:mm:ss";

                    if (DateTime.TryParseExact(input10, format10, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 10: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input10} Format: {format10} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 10: Input: {input10} Format: {format10} \n");
                    }

                    //NOW DOING 14 HOUR FORMAT AS RETURNED BY LUIS

                    var input11  = "2018-10-28T14:35:00";
                    var format11 = "yyyy-MM-ddThh:mm:ss";

                    if (DateTime.TryParseExact(input11, format11, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        //THIS DOES NOT WORK
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 11: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input11} Format: {format11} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 11: Input: {input11} Format: {format11} \n");
                    }

                    //THIS DOES NOT WORK
                    var input12  = "2018-10-28T14:35:00";
                    var format12 = "yyyy-MM-ddTHH:mm:ss";

                    if (DateTime.TryParseExact(input12, format12, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        //THIS DOES NOT WORK
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 12: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input12} Format: {format12} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 12: Input: {input12} Format: {format12} \n");
                    }

                    var input13  = "2018-10-28T14:35:00";
                    var format13 = "yyyy-MM-ddTh:mm:ss";

                    if (DateTime.TryParseExact(input13, format13, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        // Do whatever you want with "parsed"
                        await turnContext.SendActivityAsync($"Parsed 13: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input13} Format: {format13} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 13: Input: {input13} Format: {format13} \n");
                    }

                    var input14  = "2018-10-28T14:35:00";
                    var format14 = "yyyy-MM-ddTH:mm:ss";

                    if (DateTime.TryParseExact(input14, format14, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 14: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input14} Format: {format14} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 14: Input: {input14} Format: {format14} \n");
                    }
                    ///////////////////////////

                    var input15  = "2018-10-28T14:35";
                    var format15 = "yyyy-MM-ddTH:mm";

                    if (DateTime.TryParseExact(input15, format15, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 15: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input15} Format: {format15} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 15: Input: {input15} Format: {format15} \n");
                    }

                    var input15a  = "2018-10-28T14";
                    var format15a = "yyyy-MM-ddTH:mm";

                    if (DateTime.TryParseExact(input15a, format15a, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 15a: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input15a} Format: {format15a} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 15a: Input: {input15a} Format: {format15a} \n");
                    }

                    var input16  = "2018-10-28T14";
                    var format16 = "yyyy-MM-ddTH";

                    if (DateTime.TryParseExact(input16, format16, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 16: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input16} Format: {format16} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 16: Input: {input16} Format: {format16} \n");
                    }

                    //////////////////////////////
                    ///

                    var input17 = "2018-10-28 14:00:00Z";
                    //var format16 = "yyyy-MM-ddTH";

                    if (DateTime.TryParse(input17, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))

                    //                        if (DateTime.TryParseExact(input16, format16, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 17: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input17} Format: NO FORMAT \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 17: Input: {input17} Format: NO FORMAT \n");
                    }

                    var input18 = "2018-10-28 14:00Z";
                    //var format16 = "yyyy-MM-ddTH";

                    if (DateTime.TryParse(input18, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))

                    //                        if (DateTime.TryParseExact(input16, format16, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 18: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input18} Format: NO FORMAT \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 18: Input: {input18} Format: NO FORMAT \n");
                    }

                    var input19 = "2018-10-28 14Z";
                    //var format16 = "yyyy-MM-ddTH";

                    if (DateTime.TryParse(input19, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))

                    //                        if (DateTime.TryParseExact(input16, format16, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 19: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input19} Format: NO FORMAT \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 19: Input: {input19} Format: NO FORMAT \n");
                    }

                    var input20  = "03-15";
                    var format20 = "MM-dd";

                    if (DateTime.TryParseExact(input20, format20, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 20: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input20} Format: {format20} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 20: Input: {input20} Format: {format20} \n");
                    }

                    var input21  = "XXXX-03-15";
                    var format21 = "MM-dd";

                    if (DateTime.TryParseExact(input21, format21, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed 21: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input21} Format: {format21} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 21: Input: {input21} Format: {format21} \n");
                    }

                    var input22  = "XXXX-03-15";
                    var format22 = "MM-dd";

                    if (input22.Contains("XXXX-") & !input22.Contains("XXXX-W"))
                    {
                        input22 = input22.Replace("XXXX-", "");
                    }

                    if (DateTime.TryParseExact(input22, format22, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();

                        parsedString = parsedString.Replace(" 12:00:00 AM", "");

                        await turnContext.SendActivityAsync($"Parsed 22: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input22} Format: {format22} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 22: Input: {input22} Format: {format22} \n");
                    }

                    var input23  = "XXXX-03";
                    var format23 = "MM";

                    if (input23.Contains("XXXX-") & !input23.Contains("XXXX-W"))
                    {
                        input23 = input23.Replace("XXXX-", "");
                    }

                    if (DateTime.TryParseExact(input23, format23, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();

//                        parsedString = parsedString.Replace(" 12:00:00 AM", "");

                        await turnContext.SendActivityAsync($"Parsed 23: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input: {input23} Format: {format23} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED 23: Input: {input23} Format: {format23} \n");
                    }


                    var input24  = "XXXX-03";
                    var format24 = "MM";

                    if (input24.Contains("XXXX-") & !input24.Contains("XXXX-W"))
                    {
                        input24 = input24.Replace("XXXX-", "");
                    }

                    var formattedDateMonthOnly = MonthByStringNumber(input24);
                    await turnContext.SendActivityAsync($"Parsed 24: through Methods and Formatted: {formattedDateMonthOnly} \n");

                    var input25 = "XXXX-XX-15";
                    //var format25 = "MM";

                    if (input25.Contains("XXXX-XX-") & !input25.Contains("XXXX-W"))
                    {
                        input25 = input25.Replace("XXXX-XX-", "");
                    }

                    var formattedDayNumber = DayNumberByStringNumber(input25);

                    //InvariantCulture
                    var createdDateTimeString = DateTime.Now.ToString("yyyy-MM-", new CultureInfo("en-US"));


                    //CreatedDateTimeString = DateTime.Now.ToString("MMM d h:mm tt", new CultureInfo("en-US")),
                    //    CreatedDateTime = DateTimeOffset.UtcNow,

                    await turnContext.SendActivityAsync($"Parsed 25: through Methods and Formatted: {formattedDayNumber} \n");

                    await turnContext.SendActivityAsync($"Parsed 25b: through Methods and Formatted: {createdDateTimeString} \n");

                    var combinedDateString = createdDateTimeString + formattedDayNumber;

                    await turnContext.SendActivityAsync($"Parsed 25c: through Methods and Formatted: {combinedDateString} \n");

                    ///////////////////////////
                    ///

                    var input26 = "XXXX-03-15T17:30";

                    //InvariantCulture
                    var createdDateTimeString26 = DateTime.Now.ToString("yyyy-", new CultureInfo("en-US"));

                    if (input26.Contains("XXXX-") & !input26.Contains("XXXX-XX-") & !input26.Contains("XXXX-W"))
                    {
                        input26 = input26.Replace("XXXX-", createdDateTimeString26);
                    }

                    //Format-26
                    var dateAndDateTimeClassTheDatePostFormatted26 = FormattingHoursWithOrWithoutMinutes(input26);
                    var formattedTime26 = FormatDateTimeBasedOnTHmm(dateAndDateTimeClassTheDatePostFormatted26);
                    await turnContext.SendActivityAsync($"Entities Through Methods and Formatted: 2. {formattedTime26}\n");

//                  await turnContext.SendActivityAsync($"Parsed 25c: through Methods and Formatted: {combinedDateString} \n");

                    //if (DateTime.TryParseExact(input24, format24, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    //{
                    //    parsedString = parsed.ToString();

                    //    //                        parsedString = parsedString.Replace(" 12:00:00 AM", "");

                    //    await turnContext.SendActivityAsync($"Parsed 24: {parsedString} \n");
                    //    await turnContext.SendActivityAsync($"Input: {input24} Format: {format24} \n");
                    //}
                    //else
                    //{
                    //    await turnContext.SendActivityAsync($"FAILED 24: Input: {input24} Format: {format24} \n");
                    //}



                    /////////////////////////////////////////////////////////////

                    var inputSystematic  = "2018-10-28T14";
                    var formatSystematic = "yyyy-MM-ddTH:mm";

                    if (!inputSystematic.Contains(":"))
                    {
                        inputSystematic = inputSystematic + ":00";
                    }

                    if (DateTime.TryParseExact(inputSystematic, formatSystematic, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsed))
                    {
                        parsedString = parsed.ToString();
                        await turnContext.SendActivityAsync($"Parsed Systematic: {parsedString} \n");

                        await turnContext.SendActivityAsync($"Input Systematic: {inputSystematic} Format: {formatSystematic} \n");
                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"FAILED Systematic: Input: {inputSystematic} Format: {formatSystematic} \n");
                    }
                    /////////////////////////////
                    ///
                    var dayOfWeek = "XXXX-WXX-7";

                    if (dayOfWeek.Contains("XXXX-WXX-"))
                    {
                        dayOfWeek = dayOfWeek.Replace("XXXX-WXX-", "");
                        //var newItem = dayOfWeek;
                    }

                    await turnContext.SendActivityAsync($"Day of week via XXXX-WXX- : {dayOfWeek} \n");

                    var dayOfWeekPlusHours = " XXXX-WXX-7T17";

                    string justTheHours = "";

                    if (dayOfWeekPlusHours.Contains("T"))
                    {
                        if (!dayOfWeekPlusHours.Contains(":"))
                        {
                            dayOfWeekPlusHours = dayOfWeekPlusHours + ":00";
                        }

                        //count number of characters
                        //count position of T
                        //grab after T to final

                        var lengthOfString = dayOfWeekPlusHours.Length;
                        var positionOfT    = dayOfWeekPlusHours.LastIndexOf("T");
                        justTheHours       = dayOfWeekPlusHours.Substring(positionOfT, lengthOfString - positionOfT);
                        dayOfWeekPlusHours = dayOfWeekPlusHours.Replace(justTheHours, "");
                    }

                    if (dayOfWeekPlusHours.Contains("XXXX-WXX-"))
                    {
                        dayOfWeekPlusHours = dayOfWeekPlusHours.Replace("XXXX-WXX-", "");
                        //var newItem = dayOfWeek;
                    }

                    string nameDayOfWeekPlusHourPostFormat = DayOfWeekByStringNumber(dayOfWeek);
                    await turnContext.SendActivityAsync($"Entities DayOfWeekPlusHours. {nameDayOfWeekPlusHourPostFormat}\n");

////////////////////////////////////////////////////////////////////
                    var formatDayOfWeekPlusHoursTheHours = "TH:mm";

                    DateTime parsedFormatDayOfWeekPlusHoursTheHours;
                    string   parsedStringFormatDayOfWeekPlusHoursTheHours;

                    if (DateTime.TryParseExact(justTheHours, formatDayOfWeekPlusHoursTheHours, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedFormatDayOfWeekPlusHoursTheHours))
                    {
                        parsedStringFormatDayOfWeekPlusHoursTheHours = parsed.ToString();
                        //return parsedStringFormatDayOfWeekPlusHoursTheHours;
                        await turnContext.SendActivityAsync($"Entities DayOfWeekPlusHours: {parsedStringFormatDayOfWeekPlusHoursTheHours}\n");
                    }

                    //Unformatted
                    await turnContext.SendActivityAsync($"Entities: {dateAndDateTimeClassTheDate} and {dateAndDateTimeClassTheDateTime} \n");

                    //Format-1
                    string nameDayOfWeekPostFormat = DayOfWeekByStringNumber(dateAndDateTimeClassTheDate);
                    await turnContext.SendActivityAsync($"Entities Through Methods and Formatted: 1. {nameDayOfWeekPostFormat}\n");

                    //Format-2
                    var dateAndDateTimeClassTheDatePostFormatted = FormattingHoursWithOrWithoutMinutes(dateAndDateTimeClassTheDateTime);
                    var formattedTime = FormatDateTimeBasedOnTHmm(dateAndDateTimeClassTheDatePostFormatted);
                    await turnContext.SendActivityAsync($"Entities Through Methods and Formatted: 2. {formattedTime}\n");


                    //Format-3
                    var formattedDate = FormatDateTimeBasedOnYMD(dateAndDateTimeClassTheDateTime);
                    await turnContext.SendActivityAsync($"Entities Through Methods and Formatted: 3. {formattedDate}\n");

                    //Format-4
                    var formattedDateTryParse = FormatDateTimeTryParse(dateAndDateTimeClassTheDateTime);
                    await turnContext.SendActivityAsync($"Entities Through Methods and Formatted: 4. {formattedDateTryParse}\n");

                    //Format-5
                    var formattedDateWithoutYear = FormatDateTimeWithoutYear(dateAndDateTimeClassTheDateTime);
                    await turnContext.SendActivityAsync($"Entities Through Methods and Formatted: 5. {formattedDateWithoutYear} \n");

                    //Formatted
                    await turnContext.SendActivityAsync($"Entities Through Methods and Formatted: 1. {nameDayOfWeekPostFormat} and 2. {formattedTime} and 3. {formattedDate} and 4. {formattedDateTryParse}\n");

                    //string nameDayOfWeek = DayOfWeekByStringNumber(dayOfWeek);
                    //await turnContext.SendActivityAsync($"Entity formatted by XXXX-WXX- from 'dateAndDateTimeClassTheDate': {nameDayOfWeek} \n");

                    //await turnContext.SendActivityAsync($"Entities: {dateAndDateTimeClassTheDate} and {dateAndDateTimeClassTheDateTime} \n");
                }
                else
                {
                    var msg = @"No LUIS intents were found.
                            This sample is about identifying two user intents:
                            'Calendar.Add'
                            'Calendar.Find'
                            Try typing 'Add Event' or 'Show me tomorrow'.";
                    await turnContext.SendActivityAsync(msg);
                }
            }
            else if (turnContext.Activity.Type == ActivityTypes.ConversationUpdate)
            {
                // Send a welcome message to the user and tell them what actions they may perform to use this bot
                await SendWelcomeMessageAsync(turnContext, cancellationToken);
            }
            else
            {
                await turnContext.SendActivityAsync($"{turnContext.Activity.Type} event detected", cancellationToken : cancellationToken);
            }
        }
Beispiel #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.RouteData.Values["Id"] != null)
            {
                id = Page.RouteData.Values["Id"] as string;
            }
            if (Microsoft.VisualBasic.Information.IsNumeric(id) == false)
            {
                return;
            }
            if (Request.Cookies["CurrentLanguage"] != null)
            {
                Lang = Request.Cookies["CurrentLanguage"].Value;
            }
            if (!IsPostBack)
            {
                try
                {
                    DataTable dtNews = NewsService.News_GetById(id);
                    if (dtNews.Rows.Count > 0)
                    {
                        Label lblName = (Label)Master.FindControl("lblName");
                        sTitleName = dtNews.Rows[0]["Name"].ToString();
                        Page.Title = sTitleName;
                        sContent   = dtNews.Rows[0]["Content"].ToString();
                        sDetail    = dtNews.Rows[0]["Detail"].ToString();
                        sDateTime  = DateTimeClass.ConvertDate(dtNews.Rows[0]["Date"].ToString(), "dd/MM/yyyy - HH:mm");
                        if (Request.RawUrl.IndexOf(Consts.CON_VAN_BAN) < 0)
                        {
                            SqlDataProvider sql  = new SqlDataProvider();
                            string          view = dtNews.Rows[0]["Views"].ToString();
                            view = (int.Parse(view) + 1).ToString();
                            string sSQL = "Update News set Views=" + view + " Where Id=" + id;
                            sql.ExecuteNonQuery(sSQL);

                            DataTable dtG = GroupNewsService.GroupNews_GetById(dtNews.Rows[0]["GroupNewsId"].ToString());
                            if (dtG.Rows.Count > 0)
                            {
                                idU_OtherGroupNews.Level = dtG.Rows[0]["Level"].ToString();
                                groupName = dtG.Rows[0]["Name"].ToString();
                                if (lblName != null)
                                {
                                    lblName.Text = groupName;
                                }
                            }

                            DataTable dtNewsReleate = NewsService.News_GetByTop("4", "Id <> " + id + " AND Active = 1 AND GroupNewsId = '" + dtNews.Rows[0]["GroupNewsId"].ToString() + "' AND Language='" + Lang + "'", "Date Desc");
                            if (dtNewsReleate.Rows.Count > 0)
                            {
                                if (Lang == "en")
                                {
                                    titleReleate = "Relative News";
                                }
                                else
                                {
                                    titleReleate = "Tin liên quan";
                                }
                                rptReleative.DataSource = PageHelper.ModifyData(dtNewsReleate, Consts.CON_TIN_TUC);
                                rptReleative.DataBind();
                            }
                            dtNewsReleate.Clear();
                            dtNewsReleate.Dispose();
                        }
                        else
                        {
                            idU_OtherGroupNews.Visible = false;
                            rptReleative.Visible       = false;
                        }
                        DataTable dtLastNews = NewsService.News_GetByTop("10", "Id <> " + id + "  AND GroupNewsId IN (Select Id from GroupNews where Active=1 AND [Index]=0) AND Active = 1 AND Language='" + Lang + "'", "Date Desc");
                        dtLastNews = PageHelper.ModifyData(dtLastNews, Consts.CON_TIN_TUC);
                        DataTable dtLeft = dtLastNews.Clone();
                        for (int i = 0; i < dtLastNews.Rows.Count; i++)
                        {
                            DataRow dr = dtLastNews.Rows[i];
                            if (i < 5)
                            {
                                dtLeft.Rows.Add(dr.ItemArray);
                                dr.Delete();
                                dtLastNews.AcceptChanges();
                            }
                            else
                            {
                                break;
                            }
                        }
                        rptLeft.DataSource = dtLeft;
                        rptLeft.DataBind();
                        rptRight.DataSource = dtLastNews;
                        rptRight.DataBind();
                    }
                }
                catch (Exception ex)
                {
                    MailSender.SendMail("", "", "Error System", ex.Message);
                }
            }
        }
Beispiel #27
0
        public static async Task CommandDispatcherMethod(TelegramBotAbstract sender, MessageEventArgs e)
        {
            var cmdLines = e.Message.Text.Split(' ');
            var cmd      = cmdLines[0].Trim();

            if (cmd.Contains("@"))
            {
                var cmd2        = cmd.Split("@");
                var botUsername = await sender.GetBotUsernameAsync();

                if (cmd2[1].ToLower() != botUsername.ToLower())
                {
                    return;
                }
            }

            switch (cmd)
            {
            case "/start":
            {
                await Start(sender, e);

                return;
            }

            case "/force_check_invite_links":
            {
                if (GlobalVariables.Creators.Contains(e.Message?.Chat?.Username?.ToLower()))
                {
                    _ = ForceCheckInviteLinksAsync(sender, e);
                }
                else
                {
                    await DefaultCommand(sender, e);
                }
                return;
            }

            case "/contact":
            {
                await ContactUs(sender, e);

                return;
            }

            case "/help":
            {
                await Help(sender, e);

                return;
            }

            case "/muteAll":
            {
                if (e.Message.Chat.Type != ChatType.Private)
                {
                    await CommandNotSentInPrivateAsync(sender, e);

                    return;
                }

                if (GlobalVariables.AllowedMuteAll.Contains(e.Message.From?.Username?.ToLower()))
                {
                    _ = MuteAllAsync(sender, e, cmdLines, e.Message.From.LanguageCode, e.Message.From.Username);
                }
                else
                {
                    await DefaultCommand(sender, e);
                }
                return;
            }

            case "/banAll":
            {
                if (e.Message.Chat.Type != ChatType.Private)
                {
                    await CommandNotSentInPrivateAsync(sender, e);

                    return;
                }

                if (GlobalVariables.AllowedBanAll.Contains(e.Message.From?.Username?.ToLower()))
                {
                    _ = BanAllAsync(sender, e, cmdLines, e.Message.From.LanguageCode, e.Message.From.Username);
                }
                else
                {
                    await DefaultCommand(sender, e);
                }
                return;
            }

            /*
             * case "/massiveSend":
             * {
             *  if (e.Message.Chat.Type != ChatType.Private)
             *  {
             *      await CommandNotSentInPrivateAsync(sender, e);
             *      return;
             *  }
             *
             *  try
             *  {
             *      if (GlobalVariables.AllowedBanAll.Contains(e.Message.From?.Username?.ToLower()))
             *          _ = MassiveSendAsync(sender, e, cmdLines, e.Message.From.LanguageCode, e.Message.From.Username);
             *      else
             *          await DefaultCommand(sender, e);
             *  }
             *  catch
             *  {
             *      ;
             *  }
             *
             *  return;
             * }
             */

            case "/ban":
            {
                _ = BanUserAsync(sender, e, cmdLines);
                return;
            }

            case "/banAllHistory":
            {
                // _ = BanUserAsync(sender, e, cmdLines);
                _ = BanUserHistoryAsync(sender, e);
                return;
            }

            case "/unbanAll":
            {
                if (e.Message.Chat.Type != ChatType.Private)
                {
                    await CommandNotSentInPrivateAsync(sender, e);

                    return;
                }

                if (GlobalVariables.AllowedBanAll.Contains(e.Message.From?.Username?.ToLower()))
                {
                    _ = UnbanAllAsync(sender, e, cmdLines, e.Message.From.LanguageCode, e.Message.From.Username);
                }
                else
                {
                    await DefaultCommand(sender, e);
                }
                return;
            }

            case "/test_spam":
            {
                if (e.Message == null)
                {
                    return;
                }
                if (e.Message.ReplyToMessage == null)
                {
                    return;
                }

                await TestSpamAsync(e.Message.ReplyToMessage, sender, e);

                return;
            }

            case "/groups":
            {
                await SendRecommendedGroupsAsync(sender, e);

                return;
            }

            case "/getGroups":
            {
                if ((GlobalVariables.Creators.Contains(e.Message.From.Username) ||
                     Owners.CheckIfOwner(e.Message.From.Id)) &&
                    e.Message.Chat.Type == ChatType.Private)
                {
                    string username = null;
                    if (!string.IsNullOrEmpty(e.Message.From.Username))
                    {
                        username = e.Message.From.Username;
                    }

                    _ = GetAllGroups(e.Message.From.Id, username, sender, e.Message.From.LanguageCode);
                    return;
                }

                await DefaultCommand(sender, e);

                return;
            }

            case "/allowmessage":
            {
                if ((Owners.CheckIfOwner(e.Message.From.Id)) &&
                    e.Message.Chat.Type == ChatType.Private)
                {
                    if (e.Message.ReplyToMessage == null || string.IsNullOrEmpty(e.Message.ReplyToMessage.Text))
                    {
                        var text = new Language(new Dictionary <string, string>
                            {
                                { "en", "You have to reply to a message containing the message" }
                            });
                        await sender.SendTextMessageAsync(e.Message.From.Id, text, ChatType.Private,
                                                          e.Message.From.LanguageCode, ParseMode.Html, null, e.Message.From.Username,
                                                          e.Message.MessageId);

                        return;
                    }

                    AllowedMessages.AddMessage(e.Message.ReplyToMessage.Text);
                    return;
                }

                await DefaultCommand(sender, e);

                return;
            }

            case "/unallowmessage":
            {
                if ((Owners.CheckIfOwner(e.Message.From.Id)) &&
                    e.Message.Chat.Type == ChatType.Private)
                {
                    if (e.Message.ReplyToMessage == null || string.IsNullOrEmpty(e.Message.ReplyToMessage.Text))
                    {
                        var text = new Language(new Dictionary <string, string>
                            {
                                { "en", "You have to reply to a message containing the message" }
                            });
                        await sender.SendTextMessageAsync(e.Message.From.Id, text, ChatType.Private,
                                                          e.Message.From.LanguageCode, ParseMode.Html, null, e.Message.From.Username,
                                                          e.Message.MessageId);

                        return;
                    }

                    AllowedMessages.removeMessage(e.Message.ReplyToMessage.Text);
                    return;
                }

                await DefaultCommand(sender, e);

                return;
            }

            case "/updateGroups":
            {
                if ((GlobalVariables.Creators.Contains(e.Message.From.Username) ||
                     Owners.CheckIfOwner(e.Message.From.Id)) &&
                    e.Message.Chat.Type == ChatType.Private)
                {
                    //System.Data.DataTable groups = Groups.GetAllGroups();
                    //var jsonFile = JObject.Parse(groups.ToString());
                    if (Variabili.L == null)
                    {
                        Variabili.L = new ListaGruppo();
                    }

                    Variabili.L.ImportaGruppiDaTabellaTelegramGruppiBot_PuntoBin();

                    var json =
                        JsonBuilder.getJson(new CheckGruppo(CheckGruppo.E.RICERCA_SITO_V3),
                                            false);
                }

                await DefaultCommand(sender, e);

                return;
            }

            case "/testtime":
            {
                if (e.Message.Chat.Type == ChatType.Private)
                {
                    await TestTime(sender, e);
                }

                return;
            }

            case "/time":
            {
                var lang = new Language(new Dictionary <string, string>
                    {
                        { "", DateTimeClass.NowAsStringAmericanFormat() }
                    });
                await SendMessage.SendMessageInPrivate(sender, e.Message.From.Id,
                                                       usernameToSendTo : e.Message.From.Username, langCode : e.Message.From.LanguageCode,
                                                       text : lang, parseMode : ParseMode.Default, messageIdToReplyTo : null);

                return;
            }

            case "/assoc_write":
            case "/assoc_send":
            {
                _ = await Assoc.Assoc_SendAsync(sender, e);

                return;
            }

            case "/assoc_publish":
            {
                if (Owners.CheckIfOwner(e.Message.From.Id))
                {
                    _ = await Assoc.Assoc_Publish(sender, e);
                }
                else
                {
                    _ = await DefaultCommand(sender, e);
                }
                return;
            }

            case "/assoc_read":
            {
                _ = await Assoc.Assoc_Read(sender, e, false);

                return;
            }

            case "/assoc_read_all":
            {
                if (Owners.CheckIfOwner(e.Message.From.Id))
                {
                    _ = await Assoc.Assoc_ReadAll(sender, e);
                }
                else
                {
                    _ = await DefaultCommand(sender, e);
                }
                return;
            }

            case "/assoc_delete":
            case "/assoc_remove":
            {
                _ = await Assoc.Assoc_Delete(sender, e);

                return;
            }

            case "/rooms":
            {
                await Rooms.RoomsMainAsync(sender, e);

                return;
            }

            case "/rules":
            {
                _ = await Rules(sender, e);

                return;
            }

            case "/qe":
            {
                _ = await QueryBot(true, e, sender);

                return;
            }

            case "/qs":
            {
                _ = await QueryBot(false, e, sender);

                return;
            }

            case "/update_links_from_json":
            {
                await InviteLinks.UpdateLinksFromJsonAsync(sender, e);

                return;
            }

            default:
            {
                await DefaultCommand(sender, e);

                return;
            }
            }
        }
Beispiel #28
0
 public FormalBusiness(ISchedulerFactory schedulerFactory)
 {
     _schedulerFactory = schedulerFactory ?? throw new ArgumentNullException(nameof(schedulerFactory));
     timeClass         = new DateTimeClass();
     helperFunction    = new HelperFunction();
 }
    void load_DDH()
    {
        string        tennguoidung = Session["nguoidung"].ToString();
        string        thongtinkh   = "select * from Nguoi_Dung where Ten_Nguoi_Dung='" + tennguoidung + "'";
        DataTable     dt           = XLDL.docbang(thongtinkh);
        int           manguoidung  = int.Parse(dt.Rows[0][0].ToString());
        SqlConnection conn         = new SqlConnection(DataProvider.ConnectionString);
        SqlCommand    cmd          = new SqlCommand("select * from Thue_Xe where userid = @Ma_KH and end_date <='" + DateTimeClass.ConvertDateTime(DateTime.Now, "MM/dd/yyyy HH:mm:ss tt") + "'", conn);

        cmd.Parameters.AddWithValue("@Ma_KH", manguoidung);
        SqlDataAdapter adapter;

        adapter = new SqlDataAdapter(cmd);
        // PHANLOAI = adapter.("PHAN_LOAI");
        DataTable dt_TX_hethan = new DataTable();

        adapter.Fill(dt_TX_hethan);
        adapter.Dispose();
        gdvTX.DataSource = dt_TX_hethan;
        gdvTX.DataBind();
        //load DDH chưa giao

        SqlCommand cmd1 = new SqlCommand("select * from Thue_Xe where userid = @Ma_KH1 and end_date >'" + DateTimeClass.ConvertDateTime(DateTime.Now, "MM/dd/yyyy HH:mm:ss tt") + "'", conn);

        cmd1.Parameters.AddWithValue("@Ma_KH1", manguoidung);
        SqlDataAdapter adapter2;

        adapter2 = new SqlDataAdapter(cmd1);
        // PHANLOAI = adapter.("PHAN_LOAI");
        DataTable dt_TX_hientai = new DataTable();

        adapter2.Fill(dt_TX_hientai);
        adapter2.Dispose();
        gdvTX2.DataSource = dt_TX_hientai;
        gdvTX2.DataBind();
    }
 internal void ConvertDateTimeToString(DateTimeClass source)
 {
     Assert.Equal(source.MapTo <DateTimeClassDto>().Date, source.Date.ToString(CultureInfo.CurrentUICulture));
 }