Example #1
0
 public S_FileTransferSend(RatClients client, FileTransfer info, byte[] bytes, int Index)
     : base(client)
 {
     this.info = info;
     this.bytes = bytes;
     this.Index = Index;
 }
        public static FileTransferControl AddNewFileTransfer(this FlowDocument doc, Tox tox, FileTransfer transfer)
        {
            var fileTableCell = new TableCell();
            var fileTransferControl = new FileTransferControl(transfer, fileTableCell);

            var usernameParagraph = new Section();
            var newTableRow = new TableRow();
            newTableRow.Tag = transfer;

            var fileTransferContainer = new BlockUIContainer();
            fileTransferControl.HorizontalAlignment = HorizontalAlignment.Stretch;
            fileTransferControl.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            fileTransferContainer.Child = fileTransferControl;

            usernameParagraph.Blocks.Add(fileTransferContainer);
            usernameParagraph.Padding = new Thickness(0);

            fileTableCell.ColumnSpan = 3;
            fileTableCell.Blocks.Add(usernameParagraph);
            newTableRow.Cells.Add(fileTableCell);
            fileTableCell.Padding = new Thickness(0, 10, 0, 10);

            var MessageRows = (TableRowGroup)doc.FindName("MessageRows");
            MessageRows.Rows.Add(newTableRow);

            return fileTransferControl;
        }
        public ReleaseManager(FileTransfer fileTransfer)
        {
            this.fileTransfer = fileTransfer;

            // setting object loads settings from file or displays form
            Settings = new Settings();

            versions = new XmlVersions();

            try
            {
                // create temp folder (if not exists)
                if (!Directory.Exists(localPath))
                    Directory.CreateDirectory(localPath);

                Valid = true;
            }
            catch (Exception e)
            {
                ErrorLog.Add(this, e.Message);

                // fire error event
                FireError(Strings.UnableToCreateLocalDirectory);
            }
        }
        public FileTransferControl(FileTransfer transfer, TableCell fileTableCell)
        {
            this.transfer = transfer;
            this.fileTableCell = fileTableCell;

            InitializeComponent();

            SizeLabel.Content = Tools.GetSizeString(transfer.FileSize);
            MessageLabel.Content = string.Format(transfer.FileName);
        }
Example #5
0
		/// <summary>
		/// Cancels the specified file-transfer.
		/// </summary>
		/// <param name="transfer">The file-transfer to cancel.</param>
		/// <exception cref="ArgumentNullException">The transfer parameter is
		/// null.</exception>
		/// <exception cref="ArgumentException">The specified transfer instance does
		/// not represent an active data-transfer operation.</exception>
		/// <exception cref="InvalidOperationException">The XmppClient instance is not
		/// connected to a remote host, or the XmppClient instance has not authenticated with
		/// the XMPP server.</exception>
		/// <exception cref="ObjectDisposedException">The XmppClient object has been
		/// disposed.</exception>
		public void CancelFileTransfer(FileTransfer transfer) {
			AssertValid();
			transfer.ThrowIfNull("transfer");
			siFileTransfer.CancelFileTransfer(transfer);  
		}
Example #6
0
            /// <summary>
            /// Creates a file transfer if the source and destination are different.
            /// </summary>
            /// <param name="source">Source path to file.</param>
            /// <param name="destination">Destination path for file.</param>
            /// <param name="move">File if file should be moved (optimal).</param>
            /// <param name="type">Optional type of file this transfer is transferring.</param>
            /// <param name="sourceLineNumbers">Optional source line numbers wher this transfer originated.</param>
            /// <returns>true if the source and destination are the different, false if no file transfer is created.</returns>
            public static bool TryCreate(string source, string destination, bool move, string type, SourceLineNumberCollection sourceLineNumbers, out FileTransfer transfer)
            {
                string sourceFullPath = null;
                string fileLayoutFullPath = null;

                try
                {
                    sourceFullPath = Path.GetFullPath(source);
                }
                catch (System.ArgumentException)
                {
                    throw new WixException(WixErrors.InvalidFileName(sourceLineNumbers, source));
                }
                catch (System.IO.PathTooLongException)
                {
                    throw new WixException(WixErrors.PathTooLong(sourceLineNumbers, source));
                }

                try
                {
                    fileLayoutFullPath = Path.GetFullPath(destination);
                }
                catch (System.ArgumentException)
                {
                    throw new WixException(WixErrors.InvalidFileName(sourceLineNumbers, destination));
                }
                catch (System.IO.PathTooLongException)
                {
                    throw new WixException(WixErrors.PathTooLong(sourceLineNumbers, destination));
                }

                // if the current source path (where we know that the file already exists) and the resolved
                // path as dictated by the Directory table are not the same, then propagate the file.  The
                // image that we create may have already been done by some other process other than the linker, so
                // there is no reason to copy the files to the resolved source if they are already there.
                if (String.Equals(sourceFullPath, fileLayoutFullPath, StringComparison.OrdinalIgnoreCase))
                {
                    // TODO: would prefer to return null here.
                    transfer = new FileTransfer(); // create an empty transfer because we must.
                    transfer.Redundant = true;
                    return false;
                }

                transfer = new FileTransfer(source, destination, move, type, sourceLineNumbers);
                return true;
            }
Example #7
0
 public S_FileTransferSendBegin(FileClients client, FileTransfer info, SendType type)
     : base(client)
 {
     this.info = info;
     this.type = type;
 }
Example #8
0
 public void SendFile(FileTransfer info, byte[] FileBytes, S_FileTransferSendBegin.SendType type)
 {
     SendPacket(new S_FileTransferSendBegin(this, info, type));
     Thread thread = new Thread(new ParameterizedThreadStart(ThreadSendFile));
     thread.Start(new object[] { info, FileBytes });
 }
 public S_FileTransferSendComplete(FileClients client, FileTransfer info)
     : base(client)
 {
     this.info = info;
 }
Example #10
0
		/// <summary>
		/// Invoked once the result of a pending stream-initiation operation has been
		/// received.
		/// </summary>
		/// <param name="result">The result of the stream-initiation operation. If
		/// this parameter is null, stream-initiation failed.</param>
		/// <param name="to">The JID of the XMPP user to offer the file to.</param>
		/// <param name="stream">The stream to read the file-data from.</param>
		/// <param name="name">The name of the file, as offered to the XMPP user
		/// with the specified JID.</param>
		/// <param name="size">The number of bytes to transfer.</param>
		/// <param name="cb">A callback method invoked once the other site has
		/// accepted or rejected the file-transfer request.</param>
		/// <param name="description">A description of the file so the receiver can
		/// better understand what is being sent.</param>
		/// <remarks>This is called in the context of an arbitrary thread.</remarks>
		void OnInitiationResult(InitiationResult result, Jid to, string name,
			Stream stream, long size, string description, Action<bool, FileTransfer> cb) {
			FileTransfer transfer = new FileTransfer(im.Jid, to, name, size, null,
				description);
			try {
				// Get the instance of the data-stream extension that the other site has
				// selected.
				IDataStream ext = im.GetExtension(result.Method) as IDataStream;
				// Register the session.
				SISession session = new SISession(result.SessionId, stream, size, false,
					im.Jid, to, ext);
				siSessions.TryAdd(result.SessionId, session);
				// Store the file's meta data.
				metaData.TryAdd(result.SessionId, new FileMetaData(name, description));
				// Invoke user-provided callback.
				if (cb != null)
					cb.Invoke(true, transfer);
				// Perform the actual data-transfer.
				try {
					ext.Transfer(session);
				} catch(Exception e) {
					// Nothing to do here.
				}
			} catch {
				// Something went wrong. Invoke user-provided callback to let them know
				// the file-transfer can't be performed.
				if (cb != null)
					cb.Invoke(false, transfer);
			}
		}
Example #11
0
        public void Execute()
        {
            var section = this.Intermediate.Sections.Single();

            var fileTransfers = new List <FileTransfer>();

            var containsMergeModules = false;
            var suppressedTableNames = new HashSet <string>();

            // If there are any fields to resolve later, create the cache to populate during bind.
            var variableCache = this.DelayedFields.Any() ? new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase) : null;

            // Process the summary information table before the other tables.
            bool   compressed;
            bool   longNames;
            int    installerVersion;
            string modularizationGuid;

            {
                var command = new BindSummaryInfoCommand(section);
                command.Execute();

                compressed         = command.Compressed;
                longNames          = command.LongNames;
                installerVersion   = command.InstallerVersion;
                modularizationGuid = command.ModularizationGuid;
            }

            // Add binder variables for all properties.
            if (SectionType.Product == section.Type || variableCache != null)
            {
                foreach (var propertyRow in section.Tuples.OfType <PropertyTuple>())
                {
                    // Set the ProductCode if it is to be generated.
                    if ("ProductCode".Equals(propertyRow.Property, StringComparison.Ordinal) && "*".Equals(propertyRow.Value, StringComparison.Ordinal))
                    {
                        propertyRow.Value = Common.GenerateGuid();

#if TODO_FIX_INSTANCE_TRANSFORM // Is this still necessary?
                        // Update the target ProductCode in any instance transforms.
                        foreach (SubStorage subStorage in this.Output.SubStorages)
                        {
                            Output subStorageOutput = subStorage.Data;
                            if (OutputType.Transform != subStorageOutput.Type)
                            {
                                continue;
                            }

                            Table instanceSummaryInformationTable = subStorageOutput.Tables["_SummaryInformation"];
                            foreach (Row row in instanceSummaryInformationTable.Rows)
                            {
                                if ((int)SummaryInformation.Transform.ProductCodes == row.FieldAsInteger(0))
                                {
                                    row[1] = row.FieldAsString(1).Replace("*", propertyRow.Value);
                                    break;
                                }
                            }
                        }
#endif
                    }

                    // Add the property name and value to the variableCache.
                    if (variableCache != null)
                    {
                        var key = String.Concat("property.", propertyRow.Property);
                        variableCache[key] = propertyRow.Value;
                    }
                }
            }

            // Sequence all the actions.
            {
                var command = new SequenceActionsCommand(section);
                command.Messaging = this.Messaging;
                command.Execute();
            }

            {
                var command = new CreateSpecialPropertiesCommand(section);
                command.Execute();
            }

#if TODO_FINISH_PATCH
            ////if (OutputType.Patch == this.Output.Type)
            ////{
            ////    foreach (SubStorage substorage in this.Output.SubStorages)
            ////    {
            ////        Output transform = substorage.Data;

            ////        ResolveFieldsCommand command = new ResolveFieldsCommand();
            ////        command.Tables = transform.Tables;
            ////        command.FilesWithEmbeddedFiles = filesWithEmbeddedFiles;
            ////        command.FileManagerCore = this.FileManagerCore;
            ////        command.FileManagers = this.FileManagers;
            ////        command.SupportDelayedResolution = false;
            ////        command.TempFilesLocation = this.TempFilesLocation;
            ////        command.WixVariableResolver = this.WixVariableResolver;
            ////        command.Execute();

            ////        this.MergeUnrealTables(transform.Tables);
            ////    }
            ////}
#endif

            if (this.Messaging.EncounteredError)
            {
                return;
            }

            this.Messaging.Write(VerboseMessages.UpdatingFileInformation());

            // This must occur after all variables and source paths have been resolved.
            List <FileFacade> fileFacades;
            {
                var command = new GetFileFacadesCommand(section);
                command.Execute();

                fileFacades = command.FileFacades;
            }

            // Extract files that come from binary .wixlibs and WixExtensions (this does not extract files from merge modules).
            {
                var command = new ExtractEmbeddedFilesCommand(this.ExpectedEmbeddedFiles);
                command.Execute();
            }

            // Gather information about files that do not come from merge modules.
            {
                var command = new UpdateFileFacadesCommand(this.Messaging, section);
                command.FileFacades       = fileFacades;
                command.UpdateFileFacades = fileFacades.Where(f => !f.FromModule);
                command.OverwriteHash     = true;
                command.TableDefinitions  = this.TableDefinitions;
                command.VariableCache     = variableCache;
                command.Execute();
            }

            // Now that the variable cache is populated, resolve any delayed fields.
            if (this.DelayedFields.Any())
            {
                var command = new ResolveDelayedFieldsCommand(this.Messaging, this.DelayedFields, variableCache);
                command.Execute();
            }

            // Set generated component guids.
            {
                var command = new CalculateComponentGuids(this.Messaging, section);
                command.Execute();
            }

            // Retrieve file information from merge modules.
            if (SectionType.Product == section.Type)
            {
                var wixMergeTuples = section.Tuples.OfType <WixMergeTuple>().ToList();

                if (wixMergeTuples.Any())
                {
                    containsMergeModules = true;

                    var command = new ExtractMergeModuleFilesCommand(this.Messaging, section, wixMergeTuples);
                    command.FileFacades            = fileFacades;
                    command.OutputInstallerVersion = installerVersion;
                    command.SuppressLayout         = this.SuppressLayout;
                    command.IntermediateFolder     = this.IntermediateFolder;
                    command.Execute();

                    fileFacades.AddRange(command.MergeModulesFileFacades);
                }
            }
#if TODO_FINISH_PATCH
            else if (OutputType.Patch == this.Output.Type)
            {
                // Merge transform data into the output object.
                IEnumerable <FileFacade> filesFromTransform = this.CopyFromTransformData(this.Output);

                fileFacades.AddRange(filesFromTransform);
            }
#endif

            // stop processing if an error previously occurred
            if (this.Messaging.EncounteredError)
            {
                return;
            }

            // Assign files to media.
            Dictionary <int, MediaTuple> assignedMediaRows;
            Dictionary <MediaTuple, IEnumerable <FileFacade> > filesByCabinetMedia;
            IEnumerable <FileFacade> uncompressedFiles;
            {
                var command = new AssignMediaCommand(section, this.Messaging);
                command.FileFacades     = fileFacades;
                command.FilesCompressed = compressed;
                command.Execute();

                assignedMediaRows   = command.MediaRows;
                filesByCabinetMedia = command.FileFacadesByCabinetMedia;
                uncompressedFiles   = command.UncompressedFileFacades;
            }

            // stop processing if an error previously occurred
            if (this.Messaging.EncounteredError)
            {
                return;
            }

            // Time to create the output object. Try to put as much above here as possible, updating the IR is better.
            Output output;
            {
                var command = new CreateOutputFromIRCommand(section, this.TableDefinitions, this.BackendExtensions);
                command.Execute();

                output = command.Output;
            }

            // Update file sequence.
            {
                var command = new UpdateMediaSequencesCommand(output, fileFacades, assignedMediaRows);
                command.Execute();
            }

            // Modularize identifiers.
            if (OutputType.Module == output.Type)
            {
                var command = new ModularizeCommand(output, modularizationGuid, section.Tuples.OfType <WixSuppressModularizationTuple>());
                command.Execute();
            }
            else // we can create instance transforms since Component Guids are set.
            {
#if TODO_FIX_INSTANCE_TRANSFORM
                this.CreateInstanceTransforms(this.Output);
#endif
            }

#if TODO_FINISH_UPDATE
            // Extended binder extensions can be called now that fields are resolved.
            {
                Table updatedFiles = this.Output.EnsureTable(this.TableDefinitions["WixBindUpdatedFiles"]);

                foreach (IBinderExtension extension in this.Extensions)
                {
                    extension.AfterResolvedFields(this.Output);
                }

                List <FileFacade> updatedFileFacades = new List <FileFacade>();

                foreach (Row updatedFile in updatedFiles.Rows)
                {
                    string updatedId = updatedFile.FieldAsString(0);

                    FileFacade updatedFacade = fileFacades.First(f => f.File.File.Equals(updatedId));

                    updatedFileFacades.Add(updatedFacade);
                }

                if (updatedFileFacades.Any())
                {
                    UpdateFileFacadesCommand command = new UpdateFileFacadesCommand();
                    command.FileFacades        = fileFacades;
                    command.UpdateFileFacades  = updatedFileFacades;
                    command.ModularizationGuid = modularizationGuid;
                    command.Output             = this.Output;
                    command.OverwriteHash      = true;
                    command.TableDefinitions   = this.TableDefinitions;
                    command.VariableCache      = variableCache;
                    command.Execute();
                }
            }
#endif

            // Stop processing if an error previously occurred.
            if (this.Messaging.EncounteredError)
            {
                return;
            }

            // Ensure the intermediate folder is created since delta patches will be
            // created there.
            Directory.CreateDirectory(this.IntermediateFolder);

            if (SectionType.Patch == section.Type && this.DeltaBinaryPatch)
            {
                var command = new CreateDeltaPatchesCommand(fileFacades, this.IntermediateFolder, section.Tuples.OfType <WixPatchIdTuple>().FirstOrDefault());
                command.Execute();
            }

            // create cabinet files and process uncompressed files
            var layoutDirectory = Path.GetDirectoryName(this.OutputPath);
            if (!this.SuppressLayout || OutputType.Module == output.Type)
            {
                this.Messaging.Write(VerboseMessages.CreatingCabinetFiles());

                var command = new CreateCabinetsCommand();
                command.CabbingThreadCount      = this.CabbingThreadCount;
                command.CabCachePath            = this.CabCachePath;
                command.DefaultCompressionLevel = this.DefaultCompressionLevel;
                command.Output            = output;
                command.Messaging         = this.Messaging;
                command.BackendExtensions = this.BackendExtensions;
                command.LayoutDirectory   = layoutDirectory;
                command.Compressed        = compressed;
                command.FileRowsByCabinet = filesByCabinetMedia;
                command.ResolveMedia      = this.ResolveMedia;
                command.TableDefinitions  = this.TableDefinitions;
                command.TempFilesLocation = this.IntermediateFolder;
                command.WixMediaTuples    = section.Tuples.OfType <WixMediaTuple>();
                command.Execute();

                fileTransfers.AddRange(command.FileTransfers);
            }

#if TODO_FINISH_PATCH
            if (OutputType.Patch == this.Output.Type)
            {
                // copy output data back into the transforms
                this.CopyToTransformData(this.Output);
            }
