Exemplo n.º 1
0
        /// <summary>
        /// 获取查岗信息
        /// </summary>
        public ActionResult GetInspectionInfos()
        {
            List <InspectionListModel> result;

            if (base.IsUser)
            {
                result = InspectionBLL.GetUserInspectionInfos(base.CurrentStrucID);
            }
            else//管理员、超级管理员
            {
                result = InspectionBLL.GetPlatformInspectionInfos();
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Page")
            {
                switch (e.CommandArgument.ToString())
                {
                case ("Last"): GridView1.PageIndex = 1000;
                    break;

                case ("First"): GridView1.PageIndex = 1;
                    break;

                case ("Next"): GridView1.PageIndex = GridView1.PageIndex + 1;
                    break;

                case ("Prev"): GridView1.PageIndex = GridView1.PageIndex - 1;
                    break;

                default:
                    int pageNo;
                    if (int.TryParse(e.CommandArgument.ToString(), out pageNo))
                    {
                        GridView1.PageIndex = pageNo;
                    }
                    break;
                }
            }
            else
            {
                int         id      = int.Parse(e.CommandArgument.ToString());
                Call        rowCall = callsBLL.GetById(id);
                SiteSession session = SiteSessionFactory.LoadSession(this.Page);

                if (rowCall.Instruction != 1 && !rowCall.IsSony)
                {
                    InspectionBLL inspectionsBLL = new InspectionBLL();
                    rowCall.hasInspections = inspectionsBLL.CallHasInspections(rowCall.SaediToId, rowCall.SaediFromId, rowCall.ClientRef);
                }

                if (session.Data.ContainsKey("call"))
                {
                    session.Data["call"] = rowCall;
                }
                else
                {
                    session.Data.Add("call", rowCall);
                }


                SiteSessionFactory.SaveSession(this.Page, session);
                if (rowCall.Instruction == 1)
                {
                    Response.Redirect("~/Accept.aspx");
                }
                else
                {
                    /////////////////////////// CHECK STOCK PARTS IN SAEDICALLS ////////////////////////////
                    // This should be added on add stock parts or Allocate part.
                    // Sometimes the proper part wasn't added (web service return different part!!??)
                    // We check the part here again:
                    ///////////////////////////////////////////////////////////////////////////////////////
                    //OSPRefBLL ospBLL = new OSPRefBLL();
                    //List<OSPRefs> ospRefsList = ospBLL.GetOSPRefByCallID(rowCall.Id.ToString());
                    //OSPRefs ospRefs = new OSPRefs();
                    //if (ospRefsList.Count > 0)
                    //    ospRefs = ospRefsList[0];
                    //else
                    //    ospRefs.StockAddSearch = "False";

                    //if (ospRefs.StockAddSearch == "True") // If it is SONY
                    //{
                    //    PartsBLL partsBLL = new PartsBLL();
                    //    PartsBLL stockPartsBLL = new PartsBLL();
                    //    PartsBLL allocatedPartsBLL = new PartsBLL();
                    //    PartsBLL partsAll = new PartsBLL();
                    //    PartsBLL partsOrdered = new PartsBLL();
                    //    PartsBLL SAEDIParts = new PartsBLL();

                    //    SAEDIParts.List = SAEDIParts.GetSAEDIPartsByCall(rowCall.SaediFromId, rowCall.ClientRef).ToList();
                    //    stockPartsBLL.List = partsBLL.GetPartsByClientIdForSONY(rowCall.Id.ToString(), rowCall.SaediFromId, rowCall.ClientRef).ToList();

                    //    try
                    //    { partsAll.List = partsBLL.GetPartsByCallId(rowCall.Id); }
                    //    catch { }
                    //    foreach (CallPart line in partsAll.List.ToList())
                    //    {
                    //        CallPart callPartAllocated = rowCall.UsedParts.Items.Find(p => p.Code == line.Code);
                    //        if (callPartAllocated != null && line.StatusID.ToUpper().Trim() != "V" && line.IsStock == false)
                    //        {
                    //            allocatedPartsBLL.List.Add(line);
                    //        }
                    //    }

                    //    try
                    //    {
                    //        // ---------------------------
                    //        // 1.) SYNCHRONISE SAEDICalls
                    //        // ---------------------------
                    //        rowCall.UsedParts.Items.Clear();
                    //        rowCall.UsedParts.Items.AddRange(stockPartsBLL.List.ToList());
                    //        rowCall.UsedParts.Items.AddRange(allocatedPartsBLL.List.ToList());
                    //        callsBLL.UpdateCall(rowCall);
                    //        session.Data["call"] = rowCall;
                    //        SiteSessionFactory.SaveSession(this.Page, session);

                    //        // --------------------------
                    //        // 2.) SYNCHRONISE SAEDIParts
                    //        // --------------------------
                    //        foreach (CallPart part in partsAll.List.ToList())
                    //        {
                    //            CallPart saediPart = SAEDIParts.List.ToList().Find(p => p.PartReference == part.PartReference && p.StatusID == part.StatusID);
                    //            bool IsSAEDIAllocated = false;
                    //            if (saediPart != null)
                    //                IsSAEDIAllocated = saediPart.IsAllocated;

                    //            if (IsSAEDIAllocated == false)
                    //            {
                    //                CallPart allocatedPart = allocatedPartsBLL.List.ToList().Find(p => p.PartReference == part.PartReference && p.StatusID == part.StatusID);
                    //                if (allocatedPart != null)
                    //                    part.IsAllocated = true;

                    //                part.SAEDIFromID = rowCall.SaediFromId;
                    //                part.SAEDICallRef = rowCall.ClientRef;

                    //                SAEDIParts.DeleteSAEDIPart(part);
                    //                SAEDIParts.InsertSAEDIPart(part);
                    //            }
                    //        }

                    //        foreach (CallPart part in SAEDIParts.List.ToList())
                    //        {
                    //            CallPart partExist = partsAll.List.ToList().Find(p => p.PartReference == part.PartReference && p.StatusID == part.StatusID);
                    //            if (partExist == null)
                    //                SAEDIParts.DeleteSAEDIPart(part);
                    //        }
                    //    }
                    //    catch { }
                    //}
                    //////////////////////////

                    Response.Redirect("~/Appointment.aspx");
                }
            }
        }
Exemplo n.º 3
0
        public ActionResult ReplyInspection(UInt32 id, string replyContent)
        {
            string msg = PromptInformation.OperationFailure + ":{0}";


            #region 检查数据
            var obj = InspectionBLL.GetInspectionInfoByID(id);
            if (obj.DataResult == null)
            {
                return(Json(new OperationResult()
                {
                    Message = string.Format(msg, obj.Message)
                }));
            }
            var data = obj.DataResult;
            //true代表已被其他人回复
            //这里其实有点问题,因为可能出现查询出以后被人回复的情况,所以实际上如果为了保证不会重复回复,需要做乐观并发
            //但是实际上发生概率实在太低,而且即使重复回复也不会有什么后果,所以不处理
            if (data.Flag)
            {
                return(Json(new OperationResult()
                {
                    Message = string.Format(msg, PromptInformation.InspectionHadBeenRelied)
                }));
            }
            #endregion


            #region 回复查岗
            try
            {
                var    remoteObj = GetRemoteObj();
                string pn        = data.PlatformName;
                string ac        = data.AccessCode;
                string version   = data.Version;
                uint   M1        = (uint)data.M1;
                uint   IA1       = (uint)data.IA1;
                uint   IC1       = (uint)data.IC1;
                string opResult  = string.Empty;
                byte[] sendBytes = BuildReplyContentBytes(id, replyContent, data);
                //进行回复
                if (data.ObjType == "1")//针对平台的查岗
                {
                    opResult = remoteObj.BeginSendPlatFormCheckMsg(sendBytes, pn, ac, version, M1, IA1, IC1);
                }
                else//针对具体业户的查岗
                {
                    opResult = remoteObj.BeginSendPlatFormCheckMsg(sendBytes, pn, data.ObjID, ac, version, M1, IA1, IC1);
                }
                bool   success = opResult == "成功";//remoting那边返回的结果是中文字
                string tempMsg = string.Empty;
                if (success)
                {
                    tempMsg = PromptInformation.OperationSuccess;
                    InspectionBLL.UpdateInspectionState(id, replyContent);//更新物流TMS库的查岗数据,注意这里无所谓更新失败还是成功,大不了重新再回复一次查岗
                }
                else
                {
                    tempMsg = string.Format(msg, PromptInformation.CommunicationError) + "[" + opResult + "]";
                }
                //不论是否成功,只要正常操作了就记录日志
                InspectionBLL.DoReplyLog(id, base.UserIDForLog, tempMsg, success);
                return(Json(new OperationResult()
                {
                    Success = success, Message = tempMsg
                }));
            }
            catch
            {
                return(Json(new OperationResult()
                {
                    Message = string.Format(msg, PromptInformation.RemotingError)
                }));
            }
            #endregion
        }
Exemplo n.º 4
0
        public int ReplyInspectionMessage(UInt32 msgID, string replyContent)
        {
            //TODO: 回复查岗信息 内部逻辑待定
            //根据msgID获取查岗信息
            var result = InspectionBLL.GetInspectionInfoByID(msgID).DataResult;

            if (result == null)//发生错误或未找到记录
            {
                return(-1);
            }
            //true代表已被其他人回复
            //这里其实不对,因为可能出现查询出以后被人回复的情况,所以实际上如果为了保证不会重复回复,需要做乐观并发
            //但是实际上发生概率实在太低,而且即使重复回复也不会有什么后果,所以不处理
            if (result.Flag)
            {
                return(2);
            }

            #region 由于老版本remoting设计问题,导致这里需要编写一次消息体

            if (!GetRemoteObj())
            {
                return(-2);
            }

            //查岗应答内容
            byte[] byteText = Encoding.GetEncoding("GBK").GetBytes(replyContent.Trim());
            //查岗应答消息体
            //子业务类型标识2+后续数据长度4+查岗对象的类型1+查岗对象的ID12+信息ID4+数据长度4+应答内容
            byte[] clientSend = new byte[27 + byteText.Length];


            //子业务类型标识 开始0 结束1
            clientSend[0] = 0x13;
            clientSend[1] = 0x01;

            //后续数据长度 开始2 结束5
            byte[] checkObject = GetBigEndianBytes4(21 + byteText.Length);
            checkObject.CopyTo(clientSend, 2);

            //对象类型 开始6 结束6
            clientSend[6] = Convert.ToByte(result.ObjType);

            //查岗对象的ID 开始7 结束18
            byte[] B12 = new byte[12];
            B12 = Encoding.GetEncoding("GBK").GetBytes(result.ObjID);
            B12.CopyTo(clientSend, 7);

            // 信息ID 开始19 结束22
            byte[] byteSendId = GetBigEndianBytes4(msgID);
            byteSendId.CopyTo(clientSend, 19);

            // 数据长度 开始23 结束26
            byte[] sendTextLen = GetBigEndianBytes4(byteText.Length);
            sendTextLen.CopyTo(clientSend, 23);

            //应答内容 开始27
            byteText.CopyTo(clientSend, 27);
            #endregion



            string pn      = result.PlatformName;
            string ac      = result.AccessCode;
            string version = result.Version;
            uint   M1      = (uint)result.M1;
            uint   IA1     = (uint)result.IA1;
            uint   IC1     = (uint)result.IC1;

            string opResult = string.Empty;
            //进行回复
            if (result.ObjType == "1")//针对平台的查岗
            {
                opResult = remoteObj.BeginSendPlatFormCheckMsg(clientSend, pn, ac, version, M1, IA1, IC1);
            }
            else//针对业户的查岗
            {
                opResult = remoteObj.BeginSendPlatFormCheckMsg(clientSend, pn, result.ObjID, ac, version, M1, IA1, IC1);
            }
            if (opResult != "成功")
            {
                return(0);
            }
            InspectionBLL.UpdateInspectionState(msgID, replyContent);
            return(1);
        }