Exemplo n.º 1
0
        protected void BtnConfirmDeleting_Click(object sender, EventArgs e)
        {
            try
            {
                Int32 IdToDelete = Convert.ToInt32(HydIdToDelete.Value);

                ImageEFRepository   rep = new ImageEFRepository("");
                Ls.Prj.Entity.Image ImgToStoreInAudit = rep.SelectEntity(IdToDelete);


                //cancella la riga
                DeleteEntity(IdToDelete);

                //cancella l'immagine fisica
                string DestPdfFullPath = HttpContext.Current.Server.MapPath("~/Public/Photos/");
                string ImgName         = ImgToStoreInAudit.ImageName;
                System.IO.File.Delete(DestPdfFullPath + ImgName);

                AuditPageManager ObjPageManager = new AuditPageManager();
                ObjPageManager.InsertAudit(LoginUsr, "Image deleted: " + ImgToStoreInAudit.ImageName);


                BindRepeater();

                DivDelete.Attributes.Add("Class", "ParentDivDeleting Disattivato");
            }
            catch (Exception ex)
            {
                PrintError(ex);
            }
        }
Exemplo n.º 2
0
 private void ValorizzaForm(Ls.Prj.Entity.Image Img)
 {
     TxtNomeImmagine.Text = Img.ImageName;
     TxtArgument.Text     = Img.Argument;
     TxtDevice.Text       = Img.Device;
     TxtAlias.Text        = Img.Alias;
     TxtTags.Text         = Img.Tags;
     TxtDescription.Text  = Img.Description;
     Utility.SetDropByValue(CboEnable, Img.Enabled.ToString());
 }
Exemplo n.º 3
0
 public void DeleteEntity(Int32 IdEntity)
 {
     using (ImageEFRepository Rep = new ImageEFRepository(""))
     {
         var entity = new Ls.Prj.Entity.Image {
             IdImage = IdEntity
         };
         Rep.Context.Entry(entity).State = EntityState.Deleted;
         Rep.Context.SaveChanges();
     }
 }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    ImageDetailPageManager ObjImageDetailPageManager = new ImageDetailPageManager();


                    //PopolaCboTypology(CboTypology, ObjDocumentDetailPageManager.GetTypes());
                    //CboTypology.Items.Add(new ListItem("--Select--", "0"));

                    #region script

                    //aggiunge il tag script con il path del file jquery con la validazione della pagina nella masterpage
                    Literal LitPathFormScriptValidation = (Literal)Master.FindControl("LitPathFormScriptValidation");
                    LitPathFormScriptValidation.Text = "<script src='../js/ImageDetail.js'></script>";

                    //appende gli script alla pagina per far funzionare la dropzone area
                    Literal LitDropZoneJs = (Literal)Master.FindControl("LitDropZoneJs");
                    LitDropZoneJs.Text = GetDropZoneScript();

                    #endregion



                    if (Request.QueryString["Id"] != null)
                    {
                        //siamo in modifica
                        Ls.Prj.Entity.Image Img = ObjImageDetailPageManager.GetSelectedImage(Convert.ToInt32(Request.QueryString["Id"]));
                        LitEntity.Text = "Image " + Img.ImageName;
                        ValorizzaForm(Img);
                        //nascondo possibilità di fare upload
                        PhdDropZone.Visible  = false;
                        PhdLnkPdfDoc.Visible = true;
                        ImgPreview.ImageUrl  = "/Public/Photos/" + Img.ImageName + "?w=200&mode=max";
                        //  HypLnkPdfDoc.Text = Img.ImageName;
                        //HypLnkPdfDoc.NavigateUrl = "/Public/Photos/" + Img.ImageName;
                    }
                    else
                    {
                        //siamo in inserimento
                        LitEntity.Text = "New image...";
                        ResettaForm();
                        PhdDropZone.Visible  = true;
                        PhdLnkPdfDoc.Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                PrintError(ex);
            }
        }
