コード例 #1
0
        private string CreateAssessmentItem(ClsListAssessmentItem pObj, bool pIs_Sub_Grid, int pParentOrder = -1, int pSubOrder = -1)
        {
            StringBuilder sb = new StringBuilder();
            //question
            string _display            = string.Empty;
            string _tooltip            = string.Empty;
            string _is_required_symbol = string.Empty;
            bool   is_sub          = (pObj.ParentID > 0 && pParentOrder > 0 && pSubOrder > 0);
            string header_tag      = "<h6";
            string _id_img_postfix = "_";

            if (!string.IsNullOrEmpty(pObj.HelpText))
            {
                _tooltip = " data-toggle='tooltip' data-placement='top' title='" + pObj.HelpText + "' ";
            }

            if (pObj.IsMandatory)
            {
                _is_required_symbol = "<text style='color:red;'>*</text>";
            }

            if (is_sub && !pIs_Sub_Grid)
            {
                header_tag       = "<h7";
                _id_img_postfix += pParentOrder.ToString() + "_" + pSubOrder.ToString();
            }
            else if (is_sub && pIs_Sub_Grid)
            {
                _id_img_postfix += pParentOrder.ToString();
            }
            else
            {
                _id_img_postfix += pObj.Order.ToString();
            }


            if (!pIs_Sub_Grid)
            {
                if (!string.IsNullOrEmpty(pObj.DisplayCondition))
                {
                    bool formula_result = false;
                    gAssessment_br.ExecuteFormula(pObj.ItemID, "", ref formula_result);
                    if (!formula_result)
                    {
                        _display = " display: none !important; ";
                    }
                }
                sb.Append("<hr />");
                sb.AppendFormat("{0} class='mb-3 text-black' id='item{1}' style='{2}' data-key='{3}' >", header_tag, _id_img_postfix, _display, pObj.ItemID.ToString());
                sb.AppendFormat("<strong {0}>", _tooltip);
                if (is_sub)
                {
                    sb.AppendFormat("{0}.{1}) {2} {3}", pParentOrder.ToString(), pSubOrder.ToString(), pObj.Text, _is_required_symbol);
                }
                else
                {
                    sb.AppendFormat("{0}) {1} {2}", pObj.Order.ToString(), pObj.Text, _is_required_symbol);
                }

                sb.Append("</strong>");

                sb.AppendFormat("<a id='divStatus_{0}' class='pull-right'> <i id='img{0}' data-required='{1}' class='' style='font-size:20px;' ></i> </a>", _id_img_postfix, pObj.IsMandatory.ToString());
                sb.Append("<hr />");
            }

            //answer & option
            ClsListAssessmentItem objAI = null;

            if (pIs_Sub_Grid)
            {
                objAI = pObj;
            }
            sb.Append(CreateAssessmentItemXChoice(pObj.ItemID, pObj.TypeID, _id_img_postfix, pObj.RelatedDCIds, pObj.RelatedFBIds, objAI));
            //CommonUtilities.GlobalEncrypt(pObj.AssessmentItemID.ToString(), BSWSession.SessionKey)
            return(sb.ToString());
        }
