示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(Request.QueryString["needret"]))
        {
            strNeedReturn = "0";
        }
        else
        {
            strNeedReturn = "1";
        }

        if (this.IsPostBack == false)
        {
            #region 加载email template
            LoanTasks      LoanTaskManager  = new LoanTasks();
            Template_Email EmailTempManager = new Template_Email();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1");

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an email template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

            this.ddlRecomActionTemplate.DataSource = EmailTemplates;
            this.ddlRecomActionTemplate.DataBind();

            this.ddlAlertEmailTemplate.DataSource = EmailTemplates;
            this.ddlAlertEmailTemplate.DataBind();

            #endregion
        }
    }
示例#2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (this.IsPostBack == false)
     {
         if (this.CurrUser.RemindTaskDue == true && this.CurrUser.TaskReminder != null)
         {
             LoanTasks LoanTaskManager  = new LoanTasks();
             DataTable ReminderTaskList = LoanTaskManager.GetReminderTaskList(this.CurrUser.iUserID, (int)this.CurrUser.TaskReminder);
             this.gridTaskList.DataSource = ReminderTaskList;
             this.gridTaskList.DataBind();
         }
     }
 }
示例#3
0
        protected void btnComplete_Click(object sender, EventArgs e)
        {
            if (hfdFileId.Value.Trim() == "")
            {
                PageCommon.AlertMsg(this, "Invalid parameter:'File ID'.");
                return;
            }

            LoanTasks bllLoanTask = new LoanTasks();

            var dtTasks = new List <Model.LoanTasks>();

            if (hfdTaskId.Value.Trim() != "")
            {
                dtTasks = bllLoanTask.GetModelList("LoanTaskId=" + hfdTaskId.Value);
            }
            else
            {
                dtTasks = bllLoanTask.GetModelList("FileId=" + hfdFileId.Value);
            }

            if (dtTasks == null || dtTasks.Count == 0)
            {
                PageCommon.AlertMsg(this, "There is no tasks in database.");
                return;
            }

            Dictionary <int, int> successTasks = new Dictionary <int, int>();
            int userId     = new LoginUser().iUserID;
            int emailTmpId = 0;

            foreach (var task in dtTasks)
            {
                bool bIsSuccess = DAL.WorkflowManager.CompleteTask(task.LoanTaskId, userId, ref emailTmpId);
                if (bIsSuccess == true)
                {
                    successTasks.Add(task.LoanTaskId, emailTmpId);
                }
            }

            if (successTasks.Count == dtTasks.Count)
            {
                PageCommon.RegisterJsMsg(this, "Completed task(s) Successfuly!", "parent.closeDialog();");
                //PageCommon.AlertMsg(this,"Complete task(s) Successfuly!");
            }
            else
            {
                PageCommon.RegisterJsMsg(this, "There are " + successTasks.Count + " success and " + (dtTasks.Count - successTasks.Count) + " failture of " + dtTasks.Count + " Tasks.", "parent.closeDialog();");
                //PageCommon.AlertMsg(this, "There are " + successTasks.Count + " success and " + (dtTasks.Count - successTasks.Count) + " failture of " + dtTasks.Count + " Tasks.");
            }
        }
示例#4
0
    protected void btnSnooze_Click(object sender, EventArgs e)
    {
        string sMinutes = this.txtMinutes.Text.Trim();
        int    iMinutes = Convert.ToInt32(sMinutes);

        LoanTasks LoanTaskManager = new LoanTasks();

        LoanTaskManager.SnoozeTask(this.sTaskIDs, iMinutes);

        // success
        if (this.Request.QueryString["All"] == null)
        {
            PageCommon.WriteJsEnd(this, "Snooze successfully.", PageCommon.Js_RefreshParent);
        }
        else
        {
            PageCommon.WriteJsEnd(this, "Snooze successfully.", "window.parent.parent.CloseGlobalPopup();");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        string sJsCloseDialog = "$('#divContainer').hide();window.parent.CloseGlobalDialog();";

        bool bIsValid = PageCommon.ValidateQueryString(this, "TemplateID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "alert('Missing required query string.');" + sJsCloseDialog, true);
            return;
        }
        this.iTemplateID = Convert.ToInt32(this.Request.QueryString["TemplateID"]);


        if (this.Request.QueryString["StageID"] != null)
        {
            bIsValid = PageCommon.ValidateQueryString(this, "StageID", QueryStringType.ID);
            if (bIsValid == false)
            {
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "alert('Missing required query string.');" + sJsCloseDialog, true);
                return;
            }
            this.iStageID = Convert.ToInt32(this.Request.QueryString["StageID"]);
        }

        #endregion

        #region 获取Workflow Template Name

        string    sSql = "select * from dbo.Template_Workflow where WflTemplId=" + this.iTemplateID;
        DataTable WorkflowTemplateInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql);
        if (WorkflowTemplateInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_m1", "alert('Invalid workflow template id.');" + sJsCloseDialog, true);
            return;
        }
        string sWorkflowTemplateName = WorkflowTemplateInfo.Rows[0]["Name"].ToString();
        this.tbxTemplateName.Text = sWorkflowTemplateName;

        #endregion

        if (this.IsPostBack == false)
        {
            #region 获取Workflow Stage List

            string    sSql2     = "select * from Template_Wfl_Stages where WflTemplId=" + this.iTemplateID;
            DataTable StageList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql2);

            DataRow NoneStageRow = StageList.NewRow();
            NoneStageRow["WflStageId"] = 0;
            NoneStageRow["Name"]       = "-- select an stage --";
            StageList.Rows.InsertAt(NoneStageRow, 0);

            this.ddlStage.DataSource = StageList;
            this.ddlStage.DataBind();

            this.ddlStage.SelectedValue = this.iStageID.ToString();

            #endregion

            #region 获取Default Owner

            string    sSql3    = "select * from Roles where Name<>'Executive' AND Name <>'Branch Manager'";
            DataTable RoleList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql3);

            DataView RoleView = new DataView(RoleList);
            RoleView.Sort            = "Name";
            this.ddlOwner.DataSource = RoleView;
            this.ddlOwner.DataBind();

            #endregion

            #region 获取Prerequisite

            string    sSql4       = "select * from Template_Wfl_Tasks where (PrerequisiteTaskId IS NULL OR PrerequisiteTaskId=0) AND WflStageId=" + this.iStageID;
            DataTable WflTaskList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql4);

            DataRow NoneWflTaskRow = WflTaskList.NewRow();
            NoneWflTaskRow["TemplTaskId"] = 0;
            NoneWflTaskRow["Name"]        = "";
            WflTaskList.Rows.InsertAt(NoneWflTaskRow, 0);

            this.ddlPrerequisiteTask.DataSource = WflTaskList;
            this.ddlPrerequisiteTask.DataBind();

            #endregion

            #region 加载email template

            LoanTasks      LoanTaskManager     = new LoanTasks();
            Template_Email EmailTempManager    = new Template_Email();
            DataTable      EmailTemplates      = EmailTempManager.GetEmailTemplate(" and Enabled = 1");
            DataTable      CmpltEmailTemplates = EmailTemplates.Copy();

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an Email Template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

            this.ddlWarningEmail.DataSource = EmailTemplates;
            this.ddlWarningEmail.DataBind();

            this.ddlOverdueEmail.DataSource = EmailTemplates;
            this.ddlOverdueEmail.DataBind();

            this.CmpltEmailTmpltText.DataSource = new DataView(CmpltEmailTemplates, "", "Name", DataViewRowState.CurrentRows);
            this.CmpltEmailTmpltText.DataBind();

            #endregion
        }
    }
        private void LoadTaskData()
        {
            this.tbxTemplateName.Text = "";

            this.tbxTaskName.Text                  = "";
            this.tbxDescription.Text               = "";
            this.ddlOwner.SelectedIndex            = -1;
            this.tbxDueDaysByDate.Text             = "";
            this.tbxDueDaysByTask.Text             = "";
            this.tbxDaysDueAfterCreationDate.Text  = "";
            this.ddlPrerequisiteTask.SelectedIndex = -1;
            this.ddlWarningEmail.SelectedIndex     = -1;
            //this.ddlCompletionEmail.SelectedIndex = -1;
            this.ddlOverdueEmail.SelectedIndex = -1;
            this.ddlStage.SelectedIndex        = -1;

            LPWeb.Model.Template_Wfl_Tasks model = null;
            try
            {
                Template_Workflow             templateMgr = new Template_Workflow();
                LPWeb.Model.Template_Workflow tempModel   = new Model.Template_Workflow();
                tempModel = templateMgr.GetModel(this.iTemplateID);

                Template_Wfl_Stages             wflStageMgr = new Template_Wfl_Stages();
                LPWeb.Model.Template_Wfl_Stages stageModel  = new Model.Template_Wfl_Stages();

                this.iCalculationMethod = tempModel.CalculationMethod;
                if (this.iStageID != 0)
                {
                    stageModel = wflStageMgr.GetModel(this.iStageID);
                    if (stageModel.CalculationMethod.ToString() != "" && stageModel.CalculationMethod.ToString() != "0")
                    {
                        iCalculationMethod = int.Parse(stageModel.CalculationMethod.ToString());
                    }
                }

                this.tbxTemplateName.Text = tempModel.Name;


                model = this.taskTmpMgr.GetModel(this.iTaskID);
                if (this.iTaskID == 0 || model == null)
                {
                    if (this.iTemplateID != 0)
                    {
                        if (this.iStageID != 0)
                        {
                            this.ddlStage.SelectedValue = this.iStageID.ToString();
                        }
                    }
                    this.chkEnable.Checked = true;
                    return;
                }
                //Get Template Name by taskid
                this.ddlStage.SelectedValue            = model.WflStageId.ToString();
                this.tbxTaskName.Text                  = model.Name;
                this.tbxDescription.Text               = model.Description;
                this.ddlOwner.SelectedValue            = model.OwnerRoleId.ToString();
                this.tbxDueDaysByDate.Text             = model.DaysDueFromCoe.ToString();
                this.tbxDueDaysByTask.Text             = model.DaysDueAfterPrerequisite.ToString();
                this.tbxDaysDueAfterCreationDate.Text  = model.DaysFromCreation.ToString();
                this.ddlPrerequisiteTask.SelectedValue = model.PrerequisiteTaskId.ToString();
                if (this.ddlPrerequisiteTask.SelectedIndex > 0)
                {
                    this.ddlStage.Enabled = false;
                }
                if (model.Enabled)
                {
                    this.chkEnable.Checked = true;
                }
                else
                {
                    this.chkEnable.Checked = false;
                }

                if (model.ExternalViewing)
                {
                    this.chkExternalViewing.Checked = true;
                }
                else
                {
                    this.chkExternalViewing.Checked = false;
                }

                //
                if (iCalculationMethod == 1)
                {
                    this.tbxDueDaysByDate.Enabled = true;
                    if (model.DaysFromCreation.ToString() == "" || model.DaysFromCreation.ToString() == "0")
                    {
                        this.tbxDaysDueAfterCreationDate.Enabled = false;
                    }
                    //this.tbxDaysDueAfterCreationDate.Text = "";
                }
                else if (iCalculationMethod == 2)
                {
                    if (model.DaysDueFromCoe.ToString() == "" || model.DaysDueFromCoe.ToString() == "0")
                    {
                        this.tbxDueDaysByDate.Enabled = false;
                    }
                    //this.tbxDueDaysByDate.Text = "";
                    this.tbxDaysDueAfterCreationDate.Enabled = true;
                }

                this.ddlWarningEmail.SelectedValue = model.WarningEmailId.ToString();
                //this.ddlCompletionEmail.SelectedValue = model.CompletionEmailId.ToString();
                this.ddlOverdueEmail.SelectedValue = model.OverdueEmailId.ToString();

                //Set prerequisitetask status base on taskid
                DataTable dtTask = this.taskTmpMgr.GetList(" PrerequisiteTaskId=" + this.iTaskID.ToString()).Tables[0];
                if (dtTask.Rows.Count > 0)
                {
                    this.ddlPrerequisiteTask.SelectedIndex    = -1;
                    this.tbxDueDaysByTask.Text                = "";
                    this.tbxDueDaysByTask.ReadOnly            = true;
                    this.tbxDaysDueAfterCreationDate.Text     = "";
                    this.tbxDaysDueAfterCreationDate.ReadOnly = true;
                    this.ddlPrerequisiteTask.Enabled          = false;
                    this.ddlStage.Enabled      = false;
                    this.hdnIsDependTask.Value = "true";
                }
                //Check Referenced
                LoanTasks loanTaskMgr = new LoanTasks();
                if (loanTaskMgr.GetLoanTaskList(" AND a.TemplTaskId=" + this.iTaskID.ToString()).Rows.Count > 0)
                {
                    this.hdnIsReferenced.Value = "true";
                }
                this.hdnTaskID.Value = this.iTaskID.ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        string sJsCloseDialog = "$('#divContainer').hide();window.parent.CloseGlobalDialog();";

        bool bIsValid = PageCommon.ValidateQueryString(this, "TemplateID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "alert('Missing required query string.');" + sJsCloseDialog, true);
            return;
        }
        this.iTemplateID = Convert.ToInt32(this.Request.QueryString["TemplateID"]);


        if (this.Request.QueryString["StageID"] != null)
        {
            bIsValid = PageCommon.ValidateQueryString(this, "StageID", QueryStringType.ID);
            if (bIsValid == false)
            {
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "alert('Missing required query string.');" + sJsCloseDialog, true);
                return;
            }
            this.iStageID = Convert.ToInt32(this.Request.QueryString["StageID"]);
        }

        bIsValid = PageCommon.ValidateQueryString(this, "TaskID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "alert('Missing required query string.');" + sJsCloseDialog, true);
            return;
        }
        this.iTaskID = Convert.ToInt32(this.Request.QueryString["TaskID"]);

        #endregion

        #region 获取Workflow Template Name

        string    sSql = "select * from dbo.Template_Workflow where WflTemplId=" + this.iTemplateID;
        DataTable WorkflowTemplateInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql);
        if (WorkflowTemplateInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_m1", "alert('Invalid workflow template id.');" + sJsCloseDialog, true);
            return;
        }
        string sWorkflowTemplateName = WorkflowTemplateInfo.Rows[0]["Name"].ToString();
        this.tbxTemplateName.Text = sWorkflowTemplateName;

        #endregion

        #region 加载Workflow Task信息

        string    sSql4    = "select * from Template_Wfl_Tasks where TemplTaskId=" + this.iTaskID;
        DataTable TaskInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql4);
        if (TaskInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_m2", "alert('Invalid workflow task id.');" + sJsCloseDialog, true);
            return;
        }

        #endregion

        //Check Referenced
        LoanTasks loanTaskMgr = new LoanTasks();
        if (loanTaskMgr.GetLoanTaskList(" AND a.TemplTaskId=" + this.iTaskID.ToString()).Rows.Count > 0)
        {
            this.hdnIsReferenced.Value = "true";
        }

        // __doPostBack
        this.GetPostBackEventReference(this.btnClone1);

        if (this.IsPostBack == false)
        {
            #region 获取Workflow Stage List

            string    sSql2     = "select * from Template_Wfl_Stages where WflTemplId=" + this.iTemplateID;
            DataTable StageList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql2);

            DataRow NoneStageRow = StageList.NewRow();
            NoneStageRow["WflStageId"] = 0;
            NoneStageRow["Name"]       = "-- select an stage --";
            StageList.Rows.InsertAt(NoneStageRow, 0);

            this.ddlStage.DataSource = StageList;
            this.ddlStage.DataBind();

            this.ddlStage.SelectedValue = this.iStageID.ToString();

            #endregion

            #region 获取Default Owner

            string    sSql3    = "select * from Roles where Name<>'Executive' AND Name <>'Branch Manager'";
            DataTable RoleList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql3);

            DataView RoleView = new DataView(RoleList);
            RoleView.Sort            = "Name";
            this.ddlOwner.DataSource = RoleView;
            this.ddlOwner.DataBind();

            #endregion

            #region 获取Prerequisite

            string    sSql6       = "select * from Template_Wfl_Tasks where (PrerequisiteTaskId IS NULL OR PrerequisiteTaskId=0) AND WflStageId=" + this.iStageID;
            DataTable WflTaskList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql6);

            DataRow NoneWflTaskRow = WflTaskList.NewRow();
            NoneWflTaskRow["TemplTaskId"] = 0;
            NoneWflTaskRow["Name"]        = "";
            WflTaskList.Rows.InsertAt(NoneWflTaskRow, 0);

            this.ddlPrerequisiteTask.DataSource = WflTaskList;
            this.ddlPrerequisiteTask.DataBind();

            #endregion

            #region 加载email template

            LoanTasks      LoanTaskManager  = new LoanTasks();
            Template_Email EmailTempManager = new Template_Email();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1");
            this.CmpltEmailTemplates = EmailTemplates.Copy();

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an Email Template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

            this.ddlWarningEmail.DataSource = EmailTemplates;
            this.ddlWarningEmail.DataBind();

            this.ddlOverdueEmail.DataSource = EmailTemplates;
            this.ddlOverdueEmail.DataBind();

            this.CmpltEmailTmpltText.DataSource = new DataView(this.CmpltEmailTemplates, "", "Name", DataViewRowState.CurrentRows);
            this.CmpltEmailTmpltText.DataBind();

            #endregion

            #region 绑定数据

            this.tbxTaskName.Text           = TaskInfo.Rows[0]["Name"].ToString();
            this.chkEnable.Checked          = Convert.ToBoolean(TaskInfo.Rows[0]["Enabled"]);
            this.chkExternalViewing.Checked = TaskInfo.Rows[0]["ExternalViewing"] == DBNull.Value ? false : Convert.ToBoolean(TaskInfo.Rows[0]["ExternalViewing"]);

            this.txtSequence.Text    = TaskInfo.Rows[0]["SequenceNumber"].ToString();
            this.tbxDescription.Text = TaskInfo.Rows[0]["Description"].ToString();


            this.ddlOwner.SelectedValue           = TaskInfo.Rows[0]["OwnerRoleId"].ToString();
            this.tbxDueDaysByDate.Text            = TaskInfo.Rows[0]["DaysDueFromCoe"].ToString();
            this.tbxDaysDueAfterCreationDate.Text = TaskInfo.Rows[0]["DaysFromCreation"].ToString();


            this.txtDaysDueAfterPrevStage.Text = TaskInfo.Rows[0]["DaysDueAfterPrevStage"].ToString();

            this.ddlPrerequisiteTask.SelectedValue = TaskInfo.Rows[0]["PrerequisiteTaskId"].ToString() == string.Empty ? "0" : TaskInfo.Rows[0]["PrerequisiteTaskId"].ToString();

            this.tbxDueDaysByTask.Text = TaskInfo.Rows[0]["DaysDueAfterPrerequisite"].ToString();

            this.ddlWarningEmail.SelectedValue = TaskInfo.Rows[0]["WarningEmailId"].ToString() == string.Empty ? "0" : TaskInfo.Rows[0]["WarningEmailId"].ToString();
            this.ddlOverdueEmail.SelectedValue = TaskInfo.Rows[0]["OverdueEmailId"].ToString() == string.Empty ? "0" : TaskInfo.Rows[0]["OverdueEmailId"].ToString();

            #endregion

            #region 加载Completion Email List

            string    sSql5 = "select ROW_NUMBER() OVER (ORDER BY CompletionEmailId) AS RowIndex, * from Template_Wfl_CompletionEmails as a inner join Template_Email as b on a.TemplEmailId=b.TemplEmailId where TemplTaskid=" + this.iTaskID;
            DataTable CompletionEmailList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql5);

            this.gridCompletionEmailList.DataSource = CompletionEmailList;
            this.gridCompletionEmailList.DataBind();

            #endregion

            // set counter
            this.hdnCounter.Value = CompletionEmailList.Rows.Count.ToString();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 接收参数

        if (this.Request.QueryString["TaskIDs"] == null)
        {
            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}");
            return;
        }
        string sTaskIDs = this.Request.QueryString["TaskIDs"].ToString();
        if (Regex.IsMatch(sTaskIDs, @"^([1-9]\d*)(,[1-9]\d*)*$") == false)
        {
            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Invalid query string[" + sTaskIDs + "].\"}");
            return;
        }

        // LoanID
        bool bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}");
            return;
        }
        string sLoanID = this.Request.QueryString["LoanID"].ToString();
        int    iLoanID = Convert.ToInt32(sLoanID);

        #endregion

        // json示例
        // {"ExecResult":"Success","ErrorMsg":""}
        // {"ExecResult":"Failed","ErrorMsg":"执行数据库脚本时发生错误。"}

        string sExecResult = string.Empty;
        string sErrorMsg   = string.Empty;
        string sLoanClosed = "No";
        string result      = "";
        bool   bIsSuccess  = false;
        try
        {
            // workflow api
            string[] TaskIDArray = sTaskIDs.Split(',');
            foreach (string sTaskID in TaskIDArray)
            {
                int iTaskID = Convert.ToInt32(sTaskID);

                #region get loan task info

                LoanTasks LoanTaskManager = new LoanTasks();
                DataTable LoanTaskInfo    = LoanTaskManager.GetLoanTaskInfo(iTaskID);
                if (LoanTaskInfo.Rows.Count == 0)
                {
                    sErrorMsg = "Failed to delete the tasks(s) invalid task id.";
                    return;
                }
                string sLoanStageID = LoanTaskInfo.Rows[0]["LoanStageId"].ToString();
                if (sLoanStageID == string.Empty)
                {
                    sErrorMsg = "Failed to delete the task(s) invalid Stage Id";
                    return;
                }
                int iLoanStageID = Convert.ToInt32(sLoanStageID);

                #endregion

                #region delete task

                bIsSuccess = LPWeb.DAL.WorkflowManager.DeleteTask(iTaskID, this.CurrUser.iUserID);

                if (bIsSuccess == false)
                {
                    sErrorMsg = "Failed to delete the task(s) due to a Workflow Manager problem.";
                    return;
                }
                bool StageCompletedAfter = LPWeb.BLL.WorkflowManager.StageCompleted(iLoanStageID);

                #endregion
                if (StageCompletedAfter)
                {
                    #region update point file stage

                    #region invoke PointManager.UpdateStage()

                    string sError = LoanTaskCommon.UpdatePointFileStage(iLoanID, this.CurrUser.iUserID, iLoanStageID);

                    // the last one, sleep 1 second
                    System.Threading.Thread.Sleep(1000);

                    if (sError == string.Empty) // success
                    {
                        bIsSuccess = true;
                        sErrorMsg  = "Deleted the task(s) successfully.";
                    }
                    else
                    {
                        sErrorMsg = "Deleted the task(s) but failed to update stage date in Point.";
                        return;
                    }

                    if (WorkflowManager.IsLoanClosed(iLoanID))
                    {
                        sLoanClosed = "Yes";
                    }

                    #endregion

                    #endregion
                }
            }
            return;
        }
        catch (Exception ex)
        {
            sErrorMsg = "Failed to delete selected task(s): " + ex.ToString().Replace("\"", "\\\"");
            return;
        }
        finally
        {
            string sEmailTemplateID = "";
            if (bIsSuccess)
            {
                result = "{\"ExecResult\":\"Success\",\"ErrorMsg\":\"" + sErrorMsg + "\",\"EmailTemplateID\":\"" + sEmailTemplateID + "\",\"LoanClosed\":\"" + sLoanClosed + "\"}";
            }
            else
            {
                result = "{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sErrorMsg + "\"}";
            }
            Response.Write(result);
        }
    }