Exemplo n.º 5
0
        protected void BtnSalva_Click(object sender, EventArgs e)
        {
            try
            {
                AuditPageManager ObjPageManager = new AuditPageManager();
                //qui va validazione... meglio lato client
                if (Request.QueryString["Id"] != null)
                {
                    //modifica
                    Ls.Prj.Entity.Image Result = UpdateImg(Convert.ToInt32(Request.QueryString["Id"]));


                    ObjPageManager.InsertAudit(LoginUsr, "Tag updated: " + Result.ImageName);
                }
                else
                {
                    //inserimento

                    Ls.Prj.Entity.Image Result = InsertImg();
                    ObjPageManager.InsertAudit(LoginUsr, "Tag inserted: " + Result.ImageName);
                    //salva il documento definitivamente
                    string             OrigFullPath = HttpContext.Current.Server.MapPath("~/Public/Photos/Temp/");
                    string             DestFullPath = HttpContext.Current.Server.MapPath("~/Public/Photos/");
                    System.IO.FileInfo Fi           = new System.IO.FileInfo(OrigFullPath + HidTempFileNamePlusExt.Value);

                    string Name = Result.IdImage + "_" + TxtNomeImmagine.Text.Replace(" ", "_") + Fi.Extension;
                    try
                    {
                        System.IO.File.Move(OrigFullPath + HidTempFileNamePlusExt.Value, DestFullPath + Name);
                        try
                        {
                            Ls.Prj.Entity.Image Result2 = UpdateFileNameOfImg(Result.IdImage, Name);
                        }
                        catch (Exception ex)
                        {
                            PrintError(ex);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("No image, please upload it.");
                    }
                }
                Response.Redirect("Images.aspx");
            }
            catch (Exception ex)
            {
                //qui segnalare errore su un pannello del form
                PrintError(ex);
            }
        }
Exemplo n.º 6
0
 public Ls.Prj.Entity.Image UpdateFileNameOfImg(int Id, string Name)
 {
     Ls.Prj.Entity.Image result = null;
     using (ImageEFRepository Rep = new ImageEFRepository(""))
     {
         result = Rep.Context.Images.SingleOrDefault(x => x.IdImage == Id);
         if (result != null)
         {
             result.ImageName = Name;
             Rep.Context.SaveChanges();
         }
     }
     return(result);
 }
Exemplo n.º 7
0
 public Ls.Prj.Entity.Image UpdateImg(int Id)
 {
     Ls.Prj.Entity.Image result = null;
     using (ImageEFRepository Rep = new ImageEFRepository(""))
     {
         result = Rep.Context.Images.SingleOrDefault(x => x.IdImage == Id);
         if (result != null)
         {
             result.ImageName   = TxtNomeImmagine.Text;
             result.Argument    = TxtArgument.Text;
             result.Enabled     = Convert.ToBoolean(CboEnable.SelectedValue);
             result.Device      = TxtDevice.Text;
             result.Alias       = TxtAlias.Text;
             result.Tags        = TxtTags.Text;
             result.Description = TxtDescription.Text;
             Rep.Context.SaveChanges();
         }
     }
     return(result);
 }
Exemplo n.º 8
0
        public Ls.Prj.Entity.Image InsertImg()
        {
            Ls.Prj.Entity.Image NewImage = new Ls.Prj.Entity.Image();

            NewImage.ImageName   = TxtNomeImmagine.Text;
            NewImage.Argument    = TxtArgument.Text;
            NewImage.Enabled     = Convert.ToBoolean(CboEnable.SelectedValue);
            NewImage.Device      = TxtDevice.Text;
            NewImage.Alias       = TxtAlias.Text;
            NewImage.Tags        = TxtTags.Text;
            NewImage.Description = TxtDescription.Text;


            using (ImageEFRepository Rep = new ImageEFRepository(""))
            {
                Rep.Context.Images.Add(NewImage);
                Rep.Context.SaveChanges();
            }

            return(NewImage);
        }