Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblStatusSubmissionFailed.Visible = false;
            lblStatusSubmitted.Visible = false;
            lblZurichAdvFailed.Visible = false;
            lblZurichAdvSuccess.Visible = false;

            activity = activityStatusDao.getActivity(13);
            ViewState["activity"] = activity;

            ZPlanResponseDataContract zPlanResponse = null;
            string clonedFrom = "";

            if (!IsPostBack)
            {

                /*string nextCaseId = Request.Form["caseid"];
                string menuCaseId = Request.QueryString["caseid"];

                if (nextCaseId != null && nextCaseId != "")
                {
                    caseid = nextCaseId;
                }

                if (menuCaseId != null && menuCaseId != "")
                {
                    caseid = menuCaseId;
                }*/

                string activityID = string.Empty;

                string country = string.Empty;
                if (Request.Form["Country"] != null)
                {
                    country = Request.Form["Country"].ToString();
                }

                string salesChannel = string.Empty;
                if (Request.Form["SalesChannel"] != null)
                {
                    salesChannel = Request.Form["SalesChannel"].ToString();
                }

                if (Request.Form["ActivityID"] != null)
                {
                    activityID = Request.Form["ActivityID"].ToString();
                    //activityID = "1500";

                    ZPlanDataContract zPlanContract = new ZPlanDataContract();
                    zPlanContract.ActivityId = activityID;
                    zPlanContract.Activity = ActivityTypeEnum.ZPlan;
                    zPlanContract.Action = ActionEnumContracts.View;
                    UserInfoEntity ufo = new UserInfoEntity();
                    ufo.Country = country;
                    ufo.RoleType = salesChannel;
                    zPlanContract.UserInfo = ufo;
                    zPlanResponse = new ZPlanResponseDataContract();

                    try
                    {
                        BusinessServiceClient client = new BusinessServiceClient();
                        client.ClientCredentials.Windows.AllowedImpersonationLevel =
                            System.Security.Principal.TokenImpersonationLevel.Impersonation;
                        zPlanResponse = client.ManageZPlan(zPlanContract);

                        if (zPlanResponse != null)
                        {
                            salesportalinfo salesPortalDto = new salesportalinfo();
                            salesPortalDto.activityid = activityID;
                            salesPortalDto.activitytype = zPlanResponse.ActivityType;
                            salesPortalDto.caseid = zPlanResponse.CaseId;
                            salesPortalDto.redirecturl = zPlanResponse.RedirectUrl;
                            salesPortalDto.roletype = zPlanResponse.RoleType;
                            salesPortalDto.salesportalurl = zPlanResponse.SalesPortalUrl;
                            salesPortalDto.userfirstname = zPlanResponse.UserFirstName;
                            salesPortalDto.userid = zPlanResponse.UserId;
                            salesPortalDto.userlastname = zPlanResponse.UserLastName;
                            salesPortalDto.usertype = zPlanResponse.UserType;
                            salesPortalDto.casestatus = zPlanResponse.CaseStatus;
                            salesPortalDto.country = country;
                            salesPortalDto.saleschannel = salesChannel;
                            activityStatusDao.saveSalesPortalInfo(activityID, salesPortalDto);

                            caseid = zPlanResponse.ActivityId;

                            //check if ClonedFrom is sent from portal
                            if (zPlanResponse.ClonedFrom != null && zPlanResponse.ClonedFrom != "")
                            {
                                clonedFrom = zPlanResponse.ClonedFrom;

                                //check if case has been cloned earlier
                                clonemappingid clonemapping = activityStatusDao.getCloneMappingForCaseid(clonedFrom, zPlanResponse.ActivityId);

                                if (clonemapping == null)
                                {
                                    //if the case is not cloned, add entry in the clone mapping table and clone the case
                                    clonemapping = new clonemappingid();
                                    clonemapping.clonedfrom = clonedFrom;
                                    clonemapping.newid = zPlanResponse.ActivityId;
                                    activityStatusDao.saveClonemapping(clonemapping);

                                    activityStatusDao.cloneCase(clonedFrom, zPlanResponse.ActivityId);
                                }

                            }

                        }
                    }
                    catch (Exception ex)
                    {
                        //log exception to db
                        exceptionlog exLog = new exceptionlog();
                        exLog.message = ex.Message + " class: MyZurichAdviser Method: Page_Load";
                        exLog.source = ex.Source;

                        string strtmp = ex.StackTrace;
                        strtmp = strtmp.Replace('\r', ' ');
                        strtmp = strtmp.Replace('\n', ' ');
                        exLog.stacktrace = strtmp;

                        exLog.targetsitename = ex.TargetSite.Name;

                        activityStatusDao.logException(exLog);
                    }

                }
                else
                {
                    string backCaseId = Request.Form["caseid"];
                    string menuCaseId = Request.QueryString["caseid"];

                    if (backCaseId != null && backCaseId != "")
                    {
                        caseid = backCaseId;
                    }
                    else if (menuCaseId != null && menuCaseId != "")
                    {
                        caseid = menuCaseId;
                    }
                    else if (Session["fnacaseid"] != null)
                    {
                        caseid = Session["fnacaseid"].ToString();
                    }
                    else
                    {
                        caseid = "2040";
                    }

                }

                activityId.Value = caseid;
                PersonalDetailsDAO dao = new PersonalDetailsDAO();
                personaldetail detail = dao.getPersonalDetail(caseid);

                if (detail != null)
                {
                    if (zPlanResponse != null)
                    {
                        detail.datepicker = zPlanResponse.Dob;
                        detail.gender = zPlanResponse.Gender;
                        //detail.maritalstatus = zPlanResponse.MaritalStatus;
                        detail.name = zPlanResponse.UserFirstName;
                        detail.surname = zPlanResponse.UserLastName;
                        detail.nationality = zPlanResponse.Nationality;
                        detail.nric = zPlanResponse.NricOrPassport;
                        detail.occupation = zPlanResponse.Occupation;
                        if (zPlanResponse.Smoker)
                        {
                            detail.issmoker = "Yes";
                        }
                        else
                        {
                            detail.issmoker = "No";
                        }
                        detail.title = zPlanResponse.Title;
                    }

                    dao.updatePersonalDetails(detail);
                }
                else
                {
                    detail = new personaldetail();
                    detail.caseid = caseid;

                    if (zPlanResponse != null)
                    {
                        detail.datepicker = zPlanResponse.Dob;
                        detail.gender = zPlanResponse.Gender;
                        //detail.maritalstatus = zPlanResponse.MaritalStatus;
                        detail.name = zPlanResponse.UserFirstName;
                        detail.surname = zPlanResponse.UserLastName;
                        detail.nationality = zPlanResponse.Nationality;
                        detail.nric = zPlanResponse.NricOrPassport;
                        detail.occupation = zPlanResponse.Occupation;
                        if (zPlanResponse.Smoker)
                        {
                            detail.issmoker = "Yes";
                        }
                        else
                        {
                            detail.issmoker = "No";
                        }
                        detail.title = zPlanResponse.Title;
                    }
                    dao.savePersonalDetails(detail);
                }

                if (caseid != "")
                {
                    ViewState["caseid"] = caseid;

                    List<myzurichadviser> savedMzaoptions = mzaDao.getMza(caseid);

                    if (savedMzaoptions != null && savedMzaoptions.Count>0)
                    {
                        ViewState["casetype"] = "update";
                    }
                    else
                    {
                        ViewState["casetype"] = "new";
                        savedMzaoptions = new List<myzurichadviser>();
                        myzurichadviser mzadv = new myzurichadviser();
                        mzadv.caseid = caseid;
                        mzadv.selectedoptionid = 1;
                        savedMzaoptions.Add(mzadv);

                        mzadv = new myzurichadviser();
                        mzadv.caseid = caseid;
                        mzadv.selectedoptionid = 2;
                        savedMzaoptions.Add(mzadv);
                    }

                    populateMzaoptions(savedMzaoptions, caseid);

                }

            }
            markStatusOnTab(caseid);
        }
