Exemplo n.º 1
0
        private static string CreateSurveyBodyEmail(SR_ServiceRequest objSr)
        {
            string path = string.Empty;

            //load template emails by pr status   
            path = System.Web.HttpContext.Current.Server.MapPath("~/Views/ServiceRequestAdmin/TemplateMail.htm");
            string content = WebUtils.ReadFile(path);

            //replace the holders on template emails.
            if (objSr != null)
            {
                SR_Category objParent = new SRCategoryDao().GetCategoryParentBySub(objSr.CategoryID);
                // create message
                content = content.Replace(Constants.SR_REQUEST_ID_HOLDER, objSr.ID.ToString());
                //content = content.Replace(Constants.SR_ASSIGN_TO_HOLDER, objSr.AssignUser);
                content = content.Replace(Constants.SR_ASSIGN_TO_HOLDER, objSr.SubmitUser);

                content = content.Replace(Constants.SR_CATEGORY_HOLDER, objParent != null ? objParent.Name : string.Empty);
                content = content.Replace(Constants.SR_SUB_CATEGORY_HOLDER, objSr.SR_Category.Name);
                content = content.Replace(Constants.SR_TITLE_HOLDER, objSr.Title);
                content = content.Replace(Constants.SR_DESCRIPTION_HOLDER, HttpUtility.HtmlEncode(objSr.Description).Replace("\r\n", "<br />"));
                content = content.Replace(Constants.SR_SUBMITER_HOLDER, objSr.SubmitUser);
                content = content.Replace(Constants.SR_REQUESTOR_HOLDER, objSr.RequestUser);
                content = content.Replace(Constants.SR_SUBMITDATE_HOLDER, objSr.CreateDate.ToString(Constants.DATETIME_FORMAT_SR));
                content = content.Replace(Constants.SR_DUEDATE_HOLDER, objSr.DueDate.HasValue ? objSr.DueDate.Value.ToString(Constants.DATETIME_FORMAT_SR) : string.Empty);
                content = content.Replace(Constants.SR_CCLIST_HOLDER, objSr.CCList);
                content = content.Replace(Constants.SR_URGENCY_HOLDER, objSr.SR_Urgency.Name);
                content = content.Replace(Constants.SR_PARENTID_HOLDER, objSr.ParentID.HasValue ? Constants.SR_SERVICE_REQUEST_PREFIX + objSr.ParentID.Value.ToString() : string.Empty);
                content = content.Replace(Constants.SR_STATUS_HOLDER, objSr.SR_Status.Name);
                content = content.Replace(Constants.SR_ASSIGNEDTO_HOLDER, objSr.AssignUser);
                content = content.Replace(Constants.SR_HISTORY_HOLDER, GetSRHistory(objSr.ID));
                content = content.Replace(Constants.SR_COMMENTS_HOLDER, GetSRComments(objSr.ID));
                string linkEmployee = string.Empty;
                string linkIT = string.Empty;
                string linkSurvey = string.Empty;
                if (objSr.StatusID == Constants.SR_STATUS_CLOSED)
                {
                    content = content.Replace(Constants.SR_FORWARD_TO_HOLDER, " has been closed");
                    //content = content.Replace(Constants.PR_FORWARD_TO_NAME_HOLDER, "");
                    linkEmployee = "http://" + HttpContext.Current.Request["SERVER_NAME"] + ":" + HttpContext.Current.Request["SERVER_PORT"] + "/Portal/ServiceRequest/Detail/" + objSr.ID;
                    linkIT = "http://" + HttpContext.Current.Request["SERVER_NAME"] + ":" + HttpContext.Current.Request["SERVER_PORT"] + "/ServiceRequestAdmin/Detail/" + objSr.ID;
                    linkSurvey = "http://" + HttpContext.Current.Request["SERVER_NAME"] + ":" + HttpContext.Current.Request["SERVER_PORT"] + "/Portal/ServiceRequest/CreateEvaluation/" + objSr.ID;
                    //content = content.Replace(Constants.SR_STATUS, objSr.ID.ToString());
                    content = content.Replace("none", "table-row");
                    content = content.Replace(Constants.SR_LINK_SURVEY, linkSurvey);
                }
                else
                {

                    content = content.Replace(Constants.SR_FORWARD_TO_HOLDER, " has been forwarded to you");
                    //content = content.Replace(Constants.PR_FORWARD_TO_NAME_HOLDER, "Forwarded To: " + new UserAdminDao().GetById((int)purReq.AssignID).UserName + " (" + purReq.WFRole.Name + " )");
                    linkEmployee = "http://" + HttpContext.Current.Request["SERVER_NAME"] + ":" + HttpContext.Current.Request["SERVER_PORT"] + "/Portal/ServiceRequest/Detail/" + objSr.ID;
                    linkIT = "http://" + HttpContext.Current.Request["SERVER_NAME"] + ":" + HttpContext.Current.Request["SERVER_PORT"] + "/ServiceRequestAdmin/CreateEvaluation/" + objSr.ID;
                }

                content = content.Replace(Constants.SR_LINK_EMPLOYEE_HOLDER, linkEmployee);
                content = content.Replace(Constants.SR_LINK_IT_HOLDER, linkIT);
            }

            return content;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Write Log For Employee
        /// </summary>
        /// <param name="oldInfo"></param>
        /// <param name="newInfo"></param>
        /// <param name="action"></param>
        public void WriteLogForSR(SR_ServiceRequest oldInfo, SR_ServiceRequest newInfo, ELogAction action)
        {
            try
            {
                if (newInfo == null)
                {
                    return;
                }

                MasterLog objMasterLog = new MasterLog();

                string logId = commonDao.UniqueId;
                string[] colNameArr = new string[] { "CategoryID", "Title", "Description",
                            "SubmitUser", "RequestUser", "CCList", "UrgencyID", "Files", "OldId","StatusID", "AssignUser", "DueDate"};
                string[] colDisplayNameArr = new string[] { "Category", "Title", "Description",
                            "Submit User", "Request User", "CCList", "Urgency", "Attachments", "Related SR","Status", "Assign User", "Due Date"};
                string[] oldValueArr = null;
                if (oldInfo != null)
                {
                    oldValueArr = new string[] { oldInfo.CategoryID.ToString(), CommonFunc.SubStringRoundWord(oldInfo.Title, 100),
                            CommonFunc.SubStringRoundWord(oldInfo.Description, 100), oldInfo.SubmitUser,
                            oldInfo.RequestUser, oldInfo.CCList, oldInfo.UrgencyID.ToString(),
                            oldInfo.Files, oldInfo.OldId.HasValue ? oldInfo.OldId.Value.ToString() : null,
                            oldInfo.StatusID.ToString(), oldInfo.AssignUser,
                            oldInfo.DueDate.HasValue ? oldInfo.DueDate.Value.ToString(Constants.DATETIME_FORMAT_FULL) : null};
                }
                string[] newValueArr = new string[] { newInfo.CategoryID.ToString(), CommonFunc.SubStringRoundWord(newInfo.Title, 100),
                            CommonFunc.SubStringRoundWord(newInfo.Description, 100), newInfo.SubmitUser, newInfo.RequestUser,
                            newInfo.CCList, newInfo.UrgencyID.ToString(),
                            newInfo.Files, newInfo.OldId.HasValue ? newInfo.OldId.Value.ToString() : null,
                            newInfo.StatusID.ToString(), newInfo.AssignUser,
                            newInfo.DueDate.HasValue ? newInfo.DueDate.Value.ToString(Constants.DATETIME_FORMAT_FULL) : null};
                switch (action)
                {

                    case ELogAction.Delete:
                        // Insert to Master Log
                        commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.ServiceRequest.ToString(), action.ToString());
                        // Write Delete Log
                        string key = newInfo.ID + " [" + newInfo.Title + "]";
                        commonDao.InsertLogDetail(logId, "ID", "Key for Delete", key, null);
                        break;
                    case ELogAction.Insert:
                        commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.ServiceRequest.ToString(), action.ToString(), LogType.ServiceRequest);
                        commonDao.InsertLogDetail(logId, "ID", "Key for Insert", null, newInfo.ID.ToString());
                        for (int i = 0; i < colNameArr.Length; i++)
                            commonDao.InsertLogDetail(logId, colNameArr[i], colDisplayNameArr[i], null, newValueArr[i]);
                        break;
                    case ELogAction.Update:
                        commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.ServiceRequest.ToString(),
                            action.ToString(), LogType.ServiceRequest);
                        bool isChanged = false;
                        for (int i = 0; i < colNameArr.Length; i++)
                        {
                            if (oldValueArr[i] != newValueArr[i])
                            {
                                commonDao.InsertLogDetail(logId, colNameArr[i], colDisplayNameArr[i],
                                    oldValueArr[i], newValueArr[i]);
                                isChanged = true;
                            }
                        }
                        if(isChanged)
                            commonDao.InsertLogDetail(logId, "ID", "Key for Update", oldInfo.ID.ToString() + "[" + newInfo.UpdatedBy + "]", null);
                        break;
                    default:
                        break;

                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }