Esempio n. 1
1
        public void mapFieldsFromRequest(RequestForm req, AcroFields form)
        {
            EmployeeDB empDB = new EmployeeDB();
            var fieldKeys = form.Fields.Keys;

            foreach (string fieldKey in fieldKeys)
            {
                if (fieldKey.Equals("Employee Name"))
                    form.SetField(fieldKey, empDB.GetFullNameById(req.EmployeeId));
                if (fieldKey.Equals("Date to occur on"))
                    form.SetField(fieldKey, (string)(DateTime.Now.AddDays(7)).ToString("d"));
                if (fieldKey.Equals("CurrentJob Title"))
                    form.SetField(fieldKey, req.Current.BazookaInfo.JobTitle);
                if (fieldKey.Equals("CurrentDepartment"))
                    form.SetField(fieldKey, req.Current.BazookaInfo.Department);
                if (fieldKey.Equals("CurrentGroup"))
                    form.SetField(fieldKey, req.Current.BazookaInfo.Group);
                if (fieldKey.Equals("CurrentManager") || fieldKey.Equals("Current Manager Name"))
                    form.SetField(fieldKey, empDB.GetFullNameById(req.Current.BazookaInfo.ManagerID));
                if (fieldKey.Equals("CurrentTemplate"))
                    form.SetField(fieldKey, req.Current.BazookaInfo.JobTemplate);
                if (fieldKey.Equals("CurrentSecurity ItemRights"))
                    form.SetField(fieldKey, req.Current.BazookaInfo.SecurityItemRights);
                if (fieldKey.Equals("FutureJob Title"))
                    form.SetField(fieldKey, req.Future.BazookaInfo.JobTitle);
                if (fieldKey.Equals("FutureDepartment"))
                    form.SetField(fieldKey, req.Future.BazookaInfo.Department);
                if (fieldKey.Equals("FutureGroup"))
                    form.SetField(fieldKey, req.Future.BazookaInfo.Group);
                if (fieldKey.Equals("FutureManager"))
                    form.SetField(fieldKey, empDB.GetFullNameById(req.Future.BazookaInfo.ManagerID));
                if (fieldKey.Equals("FutureTemplate"))
                    form.SetField(fieldKey, req.Future.BazookaInfo.JobTemplate);
                if (fieldKey.Equals("FutureSecurity ItemRights"))
                    form.SetField(fieldKey, req.Future.BazookaInfo.SecurityItemRights);
                if (fieldKey.Equals("CurrentJob Title_2"))
                    form.SetField(fieldKey, req.Current.UltiproInfo.JobTitle);
                if (fieldKey.Equals("FutureJob Title_2"))
                    form.SetField(fieldKey, req.Future.UltiproInfo.JobTitle);
                if (fieldKey.Equals("CurrentDepartment_2"))
                    form.SetField(fieldKey, req.Current.UltiproInfo.Department);
                if (fieldKey.Equals("FutureDepartment_2"))
                    form.SetField(fieldKey, req.Future.UltiproInfo.Department);
                if (fieldKey.Equals("CurrentSupervisor"))
                    form.SetField(fieldKey, empDB.GetFullNameById(int.Parse(req.Current.UltiproInfo.Supervisor)));
                if (fieldKey.Equals("FutureSupervisor"))
                    form.SetField(fieldKey, empDB.GetFullNameById(int.Parse(req.Future.UltiproInfo.Supervisor)));
                if (fieldKey.Equals("CurrentOther"))
                    form.SetField(fieldKey, req.Current.UltiproInfo.Other);
                if (fieldKey.Equals("FutureOther"))
                    form.SetField(fieldKey, req.Future.UltiproInfo.Other);
                if (fieldKey.Equals("Current Desk Row1"))
                    form.SetField(fieldKey, req.Current.DeskInfo.DeskNumber);
                if (fieldKey.Equals("Future Desk Row1"))
                    form.SetField(fieldKey, req.Future.DeskInfo.DeskNumber);
                if (fieldKey.Equals("Current OfficeRow1"))
                    form.SetField(fieldKey, req.Current.DeskInfo.Office);
                if (fieldKey.Equals("Future OfficeRow1"))
                    form.SetField(fieldKey, req.Future.DeskInfo.Office);
                if (fieldKey.Equals("Need to be added to"))
                    form.SetField(fieldKey, String.Join(", ", req.EmailInfo.GroupsToBeAddedTo));
                if (fieldKey.Equals("Need to be removed from"))
                    form.SetField(fieldKey, String.Join(", ", req.EmailInfo.GroupsToBeRemovedFrom));
                if (fieldKey.Equals("Need to be added to_2"))
                    form.SetField(fieldKey, String.Join(", ", req.ReviewInfo.FilesToBeAddedTo));
                if (fieldKey.Equals("Need to be removed from_2"))
                    form.SetField(fieldKey, String.Join(", ", req.ReviewInfo.FilesToBeRemovedFrom));
            }
        }
