Esempio n. 1
0
        public string SendTaskComment(string url, string taskid, string messageName, string businessKey, string messageComment, string JWUser, string ExceptionType, string Initiator)
        {
            try
            {
                //例如:ExceptionType="成品短驳超重"
                Console.WriteLine("RestService - SendTaskComment()" + " - " + DateTime.Now.ToString());
                var _restclient = new RestClient();
                _restclient.EndPoint = url + "message";
                _restclient.Method   = HttpVerb.POST;

                Console.WriteLine(_restclient.EndPoint);
                Dictionary <string, object> processVariables = new Dictionary <string, object>();

                FormDatas fdReasonTitle = new FormDatas();
                fdReasonTitle.value = messageComment;
                fdReasonTitle.type  = "String";
                FormDatas fdJWUser = new FormDatas();
                fdJWUser.value = JWUser;
                fdJWUser.type  = "String";
                FormDatas fdExceptionType = new FormDatas();
                fdExceptionType.value = ExceptionType;
                fdExceptionType.type  = "String";
                FormDatas fdInitiator = new FormDatas();
                fdInitiator.value = Initiator;
                fdInitiator.type  = "String";

                processVariables.Add("ReasonTitle", fdReasonTitle);
                processVariables.Add("JWUser", fdJWUser);
                processVariables.Add("ExceptionType", fdExceptionType);
                processVariables.Add("initiator", fdInitiator);

                var formdate = new Dictionary <string, object>
                {
                    { "messageName", messageName },
                    { "businessKey", businessKey },
                    { "processVariables", processVariables },
                };

                Console.WriteLine("formdate");
                string plyload = JsonConvert.SerializeObject(formdate);
                Console.WriteLine(plyload);
                _restclient.PostData = plyload;
                return(_restclient.MakeRequest());
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee.ToString() + ee.StackTrace);
                ExceptionDetail d = new ExceptionDetail(ee);
                Logger.Trace(ee.ToString());
                throw new FaultException <ExceptionDetail>(d, " RestService SendTaskComment异常:" + ee.Message + ee.InnerException);
            }
        }
        public string ConvertFormData(Dictionary <string, object> formdate, string businessKey)
        {
            Dictionary <string, Object> dictionary = new Dictionary <string, Object>();
            Dictionary <string, object> rrr        = new Dictionary <string, object>();;

            foreach (var varitem in formdate)
            {
                FormDatas data = new FormDatas();
                data.value = varitem.Value.ToString();
                data.type  = "String";
                rrr.Add(varitem.Key, data);
            }
            dictionary.Add("variables", rrr);
            if (!string.IsNullOrEmpty(businessKey))
            {
                dictionary.Add("businessKey", businessKey);
            }
            string json = JsonConvert.SerializeObject(dictionary);

            Console.WriteLine(json);
            return(json);
        }