Пример #2
0
        protected void savePersonaldetails(object sender, EventArgs e)
        {
            string caseId= (string)ViewState["caseId"];
            PersonalDetailsDAO dao = new PersonalDetailsDAO();
            personaldetail detail = dao.getPersonalDetail(caseId);

            string actv = "";
            if (ViewState["activity"] != null)
            {
                actv = ViewState["activity"].ToString();
            }

            personaldetail returnDetail = new personaldetail();
            if (detail != null)
            {
                copyPersonalDetail(detail);
               detail= dao.updatePersonalDetails(detail);

            }
            else
            {
                detail = new personaldetail();
                detail.caseid = caseId;
                copyPersonalDetail(detail);
                try
                {
                    dao.savePersonalDetails(detail);
                    lblPersonalDetailSuccess.Visible = true;
                }
                catch (Exception ex)
                {
                    lblPersonalDetailFailed.Visible = true;
                    throw ex;
                }
            }

            string status = activityStatusCheck.getPersonalDetailStatus(detail);
            activityStatusDao.saveOrUpdateActivityStatus(caseId, actv, status);

            markStatusOnTab(caseId);

            string caseStatus = activityStatusCheck.getZPlanStatus(caseId);
            casestatuslbl.Visible = false;
            casestatuslbl.Text = "zplan status: " + caseStatus;

            string url = Server.MapPath("~/_layouts/Zurich/Printpages/");
            //try
            //{

            //    GeneratePdf genPdf = new GeneratePdf();
            //    MemoryStream output = genPdf.createPdf(caseId, url);
            //    pdfData = output.ToArray();
            //}
            //catch (Exception ex)
            //{
            //    throw;
            //}

            pdfData = activityStatusCheck.sendDataToSalesPortal(caseId, caseStatus, url, sendPdf);
            /*if (st == 1)
            {
                lblStatusSubmitted.Visible = false;
            }
            else
            {
                lblStatusSubmissionFailed.Visible = true;
            }*/

            populatePersonalDetails(detail);
        }