示例#9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验必要参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "RuleID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "$('#divContainer').hide();alert('Missing required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        this.iRuleID = Convert.ToInt32(this.Request.QueryString["RuleID"]);

        #endregion

        #region 加载Rule信息
        Template_Rules RuleManager = new Template_Rules();
        DataTable      RuleInfo    = RuleManager.GetRuleInfo(this.iRuleID);
        if (RuleInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Invalid", "$('#divContainer').hide();alert('Invalid required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        #endregion

        if (this.IsPostBack == false)
        {
            #region 加载email template
            LoanTasks      LoanTaskManager  = new LoanTasks();
            Template_Email EmailTempManager = new Template_Email();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1");

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an email template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

            this.ddlRecomActionTemplate.DataSource = EmailTemplates;
            this.ddlRecomActionTemplate.DataBind();

            this.ddlAlertEmailTemplate.DataSource = EmailTemplates;
            this.ddlAlertEmailTemplate.DataBind();

            #endregion

            #region 加载Conditions

            DataTable ConditionListData = RuleManager.GetConditionList(this.iRuleID);

            this.hdnTolerances.Text = "";
            string Tol = "";
            foreach (DataRow dr in ConditionListData.Rows)
            {
                if ((dr["Tolerance"] != DBNull.Value) &&
                    (dr["Tolerance"] != string.Empty))
                {
                    Tol = (string)dr["Tolerance"];
                }
                else
                {
                    Tol = "";
                }

                if (this.hdnTolerances.Text == "")
                {
                    this.hdnTolerances.Text = "[$" + Tol + "$]";
                }
                else
                {
                    this.hdnTolerances.Text += ",[$" + Tol + "$]";
                }
            }

            this.gridConditionList.DataSource = ConditionListData;
            this.gridConditionList.DataBind();

            #endregion

            #region 绑定数据

            this.txtRuleName.Text   = "Copy of " + RuleInfo.Rows[0]["Name"].ToString();
            this.txtDesc.Text       = RuleInfo.Rows[0]["Desc"].ToString();
            this.chkEnabled.Checked = Convert.ToBoolean(RuleInfo.Rows[0]["Enabled"]);
            this.ddlRecomActionTemplate.SelectedValue = RuleInfo.Rows[0]["RecomEmailTemplid"].ToString();
            this.ddlAlertEmailTemplate.SelectedValue  = RuleInfo.Rows[0]["AlertEmailTemplId"].ToString();
            this.chkReqAck.Checked      = Convert.ToBoolean(RuleInfo.Rows[0]["AckReq"]);
            this.txtFormula.Text        = RuleInfo.Rows[0]["AdvFormula"].ToString();
            this.ddlScope.SelectedValue = RuleInfo.Rows[0]["RuleScope"].ToString();

            #region get loan target

            //this.ddlTarget.SelectedValue = RuleInfo.Rows[0]["LoanTarget"].ToString();

            LPWeb.Model.Template_Rules_LoanTarget modelLoanTarget;
            if (!RuleInfo.Rows[0].IsNull("LoanTarget"))
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget(Convert.ToInt16(RuleInfo.Rows[0]["LoanTarget"]));
            }
            else
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget();
            }

            this.chkTargetActiveLoans.Checked   = modelLoanTarget.ActiveLoans;
            this.chkTargetActiveLeads.Checked   = modelLoanTarget.ActiveLeads;
            this.chkTargetArchivedLoans.Checked = modelLoanTarget.ArchivedLoans;
            this.chkTargetArchivedLeads.Checked = modelLoanTarget.ArchivedLeads;

            #endregion

            #endregion

            // set counter
            this.hdnCounter.Value = ConditionListData.Rows.Count.ToString();
        }
    }
示例#10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 接收参数

        // TaskID
        bool bIsValid = PageCommon.ValidateQueryString(this, "TaskID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}");
            return;
        }
        string sTaskID = this.Request.QueryString["TaskID"].ToString();
        int    iTaskID = Convert.ToInt32(sTaskID);

        // LoanID
        bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}");
            return;
        }
        string sLoanID = this.Request.QueryString["LoanID"].ToString();
        int    iLoanID = Convert.ToInt32(sLoanID);

        #endregion

        // json示例
        // {"ExecResult":"Success","ErrorMsg":"","EmailTemplateID":"1", "LoanClosed":"Yes"}
        // {"ExecResult":"Failed","ErrorMsg":"执行数据库脚本时发生错误。"}

        string sErrorMsg        = string.Empty;
        string sEmailTemplateID = string.Empty;
        bool   bIsSuccess       = false;
        string LoanClosed       = "No";
        var    result           = "";
        try
        {
            #region complete task

            int iEmailTemplateId = 0;
            bIsSuccess = LPWeb.DAL.WorkflowManager.CompleteTask(iTaskID, this.CurrUser.iUserID, ref iEmailTemplateId);

            if (bIsSuccess == false)
            {
                sErrorMsg = "Failed to invoke WorkflowManager.CompleteTask.";
                return;
            }

            if (iEmailTemplateId != 0)
            {
                sEmailTemplateID = iEmailTemplateId.ToString();
            }

            #endregion

            #region update point file stage

            int iLoanStageID = 0;

            #region get loan task info

            LoanTasks LoanTaskManager = new LoanTasks();
            DataTable LoanTaskInfo    = LoanTaskManager.GetLoanTaskInfo(iTaskID);
            if (LoanTaskInfo.Rows.Count == 0)
            {
                bIsSuccess = false;
                sErrorMsg  = "Invalid task id.";
                return;
            }
            string sLoanStageID = LoanTaskInfo.Rows[0]["LoanStageId"].ToString();
            if (sLoanStageID == string.Empty)
            {
                bIsSuccess = false;
                sErrorMsg  = "Invalid loan stage id.";
                return;
            }
            iLoanStageID = Convert.ToInt32(sLoanStageID);

            #endregion
            bIsSuccess = true;
            if (!WorkflowManager.StageCompleted(iLoanStageID))
            {
                sErrorMsg = "Completed task successfully.";
                return;
            }

            #region invoke PointManager.UpdateStage()

            //add by  gdc 20111212  Bug #1306
            LPWeb.BLL.PointFiles pfile = new PointFiles();
            var model = pfile.GetModel(iLoanID);
            if (model != null && !string.IsNullOrEmpty(model.Name.Trim()))
            {
                #region check Point File Status first
                ServiceManager sm = new ServiceManager();
                using (LP2ServiceClient service = sm.StartServiceClient())
                {
                    CheckPointFileStatusReq checkFileReq = new CheckPointFileStatusReq();
                    checkFileReq.hdr               = new ReqHdr();
                    checkFileReq.hdr.UserId        = CurrUser.iUserID;
                    checkFileReq.hdr.SecurityToken = "SecurityToken";
                    checkFileReq.FileId            = iLoanID;
                    CheckPointFileStatusResp checkFileResp = service.CheckPointFileStatus(checkFileReq);
                    if (checkFileResp == null || checkFileResp.hdr == null || !checkFileResp.hdr.Successful)
                    {
                        sErrorMsg = "Unable to get Point file status from Point Manager.";
                        WorkflowManager.UnCompleteTask(iTaskID, CurrUser.iUserID);
                        bIsSuccess = false;
                        return;
                    }
                    if (checkFileResp.FileLocked)
                    {
                        sErrorMsg = checkFileResp.hdr.StatusInfo;
                        WorkflowManager.UnCompleteTask(iTaskID, CurrUser.iUserID);
                        bIsSuccess = false;
                        return;
                    }
                }
                #endregion
                #region UPdatePointFileStage  WCF
                string sError = LoanTaskCommon.UpdatePointFileStage(iLoanID, this.CurrUser.iUserID, iLoanStageID);

                // the last one, sleep 1 second
                System.Threading.Thread.Sleep(1000);

                if (sError == string.Empty) // success
                {
                    sErrorMsg = "Completed task successfully.";
                }
                else
                {
                    sErrorMsg = "Completed task successfully but failed to update stage date in Point.";
                    //sErrorMsg = "Failed to update point file stage: " + sError.Replace("\"", "\\\"");
                }
                #endregion
            }
            if (WorkflowManager.IsLoanClosed(iLoanID))
            {
                LoanClosed = "Yes";
            }
            return;

            #endregion
        }
        catch (System.ServiceModel.EndpointNotFoundException ee)
        {
            sErrorMsg = "Completed task successfully but failed to update stage date in Point.";
            return;
        }
        catch (Exception ex)
        {
            if (bIsSuccess)
            {
                sErrorMsg = "Completed task successfully but encountered an error:" + ex.Message;
            }
            else
            {
                sErrorMsg = "Failed to complete task, reason:" + ex.Message;
            }
            //sErrorMsg = "Exception happened when invoke WorkflowManager.CompleteTask: " + ex.ToString().Replace("\"", "\\\"");
            bIsSuccess = false;
            return;
        }
        finally
        {
            if (bIsSuccess)
            {
                result = "{\"ExecResult\":\"Success\",\"ErrorMsg\":\"" + sErrorMsg + "\",\"EmailTemplateID\":\"" + sEmailTemplateID + "\",\"TaskID\":\"" + sTaskID + "\",\"LoanClosed\":\"" + LoanClosed + "\"}";
            }
            //result = "{\"ExecResult\":\"Success\",\"ErrorMsg\":\"\",\"EmailTemplateID\":\"" + sEmailTemplateID + "\",\"LoanClosed\":\"" + LoanClosed + "\"}";
            else
            {
                result = "{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sErrorMsg + "\"}";
            }
            this.Response.Write(result);
        }

        #endregion
    }
示例#11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sTaskIDs = this.Request.QueryString["TaskIDs"].ToString();

            string sSendEmail = this.Request.QueryString["SendEmail"].ToString();

            string sLoanIDs         = this.Request.QueryString["LoanIDs"].ToString();
            string sErrorMsg        = string.Empty;
            string sEmailTemplateID = string.Empty;
            bool   bIsSuccess       = false;
            var    result           = "";
            string LoanClosed       = "No";
            string sGlobalLoanID    = "0";

            try
            {
                string[] TaskIDs = sTaskIDs.Split(",".ToCharArray());
                string[] LoanIDs = sLoanIDs.Split(",".ToCharArray());

                for (int i = 0; i < TaskIDs.Length; i++)
                {
                    int iTaskID          = Convert.ToInt32(TaskIDs[i]);
                    int iLoanID          = Convert.ToInt32(LoanIDs[i]);
                    int iEmailTemplateId = 0;
                    // if the task is client task
                    if (iLoanID == -1)
                    {
                        ProspectTasks bpTasks = new ProspectTasks();
                        bIsSuccess = bpTasks.ComplateSelProspectTask(iTaskID, this.CurrUser.iUserID, ref iEmailTemplateId);
                        if (bIsSuccess == false)
                        {
                            sErrorMsg = "Failed to CompleteTask.";
                            return;
                        }

                        if (iEmailTemplateId != 0)
                        {
                            //根据Lin 2011-02-28邮件,暂不增加发送邮件功能。
                            sEmailTemplateID = iEmailTemplateId.ToString();
                        }
                    }
                    else
                    {
                        #region complete task;
                        bIsSuccess    = LPWEBDAL.WorkflowManager.CompleteTask(iTaskID, this.CurrUser.iUserID, ref iEmailTemplateId);
                        sGlobalLoanID = iLoanID.ToString();
                        if (bIsSuccess == false)
                        {
                            sErrorMsg = "Failed to invoke WorkflowManager.CompleteTask.";
                            return;
                        }
                        if (iEmailTemplateId != 0 && sSendEmail == "OK")
                        {
                            sEmailTemplateID = iEmailTemplateId.ToString();
                            sErrorMsg        = SendEmail(iLoanID, iTaskID, iEmailTemplateId);
                        }
                        #endregion

                        #region update point file stage

                        int iLoanStageID = 0;

                        #region get loan task info

                        LoanTasks LoanTaskManager = new LoanTasks();
                        DataTable LoanTaskInfo    = LoanTaskManager.GetLoanTaskInfo(iTaskID);
                        if (LoanTaskInfo.Rows.Count == 0)
                        {
                            bIsSuccess = false;
                            sErrorMsg  = "Invalid task id.";
                            return;
                        }
                        string sLoanStageID = LoanTaskInfo.Rows[0]["LoanStageId"].ToString();
                        if (sLoanStageID == string.Empty)
                        {
                            bIsSuccess = false;
                            sErrorMsg  = "Invalid loan stage id.";
                            return;
                        }
                        iLoanStageID = Convert.ToInt32(sLoanStageID);

                        #endregion
                        bIsSuccess = true;
                        if (!WorkflowManager.StageCompleted(iLoanStageID))
                        {
                            sErrorMsg = "Completed task successfully.";
                            continue;
                        }

                        #region invoke PointManager.UpdateStage()
                        BLL.Loans   loanMgr = new Loans();
                        Model.Loans loan    = loanMgr.GetModel(iLoanID); // if it's a prospect loan, don't update the Point file.
                        if (string.IsNullOrEmpty(loan.Status) || loan.Status.ToUpper() == "PROSPECT")
                        {
                            continue;
                        }

                        string sError = LoanTaskCommon.UpdatePointFileStage(iLoanID, this.CurrUser.iUserID, iLoanStageID);

                        if (sError == string.Empty) // success
                        {
                            sErrorMsg = "Completed task successfully.";
                        }
                        else
                        {
                            sErrorMsg = "Completed task successfully but failed to update stage date in Point.";
                            //sErrorMsg = "Failed to update point file stage: " + sError.Replace("\"", "\\\"");
                        }
                        if (WorkflowManager.IsLoanClosed(iLoanID))
                        {
                            LoanClosed = "Yes";
                        }
                        #endregion
                        #endregion
                    }
                }
                return;
            }
            catch (System.ServiceModel.EndpointNotFoundException ee)
            {
                sErrorMsg = "Completed task successfully but failed to update stage date in Point.";
                return;
            }
            catch (Exception ex)
            {
                if (bIsSuccess)
                {
                    sErrorMsg = "Completed task successfully but encountered an error:" + ex.Message;
                }
                else
                {
                    sErrorMsg = "Failed to complete task, reason:" + ex.Message;
                }
                //sErrorMsg = "Exception happened when invoke WorkflowManager.CompleteTask: " + ex.ToString().Replace("\"", "\\\"");
                bIsSuccess = false;
                return;
            }
            finally
            {
                if (bIsSuccess)
                {
                    result = "{\"ExecResult\":\"Success\",\"ErrorMsg\":\"" + sErrorMsg + "\",\"TaskID\":\"" + sTaskIDs + "\",\"LoanID\":\"" + sGlobalLoanID + "\",\"LoanClosed\":\"" + LoanClosed + "\"}";
                }
                //result = "{\"ExecResult\":\"Success\",\"ErrorMsg\":\"\",\"EmailTemplateID\":\"" + sEmailTemplateID + "\",\"LoanClosed\":\"" + LoanClosed + "\"}";
                else
                {
                    result = "{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sErrorMsg + "\"}";
                }
                this.Response.Write(result);
            }
        }
示例#12
0
    protected int CreateLoanTask(int iFileID, string sTaskName, int TaskOwnerId, string sDueDate, string sDueTime, int iLoanStageID)
    {
        #region create new task

        LoanTasks LoanTaskManager = new LoanTasks();

        // add task
        LPWeb.Model.LoanTasks taskModel = new LPWeb.Model.LoanTasks();
        taskModel.LoanTaskId = 0;
        taskModel.FileId     = iFileID;
        taskModel.Name       = sTaskName;
        if (sDueDate == string.Empty)
        {
            taskModel.Due = null;
        }
        else
        {
            taskModel.Due = DateTime.Parse(sDueDate);
        }

        DateTime DTN           = DateTime.Now;
        string   sDueTime_Span = null;
        TimeSpan DueTime       = new TimeSpan();

        if (sDueTime == string.Empty)
        {
            taskModel.DueTime = null;
        }
        else
        {
            taskModel.DueTime = null;
            if (DateTime.TryParse(sDueTime, out DTN) == true)
            {
                sDueTime_Span = DTN.ToString("HH:mm");
                if (TimeSpan.TryParse(sDueTime_Span, out DueTime) == true)
                {
                    taskModel.DueTime = DueTime;
                }
            }
        }

        taskModel.LoanStageId = iLoanStageID;

        taskModel.OldLoanStageId           = 0;
        taskModel.Owner                    = TaskOwnerId;
        taskModel.ModifiedBy               = CurrUser.iUserID;
        taskModel.LastModified             = DateTime.Now;
        taskModel.DaysDueFromEstClose      = 0;
        taskModel.DaysFromCreation         = 0;
        taskModel.PrerequisiteTaskId       = 0;
        taskModel.DaysDueAfterPrerequisite = 0;
        taskModel.CompletionEmailId        = 0;
        taskModel.WarningEmailId           = 0;
        taskModel.OverdueEmailId           = 0;
        taskModel.SequenceNumber           = 1;
        taskModel.ExternalViewing          = false;

        int iLoanTaskId = LPWeb.BLL.WorkflowManager.AddTask_Lead(taskModel);


        #endregion

        return(iLoanTaskId);
    }
