Exemple #1
0
 /// <summary>
 /// 导入基地数据
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 private string ImportBaseData(HttpContext context)
 {
     try
     {
         List <BLLJIMP.Model.WBBaseInfo> list = DatabaleToListBase(ExeclToDatabale("D:\\基地列表.xlsx"));
         if (bll.AddList <BLLJIMP.Model.WBBaseInfo>(list))
         {
             resp.Status = -1;
             resp.Msg    = "导入成功!";
         }
     }
     catch (Exception ex)
     {
         resp.Status = -1;
         resp.Msg    = ex.Message;
     }
     return(Common.JSONHelper.ObjectToJson(resp));
 }
Exemple #2
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string Add(HttpContext context)
        {
            List <BarCodeInfo> dataList = new List <BarCodeInfo>();
            BarCodeInfo        model    = new BarCodeInfo();

            if (!string.IsNullOrEmpty(context.Request["img1"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img1"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }
            if (!string.IsNullOrEmpty(context.Request["img2"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img2"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }
            if (!string.IsNullOrEmpty(context.Request["img3"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img3"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }
            if (!string.IsNullOrEmpty(context.Request["img4"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img4"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }
            if (!string.IsNullOrEmpty(context.Request["img5"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img5"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }
            if (!string.IsNullOrEmpty(context.Request["img6"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img6"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }
            if (!string.IsNullOrEmpty(context.Request["img7"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img7"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }
            if (!string.IsNullOrEmpty(context.Request["img8"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img8"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }
            if (!string.IsNullOrEmpty(context.Request["img9"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img9"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }
            if (!string.IsNullOrEmpty(context.Request["img10"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img10"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }
            if (!string.IsNullOrEmpty(context.Request["img11"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img11"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }
            if (!string.IsNullOrEmpty(context.Request["img12"]))
            {
                model              = new BarCodeInfo();
                model.ImageUrl     = context.Request["img12"];
                model.BarCode      = GetCodeByFileName(model.ImageUrl);
                model.websiteOwner = bll.WebsiteOwner;
                model.InsetData    = DateTime.Now.ToString();
                dataList.Add(model);
            }


            //var model = bll.ConvertRequestToModel<BarCodeInfo>(new BarCodeInfo());
            //if (string.IsNullOrEmpty(model.BarCode))
            //{
            //    model.BarCode = GetCodeByFileName(model.ImageUrl);
            //}
            //model.websiteOwner = bll.WebsiteOwner;
            //model.InsetData = DateTime.Now.ToString();
            if (bll.AddList(dataList))
            {
                apiResp.status = true;
            }
            else
            {
                apiResp.msg = "上传失败";
            }


            return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }