//public string UrlRef
    //{
    //    get
    //    {
    //        string _urlRef = "";
    //        if (!string.IsNullOrEmpty(Request.QueryString["urlref"]))//多图上传
    //        {
    //            _urlRef = Request.QueryString["urlref"].ToLower();
    //        }
    //        else
    //        {
    //            _urlRef = Request.UrlReferrer == null ? "" : Request.UrlReferrer.ToString().ToLower();
    //        }
    //        return _urlRef;
    //    }
    //}
    //private bool IsBar()
    //{
    //    bool flag = false;
    //    if (!string.IsNullOrEmpty(UrlRef))
    //    {
    //        flag = (UrlRef.Contains("/pclass?") || UrlRef.Contains("/pitem?") || UrlRef.Contains("/editcontent?"));
    //    }
    //    return flag;
    //}
    private M_GuestBookCate GetBarModel(UploadConfig config)
    {
        M_GuestBookCate model  = null;
        B_Guest_Bar     barBll = new B_Guest_Bar();

        if (config.SourceUrl.Contains("/pclass?"))
        {
            int cateid = DataConverter.CLng(StrHelper.GetValFromUrl(config.SourceUrl, "id"));
            model = cateBll.SelReturnModel(cateid);
        }
        else
        {
            int cateid = 0;
            int postid = DataConverter.CLng(StrHelper.GetValFromUrl(config.SourceUrl, "cateid"));
            if (postid > 0)
            {
                cateid = barBll.SelCateIDByPost(postid);
            }
            else
            {
                cateid = DataConverter.CLng(StrHelper.GetValFromUrl(config.SourceUrl, "cateid"));
            }
            model = cateBll.SelReturnModel(cateid);
        }
        return(model);
    }
        public UploadResult Upload(UploadConfig config)
        {
            if (string.IsNullOrEmpty(config.PreviosName))
            {
                var fileName    = string.Empty;
                var storageNode = _client.GetStorageNode(config.GroupName);

                if (!config.Chunked)
                {
                    fileName = _client.UploadFile(storageNode, config.Buffer, Path.GetExtension(config.FileName));
                }
                else
                {
                    //分段上传需要调用这个方法
                    fileName = _client.UploadAppenderFile(storageNode, config.Buffer, Path.GetExtension(config.FileName));
                }

                return(new UploadResult {
                    FilePath = fileName, OriginalName = config.FileName
                });
            }
            else
            {
                //分段上传:需要提供上传GroupName, 文件上传地址PreviosName,文件上传内容filebody
                //续传 地址config.PreviosName
                _client.AppendFile(config.GroupName, config.PreviosName, config.Buffer);

                return(new UploadResult {
                    FilePath = config.PreviosName, OriginalName = config.FileName
                });
            }
        }
        internal static void ImportTags(Product product, List<string> tagsList, UploadConfig config)
        {
            TaxonomyManager taxonomyManager = TaxonomyManager.GetManager();
            CatalogManager catalogManager = CatalogManager.GetManager();

            FlatTaxonomy tagsTaxonomy = taxonomyManager.GetTaxonomies<FlatTaxonomy>().Where(t => t.Name == "Tags").SingleOrDefault();

            foreach (var tagString in tagsList)
            {
                try
                {
                    Taxon tag = GetTagIfItExsistsOrCreateOneIfItDoesnt(tagString, tagsTaxonomy, taxonomyManager);

                    SetTagProperties(tag, tagString);

                    taxonomyManager.SaveChanges();

                    if (product.Organizer.TaxonExists("Tags", tag.Id) == true)
                    {
                        continue;        // Product already linked to Tag
                    }

                    product.Organizer.AddTaxa("Tags", tag.Id);

                    catalogManager.SaveChanges();
                }
                catch
                {
                    //catching so even if one fails rest goes on
                }
            }
        }
示例#4
0
        public ActionResult Upload(IFormCollection files)
        {
            var result = new UploadResult();

            foreach (var item in files.Files)
            {
                #region 把文件流转化为字节流
                byte[] buffer = new byte[item.Length];

                Stream fs = item.OpenReadStream();

                fs.Read(buffer, 0, buffer.Length);
                #endregion

                UploadConfig config = new UploadConfig
                {
                    Buffer      = buffer,
                    FileName    = item.FileName,
                    Chunked     = files.Keys.Contains("chunk"),
                    PreviosName = files["previosName"]
                };

                result = _provider.Upload(config);
            }
            return(Json(result));
        }
        public CaseModel Func_ConfigParser()
        {
            return(new CaseModel()
            {
                NameSign = @"配置分析器",
                ExeEvent = () => {
                    GlobalSystemService GSS = GlobalSystemService.GetInstance();
                    SystemConfig sys_config = GSS.Config.Get <SystemConfig>();
                    UploadConfig upload_config = GSS.Config.Get <UploadConfig>();
                    URLReWriterConfig urlrew_config = GSS.Config.Get <URLReWriterConfig>();

                    sys_config.Is_DeBug = true;
                    sys_config.EncryptedUseString = @"SSSSSSYTS>jfiwjfi";

                    upload_config.File_Size = 43434;
                    upload_config.Watermark_Fontsize = 16;

                    GSS.Config.SaveALLConfig();

                    SystemConfig newsys_config = GSS.Config.Get <SystemConfig>();
                    newsys_config.Load();
                    if (newsys_config.EncryptedUseString != @"SSSSSSYTS>jfiwjfi")
                    {
                        Console.WriteLine("加密字符串错误");
                        throw new Exception("错误");
                        return false;
                    }
                    return true;
                },
            });
        }
示例#6
0
        // GET: UEditor
        public ContentResult Handle()
        {
            UploadConfig   config = null;
            IUEditorHandle handle = null;
            string         action = Request.Query["action"].ToString();

            switch (action)
            {
            case "config":
                handle = new ConfigHandler();
                break;

            case "uploadimage":
                config = new UploadConfig()
                {
                    AllowExtensions = Config.GetStringList("imageAllowFiles"),
                    PathFormat      = Config.GetString("imagePathFormat"),
                    SizeLimit       = Config.GetInt("imageMaxSize"),
                    UploadFieldName = Config.GetString("imageFieldName")
                };
                handle = new UploadHandle(config);
                break;

            default:
                handle = new NotSupportedHandler();
                break;
            }

            var result     = handle.Process();
            var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(result);

            return(Content(jsonString));
        }
        internal static CsvData ParseFileAndGetCsvData(string filePath, UploadConfig config)
        {
            CsvConfiguration configuration = new CsvConfiguration();
            configuration.HasHeaderRecord = true;

            CsvReader csvReader = new CsvReader(new StreamReader(filePath), configuration);

            string[] header = default(string[]);

            List<string[]> rows = new List<string[]>();
            string[] row;
            while (csvReader.Read())
            {
                header = csvReader.FieldHeaders;

                row = new string[header.Length];
                for (int j = 0; j < header.Length; j++)
                {
                    row[j] = csvReader.GetField(j);
                }

                rows.Add(row);
            }

            return new CsvData { Header = header, Rows = rows };
        }
示例#8
0
        public ActionResult UploadImage()
        {
            Response           _resp         = new Response();
            string             strresult     = "";
            String             callback      = System.Web.HttpContext.Current.Request.QueryString["CKEditorFuncNum"].ToString();
            UploadConfig       _uploadConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~").GetSection("UploadConfig") as Bx_Core.Config.UploadConfig;
            HttpFileCollection files         = System.Web.HttpContext.Current.Request.Files;

            for (int iFile = 0; iFile < files.Count; iFile++)
            {
                HttpPostedFile postedFile = files[iFile];
                _resp = _productmanager.UploadImg(_uploadConfig, postedFile, "image");
                if (_resp.Status == 0)
                {
                    strresult += "<script>alert(' " + _resp.Message + " ')</script>";
                }
                else
                {
                    _resp.Data = "http://" + System.Web.HttpContext.Current.Request.Url.Host.ToString() + ":" + System.Web.HttpContext.Current.Request.Url.Port.ToString() + _resp.Data;
                    strresult += "<script type=\"text/javascript\">";
                    strresult += "window.parent.CKEDITOR.tools.callFunction(" + callback + ",'" + _resp.Data + "','')";
                    strresult += ("</script>");
                }
            }

            return(Content(strresult));
        }
示例#9
0
        //得到上传图片配置参数,0=允许上传大小,1=上传绝对路径,2=允许上传类型
        public string[] GetUploadImgSetParam()
        {
            string[] imgParam = new string[3];

            UploadConfig uploadobj = Upload.GetConfig(GetUploadImgPath);
            string       maxSize;
            string       savePath;
            string       allowExt;

            maxSize  = "0";
            savePath = string.Empty;
            allowExt = string.Empty;

            maxSize = (Utils.ParseInt(uploadobj.UploadImageSize, 1) * 1024).ToString();
            //savePath = uploadobj.ImageSavePath + "/" + SiteDir + "/Images";   //按照站点保存文件
            savePath = uploadobj.ImageSavePath + "/Images";
            if (savePath.IndexOf(":") == -1)  //判断输入的是虚拟路径
            {
                savePath = Server.MapPath(GetVirtualPath + savePath);
            }

            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }

            allowExt    = uploadobj.UploadImageType;
            imgParam[0] = maxSize;
            imgParam[1] = savePath;
            imgParam[2] = allowExt;

            return(imgParam);
        }
示例#10
0
        public ContentResult Handle()
        {
            IUEditorHandle configHandler = null;
            string         item          = base.Request["action"];
            string         str           = item;

            if (item != null)
            {
                if (str == "config")
                {
                    configHandler = new ConfigHandler();
                    return(base.Content(JsonConvert.SerializeObject(configHandler.Process())));
                }
                else
                {
                    if (str != "uploadimage")
                    {
                        configHandler = new NotSupportedHandler();
                        return(base.Content(JsonConvert.SerializeObject(configHandler.Process())));
                    }
                    UploadConfig uploadConfig = new UploadConfig()
                    {
                        AllowExtensions = Config.GetStringList("imageAllowFiles"),
                        PathFormat      = Config.GetString("imagePathFormat"),
                        SizeLimit       = Config.GetInt("imageMaxSize"),
                        UploadFieldName = Config.GetString("imageFieldName")
                    };
                    configHandler = new UploadHandle(uploadConfig);
                    return(base.Content(JsonConvert.SerializeObject(configHandler.Process())));
                }
            }
            configHandler = new NotSupportedHandler();
            return(base.Content(JsonConvert.SerializeObject(configHandler.Process())));
        }
示例#11
0
        // 初始化信息
        void Init(HttpContext context)
        {
            this.ctx = context;
            isLog    = string.IsNullOrEmpty(ctx.Request.Form["IsLog"]) ? false : bool.Parse(ctx.Request.Form["IsLog"]);

            long   fileLength = string.IsNullOrEmpty(ctx.Request.Form["FileLength"]) ? 0 : long.Parse(ctx.Request.Form["FileLength"]);
            string src        = ctx.Request.Form["src"];
            string filename   = ctx.Request.Form["filename"];



            // 客户端最后写入时间,考虑到效率,据此简单判断客户端文件是否改变,断点续传时使用(如用HashCode对大文件影响效率)
            //string clientLastWriteFileTime = Func.AttrIsNull(ctx.Request.Form["LastWriteFileTime"]) ? String.Empty : ctx.Request.Form["LastWriteFileTime"];

            // 获取文件信息状态
            //fileInfo = new UploadFileInfo(userState.UserId, filename, clientLastWriteFileTime, fileSize);
            uploadConfig = UploadHelper.RetrieveConfig();
            fileInfo     = new UploadFileInfo("USERID", filename, fileLength);

            // 开始上传
            long startByte = string.IsNullOrEmpty(ctx.Request.Form["StartByte"]) ? 0 : long.Parse(ctx.Request.Form["StartByte"]);
            // 并不是获取上传字节
            bool getBytes = string.IsNullOrEmpty(context.Request.Form["GetBytes"]) ? false : bool.Parse(context.Request.Form["GetBytes"]);

            if (startByte == 0 && !getBytes)
            {
                this.WriteLog("Upload Begin");
            }
        }
        internal static void ImportDepartments(Product product, List<string> departmentList, UploadConfig config)
        {
            TaxonomyManager taxonomyManager = TaxonomyManager.GetManager();
            CatalogManager catalogManager = CatalogManager.GetManager();

            HierarchicalTaxonomy departmentTaxonomy = taxonomyManager.GetTaxonomies<HierarchicalTaxonomy>().Where(t => t.Name == "Departments").SingleOrDefault();

            foreach (var departmentString in departmentList)
            {
                try
                {
                    Taxon department = GetDepartmentIfItExsistsOrCreateOneIfItDoesnt(departmentString, departmentTaxonomy, taxonomyManager);

                    SetDepartmentProperties(department, departmentString);

                    taxonomyManager.SaveChanges();

                    if (product.Organizer.TaxonExists("Department", department.Id) == true)
                    {
                        continue;        // Product already linked to department
                    }

                    product.Organizer.AddTaxa("Department", department.Id);

                    catalogManager.SaveChanges();
                }
                catch
                {
                    //catching so even if one department fails rest goes on
                }

            }
        }