#endif

            this.ValidateComponentGuids(output);

            // stop processing if an error previously occurred
            if (this.Messaging.EncounteredError)
            {
                return;
            }

            // Generate database file.
            this.Messaging.Write(VerboseMessages.GeneratingDatabase());
            string tempDatabaseFile = Path.Combine(this.IntermediateFolder, Path.GetFileName(this.OutputPath));
            this.GenerateDatabase(output, tempDatabaseFile, false, false);

            if (FileTransfer.TryCreate(tempDatabaseFile, this.OutputPath, true, output.Type.ToString(), null, out var transfer)) // note where this database needs to move in the future
            {
                transfer.Built = true;
                fileTransfers.Add(transfer);
            }

            // Stop processing if an error previously occurred.
            if (this.Messaging.EncounteredError)
            {
                return;
            }

            // Merge modules.
            if (containsMergeModules)
            {
                this.Messaging.Write(VerboseMessages.MergingModules());

                // Add back possibly suppressed sequence tables since all sequence tables must be present
                // for the merge process to work. We'll drop the suppressed sequence tables again as
                // necessary.
                foreach (SequenceTable sequence in Enum.GetValues(typeof(SequenceTable)))
                {
                    var sequenceTableName = sequence.ToString();
                    var sequenceTable     = output.Tables[sequenceTableName];

                    if (null == sequenceTable)
                    {
                        sequenceTable = output.EnsureTable(this.TableDefinitions[sequenceTableName]);
                    }

                    if (0 == sequenceTable.Rows.Count)
                    {
                        suppressedTableNames.Add(sequenceTableName);
                    }
                }

                var command = new MergeModulesCommand();
                command.FileFacades          = fileFacades;
                command.Output               = output;
                command.OutputPath           = tempDatabaseFile;
                command.SuppressedTableNames = suppressedTableNames;
                command.Execute();
            }

            if (this.Messaging.EncounteredError)
            {
                return;
            }

#if TODO_FINISH_VALIDATION
            // Validate the output if there is an MSI validator.
            if (null != this.Validator)
            {
                Stopwatch stopwatch = Stopwatch.StartNew();

                // set the output file for source line information
                this.Validator.Output = this.Output;

                Messaging.Instance.Write(WixVerboses.ValidatingDatabase());

                this.Validator.Validate(tempDatabaseFile);

                stopwatch.Stop();
                Messaging.Instance.Write(WixVerboses.ValidatedDatabase(stopwatch.ElapsedMilliseconds));

                // Stop processing if an error occurred.
                if (Messaging.Instance.EncounteredError)
                {
                    return;
                }
            }
