Exemple #1
0
        public MSG001 getMSGData(string proccessSerialNumber)
        {
            MSG001 ret = null;

            using (NaNaEntities db = new NaNaEntities()) {
                ret = db.MSG001.FirstOrDefault(x => x.processSerialNumber == proccessSerialNumber);
            }
            return(ret);
        }
Exemple #2
0
        public bool MSPSubmit(string processSerialNumber)
        {
            bool ret = false;

            MSPViewModel.MSPSubmitResponse res = new MSPViewModel.MSPSubmitResponse();
            string url = this.msp_host;

            MSG001 msg = this.mspDao.getMSGData(processSerialNumber);

            if (msg == null)
            {
                return(ret);
            }

            List <MSG001_gridMsg> msg_grid_list = this.mspDao.getMSGGridList(msg.formSerialNumber);

            if (msg_grid_list.Count == 0)
            {
                return(ret);
            }

            //一筆一筆 post
            List <MSPViewModel.MSPSubmitRequestParameter> request_list = this.getRequestListParamter(msg, msg_grid_list);

            foreach (var r in request_list)
            {
                string post_str = this.getPostMSPString(r);
                UtilitySvc.writeLog(post_str);
                string response_str = UtilitySvc.formPostRequest(url, post_str, new Dictionary <string, object>());
                UtilitySvc.writeLog(response_str);
            }

            if (request_list.Count > 0)
            {
                ret = true;
            }

            return(ret);
        }
Exemple #3
0
        private List <MSPViewModel.MSPSubmitRequestParameter> getRequestListParamter(MSG001 msg, List <MSG001_gridMsg> msg_gird_list)
        {
            List <MSPViewModel.MSPSubmitRequestParameter> ret = new List <MSPViewModel.MSPSubmitRequestParameter>();

            string[] ChbExcludeConditionArr = msg.hidChbExcludeCondition.Split(';');

            List <MSPViewModel.BlockListRequestParameter> blockList = new List <MSPViewModel.BlockListRequestParameter>();

            //排除名單

            foreach (var b in ChbExcludeConditionArr)
            {
                int _b = 0;

                if (!int.TryParse(b, out _b))
                {
                    continue;
                }

                blockList.Add(new MSPViewModel.BlockListRequestParameter()
                {
                    Oid = int.Parse(b)
                });
            }

            //測試名單
            string        testDistArr_str = "";
            List <string> testDistArr     = new List <string>();

            if (!string.IsNullOrEmpty(msg.hidApprovedEmp))
            {
                foreach (var s in msg.hidApprovedEmp.Split(';'))
                {
                    if (s.Length > 0)
                    {
                        testDistArr.Add(s);
                    }
                }
                testDistArr_str = string.Join(",", testDistArr.ToArray());
            }



            int sort = 1;

            foreach (var m in msg_gird_list)
            {
                string SendStartDate = "";
                string SendEndDate   = "";
                string SendStartTime = "";
                string SendEndTime   = "";

                //一次性
                if (m.gd_send_type == "一次性發送")
                {
                    DateTime sendStartDateTime = DateTime.Parse(m.gd_date_send.Trim() + " " + m.gd_time_send.Trim());
                    SendStartDate = sendStartDateTime.ToString("yyyyMMdd");
                    SendStartTime = sendStartDateTime.ToString("HHmm");
                }
                else if (m.gd_send_type == "週期性發送")
                {
                    string[] str_date      = m.gd_date_send.Split('~');
                    string   gd_start_date = str_date[0].Trim();
                    string   gd_end_date   = str_date[1].Trim();

                    string[] str_time      = m.gd_time_send.Split('~');
                    string   gd_start_time = str_time[0].Trim();
                    string   gd_end_time   = str_time[1].Trim();

                    DateTime sendStartDateTime = DateTime.Parse(gd_start_date + " " + gd_start_time);
                    DateTime sendEndDateTime   = DateTime.Parse(gd_end_date + " " + gd_end_time);

                    SendStartDate = sendStartDateTime.ToString("yyyyMMdd");
                    SendStartTime = sendStartDateTime.ToString("HHmm");
                    SendEndDate   = sendEndDateTime.ToString("yyyyMMdd");
                    SendEndTime   = sendEndDateTime.ToString("HHmm");
                }

                //換行 handler
                m.gd_content = m.gd_content.Replace("<br />", Environment.NewLine).Replace("&lt;br /&gt;", Environment.NewLine);
                m.gd_memo    = m.gd_memo.Replace("<br />", Environment.NewLine).Replace("&lt;br /&gt;", Environment.NewLine);


                MSPViewModel.MSPSubmitRequestParameter req = new MSPViewModel.MSPSubmitRequestParameter()
                {
                    FormId          = msg.SerialNumber + "-" + sort.ToString("000"), //序號  +  1 + 2 + 3
                    Department      = UtilitySvc.base64Encode(msg.txtApplyDepName),
                    Division        = UtilitySvc.base64Encode(msg.hidApplyDivsion),
                    Username        = UtilitySvc.base64Encode(msg.txtApplyName),
                    Ext             = msg.txtApplyExtNo,
                    PushSystem      = int.Parse(msg.ddlSendSystem),
                    SystemNote      = UtilitySvc.base64Encode(msg.hidITDelegateOption),
                    TaskType        = int.Parse(msg.hidRadioSendLevel),
                    CpDelegated     = int.Parse(msg.hidCPDelegate),
                    CategoryOid     = int.Parse(msg.ddlMsgCategory),
                    EmployeeId      = msg.txtApplyId,
                    PhoneNumber     = msg.hidSendPhoneNumber,
                    Subject         = UtilitySvc.base64Encode(UtilitySvc.parseGridValue(m.gd_title)),
                    Content         = UtilitySvc.base64Encode(UtilitySvc.parseGridValue(m.gd_content)),
                    Note            = UtilitySvc.base64Encode(UtilitySvc.parseGridValue(m.gd_memo)),
                    DistType        = UtilitySvc.base64Encode(m.gd_type),
                    DistFrom        = UtilitySvc.base64Encode(m.gd_src),
                    DistSize        = int.Parse(m.gd_list_count),
                    DistRule        = UtilitySvc.base64Encode(UtilitySvc.parseGridValue(m.gd_condition)),
                    RefDistList     = UtilitySvc.base64Encode(m.gd_list),           //測試名單
                    PushType        = int.Parse(m.gd_send_type == "一次性發送" ? "0" : "1"),
                    SendStartDate   = SendStartDate,
                    SendEndDate     = SendEndDate,
                    SendStartTime   = SendStartTime,
                    SendEndTime     = SendEndTime,
                    OtherDepartment = UtilitySvc.base64Encode(m.gd_segment),
                    ApplySales      = UtilitySvc.base64Encode(m.gd_sales),
                    SendArea        = UtilitySvc.base64Encode(m.gd_point_region),
                    Code            = m.gd_point_id,
                    StoreName       = UtilitySvc.base64Encode(m.gd_point_name),
                    TestDist        = testDistArr_str,          //若為 一般件 要將簽核過的人員工編號放進至試跑名單中
                    Address         = UtilitySvc.base64Encode(m.gd_point_address),
                    ApplyDate       = DateTime.Now.ToString("yyyyMMdd"),
                    BlockList       = blockList
                };


                ret.Add(req);
                sort++;
            }

            return(ret);
        }