示例#13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(Request.QueryString["needret"]))
        {
            strNeedReturn = "0";
        }
        else
        {
            strNeedReturn = "1";
        }

        #region 校验必要参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "RuleID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "$('#divContainer').hide();alert('Missing required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        this.iRuleID = Convert.ToInt32(this.Request.QueryString["RuleID"]);

        #endregion

        #region 加载Rule信息
        Template_Rules RuleManager = new Template_Rules();
        DataTable      RuleInfo    = RuleManager.GetRuleInfo(this.iRuleID);
        if (RuleInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Invalid", "$('#divContainer').hide();alert('Invalid required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        #endregion

        // is referenced by rule group
        this.hdnIsRef.Text = RuleManager.bIsRef(this.iRuleID).ToString();

        if (this.IsPostBack == false)
        {
            #region 加载email template
            LoanTasks      LoanTaskManager  = new LoanTasks();
            Template_Email EmailTempManager = new Template_Email();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1");

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an email template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

            this.ddlRecomActionTemplate.DataSource = EmailTemplates;
            this.ddlRecomActionTemplate.DataBind();

            this.ddlAlertEmailTemplate.DataSource = EmailTemplates;
            this.ddlAlertEmailTemplate.DataBind();

            #endregion

            #region 加载Conditions

            DataTable ConditionListData = RuleManager.GetConditionList(this.iRuleID);
            this.gridConditionList.DataSource = ConditionListData;
            this.gridConditionList.DataBind();

            #endregion

            #region 绑定数据

            this.txtRuleName.Text   = RuleInfo.Rows[0]["Name"].ToString();
            this.txtDesc.Text       = RuleInfo.Rows[0]["Desc"].ToString();
            this.chkEnabled.Checked = Convert.ToBoolean(RuleInfo.Rows[0]["Enabled"]);
            this.ddlRecomActionTemplate.SelectedValue = RuleInfo.Rows[0]["RecomEmailTemplid"].ToString();
            this.ddlAlertEmailTemplate.SelectedValue  = RuleInfo.Rows[0]["AlertEmailTemplId"].ToString();
            this.chkReqAck.Checked      = Convert.ToBoolean(RuleInfo.Rows[0]["AckReq"]);
            this.txtFormula.Text        = RuleInfo.Rows[0]["AdvFormula"].ToString();
            this.ddlScope.SelectedValue = RuleInfo.Rows[0]["RuleScope"].ToString();

            #region get loan target

            //this.ddlTarget.SelectedValue = RuleInfo.Rows[0]["LoanTarget"].ToString();

            LPWeb.Model.Template_Rules_LoanTarget modelLoanTarget;
            if (!RuleInfo.Rows[0].IsNull("LoanTarget"))
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget(Convert.ToInt16(RuleInfo.Rows[0]["LoanTarget"]));
            }
            else
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget();
            }

            this.chkTargetActiveLoans.Checked   = modelLoanTarget.ActiveLoans;
            this.chkTargetActiveLeads.Checked   = modelLoanTarget.ActiveLeads;
            this.chkTargetArchivedLoans.Checked = modelLoanTarget.ArchivedLoans;
            this.chkTargetArchivedLeads.Checked = modelLoanTarget.ArchivedLeads;

            #endregion

            #endregion
            if (RuleInfo.Rows[0]["AutoCampaignId"].ToString() != "")
            {
                this.hfSelCampaigns.Value = RuleInfo.Rows[0]["AutoCampaignId"].ToString();
                MarketingCampaigns             _bMarketingCampaigns = new MarketingCampaigns();
                LPWeb.Model.MarketingCampaigns _mMarketingCampaigns = _bMarketingCampaigns.GetModel(Convert.ToInt32(RuleInfo.Rows[0]["AutoCampaignId"]));
                //txtMarketingCampaign.Text = _mMarketingCampaigns.CampaignName;
            }
            // set counter
            this.hdnCounter.Value = ConditionListData.Rows.Count.ToString();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 检查必要参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID);
        if (bIsValid == false)
        {
            PageCommon.WriteJsEnd(this, "Missing required query string.", "");
        }
        this.iLoanID = Convert.ToInt32(this.Request.QueryString["LoanID"]);

        #endregion

        #region 加载Loan Info

        string    sSql3    = "select l.*, pf.FolderId, pf.Name as FileName from Loans l inner join PointFiles pf on l.FileId=pf.FileId where l.FileId=" + this.iLoanID;
        DataTable LoanInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql3);
        if ((LoanInfo == null) || (LoanInfo.Rows.Count == 0))
        {
            PageCommon.WriteJsEnd(this, string.Format("No Loan Info found for LoanID {0}.", iLoanID), "");
        }

        int    FolderId = 0;
        string FileName = string.Empty;
        FolderId = LoanInfo.Rows[0]["FolderId"] == DBNull.Value ? 0 : (int)LoanInfo.Rows[0]["FolderId"];
        FileName = LoanInfo.Rows[0]["FileName"] == DBNull.Value ? string.Empty : (string)LoanInfo.Rows[0]["FileName"];
        if (FolderId < 1 || string.IsNullOrEmpty(FileName))
        {
            lnkImport.Visible = false;
        }

        #endregion

        #region 权限验证
        //try
        //{
        //    if (this.CurrUser.userRole.Prospect.ToString().IndexOf('B') == -1)
        //    {
        //        this.btnModify.Disabled = true;
        //    }
        //    if (this.CurrUser.userRole.Prospect.ToString().IndexOf('K') == -1)
        //    {
        //        this.btnSendEmail.Disabled = true;
        //    }
        //    if (this.CurrUser.userRole.Prospect.ToString().IndexOf('F') == -1)
        //    {
        //        this.btnDispose.Disabled = true;
        //    }
        //    if (this.CurrUser.userRole.Prospect.ToString().IndexOf('C') == -1)
        //    {
        //        btnDelete.Enabled = false;
        //    }
        //    if (this.CurrUser.userRole.Prospect.ToString().IndexOf('G') == -1)
        //    {
        //        btnSyncNow.Enabled = false;
        //    }
        //}
        //catch (Exception exception)
        //{
        //    LPLog.LogMessage(exception.Message);
        //}


        if (this.CurrUser.userRole.ExportClients == true)
        {
            this.btnvCardExport.Enabled = true;
        }
        else
        {
            this.btnvCardExport.Enabled = false;
        }

        #endregion

        this.GetPostBackEventReference(this.lnkExport);

        if (this.IsPostBack == false)
        {
            #region 加载Lead Source列表

            Company_Lead_Sources LeadSourceManager = new Company_Lead_Sources();
            DataTable            LeadSourceList    = LeadSourceManager.GetList("1=1 order by LeadSource").Tables[0];

            DataRow NewLeadSourceRow = LeadSourceList.NewRow();
            NewLeadSourceRow["LeadSourceID"] = DBNull.Value;
            NewLeadSourceRow["LeadSource"]   = "-- select --";

            LeadSourceList.Rows.InsertAt(NewLeadSourceRow, 0);

            this.ddlLeadSource.DataSource = LeadSourceList;
            this.ddlLeadSource.DataBind();

            #endregion

            #region 加载Program列表

            Company_Loan_Programs ProgramMgr  = new Company_Loan_Programs();
            DataTable             ProgramList = ProgramMgr.GetList("1=1 order by LoanProgram").Tables[0];

            DataRow NewProgramRow = ProgramList.NewRow();
            NewProgramRow["LoanProgramID"] = DBNull.Value;
            NewProgramRow["LoanProgram"]   = "-- select --";

            ProgramList.Rows.InsertAt(NewProgramRow, 0);

            this.ddlProgram.DataSource = ProgramList;
            this.ddlProgram.DataBind();

            #endregion

            #region 加载Borrower Info

            DataTable BorrowerInfo = this.GetBorrowerInfo(this.iLoanID);

            #region 绑定Borrower信息
            if (BorrowerInfo.Rows.Count > 0)
            {
                string sFirstName    = BorrowerInfo.Rows[0]["FirstName"].ToString();
                string sLastName     = BorrowerInfo.Rows[0]["LastName"].ToString();
                string sBorrowerName = sLastName + ", " + sFirstName;
                this.hProspectName.InnerText = sBorrowerName;
                this.txtFirstName.Text       = sFirstName;
                this.txtLastName.Text        = sLastName;

                this.txtEmail.Text     = BorrowerInfo.Rows[0]["Email"].ToString();
                this.txtCellPhone.Text = BorrowerInfo.Rows[0]["CellPhone"].ToString();
                this.txtHomePhone.Text = BorrowerInfo.Rows[0]["HomePhone"].ToString();
                this.txtWorkPhone.Text = BorrowerInfo.Rows[0]["BusinessPhone"].ToString();
                this.txtBirthday.Text  = BorrowerInfo.Rows[0]["DOB"].ToString() == "" ? "" : Convert.ToDateTime(BorrowerInfo.Rows[0]["DOB"]).ToString("MM/dd/yyyy");

                this.lbFirstName.Text = BorrowerInfo.Rows[0]["FirstName"].ToString();
                this.lbLastName.Text  = BorrowerInfo.Rows[0]["LastName"].ToString();
                this.lbEmail.Text     = BorrowerInfo.Rows[0]["Email"].ToString();
                this.lbCellPhone.Text = BorrowerInfo.Rows[0]["CellPhone"].ToString();
                this.lbHomePhone.Text = BorrowerInfo.Rows[0]["HomePhone"].ToString();
                this.lbWorkPhone.Text = BorrowerInfo.Rows[0]["BusinessPhone"].ToString();
                this.lbBirthday.Text  = BorrowerInfo.Rows[0]["DOB"].ToString() == "" ? "" : Convert.ToDateTime(BorrowerInfo.Rows[0]["DOB"]).ToString("MM/dd/yyyy");
            }
            #endregion

            if (BorrowerInfo.Rows.Count > 0)
            {
                string sContactID = BorrowerInfo.Rows[0]["ContactId"].ToString();


                #region 加载Prospect Info

                string    sSqlx0       = "select * from Prospect where ContactId=" + sContactID;
                DataTable ProspectInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSqlx0);

                #region 绑定Prospect信息

                if (ProspectInfo.Rows.Count > 0)
                {
                    // Lead Source
                    if (ProspectInfo.Rows[0]["LeadSource"] != DBNull.Value)
                    {
                        this.ddlLeadSource.SelectedValue = ProspectInfo.Rows[0]["LeadSource"].ToString();

                        this.lbLeadSource.Text = ProspectInfo.Rows[0]["LeadSource"].ToString();
                    }

                    // Referral Source (Prospect.Referral)
                    if (ProspectInfo.Rows[0]["Referral"] != DBNull.Value)
                    {
                        int      iReferralID    = Convert.ToInt32(ProspectInfo.Rows[0]["Referral"]);
                        Contacts ContactManager = new Contacts();
                        this.txtReferralSource.Text = ContactManager.GetContactName(iReferralID);
                        this.hdnReferralID.Value    = iReferralID.ToString();

                        this.lbReferralSource.Text = ContactManager.GetContactName(iReferralID);
                    }
                }

                #endregion

                #endregion
            }
            #endregion

            #region 绑定Lead信息

            if (LoanInfo.Rows[0]["Purpose"] != DBNull.Value)
            {
                this.ddlPurpose.SelectedValue = LoanInfo.Rows[0]["Purpose"].ToString();

                this.lbPurpose.Text = LoanInfo.Rows[0]["Purpose"].ToString();
            }

            if (LoanInfo.Rows[0]["LoanType"] != DBNull.Value)
            {
                this.ddlType.SelectedValue = LoanInfo.Rows[0]["LoanType"].ToString();

                this.lbType.Text = LoanInfo.Rows[0]["LoanType"].ToString();
            }

            if (LoanInfo.Rows[0]["Program"] != DBNull.Value)
            {
                this.ddlProgram.SelectedValue = LoanInfo.Rows[0]["Program"].ToString();

                this.lbProgram.Text = LoanInfo.Rows[0]["Program"].ToString();
            }

            this.txtAmount.Text = LoanInfo.Rows[0]["LoanAmount"].ToString() == "" ? "" : Convert.ToDecimal(LoanInfo.Rows[0]["LoanAmount"]).ToString("n0");
            this.txtRate.Text   = LoanInfo.Rows[0]["Rate"].ToString() == "" ? "" : Convert.ToDecimal(LoanInfo.Rows[0]["Rate"]).ToString("n3");

            this.lbAmount.Text = LoanInfo.Rows[0]["LoanAmount"].ToString() == "" ? "" : Convert.ToDecimal(LoanInfo.Rows[0]["LoanAmount"]).ToString("n0");
            this.lbRate.Text   = LoanInfo.Rows[0]["Rate"].ToString() == "" ? "" : Convert.ToDecimal(LoanInfo.Rows[0]["Rate"]).ToString("n3") + "%";

            #endregion
        }

        #region Codes for Stage Progress Bar

        DataTable StageProgressData = this.GetStageProgressData(this.iLoanID);
        this.rptStageProgressItems.DataSource = StageProgressData;
        this.rptStageProgressItems.DataBind();

        #endregion

        #region 获取当前Point Folder的BranchID

        string    sSqlx        = "select b.BranchId,b.name from PointFiles as a inner join PointFolders as b on a.FolderId = b.FolderId where a.FileId=" + this.iLoanID;
        DataTable BranchIDInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSqlx);
        if (BranchIDInfo.Rows.Count > 0 && BranchIDInfo.Rows[0]["BranchId"].ToString() != "" && BranchIDInfo.Rows[0]["BranchId"].ToString() != "0")
        {
            this.hdnBranchID.Value = BranchIDInfo.Rows[0]["BranchId"].ToString();
        }
        else
        {
            sSqlx = "select BranchID from Loans where FileId=" + this.iLoanID;
            DataTable dtLoan = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSqlx);
            if (dtLoan.Rows.Count > 0 && dtLoan.Rows[0]["BranchID"].ToString() != "" && dtLoan.Rows[0]["BranchID"].ToString() != "0")
            {
                this.hdnBranchID.Value = dtLoan.Rows[0]["BranchID"].ToString();
            }
            else
            {
                sSqlx = "SELECT TOP 1 BranchID FROM Groups WHERE GroupId IN(SELECT GroupID FROM GroupUsers WHERE UserID IN(SELECT UserId FROM LoanTeam WHERE FileId = " + this.iLoanID + " AND RoleId =(SELECT RoleId FROM Roles WHERE [Name]='Loan Officer')))";
                DataTable dtGroup = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSqlx);
                if (dtGroup.Rows.Count > 0 && dtGroup.Rows[0]["BranchID"].ToString() != "" && dtGroup.Rows[0]["BranchID"].ToString() != "0")
                {
                    this.hdnBranchID.Value = dtGroup.Rows[0]["BranchID"].ToString();
                }
            }
        }

        #endregion

        #region 加载Point File Info

        string    sSql7         = "Select top 1 * from dbo.lpvw_GetPointFileInfo where FileId=" + this.iLoanID;
        DataTable PointFileInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql7);

        string sHasPointFile = "False";
        if (PointFileInfo.Rows.Count > 0)
        {
            string sPointFilePath = PointFileInfo.Rows[0]["Path"].ToString();
            string sFolderID      = PointFileInfo.Rows[0]["FolderId"].ToString();

            if (sPointFilePath != string.Empty || sFolderID != string.Empty)
            {
                sHasPointFile = "True";
            }
        }

        this.hdnHasPointFile.Value = sHasPointFile;

        #endregion

        #region Context Menu

        if (LoanInfo.Rows.Count > 0)
        {
            string sProspectLoanStatus = LoanInfo.Rows[0]["ProspectLoanStatus"].ToString();

            //加载 ArchiveLeadStatus

            ArchiveLeadStatus ArchiveLeadStatusMgr  = new ArchiveLeadStatus();
            DataSet           ArchiveLeadStatusList = ArchiveLeadStatusMgr.GetList("isnull([Enabled],0)=1 order by LeadStatusName");

            #region Build Sub Menu Item

            StringBuilder sbSubMenuItems = new StringBuilder();
            if (ArchiveLeadStatusList.Tables[0].Rows.Count > 0)
            {
                sbSubMenuItems.AppendLine("<ul>");
                foreach (DataRow dr in ArchiveLeadStatusList.Tables[0].Rows)
                {
                    string sLeadStatusName1 = dr["LeadStatusName"].ToString();
                    string sLeadStatusName2 = dr["LeadStatusName"].ToString().Replace("'", "\\'");
                    sbSubMenuItems.AppendLine("<li><a href=\"\" onclick=\"ChangeStatus('" + sLeadStatusName2 + "'); return false;\">" + sLeadStatusName1 + "</a></li>");
                }
                sbSubMenuItems.AppendLine("</ul>");
            }

            #endregion

            StringBuilder sbMenuItems = new StringBuilder();
            if (sProspectLoanStatus.ToLower() == "active")
            {
                sbMenuItems.AppendLine("<li><a href=\"\" onclick=\"return false;\">Archive</a>" + sbSubMenuItems + "</li>");
                sbMenuItems.AppendLine("<li><a href=\"\" onclick=\"ChangeStatus('Convert'); return false;\">Convert to Loan</a></li>");
            }

            this.ltrChangeStatusMenuItems.Text = sbMenuItems.ToString();
        }

        #endregion

        #region Actions

        LoanTasks LoanTasksMgr = new LoanTasks();

        DataTable LastTaskInfo = LoanTasksMgr.GetLoanTaskList(1, " and FileId=" + this.iLoanID + " and Completed is not null", " order by Completed desc");
        DataTable NextTaskInfo = LoanTasksMgr.GetLoanTaskList(1, " and FileId=" + this.iLoanID + " and Completed is null", " order by LoanTaskId asc");

        if (LastTaskInfo.Rows.Count == 0 && NextTaskInfo.Rows.Count == 0)
        {
            this.divActions.Visible = false;
        }
        else
        {
            if (LastTaskInfo.Rows.Count == 0)
            {
                this.trLastAction.Visible = false;
            }
            else
            {
                this.ltrLastTaskName.Text = LastTaskInfo.Rows[0]["Name"].ToString();
                this.ltrLastDueDate.Text  = LastTaskInfo.Rows[0]["Due"] == DBNull.Value ? string.Empty : Convert.ToDateTime(LastTaskInfo.Rows[0]["Due"].ToString()).ToLongDateString();
                this.ltrLastDueTime.Text  = LastTaskInfo.Rows[0]["DueTime"] == DBNull.Value ? string.Empty : TimeSpan.Parse(LastTaskInfo.Rows[0]["DueTime"].ToString()).ToString();
            }


            if (NextTaskInfo.Rows.Count == 0)
            {
                this.trNextAction.Visible = false;
            }
            else
            {
                this.ltrNextTaskName.Text = NextTaskInfo.Rows[0]["Name"].ToString();
                this.ltrNextDueDate.Text  = NextTaskInfo.Rows[0]["Due"] == DBNull.Value ? string.Empty : Convert.ToDateTime(NextTaskInfo.Rows[0]["Due"].ToString()).ToLongDateString();
                this.ltrNextDueTime.Text  = NextTaskInfo.Rows[0]["DueTime"] == DBNull.Value ? string.Empty : TimeSpan.Parse(NextTaskInfo.Rows[0]["DueTime"].ToString()).ToString();

                // hidden fields
                this.hdnNextTaskID.Value        = NextTaskInfo.Rows[0]["LoanTaskId"].ToString();
                this.hdnNextTaskOwnerID.Value   = NextTaskInfo.Rows[0]["Owner"].ToString();
                this.hdnLoginUserID.Value       = this.CurrUser.iUserID.ToString();
                this.hdnCompleteOtherTask.Value = this.CurrUser.userRole.MarkOtherTaskCompl == true ? "True" : "False";
                this.hdnLoanStatus.Value        = LoanInfo.Rows[0]["Status"].ToString();
            }
        }

        #endregion
    }
示例#15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 接收参数

            // TaskID
            bool bIsValid = PageCommon.ValidateQueryString(this, "TaskID", QueryStringType.ID);
            if (bIsValid == false)
            {
                this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}");
                return;
            }
            string sTaskID = this.Request.QueryString["TaskID"].ToString();
            int    iTaskID = Convert.ToInt32(sTaskID);
            string sLoanID = this.Request.QueryString["LoanID"].ToString();
            int    iLoanID = Convert.ToInt32(sLoanID);

            #endregion

            // json示例
            // {"ExecResult":"Success","ErrorMsg":"","EmailTemplateID":"1"}
            // {"ExecResult":"Failed","ErrorMsg":"执行数据库脚本时发生错误。"}

            string sErrorMsg        = string.Empty;
            string sEmailTemplateID = string.Empty;
            string LoanClosed       = "No";

            ProspectTasks bpTasks          = new ProspectTasks();
            int           iEmailTemplateId = 0;
            bool          bIsSuccess       = false;
            string        result           = string.Empty;

            try
            {
                if (iLoanID == -1)
                {
                    bIsSuccess = bpTasks.ComplateSelProspectTask(iTaskID, this.CurrUser.iUserID, ref iEmailTemplateId);
                    if (bIsSuccess == false)
                    {
                        sErrorMsg = "Failed to CompleteTask.";
                        return;
                    }
                    else
                    {
                        sErrorMsg = "Completed task successfully.";
                    }
                }
                else
                {
                    bIsSuccess = LPWEBDAL.WorkflowManager.CompleteTask(iTaskID, this.CurrUser.iUserID, ref iEmailTemplateId);
                    if (bIsSuccess == false)
                    {
                        sErrorMsg = "Failed to invoke WorkflowManager.CompleteTask.";
                        return;
                    }

                    #region update point file stage

                    int iLoanStageID = 0;

                    #region get loan task info

                    LoanTasks LoanTaskManager = new LoanTasks();
                    DataTable LoanTaskInfo    = LoanTaskManager.GetLoanTaskInfo(iTaskID);
                    if (LoanTaskInfo.Rows.Count == 0)
                    {
                        bIsSuccess = false;
                        sErrorMsg  = "Invalid task id.";
                        return;
                    }
                    string sLoanStageID = LoanTaskInfo.Rows[0]["LoanStageId"].ToString();
                    if (sLoanStageID == string.Empty)
                    {
                        bIsSuccess = false;
                        sErrorMsg  = "Invalid loan stage id.";
                        return;
                    }
                    iLoanStageID = Convert.ToInt32(sLoanStageID);

                    #endregion

                    bIsSuccess = true;
                    if (!WorkflowManager.StageCompleted(iLoanStageID))
                    {
                        sErrorMsg = "Completed task successfully.";
                    }

                    #region invoke PointManager.UpdateStage()

                    string sError = LoanTaskCommon.UpdatePointFileStage(iLoanID, this.CurrUser.iUserID, iLoanStageID);

                    if (sError == string.Empty) // success
                    {
                        sErrorMsg = "Completed task successfully.";
                    }
                    else
                    {
                        sErrorMsg = "Completed task successfully but failed to update stage date in Point.";
                    }
                    #endregion

                    if (iEmailTemplateId != 0)
                    {
                        //根据Lin 2011-02-28邮件,暂不增加发送邮件功能。
                        sEmailTemplateID = iEmailTemplateId.ToString();
                    }
                }
                #endregion

                if (string.Equals(new Loans().GetLoanInfo(iLoanID).Rows[0]["Status"], "Processing"))
                {
                    LoanClosed = "Yes";
                }
            }
            catch (Exception ex)
            {
                if (bIsSuccess)
                {
                    sErrorMsg = "Completed task successfully but encountered an error:" + ex.Message;
                }
                else
                {
                    sErrorMsg = "Failed to complete task, reason:" + ex.Message;
                }
                bIsSuccess = false;
            }
            finally
            {
                if (bIsSuccess)
                {
                    this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sErrorMsg + "\",\"EmailTemplateID\":\"" + sEmailTemplateID + "\",\"LoanID\":\"" + sLoanID + "\",\"LoanClosed\":\"" + LoanClosed + "\"}");
                }
                else
                {
                    this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sErrorMsg + "\"}");
                }
                this.Response.End();
            }
        }
