public void ProcessRequest(HttpContext context)
        {
            string name = context.Request.QueryString["q"];
            string pageName = context.Request.QueryString["Page"];

            #region pageName
            switch (pageName)
            {
                case "JRAdmin":
                    //JRAdminDao jrDao = new JRAdminDao();
                    //List<sp_GetJRForAdminResult> listJRAdmin = jrDao.GetListByName(name, 0, 0);
                    //var finalListJRAdmin = listJRAdmin.Select(p => p.UserName).Distinct();
                    //foreach (string item in finalListJRAdmin)
                    //{
                    //    context.Response.Write(item + Environment.NewLine);
                    //}

                    UserAdminDao userAdminDao = new UserAdminDao();
                    List<UserAdmin> listUserAdmin = userAdminDao.GetList().Where(p => p.UserName.ToLower().Contains(name)).ToList<UserAdmin>();
                    foreach (UserAdmin item in listUserAdmin)
                    {
                        Employee objEmployee = new EmployeeDao().GetByOfficeEmailInActiveList(item.UserName + Constants.PREFIX_EMAIL_LOGIGEAR);
                        string displayName = item.UserName;
                        if (objEmployee != null)
                        {
                            displayName += " - " + objEmployee.ID;
                        }
                        context.Response.Write(displayName + Environment.NewLine);
                    }
                    break;
                case "Group":
                    GroupDao groupDao = new GroupDao();
                    List<Group> listGroup = groupDao.GetListByName(name);
                    foreach (Group item in listGroup)
                    {
                        context.Response.Write(item.GroupName + Environment.NewLine);
                    }
                    break;
                case "Employee":
                    EmployeeDao empDao = new EmployeeDao();
                    int isActive = int.Parse(context.Request.QueryString["IsActive"]);
                    List<sp_GetEmployeeResult> empList = new List<sp_GetEmployeeResult>();
                    if (isActive == Constants.EMPLOYEE_ACTIVE)
                    {
                        empList = empDao.GetListByName(name, isActive, Constants.RESIGNED);
                    }
                    else if (isActive == Constants.EMPLOYEE_NOT_ACTIVE)
                    {
                        empList = empDao.GetListByName(name, isActive, Constants.RESIGNED);
                    }
                    //var finalListEmployee = empList.Select(p => p.DisplayName).Distinct();
                    foreach (sp_GetEmployeeResult item in empList)
                    {
                        context.Response.Write(item.DisplayName + " - " + item.ID + Environment.NewLine);
                    }
                    break;
                case "AssignEmployee":
                    ExamDao examDao = new ExamDao();
                    EmployeeDao employeeDao = new EmployeeDao();
                    int examID = int.Parse(context.Request.QueryString[CommonDataKey.EXAM_ID]);
                    List<sp_GetEmployeeResult> employeeList = new List<sp_GetEmployeeResult>();
                    employeeList = employeeDao.GetListByName(name, Constants.EMPLOYEE_ACTIVE, Constants.RESIGNED);
                    List<string> assignedEmployeeListID = examDao.AssignedEmployeeListID(examID);
                    employeeList = employeeList.Where(c => !assignedEmployeeListID.Contains(c.ID)).ToList<sp_GetEmployeeResult>();

                    var finalListEmp = employeeList.Select(p => p.DisplayName).Distinct();
                    foreach (string item in finalListEmp)
                    {
                        context.Response.Write(item + Environment.NewLine);
                    }

                    break;
                case "UserAdmin":
                    //UserAdminDao userAdminDao = new UserAdminDao();
                    //List<UserAdmin> listUserAdmin = userAdminDao.GetList().Where(p => p.UserName.ToLower().Contains(name)).ToList<UserAdmin>();
                    //foreach (UserAdmin item in listUserAdmin)
                    //{
                    //    context.Response.Write(item.UserName + Environment.NewLine);
                    //}
                    List<String> listUser = new List<string>();
                    System.DirectoryServices.SearchResultCollection entriesUser = CommonFunc.GetDomainUserList(name);

                    foreach (System.DirectoryServices.SearchResult searchResult in entriesUser)
                    {
                        System.DirectoryServices.DirectoryEntry entry = searchResult.GetDirectoryEntry();

                        if (entry.Properties["mail"] != null)
                        {
                            if (entry.Properties["mail"].Count > 0)
                            {

                                string displayName = entry.Properties[CommonFunc.GetDomainUserProperty(DomainUserProperty.LoginName)][0].ToString();
                                //string emailAddress = entry.Properties[CommonFunc.GetDomainUserProperty(DomainUserProperty.OutlookEmail)][0].ToString();
                                Employee objEmployee = new EmployeeDao().GetByOfficeEmailInActiveList(displayName + Constants.PREFIX_EMAIL_LOGIGEAR);
                                string item = displayName;
                                if (objEmployee != null)
                                {
                                    item += " - " + objEmployee.ID;
                                }
                                // +" &lt;" + emailAddress + "&gt;";
                                context.Response.Write(item + Environment.NewLine);
                            }
                        }
                    }
                    break;
                case "UserLogs":
                    //List<sp_LogMasterResult> logList = new LogDao().GetList("", "");
                    //var finalList = logList.Select(p => p.UserName).Distinct();

                    List<CRM.Models.Entities.MasterLogEntity> logList = new LogDao().GetQueryList("", "").ToList();
                    var finalList = logList.Select(p => p.UserName).Distinct();
                    foreach (string item in finalList)
                    {
                        context.Response.Write(item + Environment.NewLine);
                    }
                    break;

                case "STT":
                    STTDao sttDao = new STTDao();
                    List<sp_GetSTTResult> listSTT = sttDao.GetListByName(name);
                    foreach (sp_GetSTTResult item in listSTT)
                    {
                        context.Response.Write(item.DisplayName + " - " + item.ID + Environment.NewLine);
                    }
                    break;

                case "Candidate":
                    CandidateDao candidateDao = new CandidateDao();
                    List<sp_GetCandidateResult> result = candidateDao.GetList(name, 0, 0, 0, "", "", 0);
                    List<String> lstDisplayName = result.Select(p => p.DisplayName).ToList();
                    foreach (string item in lstDisplayName)
                    {
                        context.Response.Write(item + Environment.NewLine);
                    }
                    break;
                case "AssignCandidate":
                    ExamDao exDao = new ExamDao();
                    CandidateDao canDao = new CandidateDao();
                    int exID = int.Parse(context.Request.QueryString[CommonDataKey.EXAM_ID]);
                    List<sp_GetCandidateResult> canList = canDao.GetList(name, 0, 0, 0, "", "", 0);
                    List<int> assignedCandidateListID = exDao.AssignedCandidateListID(exID);
                    canList = canList.Where(c => !assignedCandidateListID.Contains(c.ID)).ToList<sp_GetCandidateResult>();
                    List<String> canListDisplayName = canList.Select(p => p.DisplayName).ToList();
                    foreach (string item in canListDisplayName)
                    {
                        context.Response.Write(item + Environment.NewLine);
                    }
                    break;
                case "JR":
                    string action = context.Request.QueryString["Action"];

                    if (string.IsNullOrEmpty(action) || action == "undefined")
                    {
                        List<sp_GetJobRequestCompleteResult> listJr = new List<sp_GetJobRequestCompleteResult>();
                        listJr = new JobRequestDao().GetJRListComplete(name, 0, 0, 0, null, 0);
                        foreach (sp_GetJobRequestCompleteResult item in listJr)
                        {
                            context.Response.Write(Constants.JOB_REQUEST_ITEM_PREFIX + item.ID + Environment.NewLine);
                        }
                    }
                    else
                    {
                        List<sp_GetJobRequestCompleteInterviewResult> listJr = new List<sp_GetJobRequestCompleteInterviewResult>();
                        name = name.Replace("j", "");
                        name = name.Replace("r", "");
                        name = name.Replace("-", "");
                        listJr = new JobRequestDao().GetJRListInterView(name, 0, 0, 0, 0);

                        foreach (sp_GetJobRequestCompleteInterviewResult item in listJr)
                        {
                            context.Response.Write(Constants.JOB_REQUEST_ITEM_PREFIX + item.ID + Environment.NewLine);
                        }
                    }

                    break;
                case "JRIndex":
                    string containsJR = Constants.JOB_REQUEST_PREFIX;
                    JobRequestItemDao jrItemDao = new JobRequestItemDao ();
                    if (containsJR.ToLower().Contains(name.ToLower()) ||
                        Constants.JOB_REQUEST_ITEM_PREFIX.ToLower().Contains(name.ToLower()))
                    {
                        name = string.Empty;
                    }
                    string assignRole = context.Request.QueryString["Role"];
                    List<sp_GetJobRequestResult> listJrIndex =
                        new JobRequestDao().GetList(name, 0, 0, 0, 0, 0, assignRole, 0);
                    foreach (sp_GetJobRequestResult item in listJrIndex)
                    {
                        context.Response.Write(Constants.JOB_REQUEST_PREFIX + item.ID + Environment.NewLine);
                        List<JobRequestItem> jrItems = jrItemDao.GetListByJrId(item.ID);
                        foreach (JobRequestItem subItem in jrItems)
                        {
                            if (subItem.ID.ToString().ToLower().Contains(name.ToLower()))
                            {
                                context.Response.Write(Constants.JOB_REQUEST_ITEM_PREFIX + subItem.ID + Environment.NewLine);
                            }
                        }
                    }
                    break;
                case "SendMail":
                    List<String> list = new List<string>();
                    System.DirectoryServices.SearchResultCollection entries = CommonFunc.GetDomainUserList(name);

                    foreach (System.DirectoryServices.SearchResult searchResult in entries)
                    {
                        System.DirectoryServices.DirectoryEntry entry = searchResult.GetDirectoryEntry();

                        if (entry.Properties["mail"] != null)
                        {
                            if (entry.Properties["mail"].Count > 0)
                            {

                                string displayName = entry.Properties[CommonFunc.GetDomainUserProperty(DomainUserProperty.LoginName)][0].ToString();
                                //string emailAddress = entry.Properties[CommonFunc.GetDomainUserProperty(DomainUserProperty.OutlookEmail)][0].ToString();
                                string item = displayName;// +" &lt;" + emailAddress + "&gt;";
                                context.Response.Write(item + Environment.NewLine);
                            }
                        }
                    }

                    break;
                case "PRIndex":
                    string containsPR = Constants.PR_REQUEST_PREFIX;
                    if (containsPR.ToLower().Contains(name))
                    {
                        name = string.Empty;
                    }
                    string roles = context.Request.QueryString["Role"];
                    string isViewAll = context.Request.QueryString["IsViewAll"];
                    int requestorId = 0;
                    string loginName = context.Request.QueryString["loginName"];
                    if (isViewAll.Equals("False") && roles == Constants.PR_REQUESTOR_ID.ToString())
                    {
                        requestorId = int.Parse(context.Request.QueryString["UserLoginId"]);
                    }

                    //List<sp_GetPurchaseRequestResult> listPrIndex = new PurchaseRequestDao().GetList(name, 0, 0, requestorId, 0, 0, roles, requestorId, loginName);
                    //List<sp_GetPurchaseRequestResult> listPrIndex = new PurchaseRequestDao().GetList(name, 0, 0, 0, 0, null, requestorId, int.Parse(roles), 0, false);
                    //chau.ly update 14.02.2012
                    List<sp_GetPurchaseRequestResult> listPrIndex = new PurchaseRequestDao().GetList(name, 0, 0, 0, 0, null, null, requestorId, int.Parse(roles), 0, false);
                    foreach (sp_GetPurchaseRequestResult item in listPrIndex)
                    {
                        context.Response.Write(Constants.PR_REQUEST_PREFIX + item.ID + Environment.NewLine);
                    }
                    break;

                case "Question":
                    QuestionDao qDao = new QuestionDao();
                    List<LOT_Question> listQuestion = qDao.GetListAutoComplete(name);
                    foreach (LOT_Question item in listQuestion)
                    {
                        context.Response.Write(CommonFunc.TruncateAroundSubText(item.QuestionContent, name) + Environment.NewLine);
                    }
                    break;
                case "Manager":
                    List<sp_GetManagerResult> listManager = new EmployeeDao().GetManager(name, 0, 0);
                    foreach (sp_GetManagerResult item in listManager)
                    {
                        context.Response.Write(item.DisplayName + Environment.NewLine);
                    }
                    break;
                case "University":
                    List<University> listUniversity = new CandidateDao().GetUniversityList("");
                    listUniversity = listUniversity.Where(p => p.Name.ToLower().Contains(name.ToLower())).ToList<University>();
                    foreach (University item in listUniversity)
                    {
                        context.Response.Write(item.Name + Environment.NewLine);
                    }
                    break;
                case "PTOAdmin":
                    List<sp_GetEmployeeManagerResult> listEmployeeManagerForAdmin = new EmployeeDao().GetEmployeeManager(name);
                    foreach (sp_GetEmployeeManagerResult item in listEmployeeManagerForAdmin)
                    {
                        string displayName = item.OfficeEmail.Replace(Constants.PREFIX_EMAIL_LOGIGEAR, "") + " - " + item.ID;
                        context.Response.Write(displayName + Environment.NewLine);
                    }
                    break;
                case "PTO_User":
                    var listEmployeeManager = new EmployeeDao().GetManager(name, 0, 0);
                    empDao = new EmployeeDao();
                    foreach (var item in listEmployeeManager)
                    {
                        context.Response.Write(empDao.FullName(item.ID, Constants.FullNameFormat.FirstMiddleLast) + " - " + item.ID + Environment.NewLine);
                    }
                    break;
                case "PTOCC":
                    EmployeeDao emplDao = new EmployeeDao();
                    List<sp_GetEmployeeResult> listEmpl = emplDao.GetListByName(name, Constants.EMPLOYEE_ACTIVE,
                                                                                Constants.RESIGNED);
                    string content = "";
                    foreach (sp_GetEmployeeResult item in listEmpl)
                    {
                        if (item.OfficeEmail != null)
                        {
                            string[] aTmp = item.OfficeEmail.Split('@');
                            content += aTmp[0] + Environment.NewLine;
                        }
                    }
                    context.Response.Write(content);
                    break;
                case "EmployeeWithID":
                    var empListWithId = new EmployeeDao().GetListByOfficeEmail(name).
                        Select(p => new { p.ID, p.OfficeEmail });
                    foreach (var item in empListWithId)
                    {
                        string displayName = item.OfficeEmail.Remove(item.OfficeEmail.IndexOf("@")) + " - " + item.ID;
                        context.Response.Write(displayName + Environment.NewLine);
                    }
                    break;
                case "ManagerWithID":
                    var mgrList = new EmployeeDao().GetEmployeeManager(name);
                    foreach (sp_GetEmployeeManagerResult item in mgrList)
                    {
                        string displayName = item.OfficeEmail.Remove(item.OfficeEmail.IndexOf("@")) + " - " + item.ID;
                        context.Response.Write(displayName + Environment.NewLine);
                    }
                    break;
                case "JobTitleLevel":
                    var jobTitleLevelList = new JobTitleLevelDao().GetList().Where(c => c.DisplayName.ToLower().Contains(name.Trim().ToLower()));
                    foreach (JobTitleLevel item in jobTitleLevelList)
                    {
                        string displayName = item.DisplayName;
                        context.Response.Write(displayName + Environment.NewLine);
                    }
                    break;
                case "EditPosition":
                    var mgrList_EP = new EmployeeDao().GetListManagerWithAllAttr(name);
                    empDao = new EmployeeDao();
                    foreach (Employee item in mgrList_EP)
                    {
                        string displayName = empDao.FullName(item.ID,
                            Constants.FullNameFormat.FirstMiddleLast) + " - " + item.ID;
                        context.Response.Write(displayName + Environment.NewLine);
                    }
                    break;
                case "Position":
                    empDao = new EmployeeDao();
                    string deptId = context.Request.QueryString["deptId"];
                    string subDeptId = context.Request.QueryString["subDeptId"];
                    string titleId = context.Request.QueryString["titleId"];
                    string project = context.Request.QueryString["project"];
                    string locationCode = null;
                    var positionList = empDao.GetListEmployeeAndSTT(name, ConvertUtil.ConvertToInt(deptId), ConvertUtil.ConvertToInt(subDeptId),
                        ConvertUtil.ConvertToInt(titleId),project, locationCode);
                    /*foreach (Employee item in positionList)
                    {
                        string displayName = CommonFunc.GetEmployeeFullName(item,
                            Constants.FullNameFormat.FirstMiddleLast);
                        context.Response.Write(displayName + Environment.NewLine);
                    }*/
                    foreach (sp_GetPositionResult item in positionList)
                    {
                        string displayName = item.FullName;
                        context.Response.Write(displayName + Environment.NewLine);
                    }
                    break;
                case "ManagerListPR":
                    string sStatus = context.Request.QueryString["status"];
                    string sNeed = context.Request.QueryString["need"];
                    var userName = HttpContext.Current.User.Identity.Name;

                    empDao = new EmployeeDao();
                    var prlist_Manager = empDao.GetPRList(CommonFunc.GetEmployeeByUserName(userName).ID,
                        name, sStatus, sNeed.Equals(Constants.PER_REVIEW_NEED_PR_LIST));
                    foreach (sp_GetEmployeesForPRResult item in prlist_Manager)
                    {
                        string displayName = empDao.FullName(item.ID,
                            Constants.FullNameFormat.FirstMiddleLast);
                        context.Response.Write(displayName + Environment.NewLine);
                    }
                    break;
                case "HRPR":
                    string status = context.Request.QueryString["status"];
                    string need = context.Request.QueryString["need"];

                    if (string.IsNullOrEmpty(status))
                        status = "0";
                    PerformanceReviewDao perDao = new PerformanceReviewDao();
                    var prlist = perDao.GetList(name, int.Parse(status), need.Equals(Constants.PER_REVIEW_NEED_PR_LIST), Constants.PRW_ROLE_HR_ID.ToString());
                    foreach (sp_GetEmployeesPRForHRResult item in prlist)
                    {
                        context.Response.Write(item.EmployeeName + Environment.NewLine);
                    }
                    break;
                case "PTOManager":
                    DateTime? from = null;
                    DateTime? to = null;
                    string month = context.Request.QueryString["month"];
                    string managerID = context.Request.QueryString["managerId"];
                    if (!string.IsNullOrEmpty(month))
                    {
                        try
                        {
                            // filter month is date end of month and this date dependent on configuration
                            // ex: month:Feb-2011 => from: 25-Feb-2011, to: 26-Feb-2011
                            to = DateTime.Parse(Constants.DATE_LOCK_PTO + month);
                            from = to.Value.AddMonths(-1).AddDays(1);
                        }
                        catch
                        {
                            // get mon by curent date
                            month = DateTime.Now.ToString(Constants.PTO_MANAGER_DATE_FORMAT);
                            to = DateTime.Parse(Constants.DATE_LOCK_PTO + month);
                            from = to.Value.AddMonths(-1).AddDays(1);
                        }
                    }
                    List<sp_GetPTOEmployeeListForManagerResult> listPTOUser = new PTODao().GetPTOEmpListForManager(name, 0, 0, 0, from, to, managerID,null);
                    List<string> finalListPTOUser = listPTOUser.Select(p => p.Submitter + " - " + p.EmployeeID).Distinct().ToList<string>();
                    foreach (string item in finalListPTOUser)
                    {
                        context.Response.Write(item + Environment.NewLine);
                    }
                    break;
                case "WorkFlow":

                    int wfID = int.Parse(context.Request.QueryString["workflowID"]);

                    List<sp_GetJRForAdminResult> listUserAdminRole = new JRAdminDao().GetListByName(name, wfID, 0);
                    List<string> listStringName = listUserAdminRole.Select(q => q.UserName).Distinct().ToList();
                    foreach (string item in listStringName)
                    {
                        Employee objEmployee = new EmployeeDao().GetByOfficeEmailInActiveList(item + Constants.PREFIX_EMAIL_LOGIGEAR);
                        string displayName = item;
                        if (objEmployee != null)
                        {
                            displayName += " - " + objEmployee.ID;
                        }
                        context.Response.Write(displayName + Environment.NewLine);
                    }
                    break;
                case "LocationEmployee":
                    EmployeeDao empDao1 = new EmployeeDao();
                    List<sp_GetListEmployeeSttNotSeatResult> empList1 = new List<sp_GetListEmployeeSttNotSeatResult>();

                    empList1 = empDao1.GetListEmployeeNotSeat(name);

                    foreach (sp_GetListEmployeeSttNotSeatResult item in empList1)
                    {
                        context.Response.Write(item.FullName + " - " + item.ID + Environment.NewLine);
                    }
                    break;
                case "LocationChart":
                    EmployeeDao empDao2 = new EmployeeDao();

                    List<sp_GetEmployeeSTTListResult> empSttList = new List<sp_GetEmployeeSTTListResult>();

                    empSttList = empDao2.GetEmpSttList(name);
                    if (context.Request.QueryString.AllKeys.Contains("hasLocation"))
                        empSttList = empSttList.Where(p=>!string.IsNullOrEmpty(p.LocationCode)).ToList();
                    foreach (sp_GetEmployeeSTTListResult item in empSttList)
                    {
                        context.Response.Write(item.FullName + " - " + item.ID + Environment.NewLine);
                    }
                    break;
                case "MoveLocation":
                    LocationDao locatinoDao = new LocationDao();
                    var listSeatCode = locatinoDao.GetListSeatCode(name, 0, 0, 0, false);
                    foreach (var item in listSeatCode)
                    {
                        context.Response.Write(item.SeatCodeName + " (" + item.FloorName + ") - "
                             + item.SeatCodeID + Environment.NewLine);
                    }
                    break;
                case "ServiceRequest":
                    var listServiceRequestIT = new UserAdminDao().GetListITHelpDesk((int)Modules.ServiceRequestAdmin, (int)Permissions.ItHelpDesk);
                    foreach (var item in listServiceRequestIT)
                    {
                        context.Response.Write(item.Name + " -" + item.ID+ Environment.NewLine);
                    }
                    break;
                case "ServiceRequestSetting":
                    List<sp_GetSR_SettingResult> listSRSetting = new SRSettingDao().GetList(name,"",0,0);
                    List<string> listUserSetting = listSRSetting.Select(q => q.UserName).Distinct().ToList();
                    foreach (var item in listUserSetting)
                    {
                        context.Response.Write(item + Environment.NewLine);
                    }
                    break;
                case "ClassPlaning":
                    int typeCourse = ConvertUtil.ConvertToInt(context.Request["TypeCourse"]);
                    int trainingStatus = ConvertUtil.ConvertToInt(context.Request["TrainingStatus"]);
                    List<sp_GetClassPlanningResult> listClassID = new TrainingCenterDao().GetList(name, 0, 0, trainingStatus, null, typeCourse);
                    List<string> listClassName = listClassID.Select(q => q.ClassID).Distinct().ToList();
                    foreach (var item in listClassName)
                    {
                        context.Response.Write(item + Environment.NewLine);
                    }
                    break;
                case "AAsset":
                    //List<A_Asset> aAssetList = new AAssetDao().GetParentAsset();
                    //foreach (var item in aAssetList)
                    //{
                    //    context.Response.Write(item.AssetId + Environment.NewLine);
                    //}
                    break;
            }
            #endregion

            string funcName = context.Request.QueryString["func"];
            #region funcName
            switch (funcName)
            {
                case "Employee":
                    EmployeeDao empDao = new EmployeeDao();
                    //type = 1 -> user name, type = 2 -> full name (first middle last)
                    int type = ConvertUtil.ConvertToInt(context.Request.QueryString["type"]);
                    //hasSuffixId = true -> include the Employee ID in the display result
                    bool hasSuffixId = !string.IsNullOrEmpty(context.Request.QueryString["suffixId"]);
                    //idFirst = true -> display the id first then display name
                    bool idFirst = !string.IsNullOrEmpty(context.Request.QueryString["idFirst"]);
                    if (type == 1)
                    {
                        var empList = empDao.GetListByOfficeEmail(name).Where(p=>!p.DeleteFlag);
                        foreach (var item in empList)
                        {
                            string suffix = "";
                            string mainValue = "";
                            if (hasSuffixId && !idFirst)
                            {
                                suffix = " - " + item.ID;
                                mainValue = item.OfficeEmail.Remove(item.OfficeEmail.IndexOf("@"));
                            }
                            else if (hasSuffixId && idFirst)
                            {
                                suffix = " - " + item.OfficeEmail.Remove(item.OfficeEmail.IndexOf("@"));
                                mainValue = item.ID;
                            }
                            string displayName = mainValue + suffix;
                            context.Response.Write(displayName + Environment.NewLine);
                        }
                    }
                    else if (type == 2)
                    {
                        var empList = empDao.GetList(name, 0, 0, 0, 1, 0).Where(p=>p.EmpStatusId != Constants.RESIGNED);
                        foreach (var item in empList)
                        {
                            string suffix = "";
                            string mainValue = "";
                            if (hasSuffixId && !idFirst)
                            {
                                suffix = " - " + item.ID;
                                mainValue = empDao.FullName(item.ID, Constants.FullNameFormat.FirstMiddleLast);
                            }
                            else if (hasSuffixId && idFirst)
                            {
                                suffix = " - " + empDao.FullName(item.ID, Constants.FullNameFormat.FirstMiddleLast);
                                mainValue = item.ID;
                            }
                            string displayName = mainValue + suffix;
                            context.Response.Write(displayName + Environment.NewLine);
                        }
                    }
                    break;
            }
            #endregion
        }