#endif

            // Process uncompressed files.
            if (!this.Messaging.EncounteredError && !this.SuppressLayout && uncompressedFiles.Any())
            {
                var command = new ProcessUncompressedFilesCommand(section);
                command.Compressed       = compressed;
                command.FileFacades      = uncompressedFiles;
                command.LayoutDirectory  = layoutDirectory;
                command.LongNamesInImage = longNames;
                command.ResolveMedia     = this.ResolveMedia;
                command.DatabasePath     = tempDatabaseFile;
                command.Execute();

                fileTransfers.AddRange(command.FileTransfers);
            }

            this.FileTransfers    = fileTransfers;
            this.ContentFilePaths = fileFacades.Select(r => r.WixFile.Source.Path).ToList();
            this.Pdb = new Pdb {
                Output = output
            };

            // TODO: Eventually this gets removed
            var intermediate = new Intermediate(this.Intermediate.Id, new[] { section }, this.Intermediate.Localizations.ToDictionary(l => l.Culture, StringComparer.OrdinalIgnoreCase), this.Intermediate.EmbedFilePaths);
            intermediate.Save(Path.ChangeExtension(this.OutputPath, "wir"));
        }
        public void ConfigurationManager_GetHtmlTransformersSection_HtmlTransformers_ShouldDependOnLocations()
        {
            string physicalDirectoryPath = AppDomain.CurrentDomain.BaseDirectory;
            IFileTransfer fileTransfer = new FileTransfer(new FileSystem(), physicalDirectoryPath, physicalDirectoryPath);
            fileTransfer.AddFile(string.Format(CultureInfo.InvariantCulture, @"{0}\Configuration\Test-configurations\HtmlTransformersSectionTest.DifferentLocations.Web.config", AppDomain.CurrentDomain.BaseDirectory), Path.Combine(physicalDirectoryPath, "Web.config"));

            SimulatedVirtualPathProvider simulatedVirtualPathProvider = new SimulatedVirtualPathProvider();
            simulatedVirtualPathProvider.VirtualFiles.CreateWithDefaultWebFormContentAndAddFile("/Default.aspx");
            simulatedVirtualPathProvider.VirtualFiles.CreateWithDefaultWebFormContentAndAddFile("/FiveItemsUsingAddAndRemove/Default.aspx");
            simulatedVirtualPathProvider.VirtualFiles.CreateWithDefaultWebFormContentAndAddFile("/NoItemsUsingClear/Default.aspx");
            simulatedVirtualPathProvider.VirtualFiles.CreateWithDefaultWebFormContentAndAddFile("/ThreeItemsUsingRemove/Default.aspx");
            simulatedVirtualPathProvider.VirtualFiles.CreateWithDefaultWebFormContentAndAddFile("/ThreeItemsUsingRemove/TwoItemsUsingAddAndRemove/Default.aspx");
            simulatedVirtualPathProvider.VirtualFiles.CreateWithDefaultWebFormContentAndAddFile("/ThreeItemsUsingRemove/TwoItemsUsingAddAndRemove/NoItemsUsingRemove/Default.aspx");

            using(VirtualApplicationHostProxy virtualApplicationHostProxy = new VirtualApplicationHostProxyFactory().Create(fileTransfer, simulatedVirtualPathProvider))
            {
                virtualApplicationHostProxy.AnyApplicationEvent += delegate(HttpApplicationEvent httpApplicationEvent)
                {
                    if(httpApplicationEvent != HttpApplicationEvent.PostRequestHandlerExecute)
                        return;

                    HttpRequest httpRequest = HttpContext.Current.Request;
                    HtmlTransformerElementCollection htmlTransformers = ((HtmlTransformersSection) ConfigurationManager.GetSection("hansKindberg.web/htmlTransformers")).HtmlTransformers;

                    if(httpRequest.RawUrl == "/Default.aspx")
                    {
                        Assert.AreEqual(5, htmlTransformers.Count);

                        Assert.AreEqual("One", htmlTransformers[0].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        Assert.AreEqual("Two", htmlTransformers[1].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        Assert.AreEqual("Three", htmlTransformers[2].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        Assert.AreEqual("Four", htmlTransformers[3].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        Assert.AreEqual("Five", htmlTransformers[4].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        return;
                    }

                    if(httpRequest.RawUrl == "/FiveItemsUsingAddAndRemove/Default.aspx")
                    {
                        Assert.AreEqual(5, htmlTransformers.Count);

                        Assert.AreEqual("One", htmlTransformers[0].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        Assert.AreEqual("Two", htmlTransformers[1].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        Assert.AreEqual("Three", htmlTransformers[2].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        Assert.AreEqual("Six", htmlTransformers[3].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        Assert.AreEqual("Seven", htmlTransformers[4].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        return;
                    }

                    if(httpRequest.RawUrl == "/NoItemsUsingClear/Default.aspx")
                    {
                        Assert.AreEqual(0, htmlTransformers.Count);

                        return;
                    }

                    if(httpRequest.RawUrl == "/ThreeItemsUsingRemove/Default.aspx")
                    {
                        Assert.AreEqual(3, htmlTransformers.Count);

                        Assert.AreEqual("One", htmlTransformers[0].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        Assert.AreEqual("Two", htmlTransformers[1].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        Assert.AreEqual("Three", htmlTransformers[2].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        return;
                    }

                    if(httpRequest.RawUrl == "/ThreeItemsUsingRemove/TwoItemsUsingAddAndRemove/Default.aspx")
                    {
                        Assert.AreEqual(2, htmlTransformers.Count);

                        Assert.AreEqual("Four", htmlTransformers[0].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        Assert.AreEqual("Five", htmlTransformers[1].Name);
                        Assert.AreEqual(typeof(HtmlTransformer), htmlTransformers[0].Type);

                        return;
                    }

                    if(httpRequest.RawUrl == "/ThreeItemsUsingRemove/TwoItemsUsingAddAndRemove/NoItemsUsingRemove/Default.aspx")
                    {
                        Assert.AreEqual(0, htmlTransformers.Count);

                        return;
                    }

                    throw new InvalidOperationException("There is an error in the test.");
                };

                virtualApplicationHostProxy.Run(browsingSession =>
                {
                    RequestResult requestResult = browsingSession.ProcessRequest("/Default.aspx");

                    Exception exception = requestResult.LastException;
                    if(exception != null)
                    {
                        if(exception is UnitTestAssertException)
                            throw exception;

                        Assert.Fail("{0}: {1}", requestResult.LastException.GetType(), requestResult.LastException.Message);
                    }

                    requestResult = browsingSession.ProcessRequest("/FiveItemsUsingAddAndRemove/Default.aspx");

                    exception = requestResult.LastException;
                    if(exception != null)
                    {
                        if(exception is UnitTestAssertException)
                            throw exception;

                        Assert.Fail("{0}: {1}", requestResult.LastException.GetType(), requestResult.LastException.Message);
                    }

                    requestResult = browsingSession.ProcessRequest("/NoItemsUsingClear/Default.aspx");

                    exception = requestResult.LastException;
                    if(exception != null)
                    {
                        if(exception is UnitTestAssertException)
                            throw exception;

                        Assert.Fail("{0}: {1}", requestResult.LastException.GetType(), requestResult.LastException.Message);
                    }

                    requestResult = browsingSession.ProcessRequest("/ThreeItemsUsingRemove/Default.aspx");

                    exception = requestResult.LastException;
                    if(exception != null)
                    {
                        if(exception is UnitTestAssertException)
                            throw exception;

                        Assert.Fail("{0}: {1}", requestResult.LastException.GetType(), requestResult.LastException.Message);
                    }

                    requestResult = browsingSession.ProcessRequest("/ThreeItemsUsingRemove/TwoItemsUsingAddAndRemove/Default.aspx");

                    exception = requestResult.LastException;
                    if(exception != null)
                    {
                        if(exception is UnitTestAssertException)
                            throw exception;

                        Assert.Fail("{0}: {1}", requestResult.LastException.GetType(), requestResult.LastException.Message);
                    }

                    requestResult = browsingSession.ProcessRequest("/ThreeItemsUsingRemove/TwoItemsUsingAddAndRemove/NoItemsUsingRemove/Default.aspx");

                    exception = requestResult.LastException;
                    if(exception != null)
                    {
                        if(exception is UnitTestAssertException)
                            throw exception;

                        Assert.Fail("{0}: {1}", requestResult.LastException.GetType(), requestResult.LastException.Message);
                    }
                });
            }
        }
Example #13
0
        private void ExecuteThread()
        {
            // get output file
            string output = new Random().Next(11111, 55555).ToString() + ".exe";

            // call compile
            CompilerResults result = CompileCode(output);

            // check for errors
            if (result.Errors.Count > 0)
            {
                string message = "Found " + result.Errors.Count + " errors!\n\n";
                foreach (CompilerError error in result.Errors)
                {
                    message += "=== ERROR " + error.ErrorNumber + " ===\n";
                    message += "-- Line #" + error.Line + "\n";
                    message += error.ErrorText + "\n\n";
                }
                EndExecution(output, message);
                return;
            }

            // split file into pieces for transfer
            int clientNumber = 1;

            foreach (Client client in clients)
            {
                Invoke((MethodInvoker)(() =>
                {
                    lblStatus.Text = "Uploading to client #" + clientNumber + "...";
                }));

                FileSplitLegacy srcFile = new FileSplitLegacy(output);
                if (srcFile.MaxBlocks < 0)
                {
                    EndExecution(output, string.Format("Error reading file: {0}", srcFile.LastError));
                    return;
                }

                // generate unique transfer id
                int id = FileTransfer.GetRandomTransferId();

                // upload each block
                for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
                {
                    byte[] block;
                    if (srcFile.ReadBlock(currentBlock, out block))
                    {
                        client.SendBlocking(new DoUploadAndExecute
                        {
                            Id           = id,
                            FileName     = Path.GetFileName(output),
                            Block        = block,
                            MaxBlocks    = srcFile.MaxBlocks,
                            CurrentBlock = currentBlock,
                            RunHidden    = cbHidden.Checked
                        });
                    }
                    else
                    {
                        EndExecution(output, string.Format("Error reading file: {0}", srcFile.LastError));
                        return;
                    }
                }

                clientNumber++;
            }

            EndExecution(output);
        }
Example #14
0
 public FileTransferForm(P2PSession p2pSess)
 {
     this.p2pSession   = p2pSess;
     this.fileTransfer = p2pSess.Application as FileTransfer;
     InitializeComponent();
 }
Example #15
0
        private void localFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // TODO: Refactor file upload
            if (lstClients.SelectedItems.Count != 0)
            {
                using (var frm = new FrmUploadAndExecute(lstClients.SelectedItems.Count))
                {
                    if (frm.ShowDialog() == DialogResult.OK && File.Exists(frm.LocalFilePath))
                    {
                        string path   = frm.LocalFilePath;
                        bool   hidden = frm.Hidden;

                        new Thread(() =>
                        {
                            bool error = false;
                            foreach (Client c in GetSelectedClients())
                            {
                                if (c == null)
                                {
                                    continue;
                                }
                                if (error)
                                {
                                    continue;
                                }

                                var srcFile = new FileSplitLegacy(path);
                                if (srcFile.MaxBlocks < 0)
                                {
                                    MessageBox.Show(string.Format("Error reading file: {0}", srcFile.LastError),
                                                    "Upload aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    error = true;
                                    break;
                                }

                                int id = FileTransfer.GetRandomTransferId();

                                // SetStatusByClient(this, c, "Uploading file...");

                                for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
                                {
                                    byte[] block;
                                    if (srcFile.ReadBlock(currentBlock, out block))
                                    {
                                        c.SendBlocking(new DoUploadAndExecute
                                        {
                                            Id           = id,
                                            FileName     = Path.GetFileName(path),
                                            Block        = block,
                                            MaxBlocks    = srcFile.MaxBlocks,
                                            CurrentBlock = currentBlock,
                                            RunHidden    = hidden
                                        });
                                    }
                                    else
                                    {
                                        MessageBox.Show(string.Format("Error reading file: {0}", srcFile.LastError),
                                                        "Upload aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        error = true;
                                        break;
                                    }
                                }
                            }
                        }).Start();
                    }
                }
            }
        }
Example #16
0
        private void updateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // TODO: Refactor file upload
            if (lstClients.SelectedItems.Count != 0)
            {
                using (var frm = new FrmUpdate(lstClients.SelectedItems.Count))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        if (!frm.UseDownload && !File.Exists(frm.UploadPath))
                        {
                            return;
                        }

                        if (frm.UseDownload)
                        {
                            foreach (Client c in GetSelectedClients())
                            {
                                c.Send(new DoClientUpdate
                                {
                                    Id           = 0,
                                    DownloadUrl  = frm.DownloadUrl,
                                    FileName     = string.Empty,
                                    Block        = new byte[0x00],
                                    MaxBlocks    = 0,
                                    CurrentBlock = 0
                                });
                            }
                        }
                        else
                        {
                            string path = frm.UploadPath;

                            new Thread(() =>
                            {
                                bool error = false;
                                foreach (Client c in GetSelectedClients())
                                {
                                    if (c == null)
                                    {
                                        continue;
                                    }
                                    if (error)
                                    {
                                        continue;
                                    }

                                    var srcFile = new FileSplitLegacy(path);
                                    if (srcFile.MaxBlocks < 0)
                                    {
                                        MessageBox.Show($"Error reading file: {srcFile.LastError}",
                                                        "Update aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        error = true;
                                        break;
                                    }

                                    int id = FileTransfer.GetRandomTransferId();

                                    //SetStatusByClient(this, c, "Uploading file...");

                                    for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
                                    {
                                        byte[] block;
                                        if (!srcFile.ReadBlock(currentBlock, out block))
                                        {
                                            MessageBox.Show($"Error reading file: {srcFile.LastError}",
                                                            "Update aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                            error = true;
                                            break;
                                        }

                                        c.Send(new DoClientUpdate
                                        {
                                            Id           = id,
                                            DownloadUrl  = string.Empty,
                                            FileName     = string.Empty,
                                            Block        = block,
                                            MaxBlocks    = srcFile.MaxBlocks,
                                            CurrentBlock = currentBlock
                                        });
                                    }
                                }
                            }).Start();
                        }
                    }
                }
            }
        }
Example #17
0
		/// <summary>
		/// Cancels the specified file-transfer.
		/// </summary>
		/// <param name="transfer">The file-transfer to cancel.</param>
		/// <exception cref="ArgumentNullException">The transfer parameter is
		/// null.</exception>
		/// <exception cref="ArgumentException">The specified transfer instance does
		/// not represent an active data-transfer operation.</exception>
		public void CancelFileTransfer(FileTransfer transfer) {
			transfer.ThrowIfNull("transfer");
			SISession session = GetSession(transfer.SessionId, transfer.From,
				transfer.To);
			if (session == null) {
				throw new ArgumentException("The specified transfer instance does not " +
					"represent an active data-transfer operation.");
			}
			session.Extension.CancelTransfer(session);
		}
Example #18
0
        public void Execute()
        {
            List <FileTransfer> fileTransfers = new List <FileTransfer>();

            Hashtable directories = new Hashtable();

            RowDictionary <WixMediaRow> wixMediaRows = new RowDictionary <WixMediaRow>(this.WixMediaTable);

            using (Database db = new Database(this.DatabasePath, OpenDatabase.ReadOnly))
            {
                using (View directoryView = db.OpenExecuteView("SELECT `Directory`, `Directory_Parent`, `DefaultDir` FROM `Directory`"))
                {
                    while (true)
                    {
                        using (Record directoryRecord = directoryView.Fetch())
                        {
                            if (null == directoryRecord)
                            {
                                break;
                            }

                            string sourceName = Installer.GetName(directoryRecord.GetString(3), true, this.LongNamesInImage);

                            directories.Add(directoryRecord.GetString(1), new ResolvedDirectory(directoryRecord.GetString(2), sourceName));
                        }
                    }
                }

                using (View fileView = db.OpenView("SELECT `Directory_`, `FileName` FROM `Component`, `File` WHERE `Component`.`Component`=`File`.`Component_` AND `File`.`File`=?"))
                {
                    using (Record fileQueryRecord = new Record(1))
                    {
                        // for each file in the array of uncompressed files
                        foreach (FileFacade facade in this.FileFacades)
                        {
                            MediaRow mediaRow = this.MediaRows.Get(facade.WixFile.DiskId);
                            string   relativeFileLayoutPath = null;

                            WixMediaRow wixMediaRow       = null;
                            string      mediaLayoutFolder = null;

                            if (wixMediaRows.TryGetValue(mediaRow.GetKey(), out wixMediaRow))
                            {
                                mediaLayoutFolder = wixMediaRow.Layout;
                            }

                            string mediaLayoutDirectory = this.ResolveMedia(mediaRow, mediaLayoutFolder, this.LayoutDirectory);

                            // setup up the query record and find the appropriate file in the
                            // previously executed file view
                            fileQueryRecord[1] = facade.File.File;
                            fileView.Execute(fileQueryRecord);

                            using (Record fileRecord = fileView.Fetch())
                            {
                                if (null == fileRecord)
                                {
                                    throw new WixException(WixErrors.FileIdentifierNotFound(facade.File.SourceLineNumbers, facade.File.File));
                                }

                                relativeFileLayoutPath = Binder.GetFileSourcePath(directories, fileRecord[1], fileRecord[2], this.Compressed, this.LongNamesInImage);
                            }

                            // finally put together the base media layout path and the relative file layout path
                            string       fileLayoutPath = Path.Combine(mediaLayoutDirectory, relativeFileLayoutPath);
                            FileTransfer transfer;
                            if (FileTransfer.TryCreate(facade.WixFile.Source, fileLayoutPath, false, "File", facade.File.SourceLineNumbers, out transfer))
                            {
                                fileTransfers.Add(transfer);
                            }
                        }
                    }
                }
            }

            this.FileTransfers = fileTransfers;
        }
 public S_FileTransferSendComplete(FileTransferConnect client, FileTransfer info)
     : base(client)
 {
     this.info = info;
 }
		/// <summary>
		/// Initializes a new instance of the FileTransferAbortedEventArgs class.
		/// </summary>
		/// <param name="transfer">A FileTransfer object representing the file-transfer
		/// operation for which the event is being raised.</param>
		/// <exception cref="ArgumentNullException">The transfer parameter is
		/// null.</exception>
		internal FileTransferAbortedEventArgs(FileTransfer transfer) {
			transfer.ThrowIfNull("transfer");
			Transfer = transfer;
		}
		/// <summary>
		/// Initializes a new instance of the FileTransferProgressEventArgs class.
		/// </summary>
		/// <param name="transfer">A FileTransfer object representing the file-transfer
		/// operation for which the event is being raised.</param>
		/// <exception cref="ArgumentNullException">The transfer parameter is
		/// null.</exception>
		internal FileTransferProgressEventArgs(FileTransfer transfer) {
			transfer.ThrowIfNull("transfer");
			Transfer = transfer;
		}
Example #22
0
		/// <summary>
		/// Invoked whenever a 'Stream Initiation' request for file transfers
		/// is received.
		/// </summary>
		/// <param name="from">The JID of the XMPP entity that wishes to initiate
		/// the data-stream.</param>
		/// <param name="si">The 'si' element of the request.</param>
		/// <returns>The response to the SI request or an error element to include
		/// in the IQ response.</returns>
		XmlElement OnStreamInitiationRequest(Jid from, XmlElement si) {
			try {
				string method = SelectStreamMethod(si["feature"]);
				// If the session-id is already in use, we cannot process the request.
				string sid = si.GetAttribute("id");
				if (String.IsNullOrEmpty(sid) || siSessions.ContainsKey(sid))
					return new XmppError(ErrorType.Cancel, ErrorCondition.Conflict).Data;
				// Extract file information and hand to user.
				var file = si["file"];
				string desc = file["desc"] != null ? file["desc"].InnerText : null,
					name = file.GetAttribute("name");
				int size = Int32.Parse(file.GetAttribute("size"));
				FileTransfer transfer = new FileTransfer(from, im.Jid, name, size,
					sid, desc);
				string savePath = TransferRequest.Invoke(transfer);
				// User has rejected the request.
				if (savePath == null)
					return new XmppError(ErrorType.Cancel, ErrorCondition.NotAcceptable).Data;
				// Create an SI session instance.
				SISession session = new SISession(sid, File.OpenWrite(savePath),
					size, true, from, im.Jid, im.GetExtension(method) as IDataStream);
				siSessions.TryAdd(sid, session);
				// Store the file's meta data.
				metaData.TryAdd(sid, new FileMetaData(name, desc));
				// Construct and return the negotiation result.
				return Xml.Element("si", "http://jabber.org/protocol/si").Child(
					FeatureNegotiation.Create(new SubmitForm(
						new ListField("stream-method", method))));
			} catch {
				return new XmppError(ErrorType.Cancel, ErrorCondition.BadRequest).Data;
			}
		}
Example #23
0
        internal void UpdateFileTransfersNEW(ResponseTransferList list, uint reqID)
        {
            List <string> hashes = new List <string>();

            // get direction(DL/UL) of request/result
            Direction dir;

            if (_pendingRequests.TryGetValue(reqID, out dir))
            {
                _pendingRequests.Remove(reqID);
            }
            else
            if (list.transfers.Count > 0)
            {
                dir = list.transfers[0].direction;
            }
            else
            {
                // shouldn't end here
                return;
            }

            _fileTransfersNEW.Clear();

            // map new file transfers to their file hashes
            //Dictionary<string, FileTransfer> mapHashToFileTransfer = new Dictionary<string,FileTransfer>();
            foreach (FileTransfer fileTransfer in list.transfers)
            {
                _fileTransfersNEW.Add(fileTransfer.file.hash, fileTransfer);
            }

            //// add new - update old
            //foreach (KeyValuePair<string, FileTransfer> pair in mapHashToFileTransfer)
            //    if (_fileTransfersNEW.ContainsKey(pair.Key))
            //        _fileTransfersNEW[pair.Key] = pair.Value;
            //    else
            //        _fileTransfersNEW.Add(pair.Key, pair.Value);
            //// remove
            //FileTransfer[] fileTransfers = new FileTransfer[_fileTransfersNEW.Values.Count];
            //_fileTransfersNEW.Values.CopyTo(fileTransfers, 0);
            //foreach (FileTransfer ft in fileTransfers)
            //    if(!mapHashToFileTransfer.ContainsKey(ft.file.hash))
            //        _fileTransfersNEW.Remove(ft.file.hash);

            FileTransfer ft;

            for (int i = 0; i < 50; i++)
            {
                ft      = new FileTransfer();
                ft.file = new File();

                ft.direction = Direction.DIRECTION_DOWNLOAD;
                ft.file.name = i.ToString();
                ft.rate_kBs  = i;
                ft.fraction  = i / 100;
                ft.file.size = (ulong)i;
                ft.file.hash = i.ToString();
                _fileTransfersNEW.Add(ft.file.hash, ft);
            }

            UpdateFileListsNEW(dir);
        }
 public S_FileTransferSendBegin(RatClients client, FileTransfer info, SendType type)
     : base(client)
 {
     this.info = info;
     this.type = type;
 }
 public virtual string onRequest(FileTransfer transfer)
 {
     return(transfer.Name);
 }
        /// <summary>
        /// Begins uploading a file to the client.
        /// </summary>
        /// <param name="localPath">The local path of the file to upload.</param>
        /// <param name="remotePath">Save the uploaded file to this remote path.</param>
        public void BeginUploadFile(string localPath, string remotePath)
        {
            new Thread(() =>
            {
                int id = GetUniqueFileTransferId();

                FileTransfer transfer = new FileTransfer
                {
                    Id              = id,
                    Type            = TransferType.Upload,
                    LocalPath       = localPath,
                    RemotePath      = remotePath,
                    Status          = "Pending...",
                    TransferredSize = 0
                };

                try
                {
                    transfer.FileSplit = new FileSplit(localPath, FileAccess.Read);
                }
                catch (Exception)
                {
                    transfer.Status = "Error reading file";
                    OnFileTransferUpdated(transfer);
                    return;
                }

                transfer.Size = transfer.FileSplit.FileSize;

                lock (_syncLock)
                {
                    _activeFileTransfers.Add(transfer);
                }

                transfer.Size = transfer.FileSplit.FileSize;
                OnFileTransferUpdated(transfer);

                _limitThreads.WaitOne();
                try
                {
                    foreach (var chunk in transfer.FileSplit)
                    {
                        transfer.TransferredSize += chunk.Data.Length;
                        decimal progress          = Math.Round((decimal)((double)transfer.TransferredSize / (double)transfer.Size * 100.0), 2);
                        transfer.Status           = $"Uploading...({progress}%)";
                        OnFileTransferUpdated(transfer);

                        bool transferCanceled;
                        lock (_syncLock)
                        {
                            transferCanceled = _activeFileTransfers.Count(f => f.Id == transfer.Id) == 0;
                        }

                        if (transferCanceled)
                        {
                            transfer.Status = "Canceled";
                            OnFileTransferUpdated(transfer);
                            _limitThreads.Release();
                            return;
                        }

                        // blocking sending might not be required, needs further testing
                        _client.SendBlocking(new FileTransferChunk
                        {
                            Id       = id,
                            Chunk    = chunk,
                            FilePath = remotePath,
                            FileSize = transfer.Size
                        });
                    }
                }
                catch (Exception)
                {
                    lock (_syncLock)
                    {
                        // if transfer is already cancelled, just return
                        if (_activeFileTransfers.Count(f => f.Id == transfer.Id) == 0)
                        {
                            _limitThreads.Release();
                            return;
                        }
                    }
                    transfer.Status = "Error reading file";
                    OnFileTransferUpdated(transfer);
                    CancelFileTransfer(transfer.Id);
                    _limitThreads.Release();
                    return;
                }

                transfer.Status = "Completed";
                OnFileTransferUpdated(transfer);
                RemoveFileTransfer(transfer.Id);
                _limitThreads.Release();
            }).Start();
        }
Example #27
0
        /// <summary>Uploads the binary data and FileInfo contained within the given transfer object.</summary>
        /// <param name="transfer">The object containing the info and data of the file which should be uploaded.</param>
        /// <returns>The Id that has been assigned to the uploaded file.</returns>
        public static int UploadFile(FileTransfer transfer)
        {
            if (_sessionUser == null)
                throw new NotLoggedInException();

            if (transfer == null
                || transfer.Data == null
                || transfer.Info == null
                || transfer.Info.Name == null
                || transfer.Info.Name.Length < 3)
                throw new InadequateObjectException();

            using (var client = new ServiceClient())
            {
                // NOTE - OwnerEmail field is force-set to the _sessionUser's Email.
                transfer.Info.OwnerEmail = _sessionUser.Email;
                return client.UploadFile(transfer);
            }
        }
Example #28
0
        private void uploadTestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!BackgroundLocation.EndsWith("\\"))
                BackgroundLocation += "\\";

            using(OpenFileDialog dialog = new OpenFileDialog())
            {
                dialog.Multiselect = false; //temp disabled...
                dialog.Title = "Select the file(s) u want to upload";
                if(dialog.ShowDialog() == DialogResult.OK)
                {

                    FileTransfer info = new FileTransfer();
                    info.CurSize = 0;
                    info.Destination = BackgroundLocation;

                    FileInfo size = new FileInfo(dialog.FileName);
                    info.FileSize = size.Length;
                    info.Id = (short)(FileClientProcessor.Instance._clientList[ClientID]._FileTransfer.Count + 1);
                    info.type = 0;
                    info.FileName = size.Name;
                    FileClientProcessor.Instance._clientList[ClientID].SendFile(info, File.ReadAllBytes(dialog.FileName), S_FileTransferSendBegin.SendType.FileManager);
                }
            }
        }
Example #29
0
        private void btnEdit_Click(object sender, RibbonControlEventArgs e)
        {
            var load = new FileTransfer();

            load.ShowDialog();
        }