Exemplo n.º 1
0
        /// <summary>
        /// 接收到客户发来的图片消息
        /// </summary>
        /// <param name="context"></param>
        /// <param name="doc"></param>
        private void _OnImageMessage(HttpContext context, System.Xml.XmlDocument doc)
        {
//            < xml >
//  < ToUserName >< ![CDATA[toUser]] ></ ToUserName >
//  < FromUserName >< ![CDATA[fromUser]] ></ FromUserName >
//  < CreateTime > 1348831860 </ CreateTime >
//  < MsgType >< ![CDATA[image]] ></ MsgType >
//  < PicUrl >< ![CDATA[this is a url]] ></ PicUrl >
//  < MediaId >< ![CDATA[media_id]] ></ MediaId >
//  < MsgId > 1234567890123456 </ MsgId >
//</ xml >

            string toUserName   = doc.GetElementsByTagName("ToUserName")[0].InnerText;
            string fromUserName = doc.GetElementsByTagName("FromUserName")[0].InnerText;
            string createTime   = doc.GetElementsByTagName("CreateTime")[0].InnerText;
            string picurl       = doc.GetElementsByTagName("PicUrl")[0].InnerText;
            string mediaId      = doc.GetElementsByTagName("MediaId")[0].InnerText;
            string msgId        = doc.GetElementsByTagName("MsgId")[0].InnerText;

            RequestImage rqText = new RequestImage();

            rqText.ToUserName   = toUserName;
            rqText.FromUserName = fromUserName;
            rqText.CreateTime   = new DateTime(long.Parse(createTime));
            rqText.PicUrl       = picurl;
            rqText.MediaId      = mediaId;
            rqText.MsgId        = msgId;


            ResponseMessage rpMsg = OnImageMessage(rqText);

            SendResponseMessage(context, rpMsg, rqText);
        }
Exemplo n.º 2
0
 public override ResponseMessage OnImageMessage(RequestImage requestImage)
 {
     return(new ResponseImage()
     {
         MediaId = requestImage.MediaId
     });
 }
Exemplo n.º 3
0
        public Task <BaseMessage> HandleImage(RequestImage info)
        {
            BaseMessage response = new ResponseText(info)
            {
                Content = Msg
            };

            return(Task.FromResult(response));
        }
 public void InsertImage(RequestImage ReqImg)
 {
     try
     {
         RollSystemDB.RequestImages.AddObject(ReqImg);
         RollSystemDB.SaveChanges();
     }
     catch (Exception e)
     {
     }
 }
        private void ProductForm_Load(object sender, EventArgs e)
        {
            keyName = this.Text;
            DataSet ds_image_desain = new DataSet();

            DBSql.DoGetData("select url_design_img from tbl_barangs where description='" + keyName.Split('$')[0] + "' and contract='" + keyName.Split('$')[1] + "' and grade='A'", ds_image_desain);
            if (ds_image_desain.Tables[0].Rows.Count > 0)
            {
                if (!String.IsNullOrEmpty(ds_image_desain.Tables[0].Rows[0][0].ToString()))
                {
                    if (ds_image_desain.Tables[0].Rows[0][0].ToString() != "-")
                    {
                        string url = "http://ultimindserver.mywire.org:3000/img_file/designs/" + ds_image_desain.Tables[0].Rows[0][0].ToString();
                        r_image = new RequestImage();
                        r_image.loadFromUrlAsync(url, delegate(Image img)
                        {
                            if (img != null)
                            {
                                pic_product.Image = img;
                            }
                            else
                            {
                                pic_product.Image = Properties.Resources.img_error;
                            }
                        });
                    }

                    DataSet ds = DBSql.DoGetData("select design_id from tbl_barangs where description='" + keyName.Split('$')[0] + "' and contract='" + keyName.Split('$')[1] + "' and grade='A'");
                    design_id = ds.Tables[0].Rows[0][0].ToString();

                    DataSet ds_colors = DBSql.DoGetData("select color_desc, url_color_img, part_no, design_id from tbl_barangs where description='" + keyName.Split('$')[0] + "' and contract='" + keyName.Split('$')[1] + "' and grade='A'");
                    for (int i = 0; i < ds_colors.Tables[0].Rows.Count; i++)
                    {
                        list_colors.Items.Add(ds_colors.Tables[0].Rows[i][0].ToString());
                        list_colors_img.Add(ds_colors.Tables[0].Rows[i][1].ToString());
                        list_part.Add(ds_colors.Tables[0].Rows[i][2].ToString());
                    }
                }
                else
                {
                    pic_product.Image = Properties.Resources.img_error;
                }
            }
            else
            {
                MessageBox.Show("Data Tidak ditemukan");
                return;
            }
        }
Exemplo n.º 6
0
        public override string ReplyExecute(replyBase json)
        {
            string       xml   = @"<xml>
  <ToUserName><![CDATA[{0}]]></ToUserName>
  <FromUserName><![CDATA[{1}]]></FromUserName>
  <CreateTime>{2}</CreateTime>
  <MsgType><![CDATA[image]]></MsgType>
  <Image>
    <MediaId><![CDATA[{3}]]></MediaId>
  </Image>
</xml>";
            RequestImage json1 = json as RequestImage;

            xml = string.Format(xml, json.xmlmsg.ToUserName, json.xmlmsg.FromUserName, SerializeHelper.longtime().ToString(), json1.Image.MediaId);
            return(xml);
        }
Exemplo n.º 7
0
        public static void SaveRequestImage(string ImagePath, int FaceID, int StudentID, int RequestID)
        {
            //Ben ngoai ko check, ko save
            if (FaceID == -1)
            {
                return;
            }

            StudentImageBusiness StuImaBO = new StudentImageBusiness();
            RequestBusiness      ReqBO    = new RequestBusiness();

            Image <Bgr, byte> Image = new Image <Bgr, byte>(ImagePath);

            using (Image <Gray, byte> GrayImage = Image.Clone().Convert <Gray, byte>())
            {
                var FacesDetected = GrayImage.DetectHaarCascade(Haar, DETECT_SCALE, MIN_NEIGHBOR,
                                                                0, new System.Drawing.Size(MIN_SIZE, MIN_SIZE))[0];
                Image <Bgr, byte> FaceImage = Image.Copy(FacesDetected[FaceID].rect)
                                              .Resize(TRAINING_DATA_SIZE, TRAINING_DATA_SIZE,
                                                      INTER.CV_INTER_CUBIC);;

                //Tao ten file
                String ImageName = System.IO.Path.GetFileNameWithoutExtension(ImagePath);
                String FileName  = String.Format("{0}_face_{1}.jpg", ImageName, FaceID);

                if (StuImaBO.ImageExist(StudentID, FileName))
                {
                    throw new Exception(FileName);
                }
                else
                {
                    //Save file anh xuong
                    FaceImage.Save(TRAINING_FOLDER_PATH + "/" + FileName);
                    //Save xuong DB
                    RequestImage ReqImg = new RequestImage()
                    {
                        RequestID = RequestID, ImageLink = FileName
                    };
                    ReqBO.InsertImage(ReqImg);
                }
            }
            Image.Dispose();
        }
Exemplo n.º 8
0
        /// <summary>
        /// 返回图片
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public string HandleImage(RQBase info)
        {
            //发送什么,返回什么

            string xml = string.Empty;

            try
            {
                RequestImage imgeInfo = new RequestImage();
                imgeInfo.xmlmsg = info.xmlmsg;
                imgeInfo.Image  = new VoiceImage()
                {
                    MediaId = info.MediaId
                };
                xml = new replyImage().ReplyExecute(imgeInfo);
            }
            catch (Exception ex)
            {
                TracingHelper.Error(ex, typeof(WeixinApiDispatch), ex.Message);
            }
            // string xml = SerializeHelper.XmlSerialize<RequestImage>(imgeInfo);
            TracingHelper.Info(" HandleImage  " + xml);
            return(xml);
        }
        public int AbortTextureViaCircuit(
            ScriptInstance instance,
            ViewerAgentAccessor agent,
            LSLKey textureID,
            int type)
        {
            lock (instance)
            {
                ViewerConnection vc;
                ViewerCircuit    viewerCircuit;
                if (m_Clients.TryGetValue(agent.AgentID, out vc) &&
                    vc.ViewerCircuits.TryGetValue((uint)agent.CircuitCode, out viewerCircuit) &&
                    m_ActiveImageTransfers.ContainsKey(textureID.AsUUID))
                {
                    m_ActiveImageTransfers.Remove(textureID.AsUUID);
                    var reqImage = new RequestImage
                    {
                        AgentID   = viewerCircuit.AgentID,
                        SessionID = viewerCircuit.SessionID,
                    };
                    reqImage.RequestImageList.Add(new RequestImage.RequestImageEntry
                    {
                        DiscardLevel     = -1,
                        ImageID          = textureID.AsUUID,
                        Type             = (RequestImage.ImageType)type,
                        Packet           = 0,
                        DownloadPriority = 0
                    });

                    viewerCircuit.SendMessage(reqImage);

                    return(1);
                }
                return(0);
            }
        }
        private void list_colors_Click(object sender, EventArgs e)
        {
            lbl_part_no.Text    = list_part[list_colors.SelectedIndex].ToString();
            txt_color_name.Text = list_colors.SelectedItem.ToString();
            if (list_colors_img[list_colors.SelectedIndex].ToString() == "-")
            {
                return;
            }
            string url = "http://ultimindserver.mywire.org:3000/img_file/colors/" + list_colors_img[list_colors.SelectedIndex].ToString();

            r_image = new RequestImage();
            r_image.loadFromUrlAsync(url, delegate(Image img)
            {
                if (img != null)
                {
                    pic_colors.Image = img;
                }
                else
                {
                    pic_colors.Image = Properties.Resources.img_error;
                }
            });
            //MessageBox.Show(list_colors_img[list_colors.SelectedIndex].ToString());
        }
Exemplo n.º 11
0
        private void centralGradientToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListView.SelectedIndexCollection indexes = this.listViewHeap.SelectedIndices;
            if (indexes.Count > 1)
            {
                MessageBox.Show("Too many images selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int DimX = 24;
            int DimY = 16;
            int DimZ = 1;
            int Band = 1;
            float Value = 1.0f;

            if (indexes.Count == 1)
            {
                DimX = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Width;
                DimY = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Height;
                DimZ = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Depth;
                Band = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).NumBands;

            }
            RequestImage RQuest = new RequestImage();
            //RQuest.ShowDialog();
            Control[] ButtonControl = RQuest.Controls.Find("numericUpDownDimX", false);
            NumericUpDown TmpNum = (NumericUpDown)ButtonControl[0];
            TmpNum.Value = DimX;

            ButtonControl = RQuest.Controls.Find("numericUpDownDimY", false);
            TmpNum = (NumericUpDown)ButtonControl[0];
            TmpNum.Value = DimY;

            ButtonControl = RQuest.Controls.Find("numericUpDownDimZ", false);
            TmpNum = (NumericUpDown)ButtonControl[0];
            TmpNum.Value = DimZ;

            ButtonControl = RQuest.Controls.Find("numericUpDownBand", false);
            TmpNum = (NumericUpDown)ButtonControl[0];
            TmpNum.Value = Band;

            ButtonControl = RQuest.Controls.Find("numericUpDownIntensity", false);
            TmpNum = (NumericUpDown)ButtonControl[0];
            TmpNum.Value = (decimal)Value;

            if (RQuest.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Image3D UnitImage = new Image3D(DimX, DimY, DimZ, 1);

            for (int j = 0; j < UnitImage.Height; j++)
            {
                for (int i = 0; i < UnitImage.Width; i++)
                {
                    UnitImage.Data[0][i + j * UnitImage.Width] = Value * (float)Math.Sqrt((i - DimX / 2.0f) * (i - DimX / 2.0f) + (j - DimY / 2.0f) * (j - DimY / 2.0f));
                }
            }
            //UnitImage.Name = "Unit Image";
            AddImageToHeap(UnitImage, 0);

            indexes.Clear();
        }
Exemplo n.º 12
0
        public async Task <RequestImage> CreateAsync(RequestImage image)
        {
            var entityEntry = await requestImagesDbSet.AddAsync(image);

            return(entityEntry.Entity);
        }
Exemplo n.º 13
0
        public RequestImage Edit(RequestImage image)
        {
            var entityEntry = requestImagesDbSet.Update(image);

            return(entityEntry.Entity);
        }
Exemplo n.º 14
0
        public async Task <Request> CreateRequestAsync(string requestType, IFormFile fromImageFile, IFormFile toImageFile, int?userId)
        {
            var requestRepository      = storage.GetRepository <IRequestRepository>();
            var requestImageRepository = storage.GetRepository <IRequestImageRepository>();

            User user = null;

            if (userId.HasValue)
            {
                var userRepository = storage.GetRepository <IUserRepository>();
                user = await userRepository.GetAsync(options =>
                {
                    options.SearchType = UserSearchTypes.ById;
                    options.UserId     = userId.Value;
                });
            }

            Request request;

            switch (requestType)
            {
            case nameof(SwapRequest):
            {
                if (toImageFile == null)
                {
                    throw new NullReferenceException("If RequestType is Swap, then ToImage cant be a null.");
                }

                request = new SwapRequest()
                {
                    Discriminator = nameof(SwapRequest)
                };
                if (user != null)
                {
                    request.UserId = user.UserId;
                }
                await requestRepository.CreateAsync(request);

                RequestImage fromImage = new RequestImage()
                {
                    Request = request
                };
                await requestImageRepository.CreateAsync(fromImage);

                RequestImage toImage = new RequestImage()
                {
                    Request = request
                };
                await requestImageRepository.CreateAsync(toImage);

                await storage.SaveAsync();

                fromImage.ImageName = fromImage.ImageId + Path.GetExtension(fromImageFile.FileName);
                requestImageRepository.Edit(fromImage);

                toImage.ImageName = toImage.ImageId + Path.GetExtension(toImageFile.FileName);
                requestImageRepository.Edit(toImage);

                await fileService.SaveFileAsync(fromImageFile.OpenReadStream(), Path.Combine(fileService.GlobalRequestImagesPath, fromImage.ImageName));

                await fileService.SaveFileAsync(toImageFile.OpenReadStream(), Path.Combine(fileService.GlobalRequestImagesPath, toImage.ImageName));

                break;
            }

            case nameof(CutRequest):
            {
                request = new CutRequest()
                {
                    Discriminator = nameof(CutRequest)
                };
                if (user != null)
                {
                    request.UserId = user.UserId;
                }
                await requestRepository.CreateAsync(request);

                RequestImage fromImage = new RequestImage()
                {
                    Request = request
                };
                await requestImageRepository.CreateAsync(fromImage);

                await storage.SaveAsync();

                fromImage.ImageName = fromImage.ImageId + Path.GetExtension(fromImageFile.FileName);
                requestImageRepository.Edit(fromImage);
                await fileService.SaveFileAsync(fromImageFile.OpenReadStream(), Path.Combine(fileService.GlobalRequestImagesPath, fromImage.ImageName));

                break;
            }

            case nameof(DetectRequest):
            {
                request = new DetectRequest()
                {
                    Discriminator = nameof(DetectRequest)
                };
                if (user != null)
                {
                    request.UserId = user.UserId;
                }
                await requestRepository.CreateAsync(request);

                RequestImage fromImage = new RequestImage()
                {
                    Request = request
                };
                await requestImageRepository.CreateAsync(fromImage);

                await storage.SaveAsync();

                fromImage.ImageName = fromImage.ImageId + Path.GetExtension(fromImageFile.FileName);
                requestImageRepository.Edit(fromImage);
                await fileService.SaveFileAsync(fromImageFile.OpenReadStream(), Path.Combine(fileService.GlobalRequestImagesPath, fromImage.ImageName));

                break;
            }

            default:
            {
                throw new KeyNotFoundException($"RequestType is {requestType} not exist.");
            }
            }
            ;

            await storage.SaveAsync();

            return(request);
        }
        public async Task <RequestResult> Show(string messageBoxText, string title, RequestButton buttons, RequestImage image)
        {
            int choice;

            switch (buttons)
            {
            case RequestButton.OK:
                MessageBox.Query(title, messageBoxText, Strings.Ok);
                return(RequestResult.OK);

            case RequestButton.OKCancel:
                choice = MessageBox.Query(title, messageBoxText, Strings.Ok, "Cancel");
                return(choice == 0 ? RequestResult.OK : RequestResult.Cancel);

            case RequestButton.YesNoCancel:
                choice = MessageBox.Query(title, messageBoxText, "Yes", "No", "Cancel");
                return(choice == 0 ? RequestResult.Yes : choice == 1 ? RequestResult.No : RequestResult.Cancel);

            case RequestButton.YesNo:
                choice = MessageBox.Query(title, messageBoxText, "Yes", "No");
                return(choice == 0 ? RequestResult.Yes : RequestResult.No);

            default:
                return(RequestResult.None);
            }
        }
Exemplo n.º 16
0
 public void DeleteImage(RequestImage ReqImg)
 {
     RollSystemDB.RequestImages.DeleteObject(ReqImg);
     RollSystemDB.SaveChanges();
 }
Exemplo n.º 17
0
        private void unitImageToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            ListView.SelectedIndexCollection indexes = this.listViewHeap.SelectedIndices;
            if (indexes.Count > 1)
            {
                MessageBox.Show("Too many images selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int DimX = 256;
            int DimY = 256;
            int DimZ = 1;
            int Band = 1;
            float Value = 1.0f;

            if (indexes.Count == 1)
            {
                DimX = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Width;
                DimY = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Height;
                DimZ = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Depth;
                Band = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).NumBands;

            }
            RequestImage RQuest = new RequestImage();
            //RQuest.ShowDialog();
            Control[] ButtonControl = RQuest.Controls.Find("numericUpDownDimX", false);
            NumericUpDown TmpNum = (NumericUpDown)ButtonControl[0];
            TmpNum.Value = DimX;

            ButtonControl = RQuest.Controls.Find("numericUpDownDimY", false);
            TmpNum = (NumericUpDown)ButtonControl[0];
            TmpNum.Value = DimY;

            ButtonControl = RQuest.Controls.Find("numericUpDownDimZ", false);
            TmpNum = (NumericUpDown)ButtonControl[0];
            TmpNum.Value = DimZ;

            ButtonControl = RQuest.Controls.Find("numericUpDownBand", false);
            TmpNum = (NumericUpDown)ButtonControl[0];
            TmpNum.Value = Band;

            ButtonControl = RQuest.Controls.Find("numericUpDownIntensity", false);
            TmpNum = (NumericUpDown)ButtonControl[0];
            TmpNum.Value = (decimal)Value;

            if (RQuest.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            CreateNewImage(RQuest.numericUpDownDimXValue,
                RQuest.numericUpDownDimYValue,
                RQuest.numericUpDownDimZValue,
                RQuest.numericUpDownBandValue,
                RQuest.numericUpDownIntensityValue);

            indexes.Clear();
        }
Exemplo n.º 18
0
 /// <summary>
 /// 接收到客户发来的图片消息
 /// </summary>
 /// <param name="requestImage"></param>
 /// <returns></returns>
 public abstract ResponseMessage OnImageMessage(RequestImage requestImage);