Ejemplo n.º 1
0
        private void BatchPushNotice()
        {
            //必須要使用greening帳號登入才能用
            System.Xml.XmlDocument doc  = new System.Xml.XmlDocument();
            XmlElement             root = doc.CreateElement("Request");

            //標題
            var eleTitle = doc.CreateElement("Title");

            eleTitle.InnerText = "日常生活預警表已送達";
            root.AppendChild(eleTitle);

            //發送人員
            var eleDisplaySender = doc.CreateElement("DisplaySender");

            eleDisplaySender.InnerText = "電子報表通知";
            root.AppendChild(eleDisplaySender);

            //背景
            if (_message != "")
            {
                var eleMessage = doc.CreateElement("Message");
                eleMessage.InnerText = _message;
                root.AppendChild(eleMessage);

                foreach (string each in _tagIDList)
                {
                    //發送對象
                    var eleTarget = doc.CreateElement("TargetTeacher");
                    eleTarget.InnerText = each;
                    root.AppendChild(eleTarget);
                }

                //送出
                FISCA.DSAClient.XmlHelper xmlHelper = new FISCA.DSAClient.XmlHelper(root);
                var conn = new FISCA.DSAClient.Connection();
                conn.Connect(FISCA.Authentication.DSAServices.AccessPoint, "1campus.notice.admin.v17", FISCA.Authentication.DSAServices.PassportToken);
                var resp = conn.SendRequest("PostNotice", xmlHelper);


                //處理Log
                StringBuilder sb_log   = new StringBuilder();
                List <string> byAction = new List <string>();

                byAction.Add("老師");

                sb_log.AppendLine(string.Format("發送對象「{0}」", string.Join(",", byAction)));
                sb_log.AppendLine(string.Format("發送標題「{0}」", "日常生活預警表已傳送"));
                sb_log.AppendLine(string.Format("發送單位「{0}」", "電子報表通知"));
                sb_log.AppendLine(string.Format("發送內容「{0}」", _message));
                sb_log.AppendLine(string.Format("對象清單「{0}」", string.Join(",", _tagIDList)));

                FISCA.LogAgent.ApplicationLog.Log("智慧簡訊", "發送", sb_log.ToString());
            }
            else
            {
                MsgBox.Show("請輸入內容");
            }
        }
Ejemplo n.º 2
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            //    <Request>
            //    <Title>鄭明典:今日發展是關鍵</Title>
            //    <DisplaySender>芝儀</DisplaySender>
            //    <Message>鄭明典今(25)日上午於臉書上指出,目前在菲律賓東方海面上有一熱帶性低氣壓,是否會再增強須看今日發展狀況。</Message>
            //    <Category>教務</Category>
            //    <TargetStudent>17736</TargetStudent>
            //    </Request>

            //必須要使用greening帳號登入才能用
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            var root = doc.CreateElement("Request");

            //發送者名稱
            var eleTitle = doc.CreateElement("Title");

            eleTitle.InnerText = tbTitle.Text;
            root.AppendChild(eleTitle);
            //發送人員
            var eleDisplaySender = doc.CreateElement("DisplaySender");

            eleDisplaySender.InnerText = tbDisplaySender.Text;
            root.AppendChild(eleDisplaySender);


            string webContentText = "";

            // 一定要傳參數,就算空的也沒關係
            object[] array1 = new object[] { };

            //2017/8/14 穎驊新增, 取得視窗下面Web 的輸入html內容
            var task = _myBrowser.EvaluateScriptAsync("getData", array1);

            task.ContinueWith(t =>
            {
                if (!t.IsFaulted)
                {
                    var response = t.Result;

                    if (response.Success == true)
                    {
                        //MessageBox.Show(response.Result.ToString());

                        webContentText = response.Result.ToString();


                        //2017/8/14 穎驊新增, 檢查'使用者沒有輸入內容,跳出提醒,以避免server 爆炸,
                        //不把button disable 動態偵測輸入內容有無原因為,CefSharp API 的回傳沒有那模即時,異步處理會有問題。
                        if (webContentText != "")
                        {
                            //訊息內容
                            //var eleMessage = doc.CreateElement("Message");
                            //eleMessage.InnerText = tbMessageContent.Text;
                            //root.AppendChild(eleMessage);

                            //訊息內容
                            var eleMessage       = doc.CreateElement("Message");
                            eleMessage.InnerText = webContentText;
                            root.AppendChild(eleMessage);

                            //選取學生
                            if (_Type == Type.Student)
                            {
                                {
                                    //StudentVisible
                                    var ele = doc.CreateElement("StudentVisible");

                                    //ele.InnerText = "true";

                                    // 學生_依使用者選項發送
                                    ele.InnerText = checkBoxX1.Checked ? "true" : "false";

                                    root.AppendChild(ele);
                                }
                                {
                                    //ParentVisible
                                    var ele = doc.CreateElement("ParentVisible");

                                    //ele.InnerText = "true";

                                    // 家長_依使用者選項發送
                                    ele.InnerText = checkBoxX2.Checked ? "true" : "false";

                                    root.AppendChild(ele);
                                }
                                foreach (string each in K12.Presentation.NLDPanels.Student.SelectedSource)
                                {
                                    //發送對象
                                    var eleTargetStudent       = doc.CreateElement("TargetStudent");
                                    eleTargetStudent.InnerText = each;
                                    root.AppendChild(eleTargetStudent);
                                }
                            }
                            //選取教師
                            if (_Type == Type.Teacher)
                            {
                                foreach (string each in K12.Presentation.NLDPanels.Teacher.SelectedSource)
                                {
                                    //發送對象
                                    var eleTarget       = doc.CreateElement("TargetTeacher");
                                    eleTarget.InnerText = each;
                                    root.AppendChild(eleTarget);
                                }
                            }

                            //送出
                            FISCA.DSAClient.XmlHelper xmlHelper = new FISCA.DSAClient.XmlHelper(root);
                            var conn = new FISCA.DSAClient.Connection();
                            conn.Connect(FISCA.Authentication.DSAServices.AccessPoint, "1campus.notice.admin.v17", FISCA.Authentication.DSAServices.PassportToken);
                            var resp = conn.SendRequest("PostNotice", xmlHelper);

                            FISCA.Presentation.Controls.MsgBox.Show("發送成功");
                            this.Close();
                        }
                        else
                        {
                            FISCA.Presentation.Controls.MsgBox.Show("請輸入訊息內容!!");
                        }
                    }
                    else
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("task is not successful");
                    }
                }
                else
                {
                    FISCA.Presentation.Controls.MsgBox.Show("task IsFaulted");
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Ejemplo n.º 3
0
        private void BatchPushNotice(List <string> targetIDList)
        {
            //必須要使用greening帳號登入才能用
            System.Xml.XmlDocument doc  = new System.Xml.XmlDocument();
            XmlElement             root = doc.CreateElement("Request");

            //標題
            var eleTitle = doc.CreateElement("Title");

            eleTitle.InnerText = msgTitle;
            root.AppendChild(eleTitle);
            //發送人員
            var eleDisplaySender = doc.CreateElement("DisplaySender");

            eleDisplaySender.InnerText = displaySender;
            root.AppendChild(eleDisplaySender);

            string webContentText = "";

            object[] array1 = new object[] { };

            var task = _myBrowser.EvaluateScriptAsync("getData", array1);

            task.ContinueWith(t =>
            {
                //背景

                if (!t.IsFaulted)
                {
                    webContentText = t.Result.Result.ToString();
                    Console.WriteLine(t.Result.Result.ToString());

                    if (webContentText != "")
                    {
                        var eleMessage       = doc.CreateElement("Message");
                        eleMessage.InnerText = webContentText;
                        root.AppendChild(eleMessage);

                        //選取學生
                        if (_Type == Type.Student)
                        {
                            {
                                //StudentVisible
                                var ele = doc.CreateElement("StudentVisible");


                                root.AppendChild(ele);
                            }
                            {
                                //ParentVisible
                                var ele = doc.CreateElement("ParentVisible");

                                //ele.InnerText = "true";

                                // 家長_依使用者選項發送
                                ele.InnerText = Mode;

                                root.AppendChild(ele);
                            }
                            foreach (string each in K12.Presentation.NLDPanels.Student.SelectedSource)
                            {
                                //發送對象
                                var eleTargetStudent       = doc.CreateElement("TargetStudent");
                                eleTargetStudent.InnerText = each;
                                root.AppendChild(eleTargetStudent);
                            }
                        }
                        else if (_Type == Type.Teacher)
                        {
                            foreach (string each in K12.Presentation.NLDPanels.Teacher.SelectedSource)
                            {
                                //發送對象
                                var eleTarget       = doc.CreateElement("TargetTeacher");
                                eleTarget.InnerText = each;
                                root.AppendChild(eleTarget);
                            }
                        }

                        //送出
                        FISCA.DSAClient.XmlHelper xmlHelper = new FISCA.DSAClient.XmlHelper(root);
                        var conn = new FISCA.DSAClient.Connection();
                        conn.Connect(FISCA.Authentication.DSAServices.AccessPoint, "1campus.notice.admin.v17", FISCA.Authentication.DSAServices.PassportToken);
                        var resp = conn.SendRequest("PostNotice", xmlHelper);


                        //處理Log



                        FISCA.Presentation.Controls.MsgBox.Show("發送成功");
                        this.Close();
                    }
                    else
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("請輸入內容");
                    }
                }
                else
                {
                    FISCA.Presentation.Controls.MsgBox.Show("task IsFaulted");
                }
            }).ContinueWith(t =>
            {
                //前景
            }, ts);
        }
Ejemplo n.º 4
0
        private void BatchPushNotice(List <string> targetIDList)
        {
            //必須要使用greening帳號登入才能用
            System.Xml.XmlDocument doc  = new System.Xml.XmlDocument();
            XmlElement             root = doc.CreateElement("Request");

            //標題
            var eleTitle = doc.CreateElement("Title");

            eleTitle.InnerText = msgTitle;
            root.AppendChild(eleTitle);
            //發送人員
            var eleDisplaySender = doc.CreateElement("DisplaySender");

            eleDisplaySender.InnerText = displaySender;
            root.AppendChild(eleDisplaySender);

            string webContentText = "";

            //訊息內容
            //var eleMessage = doc.CreateElement("Message");
            //eleMessage.InnerText = tbMessageContent.Text;
            //root.AppendChild(eleMessage);

            //訊息內容

            var eleMessage = doc.CreateElement("Message");

            eleMessage.InnerText = msgText;
            root.AppendChild(eleMessage);

            //選取學生
            if (_Type == Type.Student)
            {
                {
                    //StudentVisible
                    var ele = doc.CreateElement("StudentVisible");

                    //ele.InnerText = "true";

                    // 學生_依使用者選項發送
                    ele.InnerText = checkBoxX1.Checked ? "true" : "false";

                    root.AppendChild(ele);
                }
                {
                    //ParentVisible
                    var ele = doc.CreateElement("ParentVisible");

                    //ele.InnerText = "true";

                    // 家長_依使用者選項發送
                    ele.InnerText = checkBoxX2.Checked ? "true" : "false";

                    root.AppendChild(ele);
                }
                foreach (string each in targetIDList)
                {
                    //發送對象
                    var eleTargetStudent = doc.CreateElement("TargetStudent");
                    eleTargetStudent.InnerText = each;
                    root.AppendChild(eleTargetStudent);
                }
            }
            //選取教師
            if (_Type == Type.Teacher)
            {
                foreach (string each in targetIDList)
                {
                    //發送對象
                    var eleTarget = doc.CreateElement("TargetTeacher");
                    eleTarget.InnerText = each;
                    root.AppendChild(eleTarget);
                }
            }

            //送出
            try
            {
                FISCA.DSAClient.XmlHelper xmlHelper = new FISCA.DSAClient.XmlHelper(root);
                var conn = new FISCA.DSAClient.Connection();
                conn.Connect(FISCA.Authentication.DSAServices.AccessPoint, "1campus.notice.admin.v17", FISCA.Authentication.DSAServices.PassportToken);
                var resp = conn.SendRequest("PostNotice", xmlHelper);


                StringBuilder sb_log = new StringBuilder();

                string        Byto     = "";
                List <string> byAction = new List <string>();
                if (_Type == Type.Student)
                {
                    if (checkBoxX1.Checked)
                    {
                        byAction.Add("學生");
                    }

                    if (checkBoxX2.Checked)
                    {
                        byAction.Add("家長");
                    }
                }
                else if (_Type == Type.Teacher)
                {
                    byAction.Add("老師");
                }
                sb_log.AppendLine(string.Format("發送對象「{0}」", string.Join(",", byAction)));
                sb_log.AppendLine(string.Format("發送標題「{0}」", msgTitle));
                sb_log.AppendLine(string.Format("發送單位「{0}」", displaySender));
                sb_log.AppendLine(string.Format("發送內容「{0}」", msgText));
                if (IsLimit)
                {
                    sb_log.AppendLine(string.Format("對象清單「{0}」", string.Join(",", userLimitList) + "\n等..." + userNameList.Count + "人"));
                }
                else
                {
                    sb_log.AppendLine(string.Format("對象清單「{0}」", string.Join(",", userLimitList)));
                }

                FISCA.LogAgent.ApplicationLog.Log("智慧簡訊", "發送", sb_log.ToString());
            }
            catch
            {
                Console.WriteLine("對象系統編號:" + string.Join(",", targetIDList) + "。發送失敗");
                //FISCA.Presentation.Controls.MsgBox.Show("對象系統編號:" + string.Join(",", targetIDList) +"。發送失敗");
            }
        }