AddImage() public method

There should be No logging in the API Adds an image to the DB
public AddImage ( OSAEImage osaeImage ) : int
osaeImage OSAEImage The image information to add
return int
Ejemplo n.º 1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (fileUpload.HasFile)
        {
            try
            {
                if (System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".jpg" && System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".png" && System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".jpeg")
                {
                    return; // wrong file type
                }
                else
                {
                    if (fileUpload.PostedFile.ContentLength < 2502400) //202400
                    {
                        OSAEImage img = new OSAEImage();
                        img.Data = fileUpload.FileBytes;
                        img.Name = txtName.Text;
                        img.Type = System.IO.Path.GetExtension(fileUpload.FileName).ToLower().Substring(1);

                        var imageManager = new OSAE.OSAEImageManager();
                        imageManager.AddImage(img);

                        loadImages();
                    }
                    else
                    {
                        return;  // file to big
                    }
                }
            }
            catch (Exception ex)
            { }
        }
    }
 private void importImage(Stream stream, String Name)
 {
     try
     {
         OSAEImage    img = new OSAEImage();
         MemoryStream ms  = new MemoryStream();
         stream.CopyTo(ms);
         img.Data = ms.ToArray();
         img.Name = Name;
         img.Type = Path.GetFileNameWithoutExtension(Name); //System.IO.Path.GetExtension(FileLoader.FileName).ToLower().Substring(1)
         var imageManager = new OSAE.OSAEImageManager();
         imageManager.AddImage(img);
     }
     catch
     {
         Master.Log.Error("There was an issue Importting the imgage: " + Name);
     }
 }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (fileUpload.HasFile)
        {
            try
            {
                if (System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".jpg" && System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".png" && System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".jpeg" && System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".gif")
                {
                    Master.Log.Error("Image not added, Wrong file type");
                    return; // wrong file type
                }
                else
                {
                    if (fileUpload.PostedFile.ContentLength < 2502400) //202400
                    {
                        if (fileUpload.HasFile && txtName.Text.Length == 0)
                        {
                            txtName.Text = fileUpload.FileName;
                        }
                        OSAEImage img = new OSAEImage();
                        img.Data = fileUpload.FileBytes;
                        img.Name = txtName.Text;
                        img.Type = System.IO.Path.GetExtension(fileUpload.FileName).ToLower().Substring(1);

                        var imageManager = new OSAE.OSAEImageManager();
                        imageManager.AddImage(img);
                        txtName.Text = "";
                        loadImages();
                    }
                    else
                    {
                        Master.Log.Error("Image not added, file is to large.");
                        return; //file to big
                    }
                }
            }
            catch (Exception ex)
            { }
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (fileUpload.HasFile)
        {
            try
            {
                if (System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".jpg" && System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".png" && System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".jpeg")
                {
                    // wrong file type
                    return;
                }
                else
                {
                    if (fileUpload.PostedFile.ContentLength < 102400)
                    {

                        OSAEImage img = new OSAEImage();
                        img.Data = fileUpload.FileBytes;
                        img.Name = txtName.Text;
                        img.Type = System.IO.Path.GetExtension(fileUpload.FileName).ToLower().Substring(1);

                        var imageManager = new OSAE.OSAEImageManager();
                        imageManager.AddImage(img);
                        loadImages();
                    }
                    else
                    {
                        // file to big
                        return;
                    }

                }
            }
            catch (Exception ex)
            {

            }
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (fileUpload.HasFile)
        {
            try
            {
                if (System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".jpg" && System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".png" && System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".jpeg" && System.IO.Path.GetExtension(fileUpload.FileName).ToLower() != ".gif")
                {
                    Master.Log.Error("Image not added, Wrong file type");
                    return; // wrong file type
                }
                else
                {
                    if (fileUpload.PostedFile.ContentLength < 2502400) //202400
                    {
                        OSAEImage img = new OSAEImage();
                        img.Data = fileUpload.FileBytes;
                        img.Name = txtName.Text;
                        img.Type = System.IO.Path.GetExtension(fileUpload.FileName).ToLower().Substring(1);

                        var imageManager = new OSAE.OSAEImageManager();
                        imageManager.AddImage(img);

                        loadImages();
                    }
                    else
                    {
                        Master.Log.Error("Image not added, file is to large.");
                        return; //file to big
                    }
                }
            }
            catch (Exception ex)
            { }
        }
    }