コード例 #1
0
        public ActionResult CreateNewFormResult(string formId)
        {
            def_FormResults frmRes = FormResults.CreateNewFormResultModel(formId);

            ContentResult result = new ContentResult();

            try
            {
                int formRsltId = formsRepo.AddFormResult(frmRes);
                result.Content = formRsltId.ToString();

                //test CreateNewResponseValues

                /*
                 * Dictionary<string, string> responsesByIdentifer = new Dictionary<string, string>();
                 * responsesByIdentifer.Add("sis_cl_addr_line1", "I am the walrus.");
                 * CreateNewResponseValues(formRsltId, responsesByIdentifer);
                 */
            }
            catch (Exception excptn)
            {
                Debug.WriteLine("Defws.CreateNewFormResult exception:" + excptn.Message);
            }

            return(result);      // return the FormResult id just added
        }
コード例 #2
0
        public ActionResult Index()
        {
            if (!SessionHelper.IsUserLoggedIn)
            {
                return(RedirectToAction("Index", "Account", null));
            }

            if (SessionHelper.SessionForm == null)
            {
                SessionHelper.SessionForm = new SessionForm();
            }

            // retrieve and set SessionForm params
            string    formIdent = "View_Test_Form";
            def_Forms frm       = formsRepo.GetFormByIdentifier(formIdent);

            if (frm == null)
            {
                return(Content("Could not find form with identifier \"" + formIdent + "\""));
            }
            def_FormResults fr = formsRepo.GetFormResultsByFormId(frm.formId).FirstOrDefault();

            if (fr == null)
            {
                fr = new def_FormResults()
                {
                    formId           = frm.formId,
                    formStatus       = 0,
                    sessionStatus    = 0,
                    dateUpdated      = DateTime.Now,
                    deleted          = false,
                    locked           = false,
                    archived         = false,
                    EnterpriseID     = 0,
                    GroupID          = 0,
                    subject          = 0,
                    interviewer      = 0,
                    assigned         = 0,
                    training         = false,
                    reviewStatus     = 0,
                    statusChangeDate = DateTime.Now
                };
                formsRepo.AddFormResult(fr);
            }


            SessionHelper.SessionForm.formId         = frm.formId;
            SessionHelper.SessionForm.formResultId   = fr.formResultId;
            SessionHelper.SessionForm.formIdentifier = frm.identifier;
            SessionHelper.LoginStatus.EnterpriseID   = 0;

            def_Parts prt = formsRepo.GetFormParts(frm)[0];

            SessionHelper.SessionForm.partId = prt.partId;
            Session["part"] = prt.partId;

            def_Sections sct = formsRepo.GetSectionsInPart(prt)[0];

            return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = SessionHelper.SessionForm.partId.ToString() }));
        }
コード例 #3
0
        public ActionResult AddFormResults()
        {
            string paramFormId = Request["formId"] as string;

            mLogger.Debug("* * *  ResultsController AddFormResults formId: {0}", paramFormId);

            Session["formId"] = paramFormId;
            int             formId = Convert.ToInt32(paramFormId);
            def_FormResults frmRes = new def_FormResults()
            {
                formId        = formId,
                formStatus    = 0,
                sessionStatus = 0,
                dateUpdated   = DateTime.Today
            };
            int frmRslt = formsRepo.AddFormResult(frmRes);

            frmRes = formsRepo.GetFormResultById(frmRslt);
            def_Forms        frm   = formsRepo.GetFormById(formId);
            List <def_Parts> parts = formsRepo.GetFormParts(frm);

            // Setup session variables
            SessionForm sf = SessionHelper.SessionForm;

            sf.formId       = frm.formId;
            sf.formResultId = frmRslt;

            return(RedirectToAction("Parts", "Results", null));
        }
コード例 #4
0
        /// <summary>
        /// Creates a new LA-ADAP Stub application for the given ramsellId
        ///
        /// This may involve inserting a new UAS_User.
        /// </summary>
        /// <returns>the formResultId of the newly-created application</returns>
        public int CreateAndPrepopulateNewStubApp(string ramsellId)
        {
            def_FormResults previousApp     = GetMostRecentAppWithRamsellId(ramsellId);
            def_FormResults previousStubApp = GetMostRecentAppWithRamsellId(ramsellId, stubForm.formId);
            def_FormResults newStubApp      = CreateNewBlankStubApp(ramsellId, previousApp);

            PrepopulateStubApp(newStubApp, previousStubApp, ramsellId);
            formsRepo.AddFormResult(newStubApp);
            ReviewStatus.ChangeStatus(formsRepo, newStubApp, ReviewStatus.TO_BE_REVIEWED, "Created Stub Application");
            return(newStubApp.formResultId);
        }
コード例 #5
0
        public bool saveInterviewer(int?intId)
        {
            if (intId == null)
            {
                return(false);
            }

            if (SessionHelper.SessionForm == null)
            {
                SessionHelper.SessionForm = new SessionForm();
            }
            SessionForm sessionForm = SessionHelper.SessionForm;

            def_FormResults frmRslt = formsRepo.GetFormResultById(sessionForm.formResultId);

            if (frmRslt == null)
            {
                string paramFormId = Request["formId"] as string;

                Session["formId"] = paramFormId;
                int formId = Convert.ToInt32(paramFormId);

                frmRslt = new def_FormResults()
                {
                    formId        = formId,
                    formStatus    = 0,
                    sessionStatus = 0,
                    dateUpdated   = DateTime.Today
                };
                int frmRsId = formsRepo.AddFormResult(frmRslt);
                frmRslt = formsRepo.GetFormResultById(frmRsId);
            }

            frmRslt.interviewer = intId;

            bool ventureMode = SessionHelper.IsVentureMode;

            if ((frmRslt.formStatus == (byte)FormResults_formStatus.NEW) && !ventureMode)
            {
                frmRslt.assigned = intId;
            }

            try
            {
                SaveFormResults(frmRslt);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
コード例 #6
0
        public ActionResult CreateAdapApplication()
        {
            def_Forms frm = formsRepo.GetFormByIdentifier("ADAP");
            //string userId = Request["userId"];
            int userId = 0;

            try
            {
                userId = Convert.ToInt32(Request["userId"]);
            }
            catch (Exception excptn)
            {
                Debug.WriteLine("Adap Controller CreateAdapApplication exception:" + excptn.Message);
            }

            int?            intSO   = formsRepo.GetStatusDetailByMasterIdentifier(1, "CANCELLED").sortOrder;
            def_FormResults prevRes = formsRepo.GetEntities <def_FormResults>(x => x.formId == frm.formId &&
                                                                              x.subject == userId &&
                                                                              x.formStatus != intSO)
                                      .OrderByDescending(x => x.dateUpdated)
                                      .FirstOrDefault();

            //def_FormResults prevRes = frm.def_FormResults.Where(f => f.subject == userId && intSO != null && f.formStatus != intSO).OrderByDescending(f => f.dateUpdated).FirstOrDefault();


            if ((prevRes == null) || (prevRes.formStatus == formsRepo.GetStatusDetailByMasterIdentifier(1, "APPROVED").sortOrder))
            {
                AuthenticationClient webclient = new AuthenticationClient();
                UserDisplay          ud        = webclient.GetUserDisplay(userId);

                Dictionary <string, string> ItemsToPopulateFromUAS = new Dictionary <string, string>();
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D1_FirstName_item", String.IsNullOrEmpty(ud.FirstName) ? String.Empty : ud.FirstName);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D1_LastName_item", String.IsNullOrEmpty(ud.LastName) ? String.Empty : ud.LastName);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D1_MiddleIntl_item", String.IsNullOrEmpty(ud.MiddleName) ? String.Empty : ud.MiddleName.Substring(0, 1));
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D2_DOB_item", (ud.DOB == null) ? String.Empty : Convert.ToDateTime(ud.DOB).ToString("MM/dd/yyyy"));
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_Address_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].Address1 : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_MayContactYN_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ((ud.Addresses[0].MayContactAddress) ? "1" : "0") : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_City_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].City : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_State_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].State : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_Zip_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].ZIP : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_Address_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].Address1 : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_MayContactYN_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ((ud.Addresses[1].MayContactAddress) ? "1" : "0") : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_City_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].City : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_State_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].State : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_Zip_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].ZIP : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone1_Num_item", (ud.Phones != null && ud.Phones.Count() > 0) ? ud.Phones[0].Phone : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone1_MayMsgYN_item", (ud.Phones != null && ud.Phones.Count() > 0) ? ((ud.Phones[0].MayContactPhone) ? "1" : "0") : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone2_Num_item", (ud.Phones != null && ud.Phones.Count() > 1) ? ud.Phones[1].Phone : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone2_MayMsgYN_item", (ud.Phones != null && ud.Phones.Count() > 1) ? ((ud.Phones[1].MayContactPhone) ? "1" : "0") : String.Empty);

                // * * * OT 1-20-16 updated this list based on Docs/ADAP/ADAP_item_list.xslx (revision 80734)
                string[] ItemIdentifiersToPopulateFromPrevApplication = new string[]
                {
                    #region long list of item identifiers
                    "ADAP_D1_LastName_item",
                    "ADAP_D1_FirstName_item",
                    "ADAP_D1_MiddleIntl_item",
                    "ADAP_D1_AltName_item",
                    "ADAP_D2_DOB_item",
                    "ADAP_D3_White_item",
                    "ADAP_D3_Black_item",
                    "ADAP_D3_Asian_item",
                    "ADAP_D3_Native_item",
                    "ADAP_D3_Indian_item",
                    "ADAP_D4_EthnicDrop_item",
                    "ADAP_D4_Mexican_item",
                    "ADAP_D4_Puerto_item",
                    "ADAP_D4_Cuban_item",
                    "ADAP_D4_Other_item",
                    "ADAP_D5_Indian_item",
                    "ADAP_D5_Filipino_item",
                    "ADAP_D5_Korean_item",
                    "ADAP_D5_Other_item",
                    "ADAP_D5_Chinese_item",
                    "ADAP_D5_Japanese_item",
                    "ADAP_D5_Vietnamese_item",
                    "ADAP_D5_NA_item",
                    "ADAP_D6_Native_item",
                    "ADAP_D6_Guam_item",
                    "ADAP_D6_Samoan_item",
                    "ADAP_D6_Other_item",
                    "ADAP_D6_NA_item",
                    "ADAP_D7_LangDrop_item",
                    "ADAP_D7_LangOther_item",
                    "ADAP_D8_CurrGenderDrop_item",
                    "ADAP_D8_BirthGenderDrop_item",
                    "ADAP_D9_Ramsell_item",
                    "ADAP_D10_SSN_item",
                    "ADAP_C1_Address_item",
                    "ADAP_C1_City_item",
                    "ADAP_C1_State_item",
                    "ADAP_C1_Zip_item",
                    "ADAP_C1_County_item",
                    "ADAP_C1_MayContactYN_item",
                    "ADAP_C2_SameAsMailing_item",
                    "ADAP_C2_Address_item",
                    "ADAP_C2_City_item",
                    "ADAP_C2_State_item",
                    "ADAP_C2_Zip_item",
                    "ADAP_C2_County_item",
                    "ADAP_C2_MayContactYN_item",
                    "ADAP_C3_Phone1_Num_item",
                    "ADAP_C3_Phone1_Type_item",
                    "ADAP_C3_Phone1_MayMsgYN_item",
                    "ADAP_C3_Phone2_Num_item",
                    "ADAP_C3_Phone2_Type_item",
                    "ADAP_C3_Phone2_MayMsgYN_item",
                    "ADAP_C4_MayCallYN_item",
                    "ADAP_C4_Name_item",
                    "ADAP_C4_Phone_item",
                    "ADAP_C4_KnowHivYN_item",
                    "ADAP_C5_HasCaseMngrYN_item",
                    "ADAP_C5_Mngr1_Name_item",
                    "ADAP_C5_Mngr1_Clinic_item",
                    "ADAP_C5_Mngr2_Name_item",
                    "ADAP_C5_Mngr2_Clinic_item",
                    "ADAP_C5_CanReferYN_item",
                    "ADAP_M1_Month_item",
                    "ADAP_M1_Year_item",
                    "ADAP_M1_DiagnosisLoc_item",
                    "ADAP_M2_ToldAIDS_item",
                    "ADAP_M3_ToldHepC_item",
                    "ADAP_M4_Clinic_item",
                    "ADAP_I1_Med_Yes_item",
                    "ADAP_I1_Med_Denied_item",
                    "ADAP_I1_Med_No_item",
                    "ADAP_I1_Med_Waiting_item",
                    "ADAP_I1_Med_DontKnow_item",
                    "ADAP_I1_DeniedReason_item",
                    "ADAP_I1_NotAppliedReason_item",
                    "ADAP_I2_AffCareOpt_item",
                    "ADAP_I2_AffCareOther_item",
                    "ADAP_I3_MedicareYN_item",
                    "ADAP_I3_MedNumber_item",
                    "ADAP_I3_PartAYN_item",
                    "ADAP_I3_PartBYN_item",
                    "ADAP_I3_PartADate_item",
                    "ADAP_I3_PartBDate_item",
                    "ADAP_H1_StatusDrop_item",
                    "ADAP_H2_RelnDrop_item",
                    "ADAP_H2_RelnOther_item",
                    "ADAP_H3_FileTaxYN_item",
                    "ADAP_H3_TaxStatusOpt_item",
                    "ADAP_H3_TaxDependants_item",
                    "ADAP_H3_TaxNotFileOpt_item",
                    "ADAP_H3_TaxNotFileOther_item",
                    "ADAP_H3_Relatives_item",
                    "ADAP_H4_ChildrenIn_item",
                    "ADAP_H4_ChildrenOut_item",
                    "ADAP_F1_EmployOpt_item",
                    "ADAP_F1_EmployOther_item",
                    "ADAP_F1_EmployerInsOpt_item",
                    "ADAP_F1_EmployNotEnrolled_item",
                    "ADAP_F2_EmployLast90YN_item",
                    "ADAP_F3_A_Recipient_item",
                    "ADAP_F3_A_IncomeTypeDrop_item",
                    "ADAP_F3_A_Employer_item",
                    "ADAP_F3_A_EmployStart_item",
                    "ADAP_F3_A_TempYN_item",
                    "ADAP_F3_A_IncomeTypeOther_item",
                    "ADAP_F3_A_IncomeAmt_item",
                    "ADAP_F3_A_EmployerForm_item",
                    "ADAP_F3_B_Recipient_item",
                    "ADAP_F3_B_IncomeTypeDrop_item",
                    "ADAP_F3_B_Employer_item",
                    "ADAP_F3_B_EmployStart_item",
                    "ADAP_F3_B_TempYN_item",
                    "ADAP_F3_B_IncomeTypeOther_item",
                    "ADAP_F3_B_IncomeAmt_item",
                    "ADAP_F3_B_EmployerForm_item",
                    "ADAP_F3_C_Recipient_item",
                    "ADAP_F3_C_IncomeTypeDrop_item",
                    "ADAP_F3_C_Employer_item",
                    "ADAP_F3_C_EmployStart_item",
                    "ADAP_F3_C_TempYN_item",
                    "ADAP_F3_C_IncomeTypeOther_item",
                    "ADAP_F3_C_IncomeAmt_item",
                    "ADAP_F3_C_EmployerForm_item",
                    "ADAP_F3_D_Recipient_item",
                    "ADAP_F3_D_IncomeTypeDrop_item",
                    "ADAP_F3_D_Employer_item",
                    "ADAP_F3_D_EmployStart_item",
                    "ADAP_F3_D_TempYN_item",
                    "ADAP_F3_D_IncomeTypeOther_item",
                    "ADAP_F3_D_IncomeAmt_item",
                    "ADAP_F3_D_EmployerForm_item",
                    "ADAP_cert_NoSharing_item",
                    "ADAP_cert_Reminders_item"
                    #endregion
                };

                Applications    appl   = new Applications(formsRepo);
                def_FormResults frmRes = appl.CreateFormResultPopulatedFromUAS(SessionHelper.LoginStatus.EnterpriseID, SessionHelper.LoginStatus.GroupID, userId, frm.formId, ItemsToPopulateFromUAS);
                appl.PopulateItemsFromPrevApplication(frmRes, ItemIdentifiersToPopulateFromPrevApplication);

                frmRes.statusChangeDate = DateTime.Now;

                // Save the FormResult, ItemResults, and ResponseVariables
                int newFormResultId = 0;
                try
                {
                    newFormResultId = formsRepo.AddFormResult(frmRes);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("AddFormResult exception:" + ex.Message);
                }

                Debug.WriteLine("AddFormResult newFormResultId:" + newFormResultId.ToString());

                // query the ramsell system and update the formResult responses based on Ramsell response
                def_ResponseVariables rvMemberId = formsRepo.GetResponseVariablesByFormResultIdentifier(newFormResultId, "ADAP_D9_Ramsell");
                if (rvMemberId != null && !String.IsNullOrWhiteSpace(rvMemberId.rspValue))
                {
                    string memberId = rvMemberId.rspValue;
                    string usrId    = UAS.Business.UAS_Business_Functions.GetEntAppConfigAdap("USR");
                    string password = UAS.Business.UAS_Business_Functions.GetEntAppConfigAdap("PWD");
                    Debug.WriteLine("Ramsell UseriD / Password: "******" / " + password);

                    string token = Ramsell.GetOauthToken(usrId, password);
                    new RamsellImport(formsRepo, frmRes.formResultId).ImportApplication(token, memberId);
                }
                //AJBoggs.Adap.Services.Api.Ramsell.PopulateItemsFromRamsellImport(formsRepo, frmRes);

                if (SessionHelper.SessionForm == null)
                {
                    SessionHelper.SessionForm = new SessionForm();
                }

                SessionForm sf = SessionHelper.SessionForm;
                sf.formId         = frm.formId;
                sf.formIdentifier = frm.identifier;
                sf.sectionId      = formsRepo.GetSectionByIdentifier("ADAP_demographic").sectionId;
                sf.partId         = formsRepo.GetPartByFormAndIdentifier(frm, "ADAP").partId;

                // *** RRB - should be deprecated - use SessionForm
                // *** BR - line 359 of the ResultsController calls this session variable, so it must be set to prevent an exception.
                //  Other parts of the application may still use that variable, so changing it in the ResultsController may break something else.
                Session["part"] = sf.partId;
                // Should have the partId also - may not be required.

                sf.formResultId = newFormResultId;

                return(RedirectToAction("Template", "Results", new { sectionId = sf.sectionId.ToString() }));
            }
            else
            {
                return(RedirectToAction("AdapPortal", "COADAP", new { userId = userId, error = "Not Approved" }));
            }
        }
