public new void ExpertAttachmentDelete(ExpertAttachment entity)
        {
            // check permission: admin
              PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permReg.Union(permAdmin).Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            FileDataContext fileDataContext = new FileDataContext();
            string ext = Path.GetExtension(entity.Path).ToLower();
            string fileName = entity.ID.ToString() + ext;
            fileDataContext.ExpertAttachmentDelete(entity.ExpertRef, fileName);
            base.ExpertAttachmentDelete(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 ExpertAttachmentDelete(ExpertAttachment entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdExpertAttachmentDelete(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 ExpertAttachmentUpdate(ExpertAttachment entity)
        {
            // check permission: admin
              PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permReg.Union(permAdmin).Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            base.ExpertAttachmentUpdate(entity);

            BusinessAuditEvent.Success(
              new EventParameter("ExpertAttachmentID", entity.ID)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ContinuativeID", entity.ID));
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public new void ExpertAttachmentInsert(ExpertAttachment entity)
        {
            // check permission: admin
              PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permReg.Union(permAdmin).Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // check required fields:
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("ExpertAttachment.Name", "A csatolt fájl aláírása nincs megadva.");
            if (entity.Path.Length == 0)
              throw new ArgumentNullException("ExpertAttachment.Path", "A csatolt fájl neve nincs megadva.");
            if (entity.FileData == null || entity.FileData.Length == 0)
              throw new ArgumentNullException("ExpertAttachment.FileData", "A csatolt fájl nincs megadva, vagy nem létezik.");

            // logical checks:
            string ext = Path.GetExtension(entity.Path).ToLower();
            FileDataContext fileDataContext = new FileDataContext();
            string fileName = entity.ID.ToString() + ext;
            fileDataContext.ExpertAttachmentInsert(entity.ExpertRef, fileName, entity.FileData);
            entity.FileSize = entity.FileData.Length;
            entity.CreatedDate = DateTime.Now;
            base.ExpertAttachmentInsert(entity);

            BusinessAuditEvent.Success();
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            try
              {
            if (!Page.IsValid)
            {
              return;
            }

            string displayMode = Request["mode"];
            string progId = Request["progId"];

            Guid expertGuid = Guid.NewGuid();
            Guid programGuid = new Guid(progId);

            Expert expert = new Expert(expertGuid);
            expert.Name = txtName.Text;
            expert.NamePrefix = txtNamePrefix.Text;
            expert.Phone1 = txtPhone1.Text;
            if (txtPhone2.Text.Trim().Length > 0) expert.Phone2 = txtPhone2.Text;
            if (txtPhone3.Text.Trim().Length > 0) expert.Phone3 = txtPhone3.Text;
            if (txtFax.Text.Trim().Length > 0) expert.Fax = txtFax.Text;
            expert.Email1 = txtEmail1.Text;
            if (txtEmail2.Text.Trim().Length > 0) expert.Email2 = txtEmail2.Text;
            if (txtEmail3.Text.Trim().Length > 0) expert.Email3 = txtEmail3.Text;
            if (txtAddressInstitute.Text.Trim().Length > 0) expert.AddressInstitute = txtAddressInstitute.Text;
            expert.PostCode = txtMailingPostCode.Text;
            expert.City = txtMailingCity.Text;
            expert.Address = txtMailingAddress.Text;
            if (txtJob.Text.Trim().Length > 0) expert.Job = txtJob.Text;
            expert.QualificationRef = cmbQualification.SelectedValue;
            if (txtProfession.Text.Trim().Length > 0) expert.Profession = txtProfession.Text;
            if (txtGraduate.Text.Trim().Length > 0) expert.Graduation = txtGraduate.Text;
            if (txtActivity.Text.Trim().Length > 0) expert.Activity = txtActivity.Text;
            if (txtPublication.Text.Trim().Length > 0) expert.Publications = txtPublication.Text;
            if (txtBiography.Text.Trim().Length > 0) expert.Biography = txtBiography.Text;

            IExpertService expSrv = ServiceFactory.GetExpertService();
            //akar feltölteni önéletrajzot

            #region önéletrajz feltöltés

            //kiválasztott egy file-t
            if (fileUpload.PostedFile != null && fileUpload.PostedFile.ContentLength != 0)
            {
              Guid attachmentID = Guid.NewGuid();
              ExpertAttachment attachment = new ExpertAttachment(attachmentID);
              attachment.Name = txtFileName.Text.Length == 0 ? attachmentID.ToString() : txtFileName.Text;
              attachment.Description = txtFileDesc.Text.Length == 0 ? "" : txtFileDesc.Text;

              string fileName = Path.GetFileName(fileUpload.PostedFile.FileName);
              attachment.Path = fileName;

              BinaryReader reader = new BinaryReader(fileUpload.PostedFile.InputStream);
              byte[] buffer = new byte[fileUpload.PostedFile.ContentLength];
              reader.Read(buffer, 0, fileUpload.PostedFile.ContentLength);
              attachment.FileData = buffer;

              expert.ExpertAttachments.Add(attachment);
            }

            #endregion

            expSrv.ExpertInsert(expert);

            IProgramService programSrv = ServiceFactory.GetProgramService();
            switch (displayMode)
            {
              case "participantSelect":
            ProgramParticipant participant = new ProgramParticipant(expertGuid, programGuid);
            IProgramParticipantService participantSrv = ServiceFactory.GetProgramParticipantService();
            participantSrv.ProgramParticipantInsert(participant);
            break;
              case "responsibleSelect":
            Program responsible = new Program(programGuid);
            responsible.ResponsibleRef = expertGuid;
            programSrv.ProgramResponsibleUpdate(responsible);
            break;
              case "coordinator1Select":
            Program coordinator1 = new Program(programGuid);
            coordinator1.Coordinator1Ref = expertGuid;
            programSrv.ProgramCoordinator1Update(coordinator1);
            break;
              case "coordinator2Select":
            Program coordinator2 = new Program(programGuid);
            coordinator2.Coordinator2Ref = expertGuid;
            programSrv.ProgramCoordinator2Update(coordinator2);
            break;
            }
            Response.Redirect("ProgramData.aspx?progId=" + progId);
              }
              catch (Exception ex)
              {
            errorPanel.Exception = ex;
              }
        }
 public virtual void ExpertAttachmentUpdate(ExpertAttachment entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       int count;
       m_DataContext.ndihdExpertAttachmentUpdate(entity.ID,
                                             entity.ExpertRef,
                                             entity.Path,
                                             entity.Name,
                                             entity.Description,
                                             entity.CreatedDate,
                                             entity.FileSize,
                                             entity.IsActive, 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 ExpertAttachment ExpertAttachmentSelect(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     ExpertAttachment result = null;
     DataSet entitySet = m_DataContext.ndihdExpertAttachmentSelect(IDVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new ExpertAttachment(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
Beispiel #8
0
        /// <summary>
        /// Add a NewsPicture to the list.
        /// </summary>
        private void AddFile()
        {
            // Validate controls
              if (txtFilePath.Text.Length == 0)
              {
            MessageBox.Show("A fájl nincs megadva. Válassza ki a kívánt fájlt!",
                        "NDI HelpDesk Adminisztrátor", MessageBoxButtons.OK, MessageBoxIcon.Information);
            btnFile.Select();
            return;
              }
              if (txtFileTitle.Text.Length == 0)
              {
            MessageBox.Show("A fájlaláírás nincs megadva. Adja meg a fájlaláírást a beviteli mezõben!",
                        "NDI HelpDesk Adminisztrátor", MessageBoxButtons.OK, MessageBoxIcon.Information);
            txtFileTitle.Select();
            return;
              }

              if (!File.Exists(txtFilePath.Text))
              {
            MessageBox.Show("A fájl nem található. Válassza ki a fájlt!",
                        "NDI HelpDesk Adminisztrátor", MessageBoxButtons.OK, MessageBoxIcon.Information);
            btnFile.Select();
            return;
              }

              try
              {
            // Add to container
            ExpertAttachment item = new ExpertAttachment(new DBGuid(Guid.NewGuid()));
            item.ExpertRef = CurrentID;
            item.Name = txtFileTitle.Text;
            item.Path = Path.GetFileName(txtFilePath.Text);
            item.Description = txtDescription.Text;
            item.IsActive = true;

            // Get picture data
            FileStream stream = new FileStream(txtFilePath.Text, FileMode.Open, FileAccess.Read);
            int fileSize = Convert.ToInt32(stream.Length);
            item.FileData = new byte[fileSize];
            stream.Read(item.FileData, 0, fileSize);
            stream.Close();
            item.FileSize = fileSize;

            //item.PicturePath = this.m_strPictureUrlOther;
            m_currentExpert.ExpertAttachments.Add(item);

            // Refresh grid
            FillFileDatagrid(item.ID);

            txtFileTitle.Text = "";
            txtDescription.Text = "";
            txtFilePath.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 ExpertAttachment(ExpertAttachment 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 ExpertAttachment(DBGuid IDVal,
                     ExpertAttachment origInstance)
     : base(IDVal, origInstance)
 {
 }