Beispiel #1
0
        //test WebForm

        //test SQL
        protected void Button2_selectSQL(object sender, EventArgs e)
        {
            //var bot = new Bot(channelAccessToken);
            //bot.PushMessage(AdminUserId, 1,2);

            //var sql = new SQLcontroller("61.216.65.239", "mydb", "sa", "leegood");
            //Console.WriteLine(sql.GetMemberInfo());

            //MemberInfo mi = new MemberInfo();
            //mi.Email = "*****@*****.**";
            //mi.Name = "leegood";
            //mi.LineID = "ouyr2345jhxcvncc";
            //mi.Valid = "not yet";
            //mi.AuthTime = DateTime.Now;
            //sql.InsertMemberInfo(mi);
            var sql = new SQLcontroller("61.216.65.239", "mydb", "sa", "leegood");

            sql.InsertMemberInfo(new MemberInfo
            {
                Email    = "*****@*****.**",
                Name     = "kaiiak",
                LineID   = "23456789qwertyuisdfghj",
                Valid    = "OK",
                AuthTime = DateTime.Now
            });
            //Mail_Server.MailController.SendEmail();
        }
Beispiel #2
0
        public void SearchMember(object sender, EventArgs e)
        {
            var    sql  = new SQLcontroller("192.168.3.247", "mydb", "leegood", "leegood");
            string name = "";

            name = searchNameTxb.Text;
            var result = sql.CheckMember(name);

            if (result.Count != 0)
            {
                Label2.Visible  = true;
                Label3.Visible  = true;
                Button1.Visible = true;
                Label2.Text     = result[0].Seq.ToString();
                Label3.Text     = result[0].Name + "  " + result[0].Email;
            }
            else
            {
                Label2.Visible  = false;
                Label3.Visible  = true;
                Button1.Visible = false;
                Label3.Text     = "查無資料";
            }

            //Label2.Text = result.;
        }
Beispiel #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         var sql = new SQLcontroller("192.168.3.247", "mydb", "sa", "leegood#09477027");
         LoadData("select * from [dbo].[MemberInfo] where [Valid] is NULL");
     }
     bot = new isRock.LineBot.Bot("fTBvt+oi30MpuWqTvT/KJDBuKDJ8iKxPhJLX5fHwT+bha1vEfZPfprFFQ7LrdgdyrDnx/yDe1C+hTbLtYxojWGRyAbRVz2iuok8WbUiZBeOn3gxlUjs5gpsGQmmySmmF9m/Uat9ZwLWxomFA3FZ6jgdB04t89/1O/w1cDnyilFU=");
 }
Beispiel #4
0
        public void verify(object sender, EventArgs e)
        {
            var sql    = new SQLcontroller("192.168.3.247", "mydb", "leegood", "leegood");
            var LineID = sql.GetMemberLineID(searchNameTxb.Text);

            if (sql.UpdateMemberInfo(Label2.Text))
            {
                bot.PushMessage(LineID[0].LineID.ToString(), "會員已啟用,快試試檢查門窗吧!!!");
                Button1.BackColor = System.Drawing.Color.Green;
            }
            //var result = sql.UpdateMemberInfo()
        }
Beispiel #5
0
        //select SQL
        //protected void selectSQL(object sender, EventArgs even)
        //{
        //    var sql = new SQLcontroller("127.0.0.1", "mydb", "sa", "leegood#09477027");
        //    string LineID = "'U8168367ec76c449dbdd98410d9333b8b'";
        //    var reerer = sql.GetMemberInfo(Txb2.Text);
        //    if (reerer.Count == 3)
        //    {
        //        kai.Text = "沒有權限";
        //    }
        //    else
        //    {
        //        kai.Text = "pass";
        //    }
        //}

        //insert Member info to SQL
        protected void insertSQL(object sender, EventArgs e)
        {
            //string queryString_url;
            //queryString_url = "?name=" + Label2;
            //Response.Redirect(queryString_url);     //queryString 使用完後重新導向新的網站
            //var bot = new isRock.LineBot.Bot();
            var name = Txb1.Text;
            var mail = Txb2.Text;

            if (name == "" || mail == "")
            {
                kai.Text = "不能空白喔";
                return;
            }
            //var message = Txb3.Text;
            var sql = new SQLcontroller("192.168.3.247", "mydb", "leegood", "leegood");

            var result = sql.CheckMember(Label2);

            if (result.Count == 0)
            {
                sql.InsertMemberInfo(new MemberInfo
                {
                    Email  = mail,
                    Name   = name,
                    LineID = Label2,
                    //Valid = "",
                    AuthTime = DateTime.Now
                });
                kai.Text = "申請成功!";
            }
            else
            {
                kai.Text = "重複的帳號";
            }
        }
        public IHttpActionResult POST()
        {
            //設定允許控制的星期
            var week = new List <string> {
                "週一", "週二", "週三", "週四", "週五", "週六"
            };
            var sql = new SQLcontroller("192.168.3.247", "mydb", "leegood", "leegood");
            ScheduleControll time = new ScheduleControll();
            RestAPI          api  = new RestAPI();

            try
            {
                //設定ChannelAccessToken(或抓取Web.Config)
                this.ChannelAccessToken = channelAccessToken;
                //取得Line Event(範例,只取第一個)
                var LineEvent = this.ReceivedMessage.events.FirstOrDefault();
                //配合Line verify
                if (LineEvent.replyToken == "00000000000000000000000000000000")
                {
                    return(Ok());
                }
                //回覆訊息
                if (LineEvent.type == "postback")
                {
                    string msg = LineEvent.postback.data;
                    //msg += $"\n Params.date : {LineEvent.postback.Params.date + ""}";
                    //msg += $"\n Params.datetime : {LineEvent.postback.Params.datetime + ""}";
                    //msg += $"\n Params.time : {LineEvent.postback.Params.time + ""}";
                    this.ReplyMessage(LineEvent.replyToken, msg);
                    return(Ok());
                }

                if (LineEvent.type == "message")
                {
                    if (LineEvent.message.type == "text")
                    { //收到文字
                      //this.ReplyMessage(LineEvent.replyToken, "你說了:" + LineEvent.message.text);

                        if (LineEvent.message.text == "個人設定")
                        {
                            ButtonTemplateParameter info = new ButtonTemplateParameter();
                            info.LineID = LineEvent.source.userId;
                            linebot227.Functions.LineTemplate.LoginTemplete(info);
                        }

                        if (LineEvent.message.text == "監看狀態" && check.VeriMember(LineEvent.source.userId))
                        {
                            ButtonTemplateParameter status = new ButtonTemplateParameter();
                            status.LineID   = LineEvent.source.userId;
                            status.ViewURL1 = "http://api.leegood.com.tw:58088/LGoffice_/home.htm";
                            status.ViewURL2 = "http://api.leegood.com.tw:58088/LGoffice_/4f_sa.htm";
                            LineTemplate.BuildingStatusTemplete(status);
                        }
                        if (LineEvent.message.text == "遠端控制" && check.VeriMember(LineEvent.source.userId))
                        {
                            ButtonTemplateParameter status = new ButtonTemplateParameter
                            {
                                LineID = LineEvent.source.userId
                            };
                            LineTemplate.CarouselTemplateTest(status);
                        }
                        if (LineEvent.message.text == "開啟6樓系統部空調" && check.VeriMember(LineEvent.source.userId))
                        {
                            LogInfo log = new LogInfo();
                            log.AuthTime = DateTime.Now;
                            log.Event    = "Open6FX-TeamAircon";
                            log.LineID   = LineEvent.source.userId;
                            sql.InsertLogTime(log);
                            var isOpenTime = time.Schedule(week, 9, 24, LineEvent.source.userId);
                            if (isOpenTime)
                            {
                                if (api.GetValue("020004") == 1)
                                {
                                    this.ReplyMessage(LineEvent.replyToken, "系統部冷氣是開著的喔.....");
                                }
                                else
                                {
                                    api.SetValue("020032", 1);
                                    Thread.Sleep(800);         //Delay 1秒
                                    api.SetValue("020032", 0); //020032
                                    if (api.GetValue("020004") == 1)
                                    {
                                        this.ReplyMessage(LineEvent.replyToken, "成功開啟空調");
                                    }
                                }
                            }
                        }
                        if (LineEvent.message.text == "開啟6樓工程部空調" && check.VeriMember(LineEvent.source.userId))
                        {
                            LogInfo log = new LogInfo();
                            log.AuthTime = DateTime.Now;
                            log.Event    = "Open6FEngineerAircon";
                            log.LineID   = LineEvent.source.userId;
                            sql.InsertLogTime(log);
                            var isOpenTime = time.Schedule(week, 9, 24, LineEvent.source.userId);
                            if (isOpenTime)
                            {
                                if (api.GetValue("020001") == 1)
                                {
                                    this.ReplyMessage(LineEvent.replyToken, "工程部冷氣是開著的喔.....");
                                }
                                else
                                {
                                    api.SetValue("020031", 1);
                                    Thread.Sleep(800);         //Delay 1秒
                                    api.SetValue("020031", 0); //020032
                                    if (api.GetValue("020001") == 1)
                                    {
                                        this.ReplyMessage(LineEvent.replyToken, "成功開啟空調");
                                    }
                                }
                            }
                        }
                        if (LineEvent.message.text == "開啟4樓會議室空調" && check.VeriMember(LineEvent.source.userId))
                        {
                            LogInfo log = new LogInfo();
                            log.AuthTime = DateTime.Now;
                            log.Event    = "Open4FConferenceRoomAircon";
                            log.LineID   = LineEvent.source.userId;
                            sql.InsertLogTime(log);
                            var isOpenTime = time.Schedule(week, 9, 24, LineEvent.source.userId);
                            if (isOpenTime)
                            {
                                if (api.GetValue("010001") == 1)
                                {
                                    this.ReplyMessage(LineEvent.replyToken, "4F會議室冷氣是開著的喔.....");
                                }
                                else
                                {
                                    api.SetValue("010031", 1);
                                    Thread.Sleep(800);
                                    api.SetValue("010031", 0);
                                    if (api.GetValue("010001") == 1)
                                    {
                                        this.ReplyMessage(LineEvent.replyToken, "成功開啟空調");
                                    }
                                }
                            }
                        }
                        if (LineEvent.message.text == "開啟4樓組盤間空調" && check.VeriMember(LineEvent.source.userId))
                        {
                            LogInfo log = new LogInfo();
                            log.AuthTime = DateTime.Now;
                            log.Event    = "Open4FDIYRoomAircon";
                            log.LineID   = LineEvent.source.userId;
                            sql.InsertLogTime(log);
                            var isOpenTime = time.Schedule(week, 9, 24, LineEvent.source.userId);
                            if (isOpenTime)
                            {
                                if (api.GetValue("010004") == 1)
                                {
                                    this.ReplyMessage(LineEvent.replyToken, "4樓組盤間冷氣是開著的喔");
                                }
                                else
                                {
                                    api.SetValue("010032", 1);
                                    Thread.Sleep(800);         //Delay 1秒
                                    api.SetValue("010032", 0); //020032
                                    if (api.GetValue("010004") == 1)
                                    {
                                        this.ReplyMessage(LineEvent.replyToken, "成功開啟空調");
                                    }
                                    else
                                    {
                                        this.ReplyMessage(LineEvent.replyToken, "失敗");
                                    }
                                }
                            }
                        }
                        if (LineEvent.message.text == "4444" && check.VeriMember(LineEvent.source.userId))
                        {
                            LogInfo log = new LogInfo();
                            log.AuthTime = DateTime.Now;
                            log.Event    = "Open4FDoor";
                            log.LineID   = LineEvent.source.userId;
                            sql.InsertLogTime(log);
                            var isOpenTime = time.Schedule(week, 9, 24, LineEvent.source.userId);
                            if (isOpenTime)
                            {
                                api.SetValue("010007", 1);
                                Thread.Sleep(800);         //Delay 1秒
                                api.SetValue("010007", 0); //020032
                            }
                        }
                        if (LineEvent.message.text == "6666" && check.VeriMember(LineEvent.source.userId))
                        {
                            LogInfo log = new LogInfo();
                            log.AuthTime = DateTime.Now;
                            log.Event    = "Open6FDoor";
                            log.LineID   = LineEvent.source.userId;
                            sql.InsertLogTime(log);
                            var isOpenTime = time.Schedule(week, 9, 24, LineEvent.source.userId);
                            if (isOpenTime)
                            {
                                api.SetValue("020007", 1);
                                Thread.Sleep(800);         //Delay 1秒
                                api.SetValue("020007", 0); //020032
                            }
                        }
                        if (LineEvent.message.text == "檢查門窗" && check.VeriMember(LineEvent.source.userId))
                        {
                            //RestAPI api = new RestAPI();
                            LogInfo log = new LogInfo();
                            log.AuthTime = DateTime.Now;
                            log.Event    = "checkDoor";
                            log.LineID   = LineEvent.source.userId;
                            sql.InsertLogTime(log);
                            var pointName = new List <string>
                            {
                                //6樓
                                "6樓大門,",
                                "志中旁窗戶,",
                                "柏欽旁窗戶,",
                                "禹任旁窗戶,",
                                "蕭董辦公室沙發旁,",
                                "蕭座位旁窗戶,",
                                "系統部窗戶,",
                                "小房間",
                                "測試點,",
                                //4樓
                                "4F大門,",
                                "組盤間,",
                                "測試間窗-1,",
                                "羅小姐辦公室窗-1,",
                                "羅小姐辦公室窗-2,",
                                "小會議室窗,",
                                "鄭總辦公室窗,",
                                "測試間窗-2"
                            };
                            var points = new List <string>
                            {
                                //6樓
                                "020030",          //大門        value是1代表門是開的
                                "BA_020023",       //志中旁窗戶
                                "BA_020024",       //柏欽旁窗戶
                                "BA_020025",       //禹任旁窗戶
                                "BA_020026",       //蕭董辦公室沙發旁
                                "BA_020027",       //蕭座位旁窗戶
                                "BA_020028",       //系統部窗戶
                                "BA_020029",       //小房間
                                "DO1",             //測試點
                                //4樓
                                "010127",
                                "BA_010121",
                                "BA_010122",
                                "BA_010123",
                                "BA_010124",
                                "BA_010125",
                                "BA_010126",
                                "BA_010128"
                            };
                            this.ReplyMessage(LineEvent.replyToken, api.GetListValue(points, pointName));
                            //bool isIn = points.Contains(1);
                            //string openStatus = "";
                            //int count = 0;
                            //if (isIn)
                            //{
                            //    foreach (var point in points)
                            //    {
                            //        count++;
                            //        if (point == 1)
                            //        {
                            //            openStatus += pointName[count - 1];
                            //        }
                            //    }
                            //    this.ReplyMessage(LineEvent.replyToken, openStatus+"沒關");
                            //}
                            //else
                            //{
                            //    this.ReplyMessage(LineEvent.replyToken, "門窗都關好了");
                            //}
                        }
                    }


                    if (LineEvent.message.type == "sticker") //收到貼圖
                    {
                        this.ReplyMessage(LineEvent.replyToken, 1, 2);
                    }
                }
                //response OK
                return(Ok());
            }
            catch (Exception ex)
            {
                //如果發生錯誤,傳訊息給Admin
                this.PushMessage(AdminUserId, "發生錯誤:\n" + ex.Message);
                //response OK
                return(Ok());
            }
        }