Esempio n. 2
0
 public bool HasEditPermisionUS(int prID, string loginName, int loginRole)
 {
     try
     {
         PurchaseRequest pr = GetByID(prID);
         if (pr.WFStatusID == Constants.STATUS_CLOSE)
             return false;
         if (!string.IsNullOrEmpty(loginName) && loginRole != 0 && pr != null)
         {
             UserAdmin userAdmin = new UserAdminDao().GetByUserName(loginName);
             if (userAdmin == null)
                 return false;
             int loginID = userAdmin.UserAdminId;
             if (new GroupDao().HasPermisionOnModule(loginID, (int)Permissions.ForceEdit, (int)Modules.PurchaseRequestUS))
                 return true;
             return IsAssigned(pr, loginID, loginRole) && loginRole == Constants.PR_REQUESTOR_ID_US;
         }
         return false;
     }
     catch
     {
         return false;
     }
 }
Esempio n. 3
0
 public bool HasViewPermision(int prID, string loginName, int loginRole)
 {
     try
     {
         PurchaseRequest pr = GetByID(prID);
         if (!string.IsNullOrEmpty(loginName) && loginRole != 0 && pr !=null)
         {
             UserAdmin userAdmin = new UserAdminDao().GetByUserName(loginName);
             if (userAdmin == null)
                 return false;
             int loginID = userAdmin.UserAdminId;
             if (new GroupDao().HasPermisionOnModule(loginID, (int)Permissions.ViewAllPR, (int)Modules.PurchaseRequest))
                 return true;
             return IsRequestor(pr, loginID, loginRole) || IsAssigned(pr, loginID, loginRole) ||
                 IsInCCList(pr, loginName) || IsInInvolveList(pr, loginID, loginRole);
         }
         return false;
     }
     catch
     {
         return false;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Update Service Request Setting
        /// </summary>
        /// <param name="objUI"></param>
        /// <returns></returns>
        public Message Update(SR_Setting objUI)
        {
            Message msg = null;

            try
            {
                if (objUI != null)
                {
                    // Get current group in dbContext
                    SR_Setting objDb = GetByID(objUI.ID);

                    if (objDb != null)
                    {
                        // Check valid update date
                        if (!IsValidUpdateDate(objUI, objDb, out msg))
                        {
                            UserAdmin objUserAdmin = new UserAdminDao().GetById(objUI.UserAdminID);
                            msg = new Message(MessageConstants.E0025, MessageType.Error, "User Admin " + objUserAdmin != null ? objUserAdmin.UserName : string.Empty, "assigned to project " + objUI.ProjectName);
                        }
                        else if(IsDuplicated(objUI, out msg,true))
                        {
                            UserAdmin objUserAdmin = new UserAdminDao().GetById(objUI.UserAdminID);
                            msg = new Message(MessageConstants.E0004, MessageType.Error, "User Admin " + ( objUserAdmin != null ? objUserAdmin.UserName : string.Empty) +  " assigned to project " + objUI.ProjectName);
                        }
                        else if (IsValidRoute(objUI, out msg, true))
                        {
                            msg = new Message(MessageConstants.E0048, MessageType.Error, "The default routing");
                        }
                        else
                        {
                             // Update info by objUI
                            objDb.OfficeID = objUI.OfficeID;
                            objDb.ProjectName = objUI.ProjectName;
                            objDb.UserAdminID = objUI.UserAdminID;
                            objDb.IsActive = objUI.IsActive;
                            objDb.DeleteFlag = objUI.DeleteFlag;
                            objDb.UpdateDate = DateTime.Now;
                            objDb.UpdatedBy = objUI.UpdatedBy;
                            objDb.EmailTo = objUI.EmailTo;
                            objDb.EmailCc = objUI.EmailCc;
                            objDb.EmailBcc = objUI.EmailBcc;

                            // Submit changes to dbContext
                            dbContext.SubmitChanges();

                            // Show success message
                            UserAdmin objUserAdmin = new UserAdminDao().GetById(objUI.UserAdminID);
                            msg = new Message(MessageConstants.I0001, MessageType.Info, "User Admin " + objUserAdmin != null?objUserAdmin.UserName:string.Empty, "assigned to project " + objUI.ProjectName);
                        }
                    }
                }
            }
            catch
            {
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }

            return msg;
        }
Esempio n. 5
0
 /// <summary>
 /// Update Status of Service Request Setting
 /// </summary>
 /// <param name="id"></param>
 /// <param name="isActive"></param>
 /// <returns></returns>
 public Message UpdateActiveStatus(int id, bool isActive,string updateDate,string userName)
 {
     try
     {
         Message msg = null;
         SR_Setting objDb = GetByID(id);
         if (objDb == null)
             return new Message(MessageConstants.E0005, MessageType.Error,
                 "Selected user", "system");
         if (updateDate != objDb.UpdateDate.ToString())
         {
             UserAdmin objUserAdmin = new UserAdminDao().GetById(objDb.UserAdminID);
             msg = new Message(MessageConstants.E0025, MessageType.Error, objUserAdmin != null ? "User Admin " + objUserAdmin.UserName : string.Empty);
             return msg;
         }
         else
         {
             objDb.IsActive = isActive;
             objDb.UpdateDate = DateTime.Now;
             objDb.UpdatedBy = userName;
             dbContext.SubmitChanges();
             return new Message(MessageConstants.I0001, MessageType.Info, " User Admin " + objDb.UserAdmin.UserName, "set " + (isActive ? "active" : "inactive"));
         }
     }
     catch
     {
         return new Message(MessageConstants.E0007, MessageType.Error);
     }
 }
Esempio n. 6
0
 public static List<ListItem> GetRolePortal(string userName)
 {
     List<ListItem> roleList = new List<ListItem>();
     roleList.Add(new ListItem("Employee", Constants.PRW_ROLE_EMPLOYEE_ID.ToString()));
     UserAdmin objAdmin = new UserAdminDao().GetByUserName(userName);
     if (objAdmin != null)
     {
         List<WFRole> list = new CommonDao().GetRoleList(objAdmin.UserAdminId, Constants.WORK_FLOW_PERFORMANCE_REVIEW);
         list = list.Where(q => q.ID == Constants.PRW_ROLE_EM_ID || q.ID == Constants.PRW_ROLE_PL || q.ID == Constants.PRW_ROLE_MANAGER_ID).ToList();
         if (list.Count > 0)
         {
             foreach (WFRole item in list)
             {
                 roleList.Add(new ListItem(item.Name, item.ID.ToString()));
             }
         }
     }
     return roleList;
 }
Esempio n. 7
0
        /// <summary>
        /// Insert Service Request Setting
        /// </summary>
        /// <param name="objUI"></param>
        /// <returns></returns>
        public Message Insert(SR_Setting objUI)
        {
            Message msg = null;
            try
            {
                if (IsValidRoute(objUI, out msg, false))
                {
                    msg = new Message(MessageConstants.E0048, MessageType.Error, "The default routing");
                }
                else if (IsDuplicated(objUI, out msg, false))
                {
                    UserAdmin objUserAdmin = new UserAdminDao().GetById(objUI.UserAdminID);
                    msg = new Message(MessageConstants.E0004, MessageType.Error, "User Admin " + (objUserAdmin != null ? objUserAdmin.UserName : string.Empty) + " assigned to project " + objUI.ProjectName);
                }
                else
                {
                    dbContext.SR_Settings.InsertOnSubmit(objUI);
                    dbContext.SubmitChanges();
                    // Show success message
                    msg = new Message(MessageConstants.I0001, MessageType.Info, "User Admin " + objUI.UserAdmin.UserName, "assigned to project " + objUI.ProjectName);
                }

            }
            catch
            {
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            return msg;
        }
Esempio n. 8
0
 public static int GetUserAdminIdFromEmpId(int Id)
 {
     string username = GetUserNameLoginByEmpID(Id.ToString());
     UserAdmin user = new UserAdminDao().GetByUserName(username);
     if (user != null)
         return user.UserAdminId;
     else return -1;
 }
Esempio n. 9
0
 public static bool CheckPortalAuthorized(string userName, byte moduleId, int permisson)
 {
     UserAdmin objAdmin = new UserAdminDao().GetByUserName(userName);
     if (objAdmin != null)
     {
         AuthenticateDao auDao = new AuthenticateDao();
         ArrayList permissionIds = new ArrayList();
         permissionIds.Add(permisson);
         return auDao.CheckPermission(objAdmin.UserAdminId, moduleId, Array.ConvertAll(permissionIds.ToArray(), arr => (int)arr));
     }
     return false;
 }
Esempio n. 10
0
 /// <summary>
 /// Descypt salary follow permission
 /// </summary>
 /// <param name="text"></param>
 /// <param name="principal"></param>
 /// <param name="groupDao"></param>
 /// <param name="userAdminDao"></param>
 /// <returns></returns>
 public static string DescyptSalary(string text, AuthenticationProjectPrincipal principal, GroupDao groupDao, UserAdminDao userAdminDao)
 {
     bool canViewSalary = groupDao.HasPermisionOnModule(
         userAdminDao.GetByUserName(principal.UserData.UserName).UserAdminId, (int)Permissions.Read, (int)Modules.ViewSalaryInfo);
     string result = "";
     if (!string.IsNullOrEmpty(text))
     {
         result = canViewSalary ? EncryptUtil.Decrypt(text) : Constants.PRIVATE_DATA;
     }
     return result;
 }
Esempio n. 11
0
        /// <summary>
        /// Check moving request
        /// </summary>
        /// <param name="userID">int</param>
        /// <param name="request">FlowType</param>
        /// <param name="id">int</param>
        /// <param name="action">ActionType</param>
        /// <param name="role">int</param>
        /// <returns>bool</returns>
        public static bool CheckMovingRequest(int userID, Constants.FlowType request, string id, Constants.ActionType action, int role, bool isPortal = false)
        {
            bool allow = false;
            try
            {
                string srole = role.ToString();
                switch (request)
                {

                    case Constants.FlowType.FLOW_JOB_REQUEST:
                        JobRequestDao jobDao = new JobRequestDao();
                        JobRequest job = jobDao.GetById(int.Parse(id));
                        switch (action)
                        {

                            case Constants.ActionType.List:
                                if (job.InvolveRole.Contains(srole))
                                    allow = true;
                                break;
                            case Constants.ActionType.Update:
                                if (job.AssignRole.Equals(role) && job.AssignID.Equals(userID))
                                    allow = true;
                                break;
                        }

                        break;
                    case Constants.FlowType.FLOW_JOB_REQUEST_ITEM:
                        JobRequestItemDao jobItemDao = new JobRequestItemDao();
                        JobRequestItem jobItem = jobItemDao.GetByID(id);
                        switch (action)
                        {

                            case Constants.ActionType.Update:
                                if (jobItem.JobRequest.AssignRole.Equals(role) && jobItem.JobRequest.AssignID.Equals(userID))
                                    allow = true;
                                break;
                        }

                        break;
                    case Constants.FlowType.FLOW_PURCHASE_REQUEST:
                        PurchaseRequestDao purDao = new PurchaseRequestDao();
                        PurchaseRequest pur = purDao.GetByID(int.Parse(id));
                        switch (action)
                        {

                            case Constants.ActionType.List:
                                if (pur.InvolveRole.Contains(srole))
                                    allow = true;
                                break;
                            case Constants.ActionType.Update:
                                string loginName = new UserAdminDao().GetById(userID).UserName;
                                if (pur.WFStatusID == Constants.STATUS_OPEN)
                                {
                                    if (purDao.HasEditPermision(pur.ID, loginName, role))
                                        allow = true;
                                    else if (role != Constants.PR_REQUESTOR_ID && purDao.IsAssigned(pur, userID, role))
                                        allow = true;
                                }
                                break;
                        }

                        break;
                    case Constants.FlowType.FLOW_PURCHASE_REQUEST_US:
                        PurchaseRequestDao purUSDao = new PurchaseRequestDao();
                        PurchaseRequest purUS = purUSDao.GetByID(int.Parse(id));
                        switch (action)
                        {

                            case Constants.ActionType.List:
                                if (purUS.InvolveRole.Contains(srole))
                                    allow = true;
                                break;
                            case Constants.ActionType.Update:
                                string loginName = new UserAdminDao().GetById(userID).UserName;
                                if (purUS.WFStatusID == Constants.STATUS_OPEN)
                                {
                                    if (purUSDao.HasEditPermisionUS(purUS.ID, loginName, role))
                                        allow = true;
                                    else if (role != Constants.PR_REQUESTOR_ID_US && purUSDao.IsAssigned(purUS, userID, role))
                                        allow = true;
                                }
                                break;
                        }

                        break;
                    case Constants.FlowType.FLOW_PERFORMANCE_REVIEW:
                        PerformanceReviewDao perDao = new PerformanceReviewDao();
                        PerformanceReview per = perDao.GetById(id);
                        CommonDao comm = new CommonDao();
                        int userAdminId = GetUserAdminIdFromEmpId(userID);
                        List<int> roles = comm.GetRoleListInt(userAdminId, Constants.WORK_FLOW_PERFORMANCE_REVIEW);
                        switch (action)
                        {

                            case Constants.ActionType.List:
                                if (isPortal)
                                {
                                    if (roles.Contains(role))
                                        allow = true;
                                }
                                else if (per.InvolveRole.Contains(srole))
                                    allow = true;

                                break;
                            case Constants.ActionType.Update:
                                if (isPortal)
                                {
                                    if (roles.Contains(role) && per.AssignID.Equals(userID.ToString()) && per.AssignRole.Equals(role))
                                        allow = true;
                                }
                                else if (roles.Contains(per.AssignRole) && per.AssignID.Equals(userID.ToString()))
                                    allow = true;

                                break;
                        }

                        break;
                }
            }
            catch
            { }
            return allow;
        }
Esempio n. 12
0
        /// <summary>
        /// Write Update Log For Job Request
        /// </summary>
        /// <param name="newInfo"></param>
        /// <param name="logId"></param>
        /// <returns></returns>
        private bool WriteUpdateLogForJobRequest(JobRequest newInfo, string logId)
        {
            bool isUpdated = false;
            try
            {
                // Get old info
                JobRequest oldInfo = new JobRequestDao().GetById(newInfo.ID);

                if ((oldInfo != null) && (newInfo != null) && (logId != null))
                {
                    if (newInfo.WFStatusID != oldInfo.WFStatusID)
                    {
                        if (newInfo.WFStatusID != 0)
                        {
                            commonDao.InsertLogDetail(logId, "WFStatusID", "Status", oldInfo.WFStatus.Name, new WFStatusDao().GetByID(newInfo.WFStatusID).Name);
                            isUpdated = true;
                        }
                    }
                    if (newInfo.CCList != oldInfo.CCList)
                    {
                        commonDao.InsertLogDetail(logId, "CCList", "CC List", oldInfo.CCList, newInfo.CCList);
                        isUpdated = true;
                    }
                    if (newInfo.RequestTypeId != oldInfo.RequestTypeId)
                    {
                        commonDao.InsertLogDetail(logId, "CCList", "CC List", oldInfo.RequestTypeId == Constants.JR_REQUEST_TYPE_NEW ? "New":"Replace", newInfo.RequestTypeId == Constants.JR_REQUEST_TYPE_NEW ? "New":"Replace");
                        isUpdated = true;
                    }
                    if (newInfo.WFResolutionID != oldInfo.WFResolutionID)
                    {
                        if (newInfo.WFResolutionID != 0)
                        {
                            WFResolution objRes = new ResolutionDao().GetByID(newInfo.WFResolutionID);
                            if (objRes != null)
                            {
                                commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, objRes.Name);
                                isUpdated = true;
                            }
                        }
                    }
                    if (newInfo.RequestDate != oldInfo.RequestDate)
                    {
                        commonDao.InsertLogDetail(logId, "RequestDate", "Request Date", oldInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW));
                        isUpdated = true;
                    }
                    if (newInfo.DepartmentId != oldInfo.DepartmentId)
                    {
                        Department objDepart = new DepartmentDao().GetById(newInfo.DepartmentId);
                        if (objDepart != null)
                        {
                            commonDao.InsertLogDetail(logId, "DepartmentId", "Sub Department", oldInfo.Department.DepartmentName, objDepart.DepartmentName);
                            commonDao.InsertLogDetail(logId, "Department", "Department", deptDao.GetDepartmentNameBySub(oldInfo.DepartmentId), deptDao.GetDepartmentNameBySub(newInfo.DepartmentId));
                            isUpdated = true;
                        }
                    }
                    //if (newInfo.PositionFrom != oldInfo.PositionFrom)
                    //{
                    //    JobTitleLevel objJobFrom = new JobTitleLevelDao().GetById(newInfo.PositionFrom);
                    //    if (objJobFrom != null)
                    //    {
                    //        commonDao.InsertLogDetail(logId, "PositionFrom", "Position From", oldInfo.JobTitleLevel.DisplayName, objJobFrom.DisplayName);
                    //        isUpdated = true;
                    //    }
                    //}
                    //if (newInfo.PositionTo != oldInfo.PositionTo)
                    //{
                    //    if (newInfo.PositionTo.HasValue)
                    //    {
                    //        JobTitleLevel objJobTo = new JobTitleLevelDao().GetById(newInfo.PositionTo.Value);
                    //        if (objJobTo != null)
                    //        {
                    //            commonDao.InsertLogDetail(logId, "PositionTo", "Position To", oldInfo.PositionTo.HasValue?oldInfo.JobTitleLevel1.DisplayName:"", objJobTo.DisplayName);
                    //            isUpdated = true;
                    //        }
                    //    }
                    //}
                    string oldSalarySuggestionValue = string.IsNullOrEmpty(oldInfo.SalarySuggestion) ? null : EncryptUtil.Decrypt(oldInfo.SalarySuggestion);
                    if (newInfo.SalarySuggestion != oldSalarySuggestionValue)
                    {
                        if (!string.IsNullOrEmpty(newInfo.SalarySuggestion))
                        {
                            commonDao.InsertLogDetail(logId, "SalarySuggestion", "Salary Suggestion", oldInfo.SalarySuggestion, EncryptUtil.Encrypt(newInfo.SalarySuggestion));
                            isUpdated = true;
                        }
                        else
                        {
                            commonDao.InsertLogDetail(logId, "SalarySuggestion", "Salary Suggestion", oldInfo.SalarySuggestion,newInfo.SalarySuggestion);
                            isUpdated = true;
                        }
                    }
                    if (newInfo.AssignRole != oldInfo.AssignRole || newInfo.AssignID != oldInfo.AssignID)
                    {
                        if (newInfo.AssignRole.HasValue)
                        {
                            WFRole obj = new RoleDao().GetByID(newInfo.AssignRole.Value);
                            if (obj != null)
                            {
                                UserAdmin objUserAdmin = new UserAdminDao().GetById(newInfo.AssignID.Value);
                                if (objUserAdmin != null)
                                {
                                    commonDao.InsertLogDetail(logId, "AssignID", "Forward to", oldInfo.UserAdmin1.UserName + " ( " + oldInfo.WFRole.Name + " )", objUserAdmin.UserName + " ( " + obj.Name + " )");
                                    isUpdated = true;
                                }
                            }
                        }
                    }
                    if (isUpdated)
                    {
                        // Insert Key Name
                        string key = Constants.JOB_REQUEST_PREFIX + oldInfo.ID.ToString();
                        commonDao.InsertLogDetail(logId, "EmployeeId", "Key for Update", key, null);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return isUpdated;
        }
Esempio n. 13
0
        /// <summary>
        /// Write Update Log For When Role Manager
        /// </summary>
        /// <param name="newInfo"></param>
        /// <param name="logId"></param>
        /// <returns></returns>
        public void WriteUpdateLogForRoleManager(JobRequest newInfo,ELogAction action)
        {
            bool isUpdated = false;
            try
            {
                // Get old info
                string logId = commonDao.UniqueId;
                commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.JobRequest.ToString(), action.ToString());
                JobRequest oldInfo = new JobRequestDao().GetById(newInfo.ID);

                if ((oldInfo != null) && (newInfo != null) && (logId != null))
                {
                    if (newInfo.WFStatusID != oldInfo.WFStatusID)
                    {
                        commonDao.InsertLogDetail(logId, "WFStatusID", "Status", oldInfo.WFStatus.Name, new WFStatusDao().GetByID(newInfo.WFStatusID).Name);
                        isUpdated = true;
                    }
                    if (newInfo.WFResolutionID != oldInfo.WFResolutionID)
                    {
                        WFResolution objRes = new ResolutionDao().GetByID(newInfo.WFResolutionID);
                        if (objRes != null)
                        {
                            commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, objRes.Name);
                            isUpdated = true;
                        }
                    }
                    if (newInfo.AssignRole != oldInfo.AssignRole)
                    {
                        if (newInfo.AssignRole.HasValue)
                        {
                            WFRole obj = new RoleDao().GetByID(newInfo.AssignRole.Value);
                            if (obj != null)
                            {
                                UserAdmin objUserAdmin = new UserAdminDao().GetById(newInfo.AssignID.Value);
                                if (objUserAdmin != null)
                                {
                                    commonDao.InsertLogDetail(logId, "AssignID", " Forward to", oldInfo.UserAdmin1.UserName + " (" + oldInfo.WFRole.Name + ")", objUserAdmin.UserName + " (" + obj.Name + ")");
                                    isUpdated = true;
                                }
                            }
                        }
                    }
                    if (isUpdated)
                    {
                        // Insert Key Name
                        string key = Constants.JOB_REQUEST_PREFIX + oldInfo.ID.ToString();
                        commonDao.InsertLogDetail(logId, "EmployeeId", "Key for Update", key, null);
                    }
                    else
                    {
                       commonDao.DeleteMasterLog(logId);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 14
0
 public JsonResult CheckCCList(string userNameList)
 {
     UserAdminDao userAdminDao = new UserAdminDao();
     JsonResult result = new JsonResult();
     result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
     if (!string.IsNullOrEmpty(userNameList))
     {
         string[] array = userNameList.Trim().TrimEnd(';').Split(';');
         foreach (string item in array)
         {
             if (!string.IsNullOrEmpty(item))
             {
                 UserAdmin obj = userAdminDao.GetByUserName(item.Split('@')[0].Trim());
                 if (obj != null)
                 {
                     result.Data = true;
                 }
                 else
                 {
                     result.Data = string.Format(Resources.Message.E0005, item, " User Admin");
                 }
             }
         }
     }
     else
     {
         result.Data = true;
     }
     return result;
 }
Esempio n. 15
0
        private bool WriteUpdateLogForWorkflowAdmin(UserAdmin_WFRole newInfo, string logId)
        {
            bool isUpdated = false;
            try
            {
                // Get old info
                UserAdmin_WFRole oldInfo = new JRAdminDao().GetById(newInfo.ID);

                if ((oldInfo != null) && (newInfo != null) && (logId != null))
                {
                    if (newInfo.UserAdminId != oldInfo.UserAdminId)
                    {
                        UserAdmin objUserName = new UserAdminDao().GetById(newInfo.UserAdminId);
                        if (objUserName != null)
                        {
                            commonDao.InsertLogDetail(logId, "UserAdminId", "User Name", oldInfo.UserAdmin.UserName, objUserName.UserName);
                            isUpdated = true;
                        }
                    }
                    if (newInfo.WFRoleID != oldInfo.WFRoleID)
                    {
                        WFRole obj = new RoleDao().GetByID(newInfo.WFRoleID);
                        if (obj != null)
                        {
                            commonDao.InsertLogDetail(logId, "WFRoleID", "Role", oldInfo.WFRole.Name, obj.Name);
                            isUpdated = true;
                        }
                    }
                    if (newInfo.IsActive != oldInfo.IsActive)
                    {
                        commonDao.InsertLogDetail(logId, "IsActive", "Active", oldInfo.IsActive == Constants.IS_ACTIVE ? "Yes" : "No", newInfo.IsActive == Constants.IS_ACTIVE ? "Yes" : "No");
                        isUpdated = true;
                    }
                    if (isUpdated)
                    {
                        // Insert Key Name
                        string key = newInfo.ID + " [" + oldInfo.UserAdmin.UserName + "] with Role [" + oldInfo.WFRole.Name + "]";
                        commonDao.InsertLogDetail(logId, "WorkFlowAdmin", "Key for Update", key, null);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return isUpdated;
        }
Esempio n. 16
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="objUI"></param>
        /// <returns></returns>
        public Message Update(UserAdmin_WFRole objUI)
        {
            Message msg = null;
            try
            {
                if (objUI != null)
                {
                    // Get current group in dbContext
                    UserAdmin_WFRole objDb = GetById(objUI.ID);
                    if (objDb != null)
                    {
                        if (hasJRAssignTo(objUI.UserAdminId,objUI.WFRoleID))
                        {
                            UserAdminDao adminDao = new UserAdminDao();
                            UserAdmin obj = adminDao.GetById(objUI.UserAdminId);
                            if (obj != null)
                            {
                                msg = new Message(MessageConstants.E0023, MessageType.Error, "update " + obj.UserName, "Job Request");
                            }
                        }
                        else
                        {
                            // Check valid update date
                            if (IsValidUpdateDate(objUI, objDb, out msg))
                            {
                                new JRAdminLogDao().WriteLogForWorkflowAdmin(null, objUI, ELogAction.Update);
                                // Update info by objUI
                                objDb.UserAdminId = objUI.UserAdminId;
                                objDb.WFRoleID = objUI.WFRoleID;
                                objDb.UpdateDate = DateTime.Now;
                                objDb.UpdatedBy = objUI.UpdatedBy;
                                objDb.IsActive = objUI.IsActive;
                                // Submit changes to dbContext
                                dbContext.SubmitChanges();
                                // Show success message
                                msg = new Message(MessageConstants.I0001, MessageType.Info, " User admin '" + objDb.UserAdmin.UserName + "'", "updated");
                            }

                        }
                    }
                }
            }
            catch (Exception)
            {
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            return msg;
        }