示例#13
0
 public static UploadConfig getInstance()
 {
     if (upConfig == null)
     {
         upConfig = new UploadConfig();
     }
     return(upConfig);
 }
示例#14
0
 public UploadHandler(HttpContext context, UploadConfig config) : base(context)
 {
     UploadConfig = config;
     Result       = new UploadResult()
     {
         State = UploadState.Unknown
     };
 }
 public UploadTemplateImagesHandler(System.Web.HttpContext context, UploadConfig config) : base(context)
 {
     this.UploadConfig = config;
     this.Result       = new UploadResult
     {
         State = UploadState.Unknown
     };
 }
示例#16
0
 public UploadHandler(UploadConfig config)
 {
     this.UploadConfig = config;
     this.Result       = new UploadResult()
     {
         State = UploadState.Unknown
     };
 }
示例#17
0
 public UploadHandler(HttpContext context, UploadConfig config) : base(context)
 {
     this.UploadConfig = config;
     UploadResult result = new UploadResult {
         State = UploadState.Unknown
     };
     this.Result = result;
 }
示例#18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            uploadobj           = Upload.GetConfig(GetUploadImgPath);      //上传设置信息
            this.UpType         = Request.QueryString["UpType"].ToLower(); //上传类型
            this.ExtType        = Request.QueryString["ExtType"];          //用户设置允许上传文件类型
            this.ControlMaxSize = Request.QueryString["MaxSize"];          //用户设置允许最大上传文件大小

            tr3.Visible = false;
            if (uploadobj.IsEnableUpload == "0")  //判断是否关闭上传功能
            {
                span1.Visible = false;
                span2.Visible = true;
                return;
            }

            switch (this.UpType)
            {
            case "media":    //视频,flash
                MaxSize  = GetMaxSize(int.Parse(uploadobj.UploadMediaSize));
                SavePath = uploadobj.MediaSavePath + "/" + SiteDir + "/Medias";
                AllowExt = GetExtType(uploadobj.UploadMediaType);
                URL      = GetUploadUrl(uploadobj.MediaUrl, "Medias", SavePath);
                break;

            case "file":    //文件
                MaxSize  = GetMaxSize(int.Parse(uploadobj.UploadFilesSize));
                SavePath = uploadobj.FileSavePath + "/" + SiteDir + "/Files";
                AllowExt = GetExtType(uploadobj.UploadFilesType);
                URL      = GetUploadUrl(uploadobj.FileUrl, "Files", SavePath);
                break;

            case "image":    //图片
                MaxSize     = GetMaxSize(int.Parse(uploadobj.UploadImageSize));
                SavePath    = uploadobj.ImageSavePath + "/" + SiteDir + "/Images";
                AllowExt    = GetExtType(uploadobj.UploadImageType);
                URL         = GetUploadUrl(uploadobj.ImageUrl, "Images", SavePath);
                tr3.Visible = true;
                break;

            case "flash":    //flash
                MaxSize  = GetMaxSize(int.Parse(uploadobj.UploadMediaSize));
                SavePath = uploadobj.MediaSavePath + "/" + SiteDir + "/Medias";
                AllowExt = "swf|fla";
                URL      = GetUploadUrl(uploadobj.MediaUrl, "Medias", SavePath);
                break;

            default:
                break;
            }
            SavePath = SavePath.Replace("//", "/");
            URL      = URL.Replace("//", "/");
            if (!Page.IsPostBack)
            {
                spanSize.InnerHtml   = (Math.Round(float.Parse(MaxSize.ToString()) / 1048576, 2)).ToString();
                this.lblMessage.Text = Utils.GetResourcesValue("Common", "UploadMsg") + AllowExt;
                UploadFiles();
            }
        }
        internal static List<ProductDocumentFileInfo> ImportDocuments(List<string> documentsAndFilesPath, UploadConfig config)
        {
            List<ProductDocumentFileInfo> productDocumentFileInfos = new List<ProductDocumentFileInfo>();

            LibrariesManager librariesManager = LibrariesManager.GetManager();

            Library libraryToUploadDocumentsTo = librariesManager.GetDocumentLibrary(config.UploadToLibraryId);

            foreach (var documentPath in documentsAndFilesPath)
            {
                try
                {
                    FileInfo fileInfo = new FileInfo(documentPath);
                    if (fileInfo == null)
                    {
                        continue;
                    }

                    //To create an image you have to be logged in as an admin.
                    Document document = librariesManager.CreateDocument();

                    var extension = fileInfo.Extension;
                    var documentTitle = fileInfo.Name;
                    if (extension.Length > 0)
                    {
                        documentTitle = documentTitle.Substring(0, documentTitle.Length - extension.Length);
                    }
                    document.Parent = libraryToUploadDocumentsTo;
                    document.Title = documentTitle;
                    document.UrlName = documentTitle.ToLower().Replace(' ', '-');
                    librariesManager.RecompileItemUrls<Document>(document);
                    using (var fileStream = fileInfo.OpenRead())
                    {
                        librariesManager.Upload(document, fileStream, fileInfo.Extension);
                    }
                    librariesManager.SaveChanges();

                    Document liveDocument = librariesManager.Lifecycle.Publish(document) as Document;

                    ProductDocumentFileInfo documentFileInfo = new ProductDocumentFileInfo
                    {
                        FileInfo = fileInfo,
                        Library = libraryToUploadDocumentsTo,
                        Document = liveDocument,
                    };

                    productDocumentFileInfos.Add(documentFileInfo);
                }
                catch
                {
                    //catching so even if one document fails rest succeeds
                }
            }

            librariesManager.SaveChanges();

            return productDocumentFileInfos;
        }
        // GET: UEditor
        public ContentResult Handle(string action)
        {
            UploadConfig   config = null;
            IUEditorHandle handle = null;

            action = Request["action"];
            switch (action)
            {
            case "config":
                handle = new ConfigHandler();
                break;

            case "uploadimage":
                config = new UploadConfig()
                {
                    AllowExtensions = Config.GetStringList("imageAllowFiles"),
                    PathFormat      = Config.GetString("imagePathFormat"),
                    SizeLimit       = Config.GetInt("imageMaxSize"),
                    UploadFieldName = Config.GetString("imageFieldName")
                };
                handle = new UploadHandle(config);
                break;

            case "uploadtemplateimage":
                var controllerName = Request["areaName"].ToString();
                var shopId         = "0";
                if (controllerName.ToLower().Equals("selleradmin"))
                {
                    ManagerInfo sellerManager = null;
                    //long userId = UserCookieEncryptHelper.Decrypt(WebHelper.GetCookie(CookieKeysCollection.SELLER_MANAGER), "SellerAdmin");
                    string _tmpstr = Request["ShopId"];
                    //if (userId != 0)
                    //{
                    //    sellerManager = ServiceHelper.Create<IManagerService>().GetSellerManager(userId);
                    //}
                    shopId = (string.IsNullOrWhiteSpace(_tmpstr) ? "NonShopID" : _tmpstr);
                }
                config = new UploadConfig()
                {
                    AllowExtensions = Config.GetStringList("templateimageAllowFiles"),
                    PathFormat      = Config.GetString("templateimagePathFormat").Replace("{ShopID}", shopId),
                    SizeLimit       = Config.GetInt("templateimageMaxSize"),
                    UploadFieldName = Config.GetString("templateimageFieldName"),
                    ShopId          = long.Parse(shopId)
                };
                handle = new UploadHandle(config);
                break;

            default:
                handle = new NotSupportedHandler();
                break;
            }

            var result     = handle.Process();
            var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(result);

            return(Content(jsonString));
        }