示例#16
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Loans LoanManager = new Loans();
        CompanyTaskPickList bllTaskPickList = new CompanyTaskPickList();
        LoginUser           CurrentUser     = new LoginUser();;

        int field = 0;

        if (Request.QueryString["FileId"] != null)
        {
            field = int.Parse(Request.QueryString["FileId"].ToString());
        }

        var loanInfo = LoanManager.GetModel(field);

        string taskName = rbtaskNameInput.Checked ? txtTaskname.Text.Trim() : ddlTaskList.SelectedValue.Trim();


        if (string.IsNullOrEmpty(txtTaskname.Text.Trim()) && string.IsNullOrEmpty(ddlTaskList.SelectedValue))
        {
            //PageCommon.WriteJs(this, "Task Name is Null!", "");
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language=javascript>alert('Task Name is Null!')</script>");
        }
        else
        {
            if (loanInfo == null || loanInfo.Status != "Prospect")  //CR54 当为Prospect时检查重复
            {
                DataSet ds = bllTaskPickList.GetList("TaskName like '%" + taskName + "%'");

                if (ds.Tables[0].Rows.Count > 0)
                {
                    //说明存在相同的TaskName
                    // PageCommon.WriteJs(this, "Task Name Repeat!", "");
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language=javascript>alert('Task Name Repeat!')</script>");
                    txtTaskname.Text = "";

                    return;
                }
            }

            LoanTasks lt = new LoanTasks();



            int Owner = CurrentUser.iUserID;

            string CompletedBy = "0";

            if (cbInterestOnly.Checked == true)
            {
                CompletedBy = CurrentUser.iUserID.ToString();
            }

            DateTime Completed = new DateTime();
            if (cbInterestOnly.Checked == true)
            {
                Completed = DateTime.Now;
            }

            DateTime Due = new DateTime();

            //if (cbInterestOnly.Checked == true)
            //{

            //string strdate = "";
            //if (!string.IsNullOrEmpty(txtDate.Text.Trim()))
            //{
            //    string[] date = txtDate.Text.Split('/');   //将字符串转换成数组arr1

            //    strdate = date[2] + "-" + date[0] + "-" + date[1];
            //}

            //if (!string.IsNullOrEmpty(txtTime.Text.Trim()))
            //{
            //    Due = DateTime.Parse(strdate + " " + txtTime.Text.Trim());
            //}

            //}


            string strdate = "";
            string strTime = "";
            if (!string.IsNullOrEmpty(txtDate.Text.Trim()))
            {
                string[] date = txtDate.Text.Split('/');   //将字符串转换成数组arr1

                strdate = date[2] + "-" + date[0] + "-" + date[1];

                Due = DateTime.Parse(strdate);
            }


            //if (!string.IsNullOrEmpty(txtTime.Text.Trim()))
            //{
            //    strTime = txtTime.Text.Trim();
            //}
            strTime = ddlDueTime_hour.SelectedValue + ":" + ddlDueTime_min.SelectedValue;


            string note = txbNotes.Text.Trim();

            string msg = lt.CreateLoanTasks(field, taskName, int.Parse(CompletedBy), Due, strTime, Owner, Completed, cbInterestOnly.Checked, note);

            if (msg == "Success")
            {
                PageCommon.WriteJsEnd(this, "Task saved successfully.", "window.parent.location.href=window.parent.location.href");
            }
            else
            {
                PageCommon.WriteJsEnd(this, "Failed to save the task.", "window.parent.location.href=window.parent.location.href");
            }
        }
    }
