Пример #1
0
        /// <summary>
        /// Sends Email when project Status is closed
        /// </summary>
        /// <param name="objAddProject"></param>
        /// <returns></returns>
        public void SendEmailForProjectEdited(BusinessEntities.Projects objProjectDetails, string rmsURL)
        {
            try
            {
                BusinessEntities.RaveHRCollection raveHRCollection = new BusinessEntities.RaveHRCollection();
                string strProjectStatus     = string.Empty;
                string projectManagerEmail  = string.Empty;
                string strProjectStatusFlag = objProjectDetails.ProjectStatus;
                string sComp = Utility.GetUrl();
                string strProjectSummaryLink = sComp +
                                               CommonConstants.ADDPROJECT_PAGE +
                                               "?" +
                                               rmsURL;


                DataAccessLayer.Projects.Projects objProjectsDAL           = new Rave.HR.DataAccessLayer.Projects.Projects();
                BusinessEntities.Projects         objProjectDetailsUpdated = new BusinessEntities.Projects();
                objProjectDetailsUpdated = objProjectsDAL.GetEditedProjectDetails(objProjectDetails);

                IRMSEmail obj = new RMSEmail(Convert.ToInt16(EnumsConstants.RMSModule.Projects),
                                             Convert.ToInt16(EnumsConstants.EmailFunctionality.EditedProject));

                //Get ProjectManager Name

                raveHRCollection = DataAccessLayer.Projects.Projects.GetProjectManagerByProjectId(objProjectDetails);

                if (raveHRCollection.Count > 0)
                {
                    foreach (BusinessEntities.Projects objProj in raveHRCollection)
                    {
                        projectManagerEmail += objProj.EmailIdOfPM;
                        //projectManagerEmail += ",";
                        objProjectDetails.EmailIdOfPM = projectManagerEmail;

                        if (objProjectDetails.EmailIdOfPM.EndsWith(","))
                        {
                            objProjectDetails.EmailIdOfPM = objProjectDetails.EmailIdOfPM.Substring(0, objProjectDetails.EmailIdOfPM.Length - 1);
                        }
                    }


                    obj.To.Add(objProjectDetails.EmailIdOfPM);
                }

                string tableData = GetHTMLForProjectEdited(objProjectDetailsUpdated);

                obj.Subject = string.Format(obj.Subject, objProjectDetails.ProjectCode,
                                            objProjectDetails.ClientName,
                                            objProjectDetails.ProjectName);

                obj.Body = string.Format(obj.Body, objProjectDetails.ProjectName,
                                         objProjectDetails.ClientName,
                                         tableData,
                                         strProjectSummaryLink);

                obj.SendEmail(obj);
            }

            catch (RaveHRException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new RaveHRException(ex.Message, ex, Sources.BusinessLayer, PROJECTS, SEND_MAIL_EDIT_PROJECT, EventIDConstants.RAVE_HR_PROJECTS_BUSNIESS_LAYER);
            }
        }