示例#21
0
        // Uploads the time data to the database, and returns the current top time list.
        public static Task <UserScore> UploadReplay(
            long time,
            LevelMap map,
            ReplayData replay)
        {
            // Get a client-generated unique id based on timestamp and random number.
            string key = FirebaseDatabase.DefaultInstance.RootReference.Push().Key;

            Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
            string name = (auth.CurrentUser != null && !string.IsNullOrEmpty(auth.CurrentUser.DisplayName))
        ? auth.CurrentUser.DisplayName
        : StringConstants.UploadScoreDefaultName;
            string userId = (auth.CurrentUser != null && !string.IsNullOrEmpty(auth.CurrentUser.UserId))
        ? auth.CurrentUser.UserId
        : StringConstants.UploadScoreDefaultName;
            string replayPath = replay != null ? Storage_Replay_Root_Folder + GetPath(map) + key : null;

            var userScore = new Firebase.Leaderboard.UserScore(
                userId,
                name,
                time,
                DateTime.Now.Ticks / TimeSpan.TicksPerSecond,
                new Dictionary <string, object> {
                { Database_Property_ReplayPath, replayPath }
            });

            UploadConfig config = new UploadConfig()
            {
                key                = key,
                storagePath        = replayPath,
                dbRankPath         = GetDBRankPath(map) + key,
                dbSharedReplayPath = GetDBSharedReplayPath(map) + key,
                shareReplay        = replay != null //TODO(chkuang): && GameOption.shareReplay
            };

            if (replay == null)
            {
                // Nothing to upload, return user score to upload to leaderboard.
                return(Task.FromResult(userScore));
            }
            else
            {
                return(UploadReplayData(userScore, replay, config)
                       .ContinueWith(task => {
                    if (config.shareReplay)
                    {
                        var dbRef = FirebaseDatabase.DefaultInstance.RootReference;
                        return dbRef.Child(config.dbSharedReplayPath)
                        .SetValueAsync(userScore.ToDictionary());
                    }
                    else
                    {
                        return null;
                    };
                }).ContinueWith(task => userScore));
            }
        }
        internal static List<ProductImageInfo> ImportImages(List<string> imagesPath, UploadConfig config)
        {
            List<ProductImageInfo> productImageInfos = new List<ProductImageInfo>();

            LibrariesManager librariesManager = LibrariesManager.GetManager();

            Album albumToUploadImagesTo = librariesManager.GetAlbum(config.UploadToAlbumId);

            foreach (var imagePath in imagesPath)
            {
                try
                {
                    FileInfo fileInfo = new FileInfo(imagePath);
                    if (fileInfo == null)
                    {
                        continue;
                    }

                    //To create an image you have to be logged in as an admin.
                    Telerik.Sitefinity.Libraries.Model.Image image = librariesManager.CreateImage();
                    image.AlternativeText = "Some alt text";

                    var extension = fileInfo.Extension;
                    var imageTitle = fileInfo.Name;
                    if (extension.Length > 0)
                    {
                        imageTitle = imageTitle.Substring(0, imageTitle.Length - extension.Length);
                    }
                    image.Parent = albumToUploadImagesTo;
                    image.Title = imageTitle;
                    image.UrlName = imageTitle.ToLower().Replace(' ', '-');
                    librariesManager.RecompileItemUrls<Telerik.Sitefinity.Libraries.Model.Image>(image);
                    using (var fileStream = fileInfo.OpenRead())
                    {
                        librariesManager.Upload(image, fileStream, fileInfo.Extension);
                    }
                    librariesManager.Lifecycle.Publish(image);

                    ProductImageInfo imageInfo = new ProductImageInfo
                    {
                        ImageInfo = fileInfo,
                        Album = albumToUploadImagesTo,
                        Image = image,
                    };

                    productImageInfos.Add(imageInfo);
                }
                catch
                {
                    //catching so even if one image fails the rest goes on
                }
            }

            librariesManager.SaveChanges();

            return productImageInfos;
        }
示例#23
0
 public QiniuUploadHandler(HttpContext context, UploadConfig config)
     : base(context)
 {
     this.UploadConfig = config;
     this.Result       = new UploadResult()
     {
         State = UploadState.Unknown
     };
 }
示例#24
0
 public UploadHandler(Controller context, UploadConfig config)
     : base(context)
 {
     this.UploadConfig = config;
     this.Result       = new UploadResult()
     {
         State = UploadState.Unknown
     };
 }
示例#25
0
 public UploadHandler(HttpContext context, UploadConfig config, int supplierId)
     : base(context)
 {
     this.UploadConfig = config;
     this.Result       = new UploadResult
     {
         State = UploadState.Unknown
     };
     this.SupplierId = supplierId;
 }
示例#26
0
 public DocumentController(
     IDocumentService documentServices,
     IOptionsMonitor <UploadConfig> uploadConfig,
     UploadHelper uploadHelper
     )
 {
     _documentServices = documentServices;
     _uploadConfig     = uploadConfig.CurrentValue;
     _uploadHelper     = uploadHelper;
 }
 public UploadController(
     AppDbContext db,
     UploadConfig config,
     IUserProvider provider
     )
 {
     this.db       = db;
     this.config   = config;
     this.provider = provider;
 }
示例#28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 文件上传
            uploadobj = Upload.GetConfig(GetUploadImgPath); //上传设置信息
            if (uploadobj.IsEnableUpload != "1")            // 判断是否允许上传
            {
                Response.Write("已经关闭上传功能,请联系管理员");
                Response.End();
            }
            MaxSize  = int.Parse(uploadobj.UploadImageSize) / 1024;
            AllowExt = uploadobj.UploadImageType;
            AllowExt = "*." + AllowExt.Replace("|", ";*.");
            string   imgSet = "0";
            string[] arr    = AllowExt.Split(';');
            for (int i = 0; i < arr.Length; i++)
            {
                if (i == 9)
                {
                    AllowExtMemo += "<br>";
                }
                if (i > 0)
                {
                    AllowExtMemo += ";";
                }
                AllowExtMemo += arr[i];
            }

            sitedir = SiteDir;

            if (uploadobj.IsEnableWatermark == "1")
            {
                imgSet           = "1";
                chkWater.Checked = true;
                if (uploadobj.WatermarkType == "0")
                {
                    WaterDivId.InnerHtml = "<br>水印文字为:<br><font color=red>" + uploadobj.WatermarkText + "</font>";
                }
                else
                {
                    if (System.IO.File.Exists(Server.MapPath("/" + uploadobj.WatermarkPic)))
                    {
                        WaterDivId.InnerHtml = "水印图片:<br><img src='/" + uploadobj.WatermarkPic + "' style='width:100px;border:1px solid #CCCCCC' alt='水印图片' title='水印图片'>";
                    }
                    else
                    {
                        WaterDivId.InnerHtml = "<font color=red>注,请上传水印图片,图片位置为:<br>/" + uploadobj.WatermarkPic + "</font>";
                    }
                }
            }
            paramKey   = DateTime.Now.ToString("yyyyMMddhhmmsfff");
            imgSet     = "0,0," + imgSet;
            paramValue = imgSet;
            #endregion
        }
        private async Task UpdateAsync(Product product)
        {
            var config = new UploadConfig(
                $"{Server}/products/{product.Id}",
                false,
                JsonConvert.SerializeObject(product));
            var request  = new PutRequest(config, _responseLogger);
            var response = await request.RunAsync <JsonParser>();

            response.OnAnyFailureThrow();
        }
示例#30
0
 public UserController(
     IUser user,
     IOptionsMonitor <UploadConfig> uploadConfig,
     UploadHelper uploadHelper,
     IUserService userServices
     )
 {
     _user         = user;
     _uploadConfig = uploadConfig.CurrentValue;
     _uploadHelper = uploadHelper;
     _userServices = userServices;
 }
示例#31
0
    public UploadHandler(HttpContext context, UploadConfig config)
        : base(context)
    {
        this.UploadConfig = config;
        this.Result       = new UploadResult()
        {
            State = UploadState.Unknown
        };

        Base_WebSiteShortName = SysLoginObjHelp.sysLoginObjHelp.GetWebSiteShortName();
        Base_WebSiteId        = SysLoginObjHelp.sysLoginObjHelp.GetWebSiteId();
    }
示例#32
0
        /// <summary>
        /// 上传文件到服务器(上传至文件服务器)
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="filecontent"></param>
        public static void UploadFileThread(string filename)
        {
            UploadConfig    upConfig    = UploadConfig.getInstance();
            string          path        = filename.Substring(0, filename.LastIndexOf('/'));
            string          linuxroot   = upConfig.linux_site.nginx_root;
            string          windowsroot = HttpContext.Current.Server.MapPath("~");
            ThreadWithState tws         = new ThreadWithState(filename, path, windowsroot, linuxroot);
            // 创建执行任务的线程,并执行
            Thread t = new Thread(new ThreadStart(tws.UploadFile));

            t.Start();
            //t.Join();
        }
示例#33
0
    public UploadService(
        IOptions <UploadConfig> uploadConfig,
        ILogger <UploadService> log)
    {
        _cfg = uploadConfig?.Value ?? throw new ArgumentNullException(nameof(uploadConfig));
        _log = log ?? throw new ArgumentNullException(nameof(log));

        if (!Directory.Exists(_cfg.RootDirectory))
        {
            _log.LogError("Upload root directory [{Directory}] does not exist!", _cfg.RootDirectory);

            throw new DirectoryNotFoundException($"Could not find File Upload root directory [{_cfg.RootDirectory}]");
        }
    }
示例#34
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            BackgroundServiceConfig.ConfigureServices(services, Configuration);
            MvcConfig.ConfigureServices(services, Configuration);

            AuthConfig.ConfigureServices(services, Configuration);
            DataConfig.ConfigureServices(services, Configuration);
            CacheConfig.ConfigureServices(services, Configuration);

            ReportServiceConfig.ConfigureServices(services, Configuration);
            UploadConfig.ConfigureServices(services, Configuration);

            return(IocConfig.ConfigureServices(services, Configuration));
        }
