Exemplo n.º 1
0
        public void Deactivate()
        {
            try
            {
                if (this.CurrentFormId == 0)
                {
                    var f = OGEForm450.GetCurrentFormByUser(AccountName);

                    CurrentFormId = f != null ? f.Id : 0;
                }

                //  Set Current Form to Canceled
                if (this.CurrentFormId > 0)
                {
                    var form = OGEForm450.Get(this.CurrentFormId);

                    form.FormStatus = Constants.FormStatus.CANCELED;

                    form.Save();

                    form.RemoveExtensions();
                }

                this.Inactive       = true;
                this.InactiveDate   = DateTime.Now;
                this.EmployeeStatus = Constants.EmployeeStatus.INACTIVE;
            }
            catch (Exception ex)
            {
                // Couldn't find form, ignore exception
                SharePointHelper.HandleException(ex, "", "Employee.Deactivate");
            }
        }
Exemplo n.º 2
0
        internal IHttpActionResult HandleException(Exception ex)
        {
            var user = AppUser == null ? "unknown" : AppUser.DisplayName;

            SharePointHelper.HandleException(ex, user, this.GetType().Name);

            return(InternalServerError(ex));
        }
Exemplo n.º 3
0
        public static List <EventRequest> Migrate()
        {
            var oldData = EthicsClearance.GetAll();

            foreach (EthicsClearance ec in oldData)
            {
                try
                {
                    var request = MigrateEthicsClearance(ec);

                    MigrateAttendees(request.Id, ec);

                    MigrateAttachments(request.Id, ec);
                }
                catch (Exception ex)
                {
                    SharePointHelper.HandleException(ex, "admin", "EthicsClearance.Migrate");
                }
            }

            return(EventRequest.GetAll());
        }
Exemplo n.º 4
0
        private static void MigrateAttachments(int id, EthicsClearance ec)
        {
            var oldAttachments = OMBEthicsAttachments.GetAllBy("Associated_x0020_Ethics_x0020_Form_x0020_ID", ec.OMBEthicsFormId);

            foreach (OMBEthicsAttachments att in oldAttachments)
            {
                try
                {
                    var attachmentWithContent = OMBEthicsAttachments.Get(att.Id);
                    var attachmentType        = Constants.AttachmentType.OTHER;

                    if (ec.AttachedInvitation.Contains(attachmentWithContent.FileName))
                    {
                        attachmentType = Constants.AttachmentType.INVITATIONS;
                    }
                    else if (ec.AttachedTravelForm.Contains(attachmentWithContent.FileName))
                    {
                        attachmentType = Constants.AttachmentType.TRAVEL_FORMS;
                    }

                    var newAttachment = new Attachment();

                    newAttachment.TypeOfAttachment = attachmentType;
                    newAttachment.AttachmentGuid   = ec.OMBEthicsFormId;
                    newAttachment.Content          = attachmentWithContent.Content;
                    newAttachment.FileName         = attachmentWithContent.FileName;
                    newAttachment.EventRequestId   = id;
                    newAttachment.Title            = attachmentWithContent.FileName;
                    newAttachment.Size             = attachmentWithContent.Content.Length;

                    newAttachment.Create();
                }
                catch (Exception ex)
                {
                    SharePointHelper.HandleException(ex, "admin", "EthicsClearance.MigrateAttachments");
                }
            }
        }
Exemplo n.º 5
0
        private static void MigrateAttendee(int id, string emp, EthicsClearance ec)
        {
            try
            {
                var attendee = new Attendee();

                attendee.Employee           = UserInfo.GetUserInfoByName(emp);
                attendee.Capacity           = ec.AttendingCapacity;
                attendee.ReasonForAttending = ec.ReasonForAttending;
                attendee.IsGivingRemarks    = ec.Speaker == "Yes";
                attendee.Remarks            = ec.PlannedRemarks;
                attendee.EmployeeType       = ec.EmployeeType;

                attendee.EventRequestId = id;
                attendee.Title          = emp;

                attendee.Save();
            }
            catch (Exception ex)
            {
                SharePointHelper.HandleException(ex, "admin", "EthicsClearance.MigrateAttendee");
            }
        }