Exemple #1
0
        protected override System.Drawing.Image Execute(CodeActivityContext context)
        {
            try
            {
                string ip         = "localhost";
                string port       = Port.Get <string>(context);
                string db         = dbName.Get <string>(context);
                string version    = Version.Get <string>(context);
                string group      = Group.Get <string>(context);
                string entity     = Entity.Get <string>(context);
                string function   = Function.Get <string>(context);
                int    merchId    = MerchId.Get <int>(context);
                int    fpid       = FPId.Get <int>(context);
                int    sysId      = SysId.Get <int>(context);
                int    formId     = FormId.Get <int>(context);
                string serviceKey = ServiceKey.Get <string>(context);
                int    imageId    = ImageId.Get <int>(context);

                string url = string.Format("http://{0}:{1}/{2}/{3}/{4}/{5}/{6}?MerchId={7}&SysId={8}&FormId={9}&FPId={10}&key={11}&ImageId={12}",
                                           ip, port, db, version, group, entity, function, merchId, sysId, formId, fpid, serviceKey, imageId);

                HttpClient client = new HttpClient();
                Task <HttpResponseMessage> message = client.GetAsync(url);
                message.Wait();
                Task <string> messageResult = message.Result.Content.ReadAsStringAsync();
                messageResult.Wait();

                System.Drawing.Image result = null;
                byte[] imageByteArray       = Convert.FromBase64String(messageResult.Result.Replace("\"", ""));
                using (MemoryStream stream = new MemoryStream(imageByteArray))
                {
                    result = System.Drawing.Image.FromStream(stream);
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }