Ejemplo n.º 1
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (textBox2.Text == textBox4.Text)
     {
         COMuser user = new COMuser();
         user.CategoryName = textBox3.Text;
         user.Email        = textBox1.Text;
         user.Password     = textBox2.Text;
         user.ImageURL     = BLLcategory.GetCategoryById(6).ImageURL;
         try
         {
             BLLuser.AddUser(user);
         }
         catch (Exception ex)
         {
             MessageBox.Show("error: add user didnt success: " + ex);
         }
     }
     else
     {
         MessageBox.Show("verify password isnt like password. try again.");
     }
     groupBox1.Visible = false;
     textBox1.Text     = string.Empty;
     textBox2.Text     = string.Empty;
     textBox4.Text     = string.Empty;
     textBox3.Text     = string.Empty;
 }
        public int GetPagesAmountPerCategory(int id)
        {
            int num;

            num = BLLcategory.GetPagesAmountPerCategory(id);
            return(num);
        }
        public IHttpActionResult GetCategoryById(int id)
        {
            COMCategory cat = BLLcategory.GetCategoryById(id);

            if (cat == null)
            {
                return(BadRequest("category does not exist"));
            }
            return(Ok(cat));
        }
        public IHttpActionResult PostCategory([FromBody] COMCategory com)
        {
            COMCategory c = BLLcategory.GetCategoryById(com.CategoryId);

            if (c != null)
            {
                return(BadRequest("category already exist"));
            }
            BLLcategory.AddCategory(com, Form1.categoriesCounter);
            return(Ok());
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
        private void button6_Click(object sender, EventArgs e)
        {
            COMCategory cat = new COMCategory();

            cat.CategoryName = textBox6.Text;
            cat.ImageURL     = path;
            BLLcategory.AddCategory(cat, categoriesCounter);
            int catId = BLLcategory.GetCategoryIdByCategoryName(cat.CategoryName);

            try
            {
                BLLcategory.UpdateURL(catId, BLLgoogleVision.Storage(catId, cat.ImageURL, categoriesCounter, true));
            }
            catch (Exception)
            {
                throw;
            }
            groupBox2.Visible = false;
            textBox6.Text     = string.Empty;
        }
Ejemplo n.º 7
0
        private void button4_Click(object sender, EventArgs e)
        {
            groupBox3.Visible = true;
            List <COMCategory> cats = new List <COMCategory>();

            if (BLLcategory.GetCategories() != null)
            {
                cats = BLLcategory.GetCategories();
                comboBox1.DataSource    = cats;
                comboBox1.DisplayMember = "CategoryName";
                comboBox1.ValueMember   = "CategoryId";
            }
            List <COMuser> users = new List <COMuser>();

            if (BLLuser.GetUsers() != null)
            {
                users = BLLuser.GetUsers();
                comboBox3.DataSource    = users;
                comboBox3.DisplayMember = "Email";
                comboBox3.ValueMember   = "UserId";
            }
        }
    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;
    }
Ejemplo n.º 9
0
 private void button17_Click(object sender, EventArgs e)
 {
     BLLcategory.RemoveCategory(Convert.ToInt32(numericUpDown3.Value));
 }
 public void DeleteCategory(int id)
 {
     BLLcategory.RemoveCategory(id);
 }
 public List <COMCategory> GetCategories()
 {
     BLLgoogleVision.pathCred = HttpRuntime.AppDomainAppPath;
     return(BLLcategory.GetCategories());
 }