Esempio n. 2
0
        public bool sendMovesRequest(RequestForm req, string sendTo)
        {
            bool isSent = false;

            if (req == null)
            {
                throw new ArgumentNullException("req");
            }

            if (sendTo == null)
            {
                throw new ArgumentNullException("sendTo");
            }

            if (sendTo == "HR")
            {
                _template.addRecipient(HRAddress);
                isSent = sendMovesRequest(req);
            }
            else if (sendTo == "SD")
            {
                _template.addRecipient(SDAddress);
                isSent = sendMovesRequest(req);
            }

            return isSent;
        }
 public void RequestRetrievedSuccessfully()
 {
     RequestForm testRequest = new RequestForm();
     testRequest = _requester.RetrieveRequest(_req.UniqueId);
     bool test = CheckEquality(_req, testRequest);
     Assert.IsTrue(test);
 }
Esempio n. 4
0
        public bool sendMovesRequest(RequestForm req)
        {
            if (req == null)
            {
                throw new ArgumentNullException("req");
            }
            MailMessage _toSend = _template.movesFormRequest(req);
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(_smtp);
            smtp.Send(_toSend);

            return (smtp != null && _toSend != null);
        }
        public RequestForm GetRequest(Guid requestID)
        {
            if (this.reader == null)
            {
                return null;
            }

            RequestForm temp = null;
            while (this.reader.Read())
            {
                temp =  new RequestForm()
                {
                    CreatedByID = GetCreateByID(),
                    Current = MakeCurrentInfo(),
                    Future = MakeFutureInfo(),
                    EmailInfo = MakeEmailInfo(),
                    EmployeeId = GetEmployeeID(),
                    ReviewInfo = MakeReviewInfo(),
                    UniqueId = requestID,
                };
                break;
            }
            return temp;
        }
