Example #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.CurrentFileId == 0)
        {
            return;
        }
        ServiceManager sm          = new ServiceManager();
        bool           bSuccessful = false;

        using (LP2ServiceClient service = sm.StartServiceClient())
        {
            ReassignLoanRequest req = new ReassignLoanRequest();
            req.hdr = new ReqHdr();
            req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data
            req.hdr.UserId        = CurrentUser.iUserID;
            ReassignUserInfo uInfo = new ReassignUserInfo();

            uInfo.FileId = this.CurrentFileId;
            uInfo.RoleId = int.Parse(ddlRole.SelectedValue);
            if (ddlUsers.SelectedValue != "")
            {
                uInfo.NewUserId = int.Parse(ddlUsers.SelectedValue);
            }
            else
            {
                uInfo.NewUserId = 0;
            }
            List <ReassignUserInfo> uList = new List <ReassignUserInfo>();
            uList.Add(uInfo);
            req.reassignUsers = uList.ToArray();
            ReassignLoanResponse respone = null;
            try
            {
                ReassignProspect(service);

                respone = service.ReassignLoan(req);

                if (respone.hdr.Successful)
                {
                    LPWeb.Model.LoanTeam lcModel = new LPWeb.Model.LoanTeam();
                    lcModel.FileId = CurrentFileId;
                    lcModel.RoleId = uInfo.RoleId;
                    lcModel.UserId = uInfo.NewUserId;

                    LPWeb.Model.LoanTeam oldlcModel = new LPWeb.Model.LoanTeam();
                    oldlcModel.FileId = CurrentFileId;
                    oldlcModel.RoleId = oldRoleID;
                    oldlcModel.UserId = oldUserID;

                    LPWeb.BLL.LoanTeam lc = new LoanTeam();

                    //lc.Reassign(oldlcModel, lcModel, req.hdr.UserId, ddlRole.SelectedItem.Text, ddlUsers.SelectedItem.Text);
                    lc.Reassign(oldlcModel, lcModel, req.hdr.UserId);

                    bSuccessful = true;
                }
                else
                {
                    bSuccessful = false;
                }
                if (bSuccessful)
                {
                    PageCommon.WriteJsEnd(this, "Reassigned loan successfully", "window.parent.RefreshPage();" + this.hdnCloseDialogCodes.Value);
                }
                else
                {
                    PageCommon.WriteJsEnd(this, string.Format("Failed to reassign loan, reason:{0}.", respone.hdr.StatusInfo), PageCommon.Js_RefreshSelf);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException ex)
            {
                LPLog.LogMessage(ex.Message);
                PageCommon.WriteJsEnd(this, "Failed to reassign loan, reason: Point Manager is not running.", PageCommon.Js_RefreshSelf);
            }
            catch (Exception exception)
            {
                LPLog.LogMessage(exception.Message);
                PageCommon.WriteJsEnd(this, string.Format("Failed to reassign loan, reason:{0}.", exception.Message), PageCommon.Js_RefreshSelf);
            }
        }
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // json示例
        // {"ExecResult":"Success","ErrorMsg":""}
        // {"ExecResult":"Failed","ErrorMsg":"错误信息"}

        int iFileID     = 0;
        int iUserID     = 0;
        int iLoanRoleID = 0;

        int iCurrrentUserID = this.CurrUser.iUserID;

        #region 校验页面参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "FileID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}");
            this.Response.End();
        }
        string sFileID = this.Request.QueryString["FileID"];
        iFileID = Convert.ToInt32(sFileID);

        bIsValid = PageCommon.ValidateQueryString(this, "UserID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}");
            this.Response.End();
        }
        string sUserID = this.Request.QueryString["UserID"];
        iUserID = Convert.ToInt32(sUserID);

        bIsValid = PageCommon.ValidateQueryString(this, "LoanRoleID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}");
            this.Response.End();
        }
        string sLoanRoleID = this.Request.QueryString["LoanRoleID"];
        iLoanRoleID = Convert.ToInt32(sLoanRoleID);

        #endregion

        ServiceManager sm = new ServiceManager();
        using (LP2ServiceClient service = sm.StartServiceClient())
        {
            #region 调用ReassignProspect

            #region Build ReassignProspectRequest

            ReassignProspectRequest rpq = new ReassignProspectRequest();
            rpq.hdr    = new ReqHdr();
            rpq.FileId = new int[1] {
                iFileID
            };
            rpq.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data
            rpq.hdr.UserId        = iCurrrentUserID;
            rpq.FromUser          = 0;
            rpq.ToUser            = iUserID;
            rpq.ContactId         = null;
            rpq.UserId            = null;

            #endregion

            #region invoke ReassignProspect

            bool   bSuccess = false;
            string sError   = string.Empty;
            try
            {
                ReassignProspectResponse rpp = service.ReassignProspect(rpq);
                bSuccess = rpp.hdr.Successful;

                if (bSuccess == false)
                {
                    sError = "Failed to invoke API ReassignProspect.";
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException ex)
            {
                bSuccess = false;
                sError   = "Exception happened: Point Manager is not running.";

                LPLog.LogMessage(ex.Message);
            }
            catch (Exception exception)
            {
                bSuccess = false;
                sError   = "Exception happened when invoke API ReassignProspect.";

                LPLog.LogMessage(exception.Message);
            }
            finally
            {
                if (bSuccess == false)
                {
                    this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sError + "\"}");
                    this.Response.End();
                }
            }

            #endregion

            #endregion

            #region 调用ReassignLoan

            #region Build ReassignLoanRequest

            ReassignLoanRequest req = new ReassignLoanRequest();
            req.hdr = new ReqHdr();
            req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data
            req.hdr.UserId        = iCurrrentUserID;

            List <ReassignUserInfo> UserList = new List <ReassignUserInfo>();

            ReassignUserInfo UserInfo = new ReassignUserInfo();
            UserInfo.FileId    = iFileID;
            UserInfo.RoleId    = iLoanRoleID;
            UserInfo.NewUserId = iUserID;
            UserList.Add(UserInfo);

            req.reassignUsers = UserList.ToArray();

            #endregion

            #region invoke api
            bSuccess = false;
            sError   = string.Empty;
            try
            {
                ReassignLoanResponse respone = service.ReassignLoan(req);
                bSuccess = respone.hdr.Successful;

                if (bSuccess == false)
                {
                    sError = "Failed to invoke API ReassignLoan.";
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException ex)
            {
                LPLog.LogMessage(ex.Message);

                bSuccess = false;
                sError   = "Exception happened: Point Manager is not running.";
            }
            catch (Exception exception)
            {
                LPLog.LogMessage(exception.Message);

                bSuccess = false;
                sError   = "Exception happened when invoke API ReassignLoan.";
            }
            finally
            {
                if (bSuccess == false)
                {
                    this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sError + "\"}");
                    this.Response.End();
                }
            }
            #endregion

            #endregion
        }

        #region Reassign Loan Team

        LPWeb.Model.LoanTeam lcModel = new LPWeb.Model.LoanTeam();
        lcModel.FileId = iFileID;
        lcModel.RoleId = iLoanRoleID;
        lcModel.UserId = iUserID;

        LPWeb.Model.LoanTeam oldlcModel = new LPWeb.Model.LoanTeam();
        oldlcModel.FileId = iFileID;
        oldlcModel.RoleId = 0;
        oldlcModel.UserId = 0;

        LPWeb.BLL.LoanTeam LoanTeam1 = new LPWeb.BLL.LoanTeam();
        LoanTeam1.Reassign(oldlcModel, lcModel, iCurrrentUserID);

        #endregion

        this.Response.Write("{\"ExecResult\":\"Success\",\"ErrorMsg\":\"\"}");
        this.Response.End();
    }
Example #3
0
        /// <summary>
        /// Delete all user info when click "Delete" button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            bool           bRessignSuccess = false;
            ServiceManager sm1             = new ServiceManager();

            using (LP2ServiceClient service = sm1.StartServiceClient())
            {
                ReassignLoanRequest req = new ReassignLoanRequest();
                req.hdr = new ReqHdr();
                req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data
                req.hdr.UserId        = CurrUser.iUserID;

                // get all loans assigned to this user
                DataSet dsUserLoan      = LoanTeamManager.GetUserLoan(UserId.Value);
                int     nReassignUserId = 0;
                if (!int.TryParse(this.hiReassignUserId.Value, out nReassignUserId))
                {
                    nReassignUserId = 0;
                }
                if (null != dsUserLoan && dsUserLoan.Tables.Count > 0 && dsUserLoan.Tables[0].Rows.Count > 0)
                {
                    List <ReassignUserInfo> uList = new List <ReassignUserInfo>();

                    Model.Users      userToDelete = UsersManager.GetModel(UserId.Value);
                    ReassignUserInfo uInfo        = null;
                    foreach (DataRow drUserLoan in dsUserLoan.Tables[0].Rows)
                    {
                        uInfo           = new ReassignUserInfo();
                        uInfo.FileId    = int.Parse(string.Format("{0}", drUserLoan["FileId"]));
                        uInfo.RoleId    = int.Parse(string.Format("{0}", drUserLoan["RoleId"]));
                        uInfo.NewUserId = nReassignUserId;
                        uList.Add(uInfo);
                    }

                    req.reassignUsers = uList.ToArray();
                    ReassignLoanResponse respone = null;
                    try
                    {
                        respone = service.ReassignLoan(req);
                        if (respone.hdr.Successful)
                        {
                            bool st = true;

                            int fileId    = 0;
                            int newUserId = 0;
                            int roleId    = 0;
                            int requester = req.hdr.UserId;

                            foreach (ReassignUserInfo u in req.reassignUsers)
                            {
                                fileId    = u.FileId;
                                newUserId = u.NewUserId;
                                roleId    = u.RoleId;

                                st = LPWeb.BLL.WorkflowManager.ReassignLoan(fileId, newUserId, UserId.Value, roleId, requester);
                            }
                            bRessignSuccess = true;
                        }
                        else
                        {
                            PageCommon.AlertMsg(this, "Failed to reassign loan, reason:" + respone.hdr.StatusInfo);
                            CloseMe(true, true);
                            return;
                        }
                    }
                    catch (System.ServiceModel.EndpointNotFoundException ex)
                    {
                        LPLog.LogMessage(ex.Message);
                        PageCommon.AlertMsg(this, "Failed to reassign loan, reason: User Manager is not running.");
                        CloseMe(true, true);
                    }
                    catch (Exception exception)
                    {
                        LPLog.LogMessage(exception.Message);
                        PageCommon.AlertMsg(this, string.Format("Failed to reassign loan, reason:{0}.", exception.Message));
                        CloseMe(true, true);
                    }
                }
                else
                {
                    bRessignSuccess = true;
                }

                if (bRessignSuccess)
                {
                    UsersManager.DeleteUserInfo(UserId.Value, null, null, CurrUser.iUserID, nReassignUserId);
                    LPLog.LogMessage(string.Format("User {0} deleted successfully.", this.tbUserName.Text));
                    CloseMe(true, true);

                    try
                    {
                        ServiceManager sm = new ServiceManager();
                        using (LP2ServiceClient service2 = sm.StartServiceClient())
                        {
                            UpdateADUserRequest uReq = new UpdateADUserRequest();
                            ReqHdr hdr = new ReqHdr();
                            hdr.UserId             = UserId.Value;
                            uReq.hdr               = hdr;
                            uReq.Command           = UserMgrCommandType.DeleteUser;
                            uReq.AD_OU_Filter      = this.lbPrefix.Text;
                            uReq.AD_User           = new LP_Service.User();
                            uReq.AD_User.Username  = this.tbUserName.Text;
                            uReq.AD_User.Firstname = this.tbFirstName.Text;
                            uReq.AD_User.Lastname  = this.tbLastName.Text;
                            uReq.AD_User.Email     = this.tbEmail.Text;
                            uReq.AD_User.Enabled   = this.ckbEnabled.Checked;

                            UpdateADUserResponse uResponse;
                            uResponse = service2.UpdateADUser(uReq);
                            if (!uResponse.hdr.Successful)
                            {
                                PageCommon.AlertMsg(this, "Failed to delete user in AD, reason:" + uResponse.hdr.StatusInfo);
                                LPLog.LogMessage(LogType.Logerror, "Failed to delete user in AD. UserID: " + UserId.ToString());
                            }
                        }
                    }
                    catch (System.ServiceModel.EndpointNotFoundException ee)
                    {
                        LPLog.LogMessage(ee.Message);
                        PageCommon.AlertMsg(this, "Failed to delete user in AD, reason: User Manager is not running.");
                    }
                    catch (Exception ex)
                    {
                        PageCommon.AlertMsg(this, "Failed to delete user in AD, reason: " + ex.Message);
                        LPLog.LogMessage(LogType.Logerror, "Error occured while trying to delete user in AD: " + ex.Message);
                    }
                }
            }
        }
Example #4
0
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            Dictionary <int, int> dicIDs = new Dictionary <int, int>();

            // Get userid of current selected row
            foreach (GridViewRow row in gridUserList.Rows)
            {
                if (DataControlRowType.DataRow == row.RowType)
                {
                    CheckBox ckbChecked = row.FindControl("ckbSelected") as CheckBox;
                    if (null != ckbChecked && ckbChecked.Checked)
                    {
                        dicIDs.Add(row.RowIndex, (int)gridUserList.DataKeys[row.RowIndex].Value);
                        originalUserId = (int)gridUserList.DataKeys[row.RowIndex].Value;
                    }
                }
            }
            if (dicIDs.Count > 0)
            {
                ReassignProspect(originalUserId);
                try
                {
                    // get all loans assigned to this user, dicIDs must have only one item in this case
                    DataSet dsUserLoan      = LoanTeamManager.GetUserLoan(dicIDs.FirstOrDefault().Value);
                    int     nReassignUserId = 0;
                    if (!int.TryParse(this.hiReassignUserId.Value, out nReassignUserId))
                    {
                        nReassignUserId = 0;
                    }
                    if (null != dsUserLoan && dsUserLoan.Tables.Count > 0 && dsUserLoan.Tables[0].Rows.Count > 0)
                    {
                        ServiceManager sm1 = new ServiceManager();
                        using (LP2ServiceClient service = sm1.StartServiceClient())
                        {
                            ReassignLoanRequest req = new ReassignLoanRequest();
                            req.hdr = new ReqHdr();
                            req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data
                            req.hdr.UserId        = CurrUser.iUserID;
                            List <ReassignUserInfo> uList = new List <ReassignUserInfo>();

                            Model.Users      userToDelete = UsersManager.GetModel(dicIDs.FirstOrDefault().Value);
                            ReassignUserInfo uInfo        = null;
                            foreach (DataRow drUserLoan in dsUserLoan.Tables[0].Rows)
                            {
                                uInfo           = new ReassignUserInfo();
                                uInfo.FileId    = int.Parse(string.Format("{0}", drUserLoan["FileId"]));
                                uInfo.RoleId    = int.Parse(string.Format("{0}", drUserLoan["RoleId"]));
                                uInfo.NewUserId = nReassignUserId;
                                uList.Add(uInfo);
                            }

                            req.reassignUsers = uList.ToArray();

                            ReassignLoanResponse respone = null;
                            try
                            {
                                respone = service.ReassignLoan(req);

                                if (respone.hdr.Successful)
                                {
                                    bool st = true;

                                    int fileId    = 0;
                                    int newUserId = 0;
                                    int roleId    = 0;
                                    int requester = req.hdr.UserId;

                                    foreach (ReassignUserInfo u in req.reassignUsers)
                                    {
                                        fileId    = u.FileId;
                                        newUserId = u.NewUserId;
                                        roleId    = u.RoleId;

                                        st = LPWeb.BLL.WorkflowManager.ReassignLoan(fileId, newUserId, originalUserId, roleId, requester);
                                    }

                                    UsersManager.DeleteUsers(dicIDs.Select(i => i.Value).ToList(), CurrUser.iUserID, nReassignUserId);
                                }
                                else
                                {
                                    //   PageCommon.WriteJsEnd(this, string.Format("Failed to reassign loan, reason:{0}.", respone.hdr.StatusInfo), PageCommon.Js_RefreshSelf);
                                    //   return;
                                }
                            }
                            catch (System.ServiceModel.EndpointNotFoundException ex)
                            {
                                LPLog.LogMessage(ex.Message);
                                //    PageCommon.WriteJsEnd(this, "Failed to reassign loan, reason: Point Manager is not running.", PageCommon.Js_RefreshSelf);
                            }
                            catch (Exception exception)
                            {
                                LPLog.LogMessage(exception.Message);
                                //    PageCommon.WriteJsEnd(this, string.Format("Failed to reassign loan, reason:{0}.", exception.Message), PageCommon.Js_RefreshSelf);
                            }
                        }
                    }
                    else
                    {
                        UsersManager.DeleteUsers(dicIDs.Select(i => i.Value).ToList(), CurrUser.iUserID, nReassignUserId);
                    }

                    BindGrid();
                }
                catch (Exception ex)
                {
                    ClientFun(this.updatePanel, "failedtodeleteuserinad", "alert('Failed to delete the selected user account(s), please try it again.');");
                    //PageCommon.AlertMsg(this, "Failed to delete the selected users, please try it again.");
                    LPLog.LogMessage(LogType.Logerror, "Failed to delete the selected user account(s): " + ex.Message);
                    return;
                }

                try
                {
                    UpdateAD(dicIDs, UserMgrCommandType.DeleteUser);
                }
                catch (Exception ex)
                {
                    ClientFun(this.updatePanel, "failed to delete user in ad", string.Format("alert('Failed to delete the selected user account(s) in AD, Exception: {0}');", ex.Message.Replace("'", "\"")));
                    //PageCommon.AlertMsg(this, "Failed to delete the selected user account in AD.");
                    LPLog.LogMessage(LogType.Logerror, "Failed to delete the selected user account(s), exception: " + ex.Message);
                    return;
                }
            }
        }