Пример #1
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="context"></param>
        private static void PostData(HttpContext context)
        {
            //获取前台数据
            string strdata = context.Request["spJson"].ToString();
            string num     = context.Request["num"].ToString();                                          //随机数
            List <Dictionary <string, string> > datalistdic = new List <Dictionary <string, string> >(); //用来接收前台数据
            Dictionary <string, string>         Valuedic    = new Dictionary <string, string>();         //用来接收字段设定

            datalistdic = FreezerProUtility.Fp_Common.FpJsonHelper.DeserializeObject <List <Dictionary <string, string> > >(strdata);
            DataTable dt  = FreezerProUtility.Fp_Common.FpJsonHelper.DeserializeObject <DataTable>(strdata);
            string    msg = "";//返回处理结果

            if (datalistdic.Count > 0)
            {
                RuRo.BLL.TB_CONVERT tb_bll = new BLL.TB_CONVERT();
                DataSet             ds     = tb_bll.GetList("type='source'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        Valuedic.Add(ds.Tables[0].Rows[i]["Name"].ToString(), ds.Tables[0].Rows[i]["REPORT_NAME"].ToString());
                    }
                }
                //匹配转换字段,可导入系统
                List <Dictionary <string, string> > newlistdic = tb_bll.PageForSource(Valuedic, datalistdic);
                BLL.EmpiInfo  bll     = new BLL.EmpiInfo();
                List <string> msgList = new List <string>();
                //将样本源导入到系统
                for (int i = 0; i < newlistdic.Count; i++)
                {
                    int    count  = i + 1;
                    string result = bll.PostData(newlistdic[i]);//导入
                    if (result.Contains("\"success\":true,") || result.Contains("should be unique."))
                    {
                        //导入成功,记录数据库
                        string              data    = FreezerProUtility.Fp_Common.FpJsonHelper.ObjectToJsonStr(newlistdic[i]);
                        Specimen_BLL        sp_bll  = new Specimen_BLL();
                        RuRo.Model.Specimen spmodel = new Model.Specimen();
                        spmodel = FreezerProUtility.Fp_Common.FpJsonHelper.DeserializeObject <RuRo.Model.Specimen>(data);
                        sp_bll.Add(spmodel);

                        msgList.Add("第" + count.ToString() + "条数据导入成功.");
                    }
                    else
                    {
                        //导入失败,记录失败条目
                        msgList.Add("第" + count.ToString() + "条数据出现错误:" + result + ".");
                    }
                }
                msg = FreezerProUtility.Fp_Common.FpJsonHelper.ObjectToJsonStr(msgList);
                context.Response.Write(msg);
            }
            else
            {
                msg = "无数据传入";
                context.Response.Write(msg);
            }
        }
Пример #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(RuRo.Model.Specimen model)
 {
     return(dal.Update(model));
 }
Пример #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(RuRo.Model.Specimen model)
 {
     return(dal.Add(model));
 }