public FileServiceSession(DirectoryFileServiceItem service, int sessionId)
            {
                this.sessionId = sessionId;
                this.service   = service;
                this.log       = LoggerProxy.Create(service.Log, sessionId.ToString());

                log.Info("Session started...");
                service.OnSessionStart();
            }             // ctor
Beispiel #2
0
			public FileServiceSession(DirectoryFileServiceItem service, int sessionId)
			{
				this.sessionId = sessionId;
				this.service = service;
				this.log = LoggerProxy.Create(service.Log, sessionId.ToString());

				log.Info("Session started...");
				service.OnSessionStart();
			} // ctor
            public FileItem(DirectoryFileServiceItem notifyTarget, FileInfo fileInfo, IOdetteFile file, bool createInfo)
            {
                var fileDescription = file as IOdetteFileDescription;

                this.notifyTarget = new WeakReference <DirectoryFileServiceItem>(notifyTarget);
                this.fileInfo     = fileInfo;

                this.virtualFileName     = file.VirtualFileName;
                this.fileStamp           = file.FileStamp;
                this.sourceOrDestination = file.SourceOrDestination;

                var fiExtended = new FileInfo(GetExtendedFile());
                var readed     = false;

                if (!createInfo && fiExtended.Exists)
                {
                    // read file
                    xExtentions = XDocument.Load(fiExtended.FullName);

                    // read description element
                    var xDescription = xExtentions.Root.Element("description") ?? new XElement("description");

                    // get the attributes
                    var stringFormat = xDescription.GetAttribute("format", "U");
                    if (string.IsNullOrEmpty(stringFormat))
                    {
                        format = OdetteFileFormat.Unstructured;
                    }
                    else
                    {
                        switch (Char.ToUpper(stringFormat[0]))
                        {
                        case 'T':
                            format = OdetteFileFormat.Text;
                            break;

                        case 'F':
                            format = OdetteFileFormat.Fixed;
                            break;

                        case 'V':
                            format = OdetteFileFormat.Variable;
                            break;

                        default:
                            format = OdetteFileFormat.Unstructured;
                            break;
                        }
                    }

                    maximumRecordSize = xDescription.GetAttribute("maximumRecordSize", 0);
                    fileSize          = xDescription.GetAttribute("fileSize", -1L);
                    if (fileSize < 0)
                    {
                        fileSize = fileInfo.Length / 1024;                         // 1ks
                        if ((fileInfo.Length & 0x3FF) != 0)
                        {
                            fileSize++;
                        }
                    }

                    fileSizeUnpacked = xDescription.GetAttribute("fileSizeUnpacked", fileSize);
                    description      = xDescription.Value ?? String.Empty;

                    readed = true;
                }

                if (!readed)                 // create the new info xml
                {
                    this.format            = fileDescription?.Format ?? OdetteFileFormat.Unstructured;
                    this.maximumRecordSize = fileDescription?.MaximumRecordSize ?? 0;
                    this.fileSize          = fileDescription?.FileSize ?? (fileInfo.Exists ? fileInfo.Length : 0);
                    this.fileSizeUnpacked  = fileDescription?.FileSizeUnpacked ?? fileSize;
                    this.description       = fileDescription?.Description ?? String.Empty;

                    // create extented attributes
                    xExtentions = new XDocument(
                        new XDeclaration("1.0", Encoding.Default.WebName, "yes"),
                        new XElement("oftp",
                                     new XElement("description",
                                                  new XAttribute("format", format),
                                                  new XAttribute("maximumRecordSize", maximumRecordSize),
                                                  new XAttribute("fileSize", fileSize),
                                                  new XAttribute("fileSizeUnpacked", fileSizeUnpacked),
                                                  new XText(description)
                                                  )
                                     )
                        );

                    if (!fiExtended.Exists)
                    {
                        xExtentions.Save(fiExtended.FullName);
                    }
                }

                // optional information for send
                xSendInfo = xExtentions.Root.Element("send") ?? new XElement("send");
            }             // ctor
Beispiel #4
0
			public FileItem(DirectoryFileServiceItem notifyTarget, FileInfo fileInfo, IOdetteFile file, bool createInfo)
			{
				var fileDescription = file as IOdetteFileDescription;

				this.notifyTarget = new WeakReference<DirectoryFileServiceItem>(notifyTarget);
				this.fileInfo = fileInfo;

				this.virtualFileName = file.VirtualFileName;
				this.fileStamp = file.FileStamp;
				this.originator = file.Originator;

				var fiExtended = new FileInfo(GetExtendedFile());
				var readed = false;
				if (!createInfo && fiExtended.Exists)
				{
					// read file
					xExtentions = XDocument.Load(fiExtended.FullName);

					// read description element
					var xDescription = xExtentions.Root.Element("description") ?? new XElement("description");

					// get the attributes
					var stringFormat = xDescription.GetAttribute("format", "U");
					if (string.IsNullOrEmpty(stringFormat))
						format = OdetteFileFormat.Unstructured;
					else
					{
						switch (Char.ToUpper(stringFormat[0]))
						{
							case 'T':
								format = OdetteFileFormat.Text;
								break;
							case 'F':
								format = OdetteFileFormat.Fixed;
								break;
							case 'V':
								format = OdetteFileFormat.Variable;
								break;
							default:
								format = OdetteFileFormat.Unstructured;
								break;
						}
					}

					maximumRecordSize = xDescription.GetAttribute("maximumRecordSize", 0);
					fileSize = xDescription.GetAttribute("fileSize", -1L);
					if (fileSize < 0)
					{
						fileSize = fileInfo.Length / 1024; // 1ks
						if ((fileInfo.Length & 0x3FF) != 0)
							fileSize++;
					}

					fileSizeUnpacked = xDescription.GetAttribute("fileSizeUnpacked", fileSize);
					description = xDescription.Value ?? String.Empty;

					readed = true;
				}

				if (!readed) // create the new info xml
				{
					this.format = fileDescription?.Format ?? OdetteFileFormat.Unstructured;
					this.maximumRecordSize = fileDescription?.MaximumRecordSize ?? 0;
					this.fileSize = fileDescription?.FileSize ?? (fileInfo.Exists ? fileInfo.Length : 0);
					this.fileSizeUnpacked = fileDescription?.FileSizeUnpacked ?? fileSize;
					this.description = fileDescription?.Description ?? String.Empty;

					// create extented attributes
					xExtentions = new XDocument(
						new XDeclaration("1.0", Encoding.Default.WebName, "yes"),
						new XElement("oftp",
							new XElement("description",
								new XAttribute("format", format),
								new XAttribute("maximumRecordSize", maximumRecordSize),
								new XAttribute("fileSize", fileSize),
								new XAttribute("fileSizeUnpacked", fileSizeUnpacked),
								new XText(description)
							)
						)
					);

					if (!fiExtended.Exists)
						xExtentions.Save(fiExtended.FullName);
				}

				// optional information for send
				xSendInfo = xExtentions.Root.Element("send") ?? new XElement("send");
			} // ctor