Beispiel #1
0
        /// <summary>
        /// 表格详情表创建添加
        /// </summary>
        /// <param name="CreateUID"></param>
        /// <param name="EditUID"></param>
        /// <param name="Eva_Table_Add"></param>
        /// <param name="Table_A_List"></param>
        private static void Eva_TableAdd_Helper(string CreateUID, string EditUID, Eva_Table Eva_Table_Add, List <Table_A> Table_A_List)
        {
            var Table_Id = Eva_Table_Add.Id;

            //开启线程操作数据库
            new Thread(() =>
            {
                try
                {
                    foreach (Table_A table_A in Table_A_List)
                    {
                        //表明细列表保证不为null513
                        if (table_A.indicator_list == null)
                        {
                            continue;
                        }
                        foreach (indicator_list item in table_A.indicator_list)
                        {
                            Eva_TableDetail Eva_TableDetail = new Eva_TableDetail()
                            {
                                CreateTime         = DateTime.Now,
                                EditTime           = DateTime.Now,
                                CreateUID          = CreateUID,
                                EditUID            = EditUID,
                                Indicator_Id       = (int)item.Id,
                                IndicatorType_Id   = (int)item.IndicatorType_Id,
                                IndicatorType_Name = item.IndicatorType_Name,
                                OptionA            = item.OptionA,
                                OptionB            = item.OptionB,
                                OptionC            = item.OptionC,
                                OptionD            = item.OptionD,
                                OptionE            = item.OptionE,
                                OptionF            = item.OptionF,
                                OptionA_S          = RequestHelper.decimal_transfer(item.OptionA_S),
                                OptionB_S          = RequestHelper.decimal_transfer(item.OptionB_S),
                                OptionC_S          = RequestHelper.decimal_transfer(item.OptionC_S),
                                OptionD_S          = RequestHelper.decimal_transfer(item.OptionD_S),
                                OptionE_S          = RequestHelper.decimal_transfer(item.OptionE_S),
                                OptionF_S          = RequestHelper.decimal_transfer(item.OptionF_S),
                                //Indicator_Name = item.Name,
                                IsDelete     = (int)IsDelete.No_Delete,
                                IsEnable     = (int)IsEnable.Enable,
                                Name         = item.Name,
                                QuesType_Id  = (int)item.QuesType_Id,
                                Remarks      = item.Remarks,
                                Sort         = RequestHelper.int_transfer(item.Sort),
                                Root         = item.Root,
                                RootID       = item.RootID,
                                Eva_table_Id = Table_Id,
                                //评价任务 1,表格设计 0
                                Type          = Convert.ToString((int)TableDetail_Type.Table),
                                OptionF_S_Max = item.OptionF_S_Max,
                            };

                            //入库
                            JsonModel model2 = Constant.Eva_TableDetailService.Add(Eva_TableDetail);
                            if (model2.errNum == 0)
                            {
                                //添加到缓存
                                Constant.Eva_TableDetail_List.Add(Eva_TableDetail);
                                Eva_TableDetail.Id = RequestHelper.int_transfer(Convert.ToString(model2.retData));

                                Indicate_Using_Add((int)item.Id);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                }
            })
            {
                IsBackground = true
            }.Start();
        }
Beispiel #2
0
        /// <summary>
        /// 复制表格
        /// </summary>
        /// <param name="context">当前上下文</param>
        public void Copy_Eva_Table(HttpContext context)
        {
            lock (obj_Copy_Eva_Table)
            {
                HttpRequest Request   = context.Request;
                int         table_Id  = RequestHelper.int_transfer(Request, "table_Id");
                string      CreateUID = RequestHelper.string_transfer(Request, "CreateUID");
                try
                {
                    Eva_Table Eva_Table_Need_Copy = Constant.Eva_Table_List.FirstOrDefault(t => t.Id == table_Id);
                    if (Eva_Table_Need_Copy != null)
                    {
                        Eva_Table Eva_Table_Copy_Clone = Constant.Clone <Eva_Table>(Eva_Table_Need_Copy);
                        Eva_Table_Copy_Clone.Id         = null;
                        Eva_Table_Copy_Clone.UseTimes   = 0;
                        Eva_Table_Copy_Clone.CreateUID  = CreateUID;
                        Eva_Table_Copy_Clone.EditUID    = CreateUID;
                        Eva_Table_Copy_Clone.CreateTime = DateTime.Now;
                        Eva_Table_Copy_Clone.EditTime   = DateTime.Now;
                        jsonModel = Constant.Eva_TableService.Add(Eva_Table_Copy_Clone);
                        if (jsonModel.errNum == 0)
                        {
                            Eva_Table_Copy_Clone.Id = Convert.ToInt32(jsonModel.retData);

                            //添加克隆出来的表
                            Constant.Eva_Table_List.Add(Eva_Table_Copy_Clone);

                            //表头复制
                            var table_headers = (from t_h in Constant.Eva_Table_Header_List where t_h.Table_Id == table_Id select t_h).ToList();
                            foreach (var header in table_headers)
                            {
                                Eva_Table_Header h_Clone = Constant.Clone <Eva_Table_Header>(header);
                                h_Clone.Table_Id = Eva_Table_Copy_Clone.Id;
                                h_Clone.Id       = null;
                                var jsonmodel = Constant.Eva_Table_HeaderService.Add(h_Clone);
                                if (jsonmodel.errNum == 0)
                                {
                                    h_Clone.Id = Convert.ToInt32(jsonmodel.retData);
                                    Constant.Eva_Table_Header_List.Add(h_Clone);
                                }
                            }

                            //详情题干添加
                            var table_details = (from detail in Constant.Eva_TableDetail_List where detail.Eva_table_Id == table_Id select detail).OrderBy(t => t.Id).ToList();
                            foreach (var detail in table_details)
                            {
                                Eva_TableDetail detail_clone = Constant.Clone <Eva_TableDetail>(detail);
                                detail_clone.Eva_table_Id = Eva_Table_Copy_Clone.Id;
                                detail_clone.Id           = null;
                                var jsonmodel = Constant.Eva_TableDetailService.Add(detail_clone);
                                if (jsonmodel.errNum == 0)
                                {
                                    detail_clone.Id = Convert.ToInt32(jsonmodel.retData);
                                    Constant.Eva_TableDetail_List.Add(detail_clone);

                                    Indicate_Using_Add((int)detail_clone.Indicator_Id);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                }
                finally
                {
                    //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】
                    context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}");
                }
            }
        }