public new void NewsPictureDelete(NewsPicture entity) { // check permission: admin PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permAdmin.Demand(); TraceCallEnterEvent.Raise(); try { FileDataContext fileDataContext = new FileDataContext(); string ext = Path.GetExtension(entity.PictureUrl).ToLower(); string fileName = entity.ID.ToString() + ext; fileDataContext.NewsPictureDelete(entity.NewsRef, fileName); base.NewsPictureDelete(entity); BusinessAuditEvent.Success(); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
public virtual void NewsPictureDelete(NewsPicture entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { m_DataContext.ndihdNewsPictureDelete(entity.ID); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public new void NewsPictureInsert(NewsPicture entity) { // check permission: admin PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permAdmin.Demand(); TraceCallEnterEvent.Raise(); try { // check required fields: if (entity.Title.Length == 0) throw new ArgumentNullException("NewsPicture.Title", "A képaláírás nincs megadva."); if (entity.PictureUrl.Length == 0 || entity.PictureUrl == DBString.Null) throw new ArgumentNullException("NewsPicture.PictureUrl", "A fájlnév nincs megadva."); if (entity.PictureData == null || entity.PictureData.Length == 0) throw new ArgumentNullException("NewsPicture.PictureData", "A kép nincs megadva."); // logical checks: string ext = Path.GetExtension(entity.PictureUrl).ToLower(); if (!(ext.Equals(".gif") || ext.Equals(".jpg") || ext.Equals(".jpeg"))) throw new ApplicationException("Csak jpeg vagy gif formátumú kép csatolható."); FileDataContext fileDataContext = new FileDataContext(); string fileName = entity.ID.ToString() + ext; fileDataContext.NewsPictureInsert(entity.NewsRef, fileName, entity.PictureData); base.NewsPictureInsert(entity); BusinessAuditEvent.Success(); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
/// <summary> /// Add a NewsPicture to the list. /// </summary> private void AddPicture() { // Validate controls if (txtUrlOther.Text.Length == 0) { MessageBox.Show("A kép nincs megadva. Válassza ki a kívánt képet!", "NDI HelpDesk Adminisztrátor", MessageBoxButtons.OK, MessageBoxIcon.Information); btnPictureUrlOther.Select(); return; } if (txtPictureTitle.Text.Length == 0) { MessageBox.Show("A képaláírás nincs megadva. Adja meg a képaláírást a beviteli mezõben!", "NDI HelpDesk Adminisztrátor", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPictureTitle.Select(); return; } if (!File.Exists(txtUrlOther.Text)) { MessageBox.Show("A fájl nem található. Válassza ki a kívánt képet!", "NDI HelpDesk Adminisztrátor", MessageBoxButtons.OK, MessageBoxIcon.Information); btnPictureUrlOther.Select(); return; } try { // Add to container NewsPicture item = new NewsPicture(new DBGuid(Guid.NewGuid())); item.NewsRef = CurrentID; item.Title = txtPictureTitle.Text; item.PictureUrl = Path.GetFileName(txtUrlOther.Text); // Get picture data FileStream stream = new FileStream(txtUrlOther.Text, FileMode.Open, FileAccess.Read); int fileSize = Convert.ToInt32(stream.Length); item.PictureData = new byte[fileSize]; stream.Read(item.PictureData, 0, fileSize); stream.Close(); //item.PicturePath = this.m_strPictureUrlOther; m_CurrentNews.NewsPictures.Add(item); // Refresh grid FillDatagrid(item.ID); txtPictureTitle.Text = ""; txtUrlOther.Text = ""; } catch (Exception ex) { // --- Log exception ExceptionManager.Publish(ex); // --- Display Exception ErrorHandler.DisplayError("Nem várt hiba lépett fel a kép hozzáadása során.", ex); } }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public NewsPicture(NewsPicture origInstance) : base(origInstance) { }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="IDVal">Value of 'uID' field</param> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public NewsPicture(DBGuid IDVal, NewsPicture origInstance) : base(IDVal, origInstance) { }
public virtual void NewsPictureUpdate(NewsPicture entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { int count; m_DataContext.ndihdNewsPictureUpdate(entity.ID, entity.Title, entity.PictureUrl, entity.NewsRef, out count); if (count == 0) throw new ServiceUpdateException(); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public virtual NewsPicture NewsPictureSelect(DBGuid IDVal) { TraceCallEnterEvent.Raise(); try { NewsPicture result = null; DataSet entitySet = m_DataContext.ndihdNewsPictureSelect(IDVal); if (entitySet.Tables[0].Rows.Count != 0) { result = new NewsPicture(entitySet); } TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }