コード例 #1
0
        /// <summary>
        /// 根据消息获得具体的K2操作
        /// </summary>
        /// <param name="oType">操作类型</param>
        /// <param name="content">调用k2服务的参数</param>
        /// <returns></returns>
        public IK2Command GetCommand(string oType, string content, IK2ServiceProvider k2ServiceProvider)
        {
            IK2Command command = null;
            var        msgObj  = JsonConvert.DeserializeObject(content);
            var        jObject = msgObj as Newtonsoft.Json.Linq.JObject;

            if (jObject != null)
            {
                switch (oType.ToLower())
                {
                case "start":
                    //command = new StartProcessCommand(k2ServiceProvider);
                    //if (jObject != null)
                    //{
                    //    ((StartProcessCommand)command).ApiKey = getJsonStringProperty(jObject, "apiKey");
                    //    ((StartProcessCommand)command).Folio = getJsonStringProperty(jObject, "folio");
                    //    ((StartProcessCommand)command).JsonData = getJsonStringProperty(jObject, "jsonData");
                    //    ((StartProcessCommand)command).ObjectId = getJsonStringProperty(jObject, "ObjectId"); ;
                    //    ((StartProcessCommand)command).ProcessCode = getJsonStringProperty(jObject, "processCode");
                    //    ((StartProcessCommand)command).LoginId = string.IsNullOrEmpty(getJsonStringProperty(jObject, "loginId")) ? 0 : int.Parse(getJsonStringProperty(jObject, "loginId"));
                    //}
                    break;

                case "approval":
                    command = new ApprovalProcessCommand(k2ServiceProvider);
                    if (jObject != null)
                    {
                        ((ApprovalProcessCommand)command).ApiKey       = getJsonStringProperty(jObject, "apiKey");
                        ((ApprovalProcessCommand)command).ActionString = getJsonStringProperty(jObject, "actionString");
                        ((ApprovalProcessCommand)command).JsonData     = getJsonStringProperty(jObject, "jsonData");
                        ((ApprovalProcessCommand)command).Memo         = getJsonStringProperty(jObject, "memo");
                        ((ApprovalProcessCommand)command).ProcessCode  = getJsonStringProperty(jObject, "processCode");
                        ((ApprovalProcessCommand)command).LoginId      = string.IsNullOrEmpty(getJsonStringProperty(jObject, "loginId")) ? 0 : int.Parse(getJsonStringProperty(jObject, "loginId"));
                        ((ApprovalProcessCommand)command).SN           = getJsonStringProperty(jObject, "sn");
                    }
                    break;

                default:
                    break;
                }
            }
            return(command);
        }
コード例 #2
0
        /// <summary>
        /// 根据消息获得具体的K2操作
        /// </summary>
        /// <param name="oType">操作类型</param>
        /// <param name="content">调用k2服务的参数</param>
        /// <returns></returns>
        public IK2Command GetCommand(string oType, string content, IK2ServiceProvider k2ServiceProvider)
        {
            IK2Command command = null;
            var msgObj = JsonConvert.DeserializeObject(content);
            var jObject = msgObj as Newtonsoft.Json.Linq.JObject;

            if (jObject != null)
            {
                switch (oType.ToLower())
                {
                    case "start":
                        //command = new StartProcessCommand(k2ServiceProvider);
                        //if (jObject != null)
                        //{
                        //    ((StartProcessCommand)command).ApiKey = getJsonStringProperty(jObject, "apiKey");
                        //    ((StartProcessCommand)command).Folio = getJsonStringProperty(jObject, "folio");
                        //    ((StartProcessCommand)command).JsonData = getJsonStringProperty(jObject, "jsonData");
                        //    ((StartProcessCommand)command).ObjectId = getJsonStringProperty(jObject, "ObjectId"); ;
                        //    ((StartProcessCommand)command).ProcessCode = getJsonStringProperty(jObject, "processCode");
                        //    ((StartProcessCommand)command).LoginId = string.IsNullOrEmpty(getJsonStringProperty(jObject, "loginId")) ? 0 : int.Parse(getJsonStringProperty(jObject, "loginId"));
                        //}
                        break;
                    case "approval":
                        command = new ApprovalProcessCommand(k2ServiceProvider);
                        if (jObject != null)
                        {
                            ((ApprovalProcessCommand)command).ApiKey = getJsonStringProperty(jObject, "apiKey");
                            ((ApprovalProcessCommand)command).ActionString = getJsonStringProperty(jObject, "actionString");
                            ((ApprovalProcessCommand)command).JsonData = getJsonStringProperty(jObject, "jsonData");
                            ((ApprovalProcessCommand)command).Memo = getJsonStringProperty(jObject, "memo");
                            ((ApprovalProcessCommand)command).ProcessCode = getJsonStringProperty(jObject, "processCode");
                            ((ApprovalProcessCommand)command).LoginId = string.IsNullOrEmpty(getJsonStringProperty(jObject, "loginId")) ? 0 : int.Parse(getJsonStringProperty(jObject, "loginId"));
                            ((ApprovalProcessCommand)command).SN = getJsonStringProperty(jObject, "sn");
                        }
                        break;

                    default:
                        break;
                }
            }
            return command;
        }