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

            if (jObject != null)
            {
                switch (oType)
                {
                case "start":
                    command = new StartProcessCommand();
                    if (jObject != null)
                    {
                        var apiKey       = getJsonStringProperty(jObject, "apiKey");
                        var folio        = getJsonStringProperty(jObject, "folio");
                        var jsonData     = getJsonStringProperty(jObject, "jsonData");
                        var ObjectId     = getJsonStringProperty(jObject, "ObjectId");
                        var processCode  = getJsonStringProperty(jObject, "processCode");
                        var businessType = getJsonStringProperty(jObject, "businessType");
                        var loginId      = string.IsNullOrEmpty(getJsonStringProperty(jObject, "loginId")) ? 0 : int.Parse(getJsonStringProperty(jObject, "loginId"));

                        ((StartProcessCommand)command).ApiKey       = apiKey;
                        ((StartProcessCommand)command).Folio        = folio;
                        ((StartProcessCommand)command).JsonData     = jsonData;
                        ((StartProcessCommand)command).ObjectId     = ObjectId;
                        ((StartProcessCommand)command).ProcessCode  = processCode;
                        ((StartProcessCommand)command).LoginId      = loginId;
                        ((StartProcessCommand)command).BusinessType = businessType;
                    }
                    break;

                case "approval":
                    command = new ApprovalProcessCommand();
                    if (jObject != null)
                    {
                        var apiKey       = getJsonStringProperty(jObject, "apiKey");
                        var actionString = getJsonStringProperty(jObject, "actionString");
                        var jsonData     = getJsonStringProperty(jObject, "jsonData");
                        var memo         = getJsonStringProperty(jObject, "memo");
                        var processCode  = getJsonStringProperty(jObject, "processCode");
                        var sn           = getJsonStringProperty(jObject, "sn");
                        var businessType = getJsonStringProperty(jObject, "businessType");
                        var loginId      = string.IsNullOrEmpty(getJsonStringProperty(jObject, "loginId")) ? 0 : int.Parse(getJsonStringProperty(jObject, "loginId"));

                        ((ApprovalProcessCommand)command).ApiKey       = apiKey;
                        ((ApprovalProcessCommand)command).ActionString = actionString;
                        ((ApprovalProcessCommand)command).JsonData     = jsonData;
                        ((ApprovalProcessCommand)command).Memo         = memo;
                        ((ApprovalProcessCommand)command).ProcessCode  = processCode;
                        ((ApprovalProcessCommand)command).LoginId      = loginId;
                        ((ApprovalProcessCommand)command).SN           = sn;
                        ((ApprovalProcessCommand)command).BusinessType = businessType;
                    }
                    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)
        {
            IK2Command command = null;
            var msgObj = JsonConvert.DeserializeObject(content);
            var jObject = msgObj as Newtonsoft.Json.Linq.JObject;

            if (jObject != null)
            {
                switch (oType)
                {
                    case "start":
                        command = new StartProcessCommand();
                        if (jObject != null)
                        {
                            var apiKey = getJsonStringProperty(jObject, "apiKey");
                            var folio = getJsonStringProperty(jObject, "folio");
                            var jsonData = getJsonStringProperty(jObject, "jsonData");
                            var ObjectId = getJsonStringProperty(jObject, "ObjectId");
                            var processCode = getJsonStringProperty(jObject, "processCode");
                            var businessType = getJsonStringProperty(jObject, "businessType");
                            var loginId = string.IsNullOrEmpty(getJsonStringProperty(jObject, "loginId")) ? 0 : int.Parse(getJsonStringProperty(jObject, "loginId"));

                            ((StartProcessCommand)command).ApiKey = apiKey;
                            ((StartProcessCommand)command).Folio = folio;
                            ((StartProcessCommand)command).JsonData = jsonData;
                            ((StartProcessCommand)command).ObjectId = ObjectId;
                            ((StartProcessCommand)command).ProcessCode = processCode;
                            ((StartProcessCommand)command).LoginId = loginId;
                            ((StartProcessCommand)command).BusinessType = businessType;
                        }
                        break;
                    case "approval":
                        command = new ApprovalProcessCommand();
                        if (jObject != null)
                        {
                            var apiKey = getJsonStringProperty(jObject, "apiKey");
                            var actionString = getJsonStringProperty(jObject, "actionString");
                            var jsonData = getJsonStringProperty(jObject, "jsonData");
                            var memo = getJsonStringProperty(jObject, "memo");
                            var processCode = getJsonStringProperty(jObject, "processCode");
                            var sn = getJsonStringProperty(jObject, "sn");
                            var businessType = getJsonStringProperty(jObject, "businessType");
                            var loginId = string.IsNullOrEmpty(getJsonStringProperty(jObject, "loginId")) ? 0 : int.Parse(getJsonStringProperty(jObject, "loginId"));

                            ((ApprovalProcessCommand)command).ApiKey = apiKey;
                            ((ApprovalProcessCommand)command).ActionString = actionString;
                            ((ApprovalProcessCommand)command).JsonData = jsonData;
                            ((ApprovalProcessCommand)command).Memo = memo;
                            ((ApprovalProcessCommand)command).ProcessCode = processCode;
                            ((ApprovalProcessCommand)command).LoginId = loginId;
                            ((ApprovalProcessCommand)command).SN = sn;
                            ((ApprovalProcessCommand)command).BusinessType = businessType;
                        }
                        break;

                    default:
                        break;
                }
            }

            return command;
        }