Ejemplo n.º 1
0
        private TimeSpan CopyTo(IIoItem source, IIoItem destination)
        {
            SendMessage(new Message
            {
                Contents = "Starting Copy '{0}' to '{1}'".format(source.FullName,
                                                                 destination
                                                                 .FullName),
                MessageType = MessageType.Info
            });
            var startTime = DateTime.Now;

            using (var from = source.OpenRead())
            {
                using (var to = destination.OpenWrite())
                {
                    from.CopyTo(to);
                    var inputLength = from.Length;

                    /* to.BytesWritten += (sender, args) => SendProgress (new ProgressMessage
                     *                                        {
                     *                                            Activity =  "Copy",
                     *                                            ActivityId = 1,
                     *                                            Description =
                     *                                                "Copying '{0}' to '{1}'".format(source.FullName,
                     *                                                                                destination
                     *                                                                                    .FullName),
                     *                                            PercentComplete =
                     *                                                (int)
                     *                                                (100*(double) args.StreamPosition/inputLength)
                     *                                        });
                     *
                     *
                     *
                     * var t = from.CopyToAsync(to, new CancellationToken(), false);
                     *
                     *   t.RunSynchronously();
                     *   SendProgress(new ProgressMessage
                     *                        {
                     *                            Activity =  "Copy",
                     *                            ActivityId = 1,
                     *                            Description =
                     *                                "Copying '{0}' to '{1}'".format(source.FullName,
                     *                                                                destination
                     *                                                                    .FullName),
                     *                            PercentComplete =
                     *                                100,
                     *                            MessageType = ProgressMessageType.Complete
                     *                        });
                     *
                     *
                     * SendMessage(new Message
                     *           {
                     *               Contents = "Finished Copy",
                     *               MessageType = MessageType.Info
                     *           });
                     *   }
                     *   );
                     *
                     */
                    /*
                     * t.RunSynchronously();
                     *
                     *
                     * t.Wait();*/
                }
            }
            var endTime = DateTime.Now;

            return(endTime - startTime);
        }
Ejemplo n.º 2
0
        private void CopyTo(IIoItem source, IIoItem destination)
        {
            SendMessage(new Message
                                {
                                    Contents = "Starting Copy '{0}' to '{1}'".format(source.FullName,
                                                                                     destination
                                                                                         .FullName),
                                    MessageType = MessageType.Info
                                });
            using (var from = source.OpenRead())
                {
                using (var to = destination.OpenWrite())
                {

                    from.CopyTo(to);
                    var inputLength = from.Length;
                   /* to.BytesWritten += (sender, args) => SendProgress (new ProgressMessage
                                                             {
                                                                 Activity =  "Copy",
                                                                 ActivityId = 1,
                                                                 Description =
                                                                     "Copying '{0}' to '{1}'".format(source.FullName,
                                                                                                     destination
                                                                                                         .FullName),
                                                                 PercentComplete =
                                                                     (int)
                                                                     (100*(double) args.StreamPosition/inputLength)
                                                             });

                    var t = from.CopyToAsync(to, new CancellationToken(), false);

                        t.RunSynchronously();
                        SendProgress(new ProgressMessage
                                             {
                                                 Activity =  "Copy",
                                                 ActivityId = 1,
                                                 Description =
                                                     "Copying '{0}' to '{1}'".format(source.FullName,
                                                                                     destination
                                                                                         .FullName),
                                                 PercentComplete =
                                                     100,
                                                 MessageType = ProgressMessageType.Complete
                                             });

                    SendMessage(new Message
                                {
                                    Contents = "Finished Copy",
                                    MessageType = MessageType.Info
                                });
                        }
                        );

                    */
                    /*
                    t.RunSynchronously();

                    t.Wait();*/

                }
            }
        }