示例#17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Loans  bllLoans        = new Loans();
                string strFileID       = Request.QueryString["fileID"];
                string strloantaskID   = Request.QueryString["LoanTaskId"];
                int    iFileID         = 0;
                int    iloantaskID     = 0;
                bool   status          = true;
                bool   loantaskID_null = false;

                this.hdnCloseDialogCodes.Value = "";
                this.hdnCloseDialogCodes.Value = this.Request.QueryString["CloseDialogCodes"];
                if (string.IsNullOrEmpty(strFileID))
                {
                    return;
                }

                if (string.IsNullOrEmpty(strloantaskID))
                {
                    loantaskID_null = true;
                }
                else
                {
                    status          = int.TryParse(strloantaskID, out iloantaskID);
                    hfdTaskId.Value = iloantaskID.ToString();
                }

                if (int.TryParse(strFileID, out iFileID))
                {
                    try
                    {
                        hfdFileId.Value = iFileID.ToString();
                        if (loantaskID_null == true)
                        {
                            dt = bllLoans.GetTaskAlertDetail(iFileID);
                        }
                        else
                        {
                            dt = bllLoans.GetTaskAlertDetail_loantaskID(iFileID, iloantaskID);
                        }

                        if (dt == null || dt.Rows.Count < 1)
                        {
                            tblNoDataMessage.Visible = true;
                            //PageCommon.WriteJs(this, "", "window.parent.closeDialog();");
                            return;
                        }

                        string taskIds = "";
                        foreach (DataRow row in dt.Rows)
                        {
                            taskIds += row["LoanTaskId"] + ",";
                        }
                        hfdAllTaskIds.Value = taskIds.TrimEnd(',');
                        //Get task id based on task table(when loan task id is null and file id not null)
                        if (loantaskID_null && dt.Rows.Count > 0)
                        {
                            hfdTaskId.Value = dt.Rows[0]["LoanTaskId"].ToString();
                        }
                        hdnLoanStatus.Value = dt.Rows[0]["LoanStatus"] == DBNull.Value ? "" : dt.Rows[0]["LoanStatus"].ToString();
                        #region neo 2011-01-07 add send completion email

                        string sPrerequisiteID = dt.Rows[0]["PrerequisiteTaskId"].ToString();
                        if (sPrerequisiteID != string.Empty) // has prerequisite task
                        {
                            // get prerequisite task info
                            LoanTasks LoanTaskManager  = new LoanTasks();
                            DataTable PrerequisiteInfo = LoanTaskManager.GetLoanTaskList(" and  FileId = " + iFileID + " and LoanTaskId = " + sPrerequisiteID);

                            if (PrerequisiteInfo.Rows.Count == 0)   // not exist
                            {
                                this.hdnHasUncompletePrerequisite.Text = "False";
                            }
                            else
                            {
                                string sCompleteDate = PrerequisiteInfo.Rows[0]["Completed"].ToString();
                                if (sCompleteDate == string.Empty)   // uncomplete
                                {
                                    this.hdnHasUncompletePrerequisite.Text = "True";
                                }
                                else
                                {
                                    this.hdnHasUncompletePrerequisite.Text = "False";
                                }
                            }
                        }
                        else
                        {
                            this.hdnHasUncompletePrerequisite.Text = "False";
                        }

                        LoginUser CurrentUser = new LoginUser();

                        if (!CurrentUser.userRole.SendEmail)
                        {
                            btnSendEmail.Enabled = false;
                        }

                        #endregion

                        #region alex

                        //Get Task Owner and Current User's Make Others' Task Complate Power  by Alex 2011-01-22
                        string sTaskOwner = dt.Rows[0]["OwnerId"] == DBNull.Value ? "0" : dt.Rows[0]["OwnerId"].ToString();
                        hdnTaskOwner.Text         = sTaskOwner;
                        hdnMakeOtherTaskComp.Text = CurrentUser.userRole.MarkOtherTaskCompl == true ? "1" : "0";
                        hdnUserId.Value           = CurrentUser.iUserID.ToString();
                        if (sTaskOwner.Trim() == hdnUserId.Value.Trim() || sTaskOwner.Trim() == "0")       // if the user id and task owner are the same, allow
                        {
                            hdnMakeOtherTaskComp.Text = "1";
                        }
                        #endregion
                        if (dt == null || dt.Rows.Count < 1)
                        {
                            tblNoDataMessage.Visible = true;
                        }

                        fvTaskAlertDetail.DataSource = dt;
                        fvTaskAlertDetail.DataBind();
                    }
                    catch (Exception exception)
                    {
                        LPLog.LogMessage(exception.Message);
                        return;
                    }
                }
            }
        }
示例#18
0
    private string CompleteTask(int iLoanTaskId)
    {
        #region complete task

        string sErrorMsg        = string.Empty;
        int    iEmailTemplateId = 0;
        bool   bIsSuccess       = LPWeb.DAL.WorkflowManager.CompleteTask(iLoanTaskId, this.CurrUser.iUserID, ref iEmailTemplateId);

        if (bIsSuccess == false)
        {
            sErrorMsg = "Failed to invoke WorkflowManager.CompleteTask.";
            return(sErrorMsg);
        }

        #endregion

        #region update point file stage

        int iLoanStageID = 0;

        #region get loan task info

        LoanTasks LoanTaskManager = new LoanTasks();
        DataTable LoanTaskInfo    = LoanTaskManager.GetLoanTaskInfo(iLoanTaskId);
        if (LoanTaskInfo.Rows.Count == 0)
        {
            sErrorMsg = "Invalid task id.";
            return(sErrorMsg);
        }
        string sLoanStageID = LoanTaskInfo.Rows[0]["LoanStageId"].ToString();
        if (sLoanStageID == string.Empty)
        {
            sErrorMsg = "Invalid loan stage id.";
            return(sErrorMsg);
        }
        iLoanStageID = Convert.ToInt32(sLoanStageID);

        #endregion
        if (WorkflowManager.StageCompleted(iLoanStageID) == true)
        {
            #region invoke PointManager.UpdateStage()

            //add by  gdc 20111212  Bug #1306
            LPWeb.BLL.PointFiles pfile = new PointFiles();
            var model = pfile.GetModel(iLoanID);
            if (model != null && !string.IsNullOrEmpty(model.Name.Trim()))
            {
                #region UPdatePointFileStage  WCF

                string sError = LoanTaskCommon.UpdatePointFileStage(iLoanID, this.CurrUser.iUserID, iLoanStageID);

                #endregion
            }

            #endregion
        }

        #endregion

        return(sErrorMsg);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 接收参数

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

        // LoanID
        bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}");
            this.Response.End();
        }
        string sLoanID = this.Request.QueryString["LoanID"].ToString();
        int    iLoanID = Convert.ToInt32(sLoanID);

        #endregion

        // json示例
        // {"ExecResult":"Success","ErrorMsg":""}
        // {"ExecResult":"Failed","ErrorMsg":"执行数据库脚本时发生错误。"}

        string sErrorMsg = string.Empty;
        int    iLoanStageID;
        bool   StageCompleted = false;

        try
        {
            #region get loan task info

            LoanTasks LoanTaskManager = new LoanTasks();
            DataTable LoanTaskInfo    = LoanTaskManager.GetLoanTaskInfo(iTaskID);
            if (LoanTaskInfo.Rows.Count == 0)
            {
                this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Invalid task id.\"}");
                return;
            }
            string sLoanStageID = LoanTaskInfo.Rows[0]["LoanStageId"].ToString();
            if (sLoanStageID == string.Empty)
            {
                this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Invalid loan stage id.\"}");
                return;
            }
            iLoanStageID = Convert.ToInt32(sLoanStageID);

            #endregion
            #region uncomplete task

            StageCompleted = WorkflowManager.StageCompleted(iLoanStageID);

            bool bIsSuccess = LPWeb.DAL.WorkflowManager.UnCompleteTask(iTaskID, this.CurrUser.iUserID);

            if (bIsSuccess == false)
            {
                this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Failed to invoke WorkflowManager.UnCompleteTask api.\"}");
                return;
            }

            #endregion
        }
        catch (Exception ex)
        {
            sErrorMsg = "Failed to invoke Workflow Manager, reason:" + ex.Message;
            //sErrorMsg = "Exception happened when invoke WorkflowManager.UnCompleteTask: " + ex.ToString().Replace("\"", "\\\"");

            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sErrorMsg + "\"}");
            return;
        }

        if (!StageCompleted)  // if the stage was not completed prior to the un-complete
        {
            this.Response.Write("{\"ExecResult\":\"Success\",\"ErrorMsg\":\"\"}");
            return;
        }
        try
        {
            //add by  gdc 20111212  Bug #1306
            LPWeb.BLL.PointFiles pfile = new PointFiles();
            var model = pfile.GetModel(iLoanID);
            if (model != null && !string.IsNullOrEmpty(model.Name.Trim()))
            {
                #region check Point File Status first
                //ServiceManager sm = new ServiceManager();
                //using (LP2ServiceClient service = sm.StartServiceClient())
                //{
                //    CheckPointFileStatusReq checkFileReq = new CheckPointFileStatusReq();
                //    checkFileReq.hdr = new ReqHdr();
                //    checkFileReq.hdr.UserId = CurrUser.iUserID;
                //    checkFileReq.hdr.SecurityToken = "SecurityToken";
                //    checkFileReq.FileId = iLoanID;
                //    int emailTemplateId = 0;
                //    CheckPointFileStatusResp checkFileResp = service.CheckPointFileStatus(checkFileReq);
                //    if (checkFileResp == null || checkFileResp.hdr == null || !checkFileResp.hdr.Successful)
                //    {
                //        sErrorMsg = "Unable to get Point file status from Point Manager.";
                //        WorkflowManager.CompleteTask(iTaskID, CurrUser.iUserID, ref emailTemplateId);
                //        this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sErrorMsg + "\"}");
                //        return;
                //    }
                //    if (checkFileResp.FileLocked)
                //    {
                //        sErrorMsg = checkFileResp.hdr.StatusInfo;
                //        WorkflowManager.CompleteTask(iTaskID, CurrUser.iUserID, ref emailTemplateId);
                //        this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sErrorMsg + "\"}");
                //        return;
                //    }
                //}
                #endregion
                #region update point file stage

                string sError = LoanTaskCommon.UpdatePointFileStage(iLoanID, this.CurrUser.iUserID, iLoanStageID);

                // the last one, sleep 1 second
                System.Threading.Thread.Sleep(1000);

                if (sError == string.Empty) // success
                {
                    this.Response.Write("{\"ExecResult\":\"Success\",\"ErrorMsg\":\"\"}");
                }
                else
                {
                    sErrorMsg = "Un-completed task successfully but failed to update stage date in Point.";
                    //sErrorMsg = "Uncomplete task successfully, but failed to update point file stage: " + sError.Replace("\"", "\\\"");

                    this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sErrorMsg + "\"}");
                }

                #endregion
            }
            else
            {
                this.Response.Write("{\"ExecResult\":\"Success\",\"ErrorMsg\":\"\"}");
            }
        }
        catch (Exception ex)
        {
            sErrorMsg = "Un-completed task successfully but failed to update stage date in Point, reason:" + ex.Message;
            //sErrorMsg = "Uncomplete task successfully, but exception happened when update point stage: " + ex.ToString().Replace("\"", "\\\"");

            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sErrorMsg + "\"}");
        }
    }