示例#35
0
 /// <summary>
 /// config upload
 /// </summary>
 /// <param name="uploadConfig">upload config</param>
 public static void ConfigUpload(UploadConfig uploadConfig)
 {
     if (uploadConfig == null)
     {
         return;
     }
     if (uploadConfig.Default != null)
     {
         ConfigDefaultUpload(uploadConfig.Default);
     }
     if (!uploadConfig.UploadObjects.IsNullOrEmpty())
     {
         ConfigUploadObject(uploadConfig.UploadObjects.ToArray());
     }
 }
        internal static List<ProductVariationImportModel> ConvertCsvDataToProductVariationImportModel(CsvData csvData, UploadConfig config)
        {
            List<ProductVariationImportModel> dataToInsertInDatabase = new List<ProductVariationImportModel>();
            foreach (var dataRow in csvData.Rows)
            {
                ProductVariationImportModel rowToInsert = new ProductVariationImportModel();
                rowToInsert.ProductNameSku = dataRow[0];
                rowToInsert.AttributeName = dataRow[1];
                rowToInsert.ValueName = dataRow[2];
                rowToInsert.Sku = dataRow[3];
                rowToInsert.AdditionalPrice = Convert.ToDecimal(dataRow[4]);
                rowToInsert.TrackInventory = GetTrackInventory(dataRow[5]);
                rowToInsert.InventoryAmount = GetSafeInt(dataRow[6]);
                rowToInsert.OutOfStockOption = GetOutOfStockOption(dataRow[7]);
                rowToInsert.IsActive = Convert.ToBoolean(dataRow[8]);

                rowToInsert.CorrespondingRowData = dataRow;

                dataToInsertInDatabase.Add(rowToInsert);
            }
            return dataToInsertInDatabase;
        }
        internal static List<ProductImportModel> ConvertCsvDataToProductImportModel(CsvData csvData, UploadConfig config)
        {
            List<ProductImportModel> dataToInsertInDatabase = new List<ProductImportModel>();
            foreach (var dataRow in csvData.Rows)
            {
                ProductImportModel rowToInsert = new ProductImportModel();
                rowToInsert.Title = dataRow[0];
                rowToInsert.ProductTypeTitle = dataRow[1];
                rowToInsert.Description = dataRow[2];
                rowToInsert.Url = dataRow[3];
                rowToInsert.Price = Convert.ToDecimal(dataRow[4]);
                rowToInsert.Weight = Convert.ToDecimal(dataRow[5]);
                rowToInsert.Sku = dataRow[6];

                rowToInsert.ImagesPath = dataRow[7].Split(config.MultipleItemsSeparator).ToList();
                rowToInsert.DocumentsAndFilesPath = dataRow[8].Split(config.MultipleItemsSeparator).ToList();
                rowToInsert.Departments = dataRow[9].Split(config.MultipleItemsSeparator).ToList();
                rowToInsert.Tags = dataRow[10].Split(config.MultipleItemsSeparator).ToList();

                rowToInsert.TrackInventory = GetTrackInventory(dataRow[11]);
                rowToInsert.InventoryAmount = GetSafeInt(dataRow[12]);
                rowToInsert.OutOfStockOption = GetOutOfStockOption(dataRow[13]);

                rowToInsert.IsActive = Convert.ToBoolean(dataRow[14]);

                rowToInsert.CustomFieldData = new List<CustomFieldData>();

                for (int i = 12; i < config.NumberOfColumns; i++)
                {
                    CustomFieldData customFieldData = new CustomFieldData { PropertyName = csvData.Header[i], PropertyValue = dataRow[i] };
                    rowToInsert.CustomFieldData.Add(customFieldData);
                }

                rowToInsert.CorrespondingRowData = dataRow;

                dataToInsertInDatabase.Add(rowToInsert);
            }
            return dataToInsertInDatabase;
        }
示例#38
0
        public Uri UploadImage(BitmapSource bitmapSource, UploadConfig config)
        {
            string url = config.Url;
            string userName = config.UserName;
            string password = config.Password;

            HttpClient http = new HttpClient();
            http.Request.Accept = HttpContentTypes.ApplicationJson;

            string apiUrl = url + "/api.php";

            // at first, request action=login (to get token)
            var paramsLogin1 = new Dictionary<string, string>()
                {
                    {"action", "login"},
                    {"format", "json"},
                    {"lgname", userName},
                    {"lgpassword", password}
                };

            var respLogin1 = http.Post(apiUrl, paramsLogin1, HttpContentTypes.ApplicationXWwwFormUrlEncoded);
            var treeLogin1 = respLogin1.DynamicBody;

            string resultLogin1 = treeLogin1.login.result;
            if (resultLogin1 != "NeedToken")
            {
                throw new UploadFailedException(
                    String.Format("Failed to login (first). You may be using older MediaWiki. (result: {0})", resultLogin1));
            }

            string token = treeLogin1.login.token;
            string cookieprefix = treeLogin1.login.cookieprefix;
            Cookie cookieSession = respLogin1.Cookies[cookieprefix + "_session"];

            // next, request login really.
            var paramsLogin2 = new Dictionary<string, string>()
                {
                    {"action", "login"},
                    {"format", "json"},
                    {"lgname", userName},
                    {"lgpassword", password},
                    {"lgtoken", token}
                };
            http.Request.Cookies = respLogin1.Cookies;
            var respLogin2 = http.Post(apiUrl, paramsLogin2, HttpContentTypes.ApplicationXWwwFormUrlEncoded);
            var treeLogin2 = respLogin2.DynamicBody;

            string resultLogin2 = treeLogin2.login.result;
            if (resultLogin2 != "Success")
            {
                throw new UploadFailedException(
                    String.Format("Failed to login. Check username and password. (result: {0})", resultLogin2));
            }

            string userId = treeLogin2.login.lguserid.ToString();
            string lgtoken = treeLogin2.login.lgtoken;

            // get edittoken
            http.Request.Cookies.Add(new Cookie(cookieprefix + "UserName", userName, "/", cookieSession.Value));
            http.Request.Cookies.Add(new Cookie(cookieprefix + "UserId", userId, "/", cookieSession.Value));
            http.Request.Cookies.Add(new Cookie(cookieprefix + "Token", lgtoken, "/", cookieSession.Value));
            var paramsQuery = new Dictionary<string, string>()
                {
                    {"action", "query"},
                    {"format", "json"},
                    {"prop", "info"},
                    {"intoken", "edit"},
                    {"titles", "NonExistPageToGetEditToken"}
                };

            var respQuery = http.Post(apiUrl, paramsQuery, HttpContentTypes.ApplicationXWwwFormUrlEncoded);
            var treeQuery = respQuery.DynamicBody;

            var pages = treeQuery.query.pages;
            // "pages" has "-1" key... since to call "-1" is difficult. this is dirty way.
            var page = (dynamic) ((IDictionary<string, object>)pages)["-1"];
            string edittoken = page.edittoken;

            if (edittoken.Length < 3) {
                throw new UploadFailedException(
                    String.Format("Failed to get edittoken (edittoken: {0})", edittoken));
            }

            string filename = ScreenToWikiUtil.GetFileName(".png");
            string descriptionUrl = null;
            ScreenToWikiUtil.UseTempDir((tempDir) =>
            {
                string path = System.IO.Path.Combine(tempDir, filename);

                ScreenToWikiUtil.SavePngFile(bitmapSource, path);

                var fileData = new FileData();
                fileData.ContentType = "image/png";
                fileData.ContentTransferEncoding = HttpContentEncoding.Binary;
                fileData.FieldName = "file";
                fileData.Filename = path;

                var paramsUpload = new Dictionary<string, object>()
                    {
                        {"action", "upload"},
                        {"format", "json"},
                        {"filename", filename},
                        {"token", edittoken}
                    };
                var respUpload = http.Post(apiUrl, paramsUpload, new List<FileData>() {fileData});
                var respTree = respUpload.DynamicBody;

                string result = respTree.upload.result;

                if (result != "Success")
                {
                    throw new UploadFailedException(String.Format("Uploading failed (result: {0})", result));
                }

                descriptionUrl = respTree.upload.imageinfo.descriptionurl;
            });

            return new Uri(descriptionUrl);
        }
        private static void ImportImages(UploadConfig config, CatalogManager catalogManager, List<ImportError> importErrors, ref int numberOfFailedRecords, ProductImportModel productImportModel, ref bool isFailedSet, Product product)
        {
            try
            {
                List<ProductImage> productImages = ImagesImporter.ImportImagesAndGetProductImages(productImportModel, config);
                product.Images.AddRange(productImages);

                catalogManager.SaveChanges();

                ContentLinkGenerator.GenerateContentLinksForProductImages(product);
            }
            catch (Exception imageEx)
            {
                if (!isFailedSet)
                {
                    isFailedSet = true;
                    numberOfFailedRecords++;
                    importErrors.Add(new ImportError { ErrorMessage = imageEx.Message, ErrorRow = productImportModel.CorrespondingRowData });
                }
            }
        }
        internal static List<ProductImage> ImportImagesAndGetProductImages(ProductImportModel productImportModel, UploadConfig config)
        {
            List<ProductImageInfo> importedImages = ImagesImporter.ImportImages(productImportModel.ImagesPath, config);

            List<ProductImage> productImages = ImagesImporter.GetProductImages(importedImages);

            return productImages;
        }
        internal static List<ProductFile> ImportDocumentsAndGetProductDocuments(ProductImportModel productImportModel, UploadConfig config)
        {
            List<ProductDocumentFileInfo> importedDocuments = DocumentsAndFilesImporter.ImportDocuments(productImportModel.DocumentsAndFilesPath, config);

            List<ProductFile> productDocumentsAndFiles = DocumentsAndFilesImporter.GetProductDocumentsAndFiles(importedDocuments);

            return productDocumentsAndFiles;
        }
