public JsonResult ImportProductJson(long paraCategory, long paraShopCategory, long?paraBrand, int paraSaleStatus, long _shopid, long _userid, long freightId, string file)
        {
            /*
             * 产品ID/主图
             * 产品ID/Details/明细图片
             */
            string filePath = Server.MapPath("/temp/" + file);
            string imgpath1 = string.Format(@"/Storage/Shop/{0}/Products", _shopid);
            string imgpath2 = Server.MapPath(imgpath1);
            long   brand    = 0;

            if (paraBrand.HasValue)
            {
                brand = paraBrand.Value;
            }
            JsonResult result = new JsonResult();

            if (System.IO.File.Exists(filePath))
            {
                ZipHelper.ZipInfo zipinfo = ZipHelper.UnZipFile(filePath);
                if (zipinfo.Success)
                {
                    try
                    {
                        int intCnt = ProcessProduct(paraCategory, paraShopCategory, brand, paraSaleStatus, _shopid, _userid, freightId, zipinfo.UnZipPath, imgpath1, imgpath2);
                        if (intCnt > 0)
                        {
                            result = Json(new { success = true, message = "成功导入【" + intCnt.ToString() + "】件诊疗项目" }, JsonRequestBehavior.AllowGet);
                        }
                        else
                        {
                            result = Json(new { success = false, message = "导入【0】件诊疗项目,请检查数据包,是否是重复导入" }, JsonRequestBehavior.AllowGet);
                        }
                    }
                    catch (Exception ex)
                    {
                        Core.Log.Error("导入诊疗项目异常:" + ex.Message);
                        Core.Cache.Remove(CacheKeyCollection.UserImportProductCount(_userid));
                        Core.Cache.Remove(CacheKeyCollection.UserImportProductTotal(_userid));
                        result = Json(new { success = false, message = "导入诊疗项目异常:" + ex.Message }, JsonRequestBehavior.AllowGet);
                    }
                }
                else
                {
                    Core.Log.Error("解压文件异常:" + zipinfo.InfoMessage);
                    result = Json(new { success = false, message = "解压出现异常,请检查压缩文件格式" }, JsonRequestBehavior.AllowGet);
                }
            }
            else
            {
                result = Json(new { success = false, message = "上传文件不存在" }, JsonRequestBehavior.AllowGet);
            }
            object opcount = Core.Cache.Get(CacheKeyCollection.UserImportOpCount);

            if (opcount != null)
            {
                Core.Cache.Insert(CacheKeyCollection.UserImportOpCount, int.Parse(opcount.ToString()) - 1);
            }
            return(result);
        }
        public JsonResult ImportProductJson(long paraCategory, long paraShopCategory, long?paraBrand, int paraSaleStatus, long _shopid, long _userid, string file)
        {
            string str   = Server.MapPath(string.Concat("/temp/", file));
            string str1  = string.Format("/Storage/Shop/{0}/Products", _shopid);
            string str2  = Server.MapPath(str1);
            long   value = 0;

            if (paraBrand.HasValue)
            {
                value = paraBrand.Value;
            }
            JsonResult jsonResult = new JsonResult();

            if (!System.IO.File.Exists(str))
            {
                jsonResult = Json(new { success = false, message = "上传文件不存在" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                ZipHelper.ZipInfo zipInfo = ZipHelper.UnZipFile(str);
                if (!zipInfo.Success)
                {
                    Log.Error(string.Concat("解压文件异常:", zipInfo.InfoMessage));
                    jsonResult = Json(new { success = false, message = "解压出现异常,请检查压缩文件格式" }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    try
                    {
                        int num = ProcessProduct(paraCategory, paraShopCategory, value, paraSaleStatus, _shopid, _userid, zipInfo.UnZipPath, str1, str2);
                        jsonResult = (num <= 0 ? Json(new { success = false, message = "导入【0】件商品,请检查数据包,是否是重复导入" }, JsonRequestBehavior.AllowGet) : Json(new { success = true, message = string.Concat("成功导入【", num.ToString(), "】件商品") }, JsonRequestBehavior.AllowGet));
                    }
                    catch (Exception exception1)
                    {
                        Exception exception = exception1;
                        Log.Error(string.Concat("导入商品异常:", exception.Message));
                        Cache.Remove(CacheKeyCollection.UserImportProductCount(_userid));
                        Cache.Remove(CacheKeyCollection.UserImportProductTotal(_userid));
                        jsonResult = Json(new { success = false, message = string.Concat("导入商品异常:", exception.Message) }, JsonRequestBehavior.AllowGet);
                    }
                }
            }
            object obj = Cache.Get("Cache-UserImportOpCount");

            if (obj != null)
            {
                Cache.Insert("Cache-UserImportOpCount", int.Parse(obj.ToString()) - 1);
            }
            return(jsonResult);
        }
 /// <summary>
 /// 异步导入诊疗项目
 /// </summary>
 /// <param name="paraCategory"></param>
 /// <param name="paraShopCategory"></param>
 /// <param name="paraBrand"></param>
 /// <param name="paraSaleStatus"></param>
 /// <param name="_shopid"></param>
 /// <param name="_userid"></param>
 /// <param name="file">压缩文件名</param>
 /// <returns></returns>
 public void ImportProductAsync(long paraCategory, long paraShopCategory, long?paraBrand, int paraSaleStatus, long _shopid, long _userid, long freightId, string file)
 {
     /*
      * 产品ID/主图
      * 产品ID/Details/明细图片
      */
     AsyncManager.OutstandingOperations.Increment();
     Task.Factory.StartNew(() =>
     {
         string filePath = Server.MapPath("/temp/" + file);
         string imgpath1 = string.Format(@"/Storage/Shop/{0}/Products", _shopid);
         string imgpath2 = Server.MapPath(imgpath1);
         long brand      = 0;
         if (paraBrand.HasValue)
         {
             brand = paraBrand.Value;
         }
         JsonResult result = new JsonResult();
         if (System.IO.File.Exists(filePath))
         {
             try
             {
                 ZipHelper.ZipInfo zipinfo = ZipHelper.UnZipFile(filePath);
                 if (zipinfo.Success)
                 {
                     int intCnt = ProcessProduct(paraCategory, paraShopCategory, brand, paraSaleStatus, _shopid, _userid, freightId, zipinfo.UnZipPath, imgpath1, imgpath2);
                     if (intCnt > 0)
                     {
                         AsyncManager.Parameters["success"] = true;
                         AsyncManager.Parameters["message"] = "成功导入【" + intCnt.ToString() + "】件诊疗项目";
                     }
                     else
                     {
                         Core.Cache.Remove(CacheKeyCollection.UserImportProductCount(_userid));
                         Core.Cache.Remove(CacheKeyCollection.UserImportProductTotal(_userid));
                         AsyncManager.Parameters["success"] = false;
                         AsyncManager.Parameters["message"] = "导入【0】件诊疗项目,请检查数据包格式,或是否重复导入";
                     }
                 }
                 else
                 {
                     Core.Log.Error("解压文件异常:" + zipinfo.InfoMessage);
                     AsyncManager.Parameters["success"] = false;
                     AsyncManager.Parameters["message"] = "解压出现异常,请检查压缩文件格式";
                 }
             }
             catch (Exception ex)
             {
                 Core.Log.Error("导入诊疗项目异常:" + ex.Message);
                 Core.Cache.Remove(CacheKeyCollection.UserImportProductCount(_userid));
                 Core.Cache.Remove(CacheKeyCollection.UserImportProductTotal(_userid));
                 AsyncManager.Parameters["success"] = false;
                 AsyncManager.Parameters["message"] = "导入诊疗项目异常:" + ex.Message;
             }
         }
         else
         {
             AsyncManager.Parameters["success"] = false;
             AsyncManager.Parameters["message"] = "上传文件不存在";
         }
         AsyncManager.OutstandingOperations.Decrement();
         object opcount = Core.Cache.Get(CacheKeyCollection.UserImportOpCount);
         if (opcount != null)
         {
             Core.Cache.Insert(CacheKeyCollection.UserImportOpCount, int.Parse(opcount.ToString()) - 1);
         }
     });
 }
 public void ImportProductAsync(long paraCategory, long paraShopCategory, long?paraBrand, int paraSaleStatus, long _shopid, long _userid, string file)
 {
     base.AsyncManager.OutstandingOperations.Increment();
     Task.Factory.StartNew(() => {
         string str  = Server.MapPath(string.Concat("/temp/", file));
         string str1 = string.Format("/Storage/Shop/{0}/Products", _shopid);
         string str2 = Server.MapPath(str1);
         long value  = 0;
         if (paraBrand.HasValue)
         {
             value = paraBrand.Value;
         }
         JsonResult jsonResult = new JsonResult();
         if (!System.IO.File.Exists(str))
         {
             AsyncManager.Parameters["success"] = false;
             AsyncManager.Parameters["message"] = "上传文件不存在";
         }
         else
         {
             ZipHelper.ZipInfo zipInfo = ZipHelper.UnZipFile(str);
             if (!zipInfo.Success)
             {
                 Log.Error(string.Concat("解压文件异常:", zipInfo.InfoMessage));
                 AsyncManager.Parameters["success"] = false;
                 AsyncManager.Parameters["message"] = "解压出现异常,请检查压缩文件格式";
             }
             else
             {
                 try
                 {
                     int num = ProcessProduct(paraCategory, paraShopCategory, value, paraSaleStatus, _shopid, _userid, zipInfo.UnZipPath, str1, str2);
                     if (num <= 0)
                     {
                         Cache.Remove(CacheKeyCollection.UserImportProductCount(_userid));
                         Cache.Remove(CacheKeyCollection.UserImportProductTotal(_userid));
                         AsyncManager.Parameters["success"] = false;
                         AsyncManager.Parameters["message"] = "导入【0】件商品,请检查数据包格式,或是否重复导入";
                     }
                     else
                     {
                         AsyncManager.Parameters["success"] = true;
                         AsyncManager.Parameters["message"] = string.Concat("成功导入【", num.ToString(), "】件商品");
                     }
                 }
                 catch (Exception exception1)
                 {
                     Exception exception = exception1;
                     Log.Error(string.Concat("导入商品异常:", exception.Message));
                     Cache.Remove(CacheKeyCollection.UserImportProductCount(_userid));
                     Cache.Remove(CacheKeyCollection.UserImportProductTotal(_userid));
                     AsyncManager.Parameters["success"] = false;
                     AsyncManager.Parameters["message"] = string.Concat("导入商品异常:", exception.Message);
                 }
             }
         }
         AsyncManager.OutstandingOperations.Decrement();
         object obj = Cache.Get("Cache-UserImportOpCount");
         if (obj != null)
         {
             Cache.Insert("Cache-UserImportOpCount", int.Parse(obj.ToString()) - 1);
         }
     });
 }