Example #1
0
        /// <summary>
        /// 直接用DSAUtil來呼叫Service
        /// </summary>
        /// <param name="service">服務名稱</param>
        /// <param name="req">申請文件</param>
        /// <returns></returns>
        private DSResponse CallTestingService(string service, DSRequest req)
        {
            FISCA.DSAClient.Connection vConnection = new FISCA.DSAClient.Connection();

            vConnection.Connect(mAccessPoint,"" , mFullUserName , mPassword);

            if (vConnection.IsConnected)
            {
                try
                {
                    Envelope vRequest = new Envelope();

                    vRequest.Body = new XmlStringHolder(req.GetContent().GetRawXml());
                    Envelope vResponse = vConnection.SendRequest(service,vRequest);

                    DSResponse rsp = new DSResponse();

                    rsp.SetContent(vResponse.Body.XmlString);

                    return rsp;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    vConnection = null;
                }
            }
            else
                throw new Exception("無法與DSA連線");

            return null;
        }
Example #2
0
        public DSASync()
        {
            //1. Login to ischool
            dsaCn = new FISCA.DSAClient.Connection();
            dsaCn.EnableSession = true ;

            try
            {
                dsaCn.Connect(Constants.EMBA_DSNS(),
                              Constants.EMBA_ISCHOOL_TARGET_CONTRACT(),
                              Constants.EMBA_ISCHOOL_ACCOUNT(),
                              Constants.EMBA_ISCHOOL_PASSWORD());
                this.isConnected = dsaCn.IsConnected;

                if (!this.isConnected)
                    throw (new Exception("對 " + Constants.EMBA_DSNS() + " 連線失敗。"));

                LogUtil.LogToTransferSummary(Constants.STEP_SyncData, "對 " + Constants.EMBA_DSNS() + " 連線成功!", this.isConnected);

            }
            catch (Exception ex)
            {
                LogUtil.LogToTransferSummary(Constants.STEP_SyncData, "對 " + Constants.EMBA_DSNS() + " 連線失敗:" + ex.Message, false);
            }
        }
        /// <summary>
        /// 查詢傳送記錄
        /// </summary>
        /// <param name="beginDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public static XElement QuerySendData(DateTime?beginDate, DateTime?endDate, List <string> isVerifyList)
        {
            XElement elmMsg = null;

            string DSNS = FISCA.Authentication.DSAServices.AccessPoint;

            string AccessPoint = @"j.kh.edu.tw";

            string Contract    = "log";
            string ServiceName = "_.QueryLog";

            try
            {
                XElement xmlRoot = new XElement("Request");
                XElement s1      = new XElement("Field");
                s1.SetElementValue("All", "");
                XElement s2 = new XElement("Condition");

                s2.SetElementValue("Dsns", DSNS);

                if (beginDate.HasValue)
                {
                    s2.SetElementValue("StartDate", string.Format("{0:yyyy-MM-dd}", beginDate.Value));
                }
                if (endDate.HasValue)
                {
                    s2.SetElementValue("EndDate", string.Format("{0:yyyy-MM-dd}", endDate.Value.AddDays(1)));
                }

                if (isVerifyList != null)
                {
                    foreach (string str in isVerifyList)
                    {
                        XElement elmV = new XElement("IsVerify");
                        elmV.Value = str;
                        s2.Add(elmV);
                    }
                }

                xmlRoot.Add(s1);
                xmlRoot.Add(s2);

                XmlHelper reqXML = new XmlHelper(xmlRoot.ToString());
                FISCA.DSAClient.Connection cn = new FISCA.DSAClient.Connection();
                cn.Connect(AccessPoint, Contract, DSNS, DSNS);
                Envelope rsp = cn.SendRequest(ServiceName, new Envelope(reqXML));
                elmMsg = XElement.Parse(rsp.XmlString);
            }
            catch (Exception ex)
            {
                elmMsg = new XElement("Error");
                elmMsg.SetElementValue("Message", ex.Message);
            }

            return(elmMsg);
        }
        /// <summary>
        /// 查詢傳送記錄
        /// </summary>
        /// <param name="beginDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public static XElement QuerySendData(DateTime beginDate, DateTime endDate)
        {
            XElement elmMsg = null;

            string DSNS = FISCA.Authentication.DSAServices.AccessPoint;

            string AccessPoint = @"j.kh.edu.tw";

            if (FISCA.RTContext.IsDiagMode)
            {
                string accPoint = FISCA.RTContext.GetConstant("KH_AccessPoint");
                if (!string.IsNullOrEmpty(accPoint))
                {
                    AccessPoint = accPoint;
                }
            }

            string Contract    = "log";
            string ServiceName = "_.QueryLog";

            try
            {
                XElement xmlRoot = new XElement("Request");
                XElement s1      = new XElement("Field");
                s1.SetElementValue("All", "");
                XElement s2 = new XElement("Condition");
                s2.SetElementValue("Dsns", DSNS);
                s2.SetElementValue("StartDate", beginDate.ToShortDateString());
                s2.SetElementValue("EndDate", endDate.ToShortDateString());
                xmlRoot.Add(s1);
                xmlRoot.Add(s2);

                XmlHelper reqXML = new XmlHelper(xmlRoot.ToString());
                FISCA.DSAClient.Connection cn = new FISCA.DSAClient.Connection();
                cn.Connect(AccessPoint, Contract, DSNS, DSNS);
                Envelope rsp = cn.SendRequest(ServiceName, new Envelope(reqXML));
                elmMsg = XElement.Parse(rsp.XmlString);
            }
            catch (Exception ex)
            {
                elmMsg = new XElement("Error");
                elmMsg.SetElementValue("Message", ex.Message);
            }

            return(elmMsg);
        }
        /// <summary>
        /// 上傳檔案到局端
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="Data"></param>
        /// <param name="FileName"></param>
        /// <returns></returns>
        public static string UploadFile(string ID, string Data, string FileName)
        {
            string DSNS        = FISCA.Authentication.DSAServices.AccessPoint;
            string AccessPoint = @"j.kh.edu.tw";

            if (FISCA.RTContext.IsDiagMode)
            {
                string accPoint = FISCA.RTContext.GetConstant("KH_AccessPoint");
                if (!string.IsNullOrEmpty(accPoint))
                {
                    AccessPoint = accPoint;
                }
            }

            string Contract    = "log";
            string ServiceName = "_.Upload";

            string errMsg = "";

            try
            {
                XElement xmlRoot = new XElement("Request");
                xmlRoot.SetElementValue("ID", ID);
                xmlRoot.SetElementValue("Data", Data);
                xmlRoot.SetElementValue("FileName", FileName);
                xmlRoot.SetElementValue("DSNS", DSNS);
                xmlRoot.SetElementValue("Type", "class");
                XmlHelper reqXML = new XmlHelper(xmlRoot.ToString());
                FISCA.DSAClient.Connection cn = new FISCA.DSAClient.Connection();
                cn.Connect(AccessPoint, Contract, DSNS, DSNS);
                Envelope rsp    = cn.SendRequest(ServiceName, new Envelope(reqXML));
                XElement rspXML = XElement.Parse(rsp.XmlString);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            return(errMsg);
        }
        public static string UpdateData(RspMsg updateRspMsg)
        {
            string DSNS        = FISCA.Authentication.DSAServices.AccessPoint;
            string AccessPoint = @"j.kh.edu.tw";
            string Contract    = "log";
            string ServiceName = "_.UpdateLog";
            string errMsg      = "";

            try
            {
                XElement xmlRoot = new XElement("Request");
                XElement s1      = new XElement("SchoolLog");
                XElement s2      = new XElement("Field");
                XElement s3      = new XElement("Condition");
                XElement Content = new XElement("Content");
                s2.SetElementValue("isVerify", updateRspMsg.Verify);
                foreach (string key in updateRspMsg.Content.Keys)
                {
                    Content.SetElementValue(key, updateRspMsg.Content[key]);
                }

                s2.Add(Content);
                s3.SetElementValue("Uid", updateRspMsg.UID);
                s1.Add(s2);
                s1.Add(s3);
                xmlRoot.Add(s1);
                XmlHelper reqXML = new XmlHelper(xmlRoot.ToString());
                FISCA.DSAClient.Connection cn = new FISCA.DSAClient.Connection();
                cn.Connect(AccessPoint, Contract, DSNS, DSNS);
                Envelope rsp    = cn.SendRequest(ServiceName, new Envelope(reqXML));
                XElement rspXML = XElement.Parse(rsp.XmlString);
            }
            catch (Exception ex) { errMsg = ex.Message; }

            return(errMsg);
        }
Example #7
0
        /// <summary>
        /// 傳送至局端
        /// </summary>
        /// <param name="action"></param>
        /// <param name="IDNumber"></param>
        /// <param name="StudentNumber"></param>
        /// <param name="StudentName"></param>
        /// <param name="GradeYear"></param>
        /// <param name="ClassName"></param>
        /// <param name="SeatNo"></param>
        /// <param name="NewClassName"></param>
        /// <param name="ScheduleClassDate"></param>
        /// <param name="Reason"></param>
        /// <returns></returns>
        public static string SendData(string action, string IDNumber, string StudentNumber, string StudentName, string GradeYear, string ClassName, string SeatNo, string NewClassName, string ScheduleClassDate, string Reason, string StudentID, string ClassID, string ClassComment)
        {
            string DSNS = FISCA.Authentication.DSAServices.AccessPoint;

            string AccessPoint = @"j.kh.edu.tw";

            if (FISCA.RTContext.IsDiagMode)
            {
                string accPoint = FISCA.RTContext.GetConstant("KH_AccessPoint");
                if (!string.IsNullOrEmpty(accPoint))
                {
                    AccessPoint = accPoint;
                }
            }

            string Contract    = "log";
            string ServiceName = "_.InsertLog";

            string errMsg = "";

            try
            {
                {
                    XElement xmlRoot = new XElement("Request");
                    XElement s1      = new XElement("SchoolLog");
                    XElement s2      = new XElement("Field");

                    s2.SetElementValue("DSNS", DSNS);
                    s2.SetElementValue("Action", action);
                    XElement Content = new XElement("Content");
                    Content.SetElementValue("IDNumber", IDNumber);
                    Content.SetElementValue("StudentNumber", StudentNumber);
                    Content.SetElementValue("ClassName", ClassName);
                    Content.SetElementValue("NewClassName", NewClassName);
                    Content.SetElementValue("SeatNo", SeatNo);
                    Content.SetElementValue("ScheduleClassDate", ScheduleClassDate);
                    Content.SetElementValue("StudentName", StudentName);
                    Content.SetElementValue("Reason", Reason);
                    Content.SetElementValue("StudentID", StudentID);
                    Content.SetElementValue("ClassID", ClassID);
                    Content.SetElementValue("ClassComment", ClassComment);
                    s2.Add(Content);
                    s1.Add(s2);
                    xmlRoot.Add(s1);
                    XmlHelper reqXML = new XmlHelper(xmlRoot.ToString());
                    FISCA.DSAClient.Connection cn = new FISCA.DSAClient.Connection();
                    cn.Connect(AccessPoint, Contract, DSNS, DSNS);
                    Envelope rsp    = cn.SendRequest(ServiceName, new Envelope(reqXML));
                    XElement rspXML = XElement.Parse(rsp.XmlString);
                }

                //2017/6/7 穎驊新增 高雄項目 [03-01][03] 巨耀局端介接學生資料欄位 巨耀自動編班 更新Service
                try
                {
                    string urlString = "http://163.32.129.9/khdc/ito";
                    // 準備 Http request
                    HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(urlString);
                    req.Method = "POST";

                    // 呼叫並取得結果
                    HttpWebResponse rsp;
                    rsp = (HttpWebResponse)req.GetResponse();

                    Stream       dataStream = rsp.GetResponseStream();
                    StreamReader reader     = new StreamReader(dataStream);

                    string response = reader.ReadToEnd(); //檢查使用,若成功回傳,response 值為 "00"

                    reader.Close();
                    dataStream.Close();
                    rsp.Close();
                }
                catch (Exception e)
                {
                }
            }
            catch (Exception ex) { errMsg = ex.Message; }

            return(errMsg);
        }
        private void Upload(Dictionary<string, object> mergeKeyValue)
        {
            Connection Connection = new FISCA.DSAClient.Connection();
            try
            {
                Connection.EnableSession = false;
                Connection.Connect(
                "j.kh.edu.tw",
                "centraloffice",
                FISCA.Authentication.DSAServices.AccessPoint,
                FISCA.Authentication.DSAServices.AccessPoint);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            #region 取得學校系統編號
            XElement elmSchool = ContractService
                .GetSchool(Connection, FISCA.Authentication.DSAServices.AccessPoint)
                .Element("School");

            if (elmSchool == null)
            {
                MessageBox.Show("學校不在局端清單中,無法上傳!");
                return;
            }

            //取得學校在局端的系統編號
            string SchoolID = elmSchool.Element("Uid").Value;
            #endregion

            #region 上傳統計資料
            try
            {
                ContractService.UploadApproach(Connection,
                    SchoolID,
                    "" + CurrentSurveyYear,
                    mergeKeyValue);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            #endregion

            MessageBox.Show("上傳成功!");
        }
        public static string SendDataList(string action, List <logStud> logStudList, ImportMode importMode)
        {
            string DSNS = FISCA.Authentication.DSAServices.AccessPoint;

            string AccessPoint = @"j.kh.edu.tw";

            if (FISCA.RTContext.IsDiagMode)
            {
                string accPoint = FISCA.RTContext.GetConstant("KH_AccessPoint");
                if (!string.IsNullOrEmpty(accPoint))
                {
                    AccessPoint = accPoint;
                }
            }

            string Contract    = "log";
            string ServiceName = "_.InsertLog";

            string errMsg = "";

            try
            {
                {
                    XElement xmlRoot = new XElement("Request");
                    XElement s1      = new XElement("SchoolLog");
                    XElement s2      = new XElement("Field");

                    s2.SetElementValue("DSNS", DSNS);
                    s2.SetElementValue("Action", action);
                    XElement Content    = new XElement("Content");
                    string   summaryTxt = action + " 共 " + logStudList.Count + " 筆";
                    Content.SetElementValue("Summary", summaryTxt);
                    XElement Detail = new XElement("Detail");

                    if (importMode == ImportMode.Insert)
                    {
                        foreach (logStud ls in logStudList)
                        {
                            XElement StudentXML = new XElement("Student");
                            StudentXML.SetElementValue("IDNumber", ls.IDNumber);
                            StudentXML.SetElementValue("StudentNumber", ls.StudentNumber);
                            StudentXML.SetElementValue("StudentName", ls.StudentName);
                            StudentXML.SetElementValue("ClassName", ls.ClassName);
                            StudentXML.SetElementValue("SeatNo", ls.SeatNo);
                            StudentXML.SetElementValue("GradeYear", ls.GradeYear);
                            StudentXML.SetElementValue("StudentStatus", ls.StudentStatus);
                            Detail.Add(StudentXML);
                        }
                    }
                    else
                    {
                        //  更新
                        foreach (logStud ls in logStudList)
                        {
                            XElement StudentXML = new XElement("Student");
                            StudentXML.SetElementValue("IDNumber", ls.IDNumber);
                            StudentXML.SetElementValue("StudentNumber", ls.StudentNumber);
                            StudentXML.SetElementValue("StudentName", ls.StudentName);
                            StudentXML.SetElementValue("ClassName", ls.oClassName);
                            StudentXML.SetElementValue("NewClassName", ls.ClassName);
                            StudentXML.SetElementValue("SeatNo", ls.SeatNo);
                            StudentXML.SetElementValue("GradeYear", ls.GradeYear);
                            StudentXML.SetElementValue("StudentStatus", ls.oStudentStatus);
                            StudentXML.SetElementValue("NewStudentStatus", ls.StudentStatus);
                            Detail.Add(StudentXML);
                        }
                    }

                    s2.Add(Content);
                    s2.Add(Detail);
                    s1.Add(s2);
                    xmlRoot.Add(s1);
                    XmlHelper reqXML = new XmlHelper(xmlRoot.ToString());
                    FISCA.DSAClient.Connection cn = new FISCA.DSAClient.Connection();
                    cn.Connect(AccessPoint, Contract, DSNS, DSNS);
                    Envelope rsp    = cn.SendRequest(ServiceName, new Envelope(reqXML));
                    XElement rspXML = XElement.Parse(rsp.XmlString);
                }


                //2017/6/7 穎驊新增 高雄項目 [03-01][03] 巨耀局端介接學生資料欄位 巨耀自動編班 更新Service
                try
                {
                    string urlString = "http://163.32.129.9/khdc/ito";
                    // 準備 Http request
                    HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(urlString);
                    req.Method = "POST";

                    // 呼叫並取得結果
                    HttpWebResponse rsp;
                    rsp = (HttpWebResponse)req.GetResponse();

                    Stream       dataStream = rsp.GetResponseStream();
                    StreamReader reader     = new StreamReader(dataStream);

                    string response = reader.ReadToEnd(); //檢查使用,若成功回傳,response 值為 "00"

                    reader.Close();
                    dataStream.Close();
                    rsp.Close();
                }
                catch (Exception e)
                {
                }
            }
            catch (Exception ex) { errMsg = ex.Message; }

            return(errMsg);
        }