Exemplo n.º 1
0
        private static void SendBack(string connId, string result, Action <float> report)
        {
            int rd = 0, rdt = result.Length;

            while (rd < rdt)
            {
                // 128Kb
                int len = Math.Min(128 * 1024, rdt - rd);
                ProcessingHub.ReceiveData(connId, result.Substring(rd, len), len, rdt);
                rd += len;

                report((float)rd / rdt);
            }
        }
Exemplo n.º 2
0
        public ActionResult PImg(string connId, string method, string parameters)
        {
            Action <float, float, float> report =
                (p, o, l) => ProcessingHub.UpdateProgress(connId, o + l * p, string.Empty);

            try
            {
                string base64 = ConvertToBase64(Request.InputStream, (p) => report(p, 0, 20));

                string result = Process(method, base64, (p) => report(p, 20, 20));

                SendBack(connId, result, (p) => report(p, 40, 60));

                ProcessingHub.UpdateProgress(connId, 100, string.Empty);
            }
            catch (Exception e)
            {
                ProcessingHub.UpdateProgress(connId, -1, $"{e.Message}|{e.StackTrace}");
                return(Content(e.Message));
            }
            return(Content(""));
        }