示例#1
0
 private void button22_Click(object sender, EventArgs e)
 {
     BLLobject.UpdateNameAndVoiceURL(Convert.ToInt32(numericUpDown7.Value), Convert.ToInt32(numericUpDown8.Value), textBox8.Text);
     textBox8.Text        = "";
     numericUpDown7.Value = 0;
     numericUpDown8.Value = 0;
 }
示例#2
0
 private void button20_Click(object sender, EventArgs e)
 {
     foreach (COMimageObject item in BLLobject.GetObjects().FindAll(obj => obj.ImageID == Convert.ToInt32(numericUpDown6.Value)))
     {
         BLLobject.RemoveObject(item.ObjectId);
     }
 }
        public IHttpActionResult GetObjectById(int id)
        {
            COMimageObject obj = BLLobject.GetObjectById(id);

            if (obj == null)
            {
                return(BadRequest("object does not exist"));
            }
            return(Ok(obj));
        }
        public IHttpActionResult PostObject([FromBody] COMimageObject obj)
        {
            COMimageObject o = BLLobject.GetObjectById(obj.ObjectId);

            if (o != null)
            {
                return(BadRequest("object already exist"));
            }
            BLLobject.AddObject(obj);
            return(Ok());
        }
示例#5
0
 // [HttpPost]
 public void PostObjects([FromBody] List <COMimageObject> objs, int id, int catid)
 {
     try
     {
         COMimage img = new COMimage();
         img.UserId     = id;
         img.CategoryID = catid;
         img.URL        = "";
         int imageid = BLLgoogleVision.UserImageStorageAndDB(img, objs[0].VoiceURL);
         Dictionary <string, int> dic = new Dictionary <string, int>();
         foreach (COMimageObject item in objs)
         {
             item.ImageID  = imageid;
             item.VoiceURL = BLLtextToSpeach.VoiceStorage(id, catid, BLLtextToSpeach.TextToSpeach(item.Name), dic);
             BLLobject.AddObject(item);
         }
     }
     catch (Exception)
     {
         //return BadRequest();
         throw;
     }
 }
    public static string VoiceStorage(int userId,int catId, string URL, Dictionary<string, int> voicesCounter)
    {
        Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS",  @"C:\keys\wordproject -29b2e0d3e0d5.json");
        // upload the image storage
        string voiceName;
        if(voicesCounter.Count>0)
        //voicesCounter[BLLcategory.GetCategoryById(catId).CategoryName]++
        voiceName = "voice" + BLLcategory.GetCategoryById(catId).CategoryName + voicesCounter[BLLcategory.GetCategoryById(catId).CategoryName]++ + ".mp3";
        else
        {
            List<COMimageObject> objs = new List<COMimageObject>();
            foreach (COMimage img in BLLimage.Getimages().FindAll(img => img.UserId == userId))
            {
                objs.AddRange(BLLobject.GetObjects().FindAll(obj => obj.ImageID == img.ImageID));
            }

            string add = catId == 6 ? BLLuser.GetUserById(userId).CategoryName : BLLcategory.GetCategoryById(catId).CategoryName;
            voiceName = "voice" + add + objs.Count + ".mp3";

        }
        string bucketName = "objectsound";
        var storage = StorageClient.Create();
        using (var f = File.OpenRead(URL))
        {
            try
            {
                var res = storage.UploadObject(bucketName, voiceName, null, f);
                URL = "https://storage.googleapis.com/" + bucketName + "/" + voiceName;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        return URL;
    }
示例#7
0
 private void delete_Click(object sender, EventArgs e)
 {
     BLLobject.RemoveObject(Convert.ToInt32(numericUpDown9.Value));
     numericUpDown9.Value = 0;
 }
示例#8
0
        public void Load()
        {
            int x = 0;

            foreach (COMCategory cat in BLLcategory.GetCategories())
            {
                x = BLLimage.Getimages().FindAll(img => img.CategoryID == cat.CategoryId).Count();
                categoriesCounter.Add(cat.CategoryName, x);
            }
            foreach (COMCategory cat in BLLcategory.GetCategories())
            {
                List <COMimageObject> objects = new List <COMimageObject>();
                BLLimage.Getimages().FindAll(img => img.CategoryID == cat.CategoryId).ForEach(img => objects.AddRange(BLLobject.GetObjects().FindAll(obj => obj.ImageID == img.ImageID)));
                x = objects.Count;
                voicesCounter.Add(cat.CategoryName, x);
            }
        }
 public void DeleteObject(int id)
 {
     BLLobject.RemoveObject(id);
 }
 public List <COMimageObject> GetObjects()
 {
     return(BLLobject.GetObjects());
 }