コード例 #1
0
    private void InitFs()
    {
      Uri serviceBaseUri = Application.Current.Host.Source;
      serviceBaseUri = new Uri(serviceBaseUri, "/");

      facade = new FileSystemFacade(serviceBaseUri.ToString());

      Dispatcher.RunAsync(() => VirtualFolder.CreateRootFolder(facade).GetFolders(), f => directories.ItemsSource = f);
    }
コード例 #2
0
        /// <summary>
        /// Saves an image on disk in a temporary location.
        /// </summary>
        /// <param name="image">The ID of the current user.</param>
        /// <param name="userId">The image that has been uploaded.</param>
        /// <param name="uploadsPath">The path to the Uploads folder.</param>
        public void SaveImageTemporarily(HttpPostedFileBase image, string userId, string uploadsPath)
        {
            string fullOriginalPath  = string.Empty;
            string fullThumbnailPath = string.Empty;

            FileSystemFacade.SaveUploadedImage(userId, image, uploadsPath, out fullOriginalPath, out fullThumbnailPath);
            PathOnDisk          = fullOriginalPath;
            ThumbnailPathOnDisk = fullThumbnailPath;
        }
コード例 #3
0
        private void InitFs()
        {
            Uri serviceBaseUri = Application.Current.Host.Source;

            serviceBaseUri = new Uri(serviceBaseUri, "/");

            facade = new FileSystemFacade(serviceBaseUri.ToString());

            Dispatcher.RunAsync(() => VirtualFolder.CreateRootFolder(facade).GetFolders(), f => directories.ItemsSource = f);
        }
コード例 #4
0
        /// <summary>
        /// Move the image from temp to the permanent location.
        /// </summary>
        /// <param name="uploadsPath">The path to the Uploads folder.</param>
        public void MovePermanently(string uploadsPath)
        {
            var fileName             = Path.GetFileName(PathOnDisk);
            var newOriginalLocation  = Path.Combine(uploadsPath, FileSystemFacade.ORIGINALS, fileName);
            var newThumbnsilLocation = Path.Combine(uploadsPath, FileSystemFacade.THUMBNAILS, fileName);

            FileSystemFacade.MoveFileToLocation(PathOnDisk, newOriginalLocation);
            FileSystemFacade.MoveFileToLocation(ThumbnailPathOnDisk, newThumbnsilLocation);
            PathOnDisk          = newOriginalLocation;
            ThumbnailPathOnDisk = newThumbnsilLocation;
        }
コード例 #5
0
        public ActionResult Sell()
        {
            var model = new ArticleViewModel();

            Session["images"] = null;
            model.Courses     = Repository.GetAllCourses().ToList();
            ThreadPool.QueueUserWorkItem(state =>
            {
                var arguments = state as Tuple <string, string>;
                FileSystemFacade.CleanTempFolder(uploadsPath: arguments.Item1, userId: arguments.Item2);
            }, state: new Tuple <string, string>(Server.MapPath(UPLOADS_PATH), User.Identity.GetUserId()));

            return(View(model));
        }
コード例 #6
0
    public void Init()
    {
      ServiceFileSystem = GetServiceProvider();
      ServiceSettings = CustomizeSettings(new VfsServiceSettings());
      
      ServiceHost = new TestServiceHost {Configuration = new TestConfiguration(ServiceFileSystem, ServiceSettings)};

      ServiceBaseUri = "http://localhost:33456/";
      ServiceHost.Initialize(new[] { ServiceBaseUri }, "/", null);
      ServiceHost.StartListening();

//      //TODO remove debug code
//      ServiceBaseUri = "http://127.0.0.1:56789/";

      ClientFileSystem = new FileSystemFacade(ServiceBaseUri);

      //get root folders
      ClientRoot = VirtualFolder.CreateRootFolder(ClientFileSystem);
      ServiceRoot = VirtualFolder.CreateRootFolder(ServiceFileSystem);

      InitInternal();
    }
コード例 #7
0
        public void Init()
        {
            ServiceFileSystem = GetServiceProvider();
            ServiceSettings   = CustomizeSettings(new VfsServiceSettings());

            ServiceHost = new TestServiceHost {
                Configuration = new TestConfiguration(ServiceFileSystem, ServiceSettings)
            };

            ServiceBaseUri = "http://localhost:33456/";
            ServiceHost.Initialize(new[] { ServiceBaseUri }, "/", null);
            ServiceHost.StartListening();

//      //TODO remove debug code
//      ServiceBaseUri = "http://127.0.0.1:56789/";

            ClientFileSystem = new FileSystemFacade(ServiceBaseUri);

            //get root folders
            ClientRoot  = VirtualFolder.CreateRootFolder(ClientFileSystem);
            ServiceRoot = VirtualFolder.CreateRootFolder(ServiceFileSystem);

            InitInternal();
        }
コード例 #8
0
ファイル: ReaderClient.cs プロジェクト: RainsSoft/UJad-AI-VFS
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public ReaderClient()
 {
     Facade = new FileSystemFacade("operationService", "readerService", "writerService");
 }
コード例 #9
0
ファイル: ReaderClient.cs プロジェクト: RainsSoft/UJad-AI-VFS
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public ReaderClient()
 {
   Facade = new FileSystemFacade("operationService", "readerService", "writerService");
 }
コード例 #10
0
 public PinPersistencePolicy(FileSystemFacade file_system)
 {
     this.file_system = file_system;
 }
コード例 #11
0
 /// <summary>
 /// Deletes the image on disk.
 /// </summary>
 public void Delete()
 {
     FileSystemFacade.DeleteFile(PathOnDisk);
     FileSystemFacade.DeleteFile(ThumbnailPathOnDisk);
 }
コード例 #12
0
        /// <summary>
        /// Generates the pdf document containing the specified stickers. No specs of the sheet are
        /// provided with the system. It should be a good idea.
        /// </summary>
        /// <param name="pdfPath">The full path to the pdf folder.</param>
        /// <param name="numberOfStickersLeftInSheet">The number of stickers left on the sheet used.</param>
        /// <param name="stickers">The stickers to layout in the document.</param>
        /// <returns></returns>
        public static string GeneratePreview(
            string pdfPath,
            int numberOfStickersLeftInSheet,
            IEnumerable <StickerInfo> stickers)
        {
            var numberOfBlanks       = MAX_NUMBER_OF_STICKERS_PER_SHEET - numberOfStickersLeftInSheet;
            var numberOfStickersLeft = stickers.Count();
            var document             = new PdfDocument();
            var page         = document.AddPage();
            var gtx          = XGraphics.FromPdfPage(page);
            var nbFormatInfo = new CultureInfo("fr-CA", false).NumberFormat;

            var firstLeftRect = new XRect(
                XUnit.FromCentimeter(0),
                XUnit.FromCentimeter(1.9),
                XUnit.FromCentimeter(10.2),
                XUnit.FromCentimeter(3.4)
                );

            page.Size        = PdfSharp.PageSize.Letter;
            page.TrimMargins = new TrimMargins()
            {
                Left   = XUnit.FromMillimeter(4),
                Top    = XUnit.FromCentimeter(2) + XUnit.FromMillimeter(1),
                Right  = XUnit.FromMillimeter(4),
                Bottom = XUnit.FromCentimeter(2) + XUnit.FromMillimeter(1)
            };

            // O(n^2)
            for (int currentColumn = 0; currentColumn < NUMBER_OF_COLUMNS && numberOfStickersLeft > 0; currentColumn++)
            {
                var currentXPos = currentColumn * (firstLeftRect.Width + XUnit.FromMillimeter(9));

                for (int position = 0; position < MAX_NUMBER_OF_STICKERS_PER_COLUMN && numberOfStickersLeft > 0; position++)
                {
                    if (numberOfBlanks == 0)
                    {
                        var sticker     = stickers.ElementAt(stickers.Count() - numberOfStickersLeft);
                        var LivrETSID   = $"{sticker.FairLivrETSID}-{sticker.UserLivrETSID}-{sticker.ArticleLivrETSID}";
                        var barcode     = GenerateLivrETSBarCode(LivrETSID);
                        var padding     = XUnit.FromMillimeter(2);
                        var currentYPos = (firstLeftRect.Height + XUnit.FromMillimeter(2.5)) * position;
                        var currentRect = new XRect(
                            currentXPos,
                            currentYPos,
                            firstLeftRect.Width,
                            firstLeftRect.Height
                            );
                        var fairTextRect = new XRect(
                            currentRect.Left + padding,
                            currentRect.Top + padding,
                            currentRect.Width / 2,
                            XUnit.FromMillimeter(5)
                            );
                        var livretsIdRect = new XRect(
                            currentRect.Left,
                            currentRect.Bottom - XUnit.FromMillimeter(4),
                            currentRect.Width,
                            XUnit.FromMillimeter(4)
                            );
                        var barCodeRect = new XRect(
                            currentRect.Left + padding,
                            livretsIdRect.Top - XUnit.FromMillimeter(6.2),
                            currentRect.Width - 2 * padding,
                            XUnit.FromMillimeter(6)
                            );
                        var priceRect = new XRect(
                            fairTextRect.Right,
                            currentRect.Top + padding,
                            currentRect.Width / 2,
                            fairTextRect.Height
                            );
                        var titleRect = new XRect(
                            currentRect.Left + padding,
                            fairTextRect.Bottom,
                            currentRect.Width - 2 * padding,
                            barCodeRect.Top - fairTextRect.Bottom
                            );

                        gtx.DrawString(
                            $"Foire {sticker.FairLivrETSID}",
                            new XFont("Arial", 8, XFontStyle.Regular),
                            XBrushes.Black,
                            fairTextRect,
                            XStringFormats.TopLeft
                            );
                        gtx.DrawString(
                            sticker.OfferPrice.ToString("C", nbFormatInfo),
                            new XFont("Arial", 12, XFontStyle.Regular),
                            XBrushes.Black,
                            priceRect,
                            XStringFormats.TopLeft
                            );
                        gtx.DrawString(
                            sticker.ArticleTitle,
                            new XFont("Arial", 10, XFontStyle.Regular),
                            XBrushes.Black,
                            titleRect,
                            XStringFormats.TopLeft
                            );
                        gtx.DrawImage(
                            XImage.FromGdiPlusImage(barcode),
                            barCodeRect
                            );
                        gtx.DrawString(
                            LivrETSID,
                            new XFont("Arial", 9, XFontStyle.Regular),
                            XBrushes.Black,
                            livretsIdRect,
                            XStringFormats.TopCenter
                            );
                        numberOfStickersLeft--;
                    }
                    else
                    {
                        numberOfBlanks--;
                    }
                }
            }

            return(FileSystemFacade.SaveStickersDocument(document, pdfPath));
        }