Esempio n. 6
0
        private SqlCommand AddParametersForStoreRequestFormInDatabaseHelper(RequestForm form)
        {
            string commandString = "[Intern_CoyoteMoves].[dbo].[spRequestData_StoreRequestAsPending]";
            SqlCommand command = new SqlCommand(commandString);
            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.Add(new SqlParameter("@EmployeeID", SqlDbType.Int));
            command.Parameters["@EmployeeID"].Value = form.EmployeeId;
            command.Parameters.Add(new SqlParameter("@C_JobTitle", SqlDbType.VarChar));
            command.Parameters["@C_JobTitle"].Value = form.Current.BazookaInfo.JobTitle;
            command.Parameters.Add(new SqlParameter("@C_Department", SqlDbType.VarChar));
            command.Parameters["@C_Department"].Value = form.Current.BazookaInfo.Department;
            command.Parameters.Add(new SqlParameter("@C_Group", SqlDbType.VarChar));
            command.Parameters["@C_Group"].Value = form.Current.BazookaInfo.Group;
            command.Parameters.Add(new SqlParameter("@C_ManagerID", SqlDbType.Int));
            command.Parameters["@C_ManagerID"].Value = form.Current.BazookaInfo.ManagerID;
            command.Parameters.Add(new SqlParameter("@C_JobTemplate", SqlDbType.VarChar));
            command.Parameters["@C_JobTemplate"].Value = form.Current.BazookaInfo.JobTemplate;
            command.Parameters.Add(new SqlParameter("@C_SecurityItemRights", SqlDbType.VarChar));
            command.Parameters["@C_SecurityItemRights"].Value = form.Current.BazookaInfo.SecurityItemRights;
            command.Parameters.Add(new SqlParameter("@C_DeskNumber", SqlDbType.VarChar));
            command.Parameters["@C_DeskNumber"].Value = form.Current.DeskInfo.DeskNumber;
            command.Parameters.Add(new SqlParameter("@C_Office", SqlDbType.VarChar));
            command.Parameters["@C_Office"].Value = form.Current.DeskInfo.Office;
            command.Parameters.Add(new SqlParameter("@C_PhoneNumber", SqlDbType.VarChar));
            command.Parameters["@C_PhoneNumber"].Value = form.Current.PhoneInfo.PhoneNumber;
            command.Parameters.Add(new SqlParameter("@C_Other", SqlDbType.VarChar));
            command.Parameters["@C_Other"].Value = form.Current.UltiproInfo.Other;
            command.Parameters.Add(new SqlParameter("@F_JobTitle", SqlDbType.VarChar));
            command.Parameters["@F_JobTitle"].Value = form.Future.BazookaInfo.JobTitle;
            command.Parameters.Add(new SqlParameter("@F_Department", SqlDbType.VarChar));
            command.Parameters["@F_Department"].Value = form.Future.BazookaInfo.Department;
            command.Parameters.Add(new SqlParameter("@F_Group", SqlDbType.VarChar));
            command.Parameters["@F_Group"].Value = form.Future.BazookaInfo.Group;
            command.Parameters.Add(new SqlParameter("@F_ManagerID", SqlDbType.Int));
            command.Parameters["@F_ManagerID"].Value = form.Future.BazookaInfo.ManagerID;
            command.Parameters.Add(new SqlParameter("@F_JobTemplate", SqlDbType.VarChar));
            command.Parameters["@F_JobTemplate"].Value = form.Future.BazookaInfo.JobTemplate;
            command.Parameters.Add(new SqlParameter("@F_SecurityItemRights", SqlDbType.VarChar));
            command.Parameters["@F_SecurityItemRights"].Value = form.Future.BazookaInfo.SecurityItemRights;
            command.Parameters.Add(new SqlParameter("@F_DeskNumber", SqlDbType.VarChar));
            command.Parameters["@F_DeskNumber"].Value = form.Future.DeskInfo.DeskNumber;
            command.Parameters.Add(new SqlParameter("@F_Office", SqlDbType.VarChar));
            command.Parameters["@F_Office"].Value = form.Future.DeskInfo.Office;
            command.Parameters.Add(new SqlParameter("@F_PhoneNumber", SqlDbType.VarChar));
            command.Parameters["@F_PhoneNumber"].Value = form.Future.PhoneInfo.PhoneNumber;
            command.Parameters.Add(new SqlParameter("@F_Other", SqlDbType.VarChar));
            command.Parameters["@F_Other"].Value = form.Future.UltiproInfo.Other;
            command.Parameters.AddWithValue("@EmailListsToBeAddedTo", form.EmailInfo.GroupsToBeAddedTo);
            command.Parameters.Add(new SqlParameter("@EmailListsToBeRemovedFrom", SqlDbType.VarChar));
            command.Parameters["@EmailListsToBeRemovedFrom"].Value = form.EmailInfo.GroupsToBeRemovedFrom;
            command.Parameters.Add(new SqlParameter("@FilesToBeAddedTo", SqlDbType.VarChar));
            command.Parameters["@FilesToBeAddedTo"].Value = form.ReviewInfo.FilesToBeAddedTo;
            command.Parameters.Add(new SqlParameter("@FilesToBeRemovedFrom", SqlDbType.VarChar));
            command.Parameters["@FilesToBeRemovedFrom"].Value = form.ReviewInfo.FilesToBeRemovedFrom;
            command.Parameters.Add(new SqlParameter("@CreateByID", SqlDbType.VarChar));
            command.Parameters["@CreateByID"].Value = 301758;
            command.Parameters.Add(new SqlParameter("@UpdateByID", SqlDbType.VarChar));
            command.Parameters["@UpdateByID"].Value = 301758;
            command.Parameters.Add(new SqlParameter("@UniqueID", SqlDbType.VarChar));
            command.Parameters["@UniqueID"].Value = form.UniqueId.ToString();

            return command;
        }
Esempio n. 7
0
        public bool StoreRequestFormInDatabaseAsPending(RequestForm form)
        {
            SqlConnection connection = new SqlConnection(_connectionString);
            SqlCommand command = AddParametersForStoreRequestFormInDatabaseHelper(form);
            command.Connection = connection;
            command.Connection.Open();
            int result = command.ExecuteNonQuery();
            command.Connection.Close();

            return (result == 1);
        }
Esempio n. 8
0
        public MailMessage movesFormRequest(RequestForm req)
        {
            if (req == null)
            {
                throw new NullReferenceException("req");
            }
            if (string.IsNullOrEmpty(_mappedLocation))
            {
                throw new IOException("_templateLocation");
            }

            PdfReader reader = new PdfReader(_mappedLocation);
            MemoryStream memory = new MemoryStream();
            PdfStamper stamper = new PdfStamper(reader, memory);
            AcroFields form = stamper.AcroFields;

            mapFieldsFromRequest(req, form);

            stamper.FormFlattening = true;
            stamper.Writer.CloseStream = false;
            stamper.Close();

            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
            foreach (string entry in _to)
            {
                message.To.Add(entry);
            }
            message.Subject = _subject + " " + req.UniqueId;
            message.From = new System.Net.Mail.MailAddress(_from);
            message.Body = _emailBody;
            memory.Position = 0;

            message.Attachments.Add(new Attachment(memory, "MovesForm" + req.UniqueId + ".pdf"));
            reader.Close();

            return message;
        }
Esempio n. 9
0
        public void Setup()
        {
            _to = new Collection<string> { };
            _emailer = new EmailSender("New Coyote Moves Request", _to, "*****@*****.**", "Here you go!", "../../../CoyoteMoves/CoyoteMovesTemplate.pdf");
            _req = new RequestForm(989);
            _template = new EmailTemplate("one", _to, "*****@*****.**", "dere you go", "../../../CoyoteMoves/CoyoteMovesTemplate.pdf");
            _falseTemplate = new EmailTemplate("one", _to, "*****@*****.**", "", "../../CoyoteMoves/CoyoteMovesTemplate.pdf");

            _req.Current = new CoyoteMovesFormEmployeeInfo();
            _req.Future = new CoyoteMovesFormEmployeeInfo();
            _req.Current.BazookaInfo = new BazookaInfo();
            _req.Future.BazookaInfo = new BazookaInfo();
            _req.Current.UltiproInfo = new UltiproInfo();
            _req.Future.UltiproInfo = new UltiproInfo();
            _req.Current.DeskInfo = new DeskInfo();
            _req.Future.DeskInfo = new DeskInfo();
            _req.Current.PhoneInfo = new PhoneInfo();
            _req.Future.PhoneInfo = new PhoneInfo();
            _req.EmailInfo = new EmailDistributionInfo();
            _req.ReviewInfo = new EmployeeReviewFileInfo();

            _req.Current.BazookaInfo.JobTitle = "test";
            _req.Future.BazookaInfo.JobTitle = "test";
            _req.Current.BazookaInfo.Department = "test";
            _req.Future.BazookaInfo.Department = "test";
            _req.Current.BazookaInfo.Group = "test";
            _req.Future.BazookaInfo.Group = "test";
            _req.Current.BazookaInfo.ManagerID = 49;
            _req.Future.BazookaInfo.ManagerID = 50;
            _req.Current.BazookaInfo.JobTemplate = "test";
            _req.Future.BazookaInfo.JobTemplate = "testy";
            _req.Current.BazookaInfo.SecurityItemRights = "test";
            _req.Future.BazookaInfo.SecurityItemRights = "test";

            _req.Current.UltiproInfo.JobTitle = "test";
            _req.Future.UltiproInfo.JobTitle = "test";
            _req.Current.UltiproInfo.Department = "test";
            _req.Future.UltiproInfo.Department = "test";
            _req.Current.UltiproInfo.Supervisor = "120 ";
            _req.Future.UltiproInfo.Supervisor = "350";
            _req.Current.UltiproInfo.Other = "test";
            _req.Future.UltiproInfo.Other = "test?";

            _req.Current.DeskInfo.DeskNumber = "test";
            _req.Future.DeskInfo.DeskNumber = "test";
            _req.Current.DeskInfo.Office = "test";
            _req.Future.DeskInfo.Office = "test";

            _req.Current.PhoneInfo.PhoneNumber = "8472718339";
            _req.Future.PhoneInfo.PhoneNumber = "99995953214";

            _req.EmailInfo.GroupsToBeAddedTo = "one, two, three";
            _req.EmailInfo.GroupsToBeRemovedFrom = "one, two, three";

            _req.ReviewInfo.FilesToBeAddedTo = "one, two, three";
            _req.ReviewInfo.FilesToBeRemovedFrom = "one, two, three";
        }
Esempio n. 10
0
 public bool sendMovesRequestHR(RequestForm req)
 {
     return sendMovesRequest(req, "HR");
 }
Esempio n. 11
0
 public bool sendMovesRequestSD(RequestForm req)
 {
     return sendMovesRequest(req, "SD");
 }
Esempio n. 12
0
 public void setup()
 {
     _requester = new RequestFormDB();
     _req = new RequestForm(301757);
     TestStoreRequestFormInDatabaseAsPending();
 }