Exemplo n.º 1
0
        /// <summary>
        /// 添加不定项选择题子选择题
        /// </summary>
        public ServiceInvokeDTO AddUncertainSubChoice(UncertainSubChoice uncertainSubChoice)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO result = null;
            try
            {
                // 叠加题目序号
                uncertainSubChoice.ItemIndex = uncertainSubChoiceDAL.GetLastItemIndex(uncertainSubChoice.UncertainItemID) + 1;

                uncertainSubChoiceDAL.Insert(uncertainSubChoice);
                result = new ServiceInvokeDTO(InvokeCode.SYS_INVOKE_SUCCESS);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
            log.Debug(Constant.DEBUG_END);

            return result;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新不定项选择题子选择题
        /// </summary>
        public ServiceInvokeDTO UpdateUncertainSubChoice(UncertainSubChoice uncertainSubChoice)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO result = null;
            try
            {
                UncertainSubChoice dbSubChoice = uncertainSubChoiceDAL.GetByID(uncertainSubChoice.ID);
                if (dbSubChoice != null)
                {
                    uncertainSubChoiceDAL.Update(uncertainSubChoice);
                    result = new ServiceInvokeDTO(InvokeCode.SYS_INVOKE_SUCCESS);
                }
                else
                {
                    result = new ServiceInvokeDTO(InvokeCode.SYS_OBJECT_NOT_EXIST_ERROR);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
            log.Debug(Constant.DEBUG_END);

            return result;
        }
Exemplo n.º 3
0
        public ActionResult AddUncertainSubChoice()
        {
            log.Debug(Constant.DEBUG_START);

            string uncertainIDString = ApiQueryUtil.QueryArgByPost("uncertain_id");

            string title = ApiQueryUtil.QueryArgByPost("title");
            HttpPostedFileBase imageFile = Request.Files["image"];
            string a = ApiQueryUtil.QueryArgByPost("a");
            string b = ApiQueryUtil.QueryArgByPost("b");
            string c = ApiQueryUtil.QueryArgByPost("c");
            string d = ApiQueryUtil.QueryArgByPost("d");
            string answer = ApiQueryUtil.QueryArgByPost("answer");
            string annotation = ApiQueryUtil.QueryArgByPost("annotation");

            ServiceInvokeDTO result = null;
            try
            {
                UncertainSubChoice subchoice = new UncertainSubChoice();
                subchoice.UncertainItemID = Convert.ToInt32(uncertainIDString);

                subchoice.Title = title;
                subchoice.A = a;
                subchoice.B = b;
                subchoice.C = c;
                subchoice.D = d;
                subchoice.Answer = answer;
                subchoice.Annotation = annotation;
                subchoice.AddPerson = (Session[Constant.SESSION_KEY_ADMIN] as AgencyAdminDTO).ChineseName;

                if (imageFile != null)
                {
                    byte[] imageBytes = null;
                    using (Stream inputStream = imageFile.InputStream)
                    {
                        MemoryStream memoryStream = inputStream as MemoryStream;
                        if (memoryStream == null)
                        {
                            memoryStream = new MemoryStream();
                            inputStream.CopyTo(memoryStream);
                        }
                        imageBytes = memoryStream.ToArray();
                    }
                    subchoice.Image = imageBytes;
                }

                result = itemDataService.AddUncertainSubChoice(subchoice);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                result = new ServiceInvokeDTO(InvokeCode.SYS_INNER_ERROR);
            }

            string json = JsonConvert.SerializeObject(result, Formatting.Indented, Constant.TIME_CONVERTER);
            log.Debug(Constant.DEBUG_END);

            return Content(json, Constant.JSON_MIME_TYPE);
        }
Exemplo n.º 4
0
        public ActionResult UpdateUncertainSubChoice()
        {
            log.Debug(Constant.DEBUG_START);

            string idString = ApiQueryUtil.QueryArgByPost("id");

            string title = ApiQueryUtil.QueryArgByPost("title");
            HttpPostedFileBase imageFile = Request.Files["image"];
            string a = ApiQueryUtil.QueryArgByPost("a");
            string b = ApiQueryUtil.QueryArgByPost("b");
            string c = ApiQueryUtil.QueryArgByPost("c");
            string d = ApiQueryUtil.QueryArgByPost("d");
            string answer = ApiQueryUtil.QueryArgByPost("answer");
            string annotation = ApiQueryUtil.QueryArgByPost("annotation");

            ServiceInvokeDTO result = null;
            try
            {
                UncertainSubChoice subchoice = new UncertainSubChoice();
                subchoice.ID = Convert.ToInt32(idString);

                subchoice.Title = title;
                subchoice.A = a;
                subchoice.B = b;
                subchoice.C = c;
                subchoice.D = d;
                subchoice.Answer = answer;
                subchoice.Annotation = annotation;

                if (imageFile != null)
                {
                    byte[] imageBytes = null;
                    using (Stream inputStream = imageFile.InputStream)
                    {
                        MemoryStream memoryStream = inputStream as MemoryStream;
                        if (memoryStream == null)
                        {
                            memoryStream = new MemoryStream();
                            inputStream.CopyTo(memoryStream);
                        }
                        imageBytes = memoryStream.ToArray();
                    }
                    subchoice.Image = imageBytes;
                }

                AgencyAdminDTO currentAdmin = Session[Constant.SESSION_KEY_ADMIN] as AgencyAdminDTO;
                ServiceInvokeDTO checkResult = permissionService.CheckPermission(DoActionType.UpdateUncertainSubChoice, currentAdmin.Agency.ID, subchoice.ID);
                if (checkResult.Code == InvokeCode.SYS_INVOKE_SUCCESS)
                {
                    result = itemDataService.UpdateUncertainSubChoice(subchoice);
                }
                else
                {
                    result = checkResult;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                result = new ServiceInvokeDTO(InvokeCode.SYS_INNER_ERROR);
            }

            string json = JsonConvert.SerializeObject(result, Formatting.Indented, Constant.TIME_CONVERTER);
            log.Debug(Constant.DEBUG_END);

            return Content(json, Constant.JSON_MIME_TYPE);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新实体信息
 /// </summary>
 public void Update(UncertainSubChoice subchoice)
 {
     const string sql = @"UPDATE UncertainSubChoice SET Title= @Title, Image = @Image, A = @A, B= @B, C = @C, D = @D,
                          Answer = @Answer, Annotation = @Annotation WHERE IsDeleted = 0 AND ID = @ID";
     using (DbConnection connection = ConnectionManager.OpenConnection)
     {
         connection.Execute(sql, subchoice);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 添加实体信息,返回添加成功后的主键ID
        /// </summary>
        public int Insert(UncertainSubChoice subchoice)
        {
            int id = 0;

            const string sql = @"INSERT INTO UncertainSubChoice(UncertainItemID, ItemIndex, Title, Image, A, B, C, D, Answer, Annotation, AddPerson)
                               VALUES (@UncertainItemID, @ItemIndex, @Title, @Image, @A, @B, @C, @D, @Answer, @Annotation, @AddPerson);
                               SELECT LAST_INSERT_ID();";
            using (DbConnection connection = ConnectionManager.OpenConnection)
            {
                id = connection.Query<int>(sql, subchoice).SingleOrDefault<int>();
            }
            return id;
        }