private void CreateThumbnail(List <DiskInfo> files)
        {
            var rootPath = HostingEnvironment.ApplicationHost.GetPhysicalPath();

            var tempPath = _fileSystemManager.RelativeToAbsolutePath(AuthorizeManager.AuthorizeActionOnPath(Config.ThumbnailPath, ActionKey.WriteToDisk));

            if (tempPath == null)
            {
                throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, Config.ThumbnailPath));
            }

            var thumbnailPath = tempPath.ToLower();

            Parallel.ForEach(files, file =>
            {
                var thumbPath = thumbnailPath +
                                file.FullName.Substring(rootPath.Length);
                if (_fileSystemManager.FileExist(thumbPath) ||
                    file.FullName.ToLower().IndexOf(thumbnailPath, StringComparison.Ordinal) != -1)
                {
                    return;
                }
                var thumbImg = _imageManager.CreateThumbnail(Image.FromFile(file.FullName, true),
                                                             200, 200);
                thumbImg.Save(thumbPath);
            });
        }
Esempio n. 2
0
 protected virtual void CreateDebugDataBase(string dbPath)
 {
     if (!FileSystemManager.FileExist((dbPath + "/" + DebugDb).Replace("//", "/")))
     {
         using (var db = new LiteDatabase((FileSystemManager
                                           .CreatDirectoryIfNotExist(dbPath) + "/" + DebugDb).Replace("//", "/")))
         {
             var debugDb = db.GetCollection <DebugInfo>(DebugCollection);
             debugDb.EnsureIndex(dg => dg.CodeId);
             //debugDb.EnsureIndex(dg => dg.Data);
             debugDb.EnsureIndex(dg => dg.IsOk);
             debugDb.EnsureIndex(dg => dg.IntegerValue);
             debugDb.EnsureIndex(dg => dg.DecimalValue);
             debugDb.EnsureIndex(dg => dg.DateTime);
             debugDb.EnsureIndex(dg => dg.CreateDateTime);
             debugDb.EnsureIndex(dg => dg.DllVersion);
             debugDb.EnsureIndex(dg => dg.IsAppDebugInfo);
         }
     }
 }
Esempio n. 3
0
        public async Task <bool> Delete(JObject data)
        {
            dynamic serviceData = data;
            int     id;

            try
            {
                id = serviceData.Id;
            }
            catch (Exception)
            {
                throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.FieldMustBeNumeric, "Service Id"));
            }
            var service = await _contentManagementContext
                          .MasterDataKeyValues.SingleOrDefaultAsync(sr => sr.Id == id && sr.TypeId == (int)EntityIdentity.Service);

            if (service == null)
            {
                throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.ServiceNotFound));
            }

            AuthorizeManager.SetAndCheckModifyAndAccessRole(service, null, false);


            if (service.EditMode)
            {
                _sourceControl.CheckCodeCheckOute(service);
            }

            var useCount = await _contentManagementContext.WebPages.Where(wp => wp.Services.Contains(service.PathOrUrl))
                           .CountAsync();

            if (useCount > 0)
            {
                throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.InUseItem, service.Name));
            }


            if (_fileSystemManager.FileExist(Path.Combine(Config.ServicesSourceCodePath, service.Guid + ".js")))
            {
                _sourceControl.RecycleBin(Config.ServicesSourceCodePath, service.Guid + ".js", codeNameIsFolder: false);

                DeleteFile(Config.ServicesSourceCodePath, service.Guid, ".js");
            }

            _contentManagementContext.MasterDataKeyValues.Remove(service);

            await _contentManagementContext.SaveChangesAsync();

            return(true);
        }