コード例 #7
0
        public ActionResult CreateAdapApplication()
        {
            def_Forms frm = formsRepo.GetFormByIdentifier("LA-ADAP");
            //string userId = Request["userId"];
            int userId = 0;

            try
            {
                userId = Convert.ToInt32(Request["userId"]);
            }
            catch (Exception excptn)
            {
                Debug.WriteLine("Adap Controller CreateAdapApplication exception:" + excptn.Message);
            }

            bool isCaseMgr = UAS.Business.UAS_Business_Functions.hasPermission(2, "RptsExpts"); // Case Manager permission

            int?intSO = formsRepo.GetStatusDetailByMasterIdentifier(1, "CANCELLED").sortOrder;

            def_FormResults prevRes = formsRepo.GetEntities <def_FormResults>(f => f.subject == userId && intSO != null && f.formStatus != intSO).OrderByDescending(f => f.dateUpdated).FirstOrDefault();

            //def_FormResults prevRes = frm.def_FormResults.Where(f => f.subject == userId && intSO != null && f.formStatus != intSO).OrderByDescending(f => f.dateUpdated).FirstOrDefault();

            if ((prevRes == null) || (prevRes.formStatus == formsRepo.GetStatusDetailByMasterIdentifier(1, "APPROVED").sortOrder))
            {
                AuthenticationClient webclient = new AuthenticationClient();
                UserDisplay          ud        = webclient.GetUserDisplay(userId);

                //Dictionary<string, string> ItemsToPopulateFromUAS = new Dictionary<string, string>();
                //ItemsToPopulateFromUAS.Add(
                //    "ADAP_D1_FirstName_item", String.IsNullOrEmpty(ud.FirstName) ? String.Empty : ud.FirstName);
                //ItemsToPopulateFromUAS.Add(
                //    "ADAP_D1_LastName_item", String.IsNullOrEmpty(ud.LastName) ? String.Empty : ud.LastName);

                //ItemsToPopulateFromUAS.Add(
                //    "ADAP_D2_DOB_item", ud.DOB.HasValue == false ? String.Empty : ud.DOB.Value.ToShortDateString());

                //if (ud.Addresses.Any())
                //{
                //    ItemsToPopulateFromUAS.Add(
                //                        "ADAP_C1_Address_item", String.IsNullOrEmpty(ud.Addresses[0].Address1) ? String.Empty
                //                        : ud.Addresses[0].Address1);
                //    ItemsToPopulateFromUAS.Add(
                //                       "LA_ADAP_AddrAptNum_item", String.IsNullOrEmpty(ud.Addresses[0].Address2) ? String.Empty
                //                       : ud.Addresses[0].Address2);
                //    ItemsToPopulateFromUAS.Add(
                //                       "ADAP_C1_City_item", String.IsNullOrEmpty(ud.Addresses[0].City) ? String.Empty
                //                       : ud.Addresses[0].City);
                //    ItemsToPopulateFromUAS.Add(
                //                       "ADAP_C1_State_item", String.IsNullOrEmpty(ud.Addresses[0].State) ? String.Empty
                //                       : ud.Addresses[0].State);
                //    ItemsToPopulateFromUAS.Add(
                //                       "ADAP_C1_Zip_item", String.IsNullOrEmpty(ud.Addresses[0].ZIP) ? String.Empty
                //                       : ud.Addresses[0].ZIP);
                //}

                //if (ud.Emails.Any())
                //{
                //    ItemsToPopulateFromUAS.Add(
                //                        "LA_ADAP_Email_Adr", String.IsNullOrEmpty(ud.Emails[0].Email) ? String.Empty
                //                        : ud.Emails[0].Email);
                //}
                Dictionary <string, string> ItemsToPopulateFromUAS = new Dictionary <string, string>();
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D1_FirstName_item", String.IsNullOrEmpty(ud.FirstName) ? String.Empty : ud.FirstName);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D1_LastName_item", String.IsNullOrEmpty(ud.LastName) ? String.Empty : ud.LastName);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D1_MiddleIntl_item", String.IsNullOrEmpty(ud.MiddleName) ? String.Empty : ud.MiddleName.Substring(0, 1));
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D2_DOB_item", (ud.DOB == null) ? String.Empty : Convert.ToDateTime(ud.DOB).ToString("MM/dd/yyyy"));
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_Address_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].Address1 : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_MayContactYN_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ((ud.Addresses[0].MayContactAddress) ? "1" : "0") : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_City_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].City : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_State_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].State : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_Zip_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].ZIP : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_Address_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].Address1 : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_MayContactYN_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ((ud.Addresses[1].MayContactAddress) ? "1" : "0") : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_City_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].City : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_State_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].State : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_Zip_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].ZIP : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone1_Num_item", (ud.Phones != null && ud.Phones.Count() > 0) ? ud.Phones[0].Phone : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone1_MayMsgYN_item", (ud.Phones != null && ud.Phones.Count() > 0) ? ((ud.Phones[0].MayContactPhone) ? "1" : "0") : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone2_Num_item", (ud.Phones != null && ud.Phones.Count() > 1) ? ud.Phones[1].Phone : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone2_MayMsgYN_item", (ud.Phones != null && ud.Phones.Count() > 1) ? ((ud.Phones[1].MayContactPhone) ? "1" : "0") : String.Empty);



                Applications    appl   = new Applications(formsRepo);
                def_FormResults frmRes = appl.CreateFormResultPopulatedFromUAS(SessionHelper.LoginStatus.EnterpriseID, SessionHelper.LoginStatus.GroupID, userId, frm.formId, ItemsToPopulateFromUAS);

                if (isCaseMgr)
                {
                    frmRes.interviewer = SessionHelper.LoginStatus.UserID;
                }
                else if (ud.ManagerID != null)
                {
                    frmRes.interviewer = ud.ManagerID;
                }

                frmRes.statusChangeDate = DateTime.Now;

                // Save the FormResult, ItemResults, and ResponseVariables
                int newFormResultId = 0;
                try
                {
                    newFormResultId = formsRepo.AddFormResult(frmRes);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("AddFormResult exception:" + ex.Message);
                }

                Debug.WriteLine("AddFormResult newFormResultId:" + newFormResultId.ToString());

                if (SessionHelper.SessionForm == null)
                {
                    SessionHelper.SessionForm = new SessionForm();
                }

                SessionForm sf = SessionHelper.SessionForm;
                sf.formId         = frm.formId;
                sf.formIdentifier = frm.identifier;
                sf.sectionId      = formsRepo.GetSectionByIdentifier("LA_ADAP_PreScreen").sectionId;
                sf.partId         = formsRepo.GetPartByFormAndIdentifier(frm, "LA-ADAP").partId;

                // *** RRB - should be deprecated - use SessionForm
                // *** BR - line 359 of the ResultsController calls this session variable, so it must be set to prevent an exception.
                //  Other parts of the application may still use that variable, so changing it in the ResultsController may break something else.
                Session["part"] = sf.partId;
                // Should have the partId also - may not be required.

                sf.formResultId = newFormResultId;

                return(RedirectToAction("Template", "Results", new { sectionId = sf.sectionId.ToString() }));
            }
            else
            {
                if (isCaseMgr)
                {
                    userId = SessionHelper.LoginStatus.UserID;
                }
                return(RedirectToAction("AdapPortal", "LAADAP", new { userId = userId, error = "Not Approved" }));
            }
        }
コード例 #8
0
        public static string ImportFormResultJSON(IFormsRepository formsRepo, string json)
        {
            string result = String.Empty;

            try
            {
                var dFormResults = fastJSON.JSON.Parse(json);
                Dictionary <string, Object> resDict = (Dictionary <string, Object>)dFormResults;

                ////add the def_FormResults object to the database, which will assign and return a formResultId
                //int formRsltId = formsRepo.AddFormResult((def_FormResults) dFormResults);

                def_FormResults formResult = new def_FormResults()
                {
                    formId        = Convert.ToInt32(resDict["formId"]),
                    dateUpdated   = DateTime.Now,
                    formStatus    = Convert.ToByte(resDict["formStatus"]),
                    sessionStatus = Convert.ToByte(resDict["sessionStatus"])
                };

                int formRsltId = formsRepo.AddFormResult(formResult);

                List <Object> itemObjectList = (List <Object>)resDict["def_ItemResults"];
                foreach (Object o in itemObjectList)
                {
                    Dictionary <string, object> dict        = (Dictionary <string, object>)o;
                    def_ItemResults             itemResults = new def_ItemResults
                    {
                        formResultId  = formRsltId,
                        itemId        = Convert.ToInt32(dict["itemId"]),
                        sessionStatus = Convert.ToInt32(dict["sessionStatus"]),
                        dateUpdated   = Convert.ToDateTime(dict["dateUpdated"])
                    };

                    int itemResultId = formsRepo.AddItemResult(itemResults);

                    List <Object> respVarObjectList = (List <Object>)dict["def_ResponseVariables"];

                    foreach (Object r in respVarObjectList)
                    {
                        Dictionary <string, object> rDict = (Dictionary <string, object>)r;

                        DateTime?date;
                        if (rDict["rspDate"] == null)
                        {
                            date = null;
                        }
                        else
                        {
                            date = Convert.ToDateTime(rDict["rspDate"]);
                        }

                        def_ResponseVariables dResponseVariables = new def_ResponseVariables
                        {
                            itemResultId   = itemResultId,
                            itemVariableId = Convert.ToInt32(rDict["itemVariableId"]),
                            rspInt         = Convert.ToInt32(rDict["rspInt"]),
                            rspFloat       = Convert.ToDouble(rDict["rspFloat"]),
                            rspDate        = date,
                            rspValue       = Convert.ToString(rDict["rspValue"])
                        };

                        formsRepo.AddResponseVariableNoSave(dResponseVariables);
                    }
                }

                formsRepo.Save();

                //pass the formResultId to the return value container
                result = formRsltId.ToString();

                AccessLogging.InsertAccessLogRecord(formsRepo, formRsltId, (int)AccessLogging.accessLogFunctions.IMPORT, "Imported assessment from JSON.");
            }
            catch (Exception excptn)
            {
                Debug.WriteLine("Def3WebServices.LoadFormResultJSON exception:" + excptn.Message);
            }

            return(result);
        }