示例#42
0
 public UploadHandler(HttpContext context, UploadConfig config)
     : base(context)
 {
     this.UploadConfig = config;
     this.Result = new UploadResult() { State = UploadState.Unknown };
 }
 private static void ImportTags(UploadConfig config, List<ImportError> importErrors, ref int numberOfFailedRecords, ProductImportModel productImportModel, ref bool isFailedSet, Product product)
 {
     try
     {
         TagsImporter.ImportTags(product, productImportModel.Tags, config);
     }
     catch (Exception tagsEx)
     {
         if (!isFailedSet)
         {
             isFailedSet = true;
             numberOfFailedRecords++;
             importErrors.Add(new ImportError { ErrorMessage = tagsEx.Message, ErrorRow = productImportModel.CorrespondingRowData });
         }
     }
 }
        internal static ImportStatistic SaveProductVariations(List<ProductVariationImportModel> data, UploadConfig config)
        {
            CatalogManager catalogManager = CatalogManager.GetManager();

            List<ImportError> importErrors = new List<ImportError>();

            int numberOfRecordsProcessed = 0;
            int numberOfSuccessfulRecords = 0;
            int numberOfFailedRecords = 0;

            foreach (ProductVariationImportModel productVariationImportModel in data)
            {

                try
                {
                    numberOfRecordsProcessed++;

                    Product parentProduct = catalogManager.GetProducts().Where(p => p.Status == ContentLifecycleStatus.Master && p.Sku == productVariationImportModel.ProductNameSku).FirstOrDefault();

                    if (parentProduct != null)
                    {
                        ProductAttribute productAttribute = catalogManager.GetProductAttributeByName(productVariationImportModel.AttributeName);
                        if (productAttribute != null)
                        {
                            ProductAttributeValue attributeValue = catalogManager.GetProductAttributeValues().Where(pav => pav.Title == productVariationImportModel.ValueName).FirstOrDefault();
                            if (attributeValue != null)
                            {
                                ProductVariation productVariation = catalogManager.CreateProductVariation();

                                //Set the properties
                                productVariation.AdditionalPrice = productVariationImportModel.AdditionalPrice;
                                productVariation.Parent = parentProduct;
                                productVariation.Sku = productVariationImportModel.Sku;
                                productVariation.TrackInventory = productVariationImportModel.TrackInventory;
                                if (productVariationImportModel.TrackInventory == TrackInventory.Track || productVariationImportModel.TrackInventory == TrackInventory.TrackByVariations)
                                {
                                    productVariation.Inventory = productVariationImportModel.InventoryAmount;
                                    productVariation.OutOfStockOption = productVariationImportModel.OutOfStockOption;
                                }
                                productVariation.IsActive = productVariationImportModel.IsActive;

                                //Set the Variant property
                                List<AttributeValuePair> attributeValuePairs = new List<AttributeValuePair>();
                                AttributeValuePair attributeValuePair = new AttributeValuePair();
                                attributeValuePair.AttributeValueId = attributeValue.Id;
                                attributeValuePair.AttributeId = attributeValue.Parent.Id;
                                attributeValuePairs.Add(attributeValuePair);

                                JavaScriptSerializer serializer = new JavaScriptSerializer();
                                string attributeValuePairsJson = serializer.Serialize(attributeValuePairs);

                                productVariation.Variant = attributeValuePairsJson;

                                //Create the product variation detail
                                ProductVariationDetail detail = catalogManager.CreateProductVariationDetail();
                                detail.ProductAttributeParent = attributeValue.Parent;
                                detail.ProductAttributeValueParent = attributeValue;
                                detail.ProductVariationParent = productVariation;
                                detail.ProductVariationDetailParentId = Guid.Empty;
                                detail.Parent = parentProduct;

                                parentProduct.ProductVariations.Add(productVariation);

                                catalogManager.SaveChanges();

                                numberOfSuccessfulRecords++;
                            }
                            else
                            {
                                throw new ArgumentException("Cannot find attribute value with title  " + productVariationImportModel.ValueName);
                            }
                        }
                        else
                        {
                            throw new ArgumentException("Cannot find attribute with title  " + productVariationImportModel.AttributeName);
                        }

                    }
                    else
                    {
                        throw new ArgumentException("Cannot find product with Sku " + productVariationImportModel.ProductNameSku);
                    }

                }
                catch (Exception ex)
                {
                    numberOfFailedRecords++;

                    importErrors.Add(new ImportError { ErrorMessage = ex.Message, ErrorRow = productVariationImportModel.CorrespondingRowData });

                    continue;
                }

            }
            ImportStatistic statisticsOfImport = new ImportStatistic
            {
                TotalNumberOfRecordsProcessed = numberOfRecordsProcessed,
                NumberOfSuccessfulRecords = numberOfSuccessfulRecords,
                NumberOfFailedRecords = numberOfFailedRecords,
                Errors = importErrors
            };
            return statisticsOfImport;
        }
        private static void ImportFiles(UploadConfig config, CatalogManager catalogManager, List<ImportError> importErrors, ref int numberOfFailedRecords, ProductImportModel productImportModel, ref bool isFailedSet, Product product)
        {
            try
            {
                List<ProductFile> productFiles = DocumentsAndFilesImporter.ImportDocumentsAndGetProductDocuments(productImportModel, config);
                product.DocumentsAndFiles.AddRange(productFiles);

                catalogManager.SaveChanges();

                ProductSynchronizer.UpdateProductDocumentsAndFilesLinks(product, DefaultProvider);
            }
            catch (Exception filesEx)
            {
                if (!isFailedSet)
                {
                    isFailedSet = true;
                    numberOfFailedRecords++;
                    importErrors.Add(new ImportError { ErrorMessage = filesEx.Message, ErrorRow = productImportModel.CorrespondingRowData });
                }
            }
        }
        /// <summary>
        /// Imports list of <see cref="ProductImportModel"/> to database
        /// </summary>
        /// <param name="dataToInsertInDatabase"></param>
        /// <returns></returns>
        internal static ImportStatistic SaveProducts(List<ProductImportModel> data, UploadConfig config)
        {
            CatalogManager catalogManager = CatalogManager.GetManager();

            List<ImportError> importErrors = new List<ImportError>();

            int numberOfRecordsProcessed = 0;
            int numberOfSuccessfulRecords = 0;
            int numberOfFailedRecords = 0;

            foreach (ProductImportModel productImportModel in data)
            {

                bool isFailedSet = false;
                try
                {
                    numberOfRecordsProcessed++;

                    ProductType productType = catalogManager.GetProductTypes().Where(pt => pt.Title == productImportModel.ProductTypeTitle).FirstOrDefault();
                    if (productType != null)
                    {
                        Product product = catalogManager.CreateProduct(productType.ClrType);

                        product.ApplicationName = "/Catalog";
                        product.Title = productImportModel.Title;
                        if (string.IsNullOrWhiteSpace(productImportModel.Url))
                        {
                            product.UrlName = Regex.Replace(productImportModel.Title.ToLower(), @"\s+", "-");
                        }
                        else
                        {
                            product.UrlName = productImportModel.Url;
                        }

                        product.Description = productImportModel.Description;
                        product.Price = productImportModel.Price;
                        product.Weight = Convert.ToDouble(productImportModel.Weight);
                        product.Sku = productImportModel.Sku;
                        product.TrackInventory = productImportModel.TrackInventory;
                        if (productImportModel.TrackInventory == TrackInventory.Track)
                        {
                            product.Inventory = productImportModel.InventoryAmount;
                            product.OutOfStockOption = productImportModel.OutOfStockOption;
                        }
                        product.ClrType = productType.ClrType;

                        catalogManager.RecompileItemUrls<Product>(product);
                        catalogManager.SaveChanges();

                        var props = TypeDescriptor.GetProperties(product);
                        foreach (var singleProp in props)
                        {
                            if (singleProp.GetType() == typeof(MetafieldPropertyDescriptor))
                            {
                                MetafieldPropertyDescriptor customField = singleProp as MetafieldPropertyDescriptor;
                                if (customField != null)
                                {
                                    foreach (var customFieldData in productImportModel.CustomFieldData)
                                    {
                                        if (customField.Name == customFieldData.PropertyName)
                                        {
                                            customField.SetValue(product, customFieldData.PropertyValue);
                                        }
                                    }
                                }
                            }
                        }
                        catalogManager.SaveChanges();

                        ImportImages(config, catalogManager, importErrors, ref numberOfFailedRecords, productImportModel, ref isFailedSet, product);

                        ImportFiles(config, catalogManager, importErrors, ref numberOfFailedRecords, productImportModel, ref isFailedSet, product);

                        ImportDepartments(config, importErrors, ref numberOfFailedRecords, productImportModel, ref isFailedSet, product);

                        ImportTags(config, importErrors, ref numberOfFailedRecords, productImportModel, ref isFailedSet, product);

                        var contextBag = new Dictionary<string, string>();
                        contextBag.Add("ContentType", product.GetType().FullName);

                        string workflowOperation = "Publish";

                        WorkflowManager.MessageWorkflow(
                                                        product.Id,
                                                        product.GetType(),
                                                        DefaultProvider,
                                                        workflowOperation,
                                                        false,
                                                        contextBag);

                        numberOfSuccessfulRecords++;
                    }
                    else
                    {
                        throw new ArgumentException("Cannot find product type " + productImportModel.ProductTypeTitle);
                    }

                }
                catch (Exception ex)
                {
                    if (!isFailedSet)
                    {
                        numberOfFailedRecords++;

                        importErrors.Add(new ImportError { ErrorMessage = ex.Message, ErrorRow = productImportModel.CorrespondingRowData });
                    }

                    continue;
                }

            }
            ImportStatistic statisticsOfImport = new ImportStatistic
                                                        {
                                                            TotalNumberOfRecordsProcessed = numberOfRecordsProcessed,
                                                            NumberOfSuccessfulRecords = numberOfSuccessfulRecords,
                                                            NumberOfFailedRecords = numberOfFailedRecords,
                                                            Errors = importErrors
                                                        };
            return statisticsOfImport;
        }