Beispiel #1
0
        private static void ProduceImage(Dictionary <string, string> model)
        {
            SendImage text = new SendImage();

            text.ToUserName   = model.ReadKey(PublicField.FromUserName);
            text.FromUserName = model.ReadKey(PublicField.ToUserName);
            text.CreateTime   = int.Parse(model.ReadKey(PublicField.CreateTime));
            text.MsgType      = "image";
        }
Beispiel #2
0
 /// <summary>
 ///  回复的图片消息的函数
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="mediaId">服务器上图片的ID</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-24 10:23:10
 private static void ProduceImage(Dictionary<string, string> model, string mediaId)
 {
     SendImage image = new SendImage();
     image.ToUserName = model.ReadKey(PublicField.FromUserName);
     image.FromUserName = model.ReadKey(PublicField.ToUserName);
     image.CreateTime = int.Parse(model.ReadKey(PublicField.CreateTime));
     image.MsgType = "image";
     image.MediaId = mediaId;
     OperateXml.ResponseEnd(Templete.SendImg(image));
 }
Beispiel #3
0
 /// <summary>
 ///  回复图片消息
 /// </summary>
 /// <param name="model">The model.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-10 11:00:22
 public static string SendImg(SendImage model)
 {
     return(string.Format(@"<xml>
                             <ToUserName><![CDATA[{0}]]></ToUserName>
                             <FromUserName><![CDATA[{1}]]></FromUserName>
                             <CreateTime>{2}</CreateTime>
                             <MsgType><![CDATA[{3}]]></MsgType>
                             <Image>
                                 <MediaId><![CDATA[{4}]]></MediaId>
                             </Image>
                            </xml>", model.ToUserName, model.FromUserName, model.CreateTime, model.MsgType, model.MediaId));
 }
 public ActionResult SendImage(SendImage model)
 {
     try
     {
         var file = Request.Files[0];
         var path = Server.MapPath("~/grf/" + model.filename);
         if (System.IO.File.Exists(path))
         {
             System.IO.File.Delete(path);
         }
         file.SaveAs(path);
         return(Json(new { success = true, path = "/grf/" + model.filename }));
     }
     catch
     {
         ViewData["Error"] = "Błąd zapisu pliku";
         return(Json(new { success = false, path = "" }));
     }
 }
Beispiel #5
0
 private int getPosition()
 {
     if (msglist.Count == 0 && receivelist.Count == 0 && photolist.Count == 0 && filelist.Count == 0 && audiolist.Count == 0 && videolist.Count == 0)
     {
         return(40);
     }
     if (lastObject is MyBubble)
     {
         MyBubble tmp = (MyBubble)lastObject;
         return(tmp.Top + tmp.Height);
     }
     if (lastObject is GetBubble)
     {
         GetBubble tmp = (GetBubble)lastObject;
         return(tmp.Top + tmp.Height);
     }
     if (lastObject is SendImage)
     {
         SendImage tmp = (SendImage)lastObject;
         return(tmp.Top + tmp.Height);
     }
     if (lastObject is SendFile)
     {
         SendFile tmp = (SendFile)lastObject;
         return(tmp.Top + tmp.Height);
     }
     if (lastObject is SendAudio)
     {
         SendAudio tmp = (SendAudio)lastObject;
         return(tmp.Top + tmp.Height);
     }
     if (lastObject is SendVideo)
     {
         SendVideo tmp = (SendVideo)lastObject;
         return(tmp.Top + tmp.Height);
     }
     else
     {
         return(0);
     }
 }
Beispiel #6
0
        private void altoButton3_Click_1(object sender, EventArgs e)
        {
            string    path;
            SendImage image = new SendImage();

            if ((path = image.SetImage()) != null)
            {
                FileStream fs    = new FileStream(path, FileMode.Open, FileAccess.Read);
                byte[]     bytes = Encoding.UTF8.GetBytes("photo");
                stream.Write(bytes, 0, bytes.Length);
                SendFileInfo(fs);
                SendFile(fs);
                fs.Close();
                image.Left = 285;
                CheckScrollBar();
                image.Top = getPosition();
                image.AddTimeLabelSender();
                panel3.Controls.Add(image);
                lastObject = image;
                photolist.Add(image);
            }
        }
Beispiel #7
0
        private Task ProceedImage(SendImage message)
        {
            return(Task.Run(() =>
            {
                if (!_cancellationTokenSource.IsCancellationRequested)
                {
                    using (var ms = new MemoryStream(message.Image))
                    {
                        using (var originalImage = new Bitmap(ms))
                        {
                            var rgba = ImageUtils.GetRgbaFromBitmap(originalImage);
                            SRCNNHandler srcnn = new SRCNNHandler()
                            {
                                Scale = 2,
                                ScaleModel = Model
                            };

                            int width = originalImage.Width;
                            int height = originalImage.Height;

                            ProgressLogging(new ProgressMessage(message.TaskId, UpscallingStatuses.Received));

                            Task upscallingTask = Task.Run(
                                async() =>
                            {
                                await srcnn.UpscaleImageAsync(message.TaskId, rgba, width, height, ResultHandling,
                                                              ProgressLogging);
                            }, _cancellationTokenSource.Token);

                            _imagePrecessingTasks.RemoveAll(t => t.IsCompleted);
                            _imagePrecessingTasks.Add(upscallingTask);
                        }
                    }
                }
            }));
        }
Beispiel #8
0
 private void timer1_Tick_1(object sender, EventArgs e)
 {
     if (gettedMessage != "")
     {
         ReceiveBubble(gettedMessage);
         gettedMessage = "";
     }
     if (path != "")
     {
         image = new SendImage();
         image.SetImage(path);
         image.Left       = 5;
         image.PhotoColor = Color.SkyBlue;
         image.Top        = getPosition();
         image.AddTimeLabelGetter();
         panel3.Controls.Add(image);
         lastObject = image;
         photolist.Add(image);
         path = "";
         CheckScrollBar();
     }
     if (filepath != "")
     {
         file = new SendFile();
         file.SetFile(filepath);
         file.FileName = filepath;
         file.FileSize = fileSizeString;
         file.Left     = 5;
         file.Top      = getPosition();
         file.AddTimeLabelGetter();
         panel3.Controls.Add(file);
         lastObject = file;
         filelist.Add(file);
         filepath = "";
         CheckScrollBar();
     }
     if (audiopath != "")
     {
         audio = new SendAudio();
         audio.SetFile(audiopath);
         audio.AudioTime = (GetWavFileDuration(audiopath)).ToString();
         audio.Left      = 5;
         audio.Top       = getPosition();
         audio.AddTimeLabelGetter();
         panel3.Controls.Add(audio);
         lastObject = audio;
         audiolist.Add(audio);
         audiopath = "";
         CheckScrollBar();
     }
     if (videopath != "")
     {
         wideo = new SendVideo();
         wideo.SetFile(videopath);
         wideo.Left = 5;
         wideo.Top  = getPosition();
         wideo.AddTimeLabelGetter();
         panel3.Controls.Add(wideo);
         lastObject = wideo;
         videolist.Add(wideo);
         videopath = "";
         CheckScrollBar();
     }
 }
        public async Task <IHttpActionResult> AddIncidentAssessmentImage([FromUri, Required(AllowEmptyStrings = false)] string key, [FromBody] SendImage image)
        {
            byte[] ImageBinaryContent;


            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            else if (image == null)
            {
                return(BadRequest(""));
            }


            if (image.File.InputStream.CanSeek)
            {
                image.File.InputStream.Seek(0, SeekOrigin.Begin);
            }

            using (var br = new BinaryReader(image.File.InputStream))
            {
                ImageBinaryContent = br.ReadBytes(image.File.ContentLength);
            }

            IncidentAssessmentImage incidentImage = new IncidentAssessmentImage()
            {
                MimeType = image.File.ContentType,
                Name     = image.File.FileName,
                Image    = ImageBinaryContent
            };

            bool result = await Task.Run(() => this._incidentAssessmentService.AddImage(key, incidentImage));

            return(Ok(result));
        }