コード例 #2
0
        public string SaveValueX(string pItemID, string pAsseID, string pScore, string pVal, string pType, string pRequired, string pCID, string pKeyRel, string pAsseRespID, string pKeyRelFB)
        {
            bool _temp_res = false;
            bool is_req    = false;

            bool.TryParse(pRequired, out is_req);

            if (string.IsNullOrEmpty(pVal) && is_req)
            {
                throw new Exception("Can not be empty!");
            }

            if (string.IsNullOrEmpty(pVal))
            {
                return("false");
            }

            int _cid = -1;
            int type_assessment_val;

            Constants.enAssessmentItemType _type = Constants.enAssessmentItemType.TEXT;
            if (Int32.TryParse(pType, out type_assessment_val))
            {
                _type = (Constants.enAssessmentItemType)type_assessment_val;
                if (_type == Constants.enAssessmentItemType.DATETIME)
                {
                    DateTime _dt;
                    if (DateTime.TryParse(pVal, out _dt) == false)
                    {
                        CommonUtilities.Log("Can not convert value to date! Value : " + pVal + Environment.NewLine + "Assessment_WS.asmx");
                        throw new Exception("Can not convert value to date!");
                    }
                }
                else if (_type == Constants.enAssessmentItemType.INTEGER)
                {
                    int _val;
                    if (int.TryParse(pVal, out _val) == false)
                    {
                        CommonUtilities.Log("Can not convert value to number! Value : " + pVal + Environment.NewLine + "Assessment_WS.asmx");
                        throw new Exception("Can not convert value to number!");
                    }
                }
                else if (_type == Constants.enAssessmentItemType.MULTIPLE_CHOICE_CHK || _type == Constants.enAssessmentItemType.MULTIPLE_CHOICE_RADIO || _type == Constants.enAssessmentItemType.GRID_RADIO || _type == Constants.enAssessmentItemType.GRID_CHK)
                {
                    if (int.TryParse(pCID, out _cid) == false)
                    {
                        CommonUtilities.Log("Can not convert value to number! Value : " + pVal + Environment.NewLine + "Assessment_WS.asmx");
                        throw new Exception("Can not convert value to number!");
                    }
                }
            }
            else
            {
                throw new Exception("An error occured!");
            }

            //if(Constants.enAssessmentItemType.TEXT )

            BSWSession cses = new BSWSession(HttpContext.Current.Session);

            if (cses == null && cses.UserID < 0)
            {
                CommonUtilities.Log("Session is empty! Assessment.asmx SaveValueX. ");
                throw new Exception("Please signin again!");
            }
            try
            {
                string _valTemp = string.Empty;
                BusinessRules.OP_Assessment       assessment_br = new BusinessRules.OP_Assessment(cses.SessionID, cses.UserID);
                DataAccess.AssessmentItemResponse objResp       = new DataAccess.AssessmentItemResponse();
                int _assessment_item_id = Convert.ToInt32(CommonUtilities.GlobalDecrypt(pItemID, cses.SessionKey));
                objResp.AssessmentItemID = _assessment_item_id;
                objResp.ScoreValue       = Convert.ToInt32(CommonUtilities.GlobalDecrypt(pScore, cses.SessionKey));
                objResp.Value            = pVal;
                if (_cid > 0)
                {
                    objResp.ChoiceID = _cid;
                    _valTemp         = _cid.ToString();
                }
                else
                {
                    _valTemp = pVal;
                }

                int  _resp_id = Convert.ToInt32(pAsseRespID);
                bool res      = assessment_br.Save_Assessment_Item_Response(objResp, Convert.ToInt32(pAsseID), ref _resp_id, cses.UserID, _type);
                if (!res)
                {
                    return(res.ToString());
                }
                if (!string.IsNullOrEmpty(pKeyRelFB))
                {
                    BusinessRules.OP_Feedback feedback_br = new BusinessRules.OP_Feedback(cses.SessionID, cses.UserID);
                    res = feedback_br.UpdateFeedbackRuleFormula(_assessment_item_id, Convert.ToInt32(pAsseID), _valTemp);
                    if (!res)
                    {
                        return(res.ToString());
                    }
                }

                string result_json = string.Empty;
                if (!string.IsNullOrEmpty(pKeyRel))
                {
                    List <AIDDisplayResult> listRes = new List <AIDDisplayResult>();
                    string[] _arr = pKeyRel.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (string item in _arr)
                    {
                        int _aid = -1;
                        if (int.TryParse(item, out _aid))
                        {
                            assessment_br.UpdateAIDisplayFormula(_aid, _assessment_item_id, _valTemp);
                            assessment_br.ExecuteFormula(_aid, _valTemp, ref _temp_res);
                            AIDDisplayResult obj = new AIDDisplayResult();
                            obj.AID    = _aid;
                            obj.Result = _temp_res;
                            obj.RespID = _resp_id;
                            listRes.Add(obj);
                            JavaScriptSerializer serializer = new JavaScriptSerializer();
                            result_json = serializer.Serialize(listRes);
                        }

                        //ExecuteFormula
                    }
                }
                else
                {
                    return(res.ToString() + "#" + _resp_id.ToString());
                }

                return(result_json);
            }
            catch (Exception ex)
            {
                CommonUtilities.Log(ex);
                throw new Exception("An error occured during save process!");
            }
        }