コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FileShareDeliverySettings"/> class.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="includeFileExtension">if set to <c>true</c> [include file extension].</param>
        /// <param name="path">The URI of the file path.</param>
        /// <param name="renderFormat">The render format. <see cref="renderFormat"/></param>
        /// <param name="userName">Username for access to the network share.</param>
        /// <param name="password">Password for the network share associated with the specified Username.</param>
        /// <param name="writeMode">The write mode of the file. <see cref="WriteMode"/></param>
        public FileShareDeliverySettings(string fileName, bool includeFileExtension, string path
            , ReportOutputType renderFormat, string userName, string password, WriteMode writeMode)
        {
            // Parameters are passed into the web service using the ExtensionSettings object.
            _extensionSettings.ParameterValues = new ParameterValueOrFieldReference[7];
            _extensionSettings.ParameterValues[0] = new ReportingService.ParameterValue { Name = "FILENAME", Value = fileName };

            _extensionSettings.ParameterValues[1] = new ReportingService.ParameterValue
                                         {
                                             Name = "FILEEXTN",
                                             Value = includeFileExtension.ToString(CultureInfo.InvariantCulture)
                                         };

            _extensionSettings.ParameterValues[2] = new ReportingService.ParameterValue { Name = "PATH", Value = GetCleanUriString(path) };

            _extensionSettings.ParameterValues[3] = new ReportingService.ParameterValue { Name = "RENDER_FORMAT", Value = renderFormat.Format() };

            _extensionSettings.ParameterValues[4] = new ReportingService.ParameterValue { Name = "USERNAME", Value = userName };

            _extensionSettings.ParameterValues[5] = new ReportingService.ParameterValue { Name = "PASSWORD", Value = password };

            _extensionSettings.ParameterValues[6] = new ReportingService.ParameterValue
                                         {Name = "WRITEMODE", Value = Convert.ToString(writeMode)};

            // The name of the extension as it appears in the report server configuration file.
            // Valid values are Report Server Email, Report Server DocumentLibrary and Report Server FileShare.
            _extensionSettings.Extension = ExtensionString;
        }
コード例 #2
0
 public override Stream OpenWrite(WriteMode mode)
 {
     switch (mode)
     {
         case WriteMode.Overwrite: return BackingFile.OpenWrite();
         case WriteMode.Append: return BackingFile.Open(FileMode.Append, FileAccess.Write);
         case WriteMode.Truncate: return BackingFile.Open(FileMode.Truncate, FileAccess.Write);
         default: throw new NotImplementedException();
     }
 }
コード例 #3
0
 public override Stream OpenWrite(WriteMode mode)
 {
     if (mode == WriteMode.Truncate)
     {
         // ! Workaround
         // if don't read before truncate, we get "a invalid stored block lengths" Exception from Ionic.Zip when reading after
         this.ReadAllBytes();
         return new InMemory.InMemoryStream(ReplaceBytes);
     }
     else
     {
         var bytes = this.ReadAllBytes();
         var stream = new InMemory.InMemoryStream(ReplaceBytes, bytes);
         if (mode == WriteMode.Append)
         {
             stream.Seek(stream.Length, System.IO.SeekOrigin.Begin);
         }
         return stream;
     }
 }
コード例 #4
0
        public TuringMachineProperties(XmlElement xmlConfig)
        {
            Enabled = XmlUtils.TryGetValueAsBool(xmlConfig, "Enabled") ?? true;
            M = XmlUtils.GetValueAsInt(xmlConfig, "M");
            N = XmlUtils.TryGetValueAsInt(xmlConfig, "N") ?? -1;
            Heads = XmlUtils.TryGetValueAsInt(xmlConfig, "Heads") ?? 1;
            ShiftLength = XmlUtils.GetValueAsInt(xmlConfig, "ShiftLength");
            MinSimilarityToJump = XmlUtils.TryGetValueAsDouble(xmlConfig, "MinSimilarityToJump") ?? 0;

            string shiftModeStr = XmlUtils.TryGetValueAsString(xmlConfig, "ShiftMode");
            ShiftMode = shiftModeStr == null ? ShiftMode.Multiple : (ShiftMode) Enum.Parse(typeof(ShiftMode), shiftModeStr);

            string writeModeStr = XmlUtils.TryGetValueAsString(xmlConfig, "WriteMode");
            WriteMode = writeModeStr == null ? WriteMode.Interpolate : (WriteMode) Enum.Parse(typeof(WriteMode), writeModeStr);

            InitalizeWithGradient = XmlUtils.TryGetValueAsBool(xmlConfig, "InitalizeWithGradient") ?? false;

            InitalValue = XmlUtils.TryGetValueAsDouble(xmlConfig, "InitalValue") ?? 0;

            UseMemoryExpandLocation = XmlUtils.TryGetValueAsBool(xmlConfig, "UseMemoryExpandLocation") ?? false;
            DidWriteThreshold = XmlUtils.TryGetValueAsDouble(xmlConfig, "DidWriteThreshold") ?? 0.9d;
        }
コード例 #5
0
        }     //function end

        /// <summary>
        /// For some files, the data need to write after the last record if file exsited, the WriteMode is Append.
        /// For some files, if the file exsits, backup it and create a new file, WriteMode is Overwrite .
        /// If file is txt, seperate with '\t'
        /// If file is csv, seperate with ','
        /// </summary>
        /// <param name="filepath">file path</param>
        /// <param name="data">data to write</param>
        /// <param name="title">columns' name of file</param>
        /// <param name="filetype">output file type</param>
        public static void WriteOutputFile(string filepath, List <List <string> > data, List <string> title, WriteMode mode)
        {
            if (!File.Exists(filepath))
            {
                string dir = Path.GetDirectoryName(filepath);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                if (title != null && title.Count > 0)
                {
                    data.Insert(0, title);
                }
            }
            else
            {
                if (mode.Equals(WriteMode.Overwrite))
                {
                    MiscUtil.BackUpFile(filepath);
                    File.Delete(filepath);
                    if (title != null && title.Count > 0)
                    {
                        data.Insert(0, title);
                    }
                }
            }
            WriteToTXT(filepath, data);
        }
コード例 #6
0
 /// <summary>
 /// 在bin文件中写入string类型二维数据
 /// Write two dimensional data to binary file.
 ///     <param name="filePath">
 ///         <para>The full path of the file to write.</para>
 ///         <para>Chinese Simplified:待写入文件的完整路径。</para>
 ///     </param>
 ///     <param name="data">
 ///         <para>One dimension datas to be write.</para>
 ///         <para>Chinese Simplified:待写入文件的一维数组</para>
 ///     </param>
 ///     <param name="writeMode">
 ///         <para>Write Mode when file exist.</para>
 ///         <para>Chinese Simplified:文件已存在时的写入模式</para>
 ///     </param>
 /// </summary>
 public static void WriteData(string filePath, string[,] data, WriteMode writeMode = WriteMode.OverLap)
 {
     FileUtil.CheckFilePath(filePath, FileExtName);
     FileUtil.CheckDataSize(data);
     WriteStrDataToFile(filePath, data);
 }
コード例 #7
0
        /// <summary>
        /// 在bin文件中写入double类型一维数据,通过弹窗选择文件路径
        /// Write one dimensional data to binary file, file path can be choosen from the pop up GUI.
        ///     <param name="data">
        ///         <para>One dimensional datas to write.</para>
        ///         <para>Chinese Simplified:待写入文件的一维数组</para>
        ///     </param>
        ///     <param name="writeMode">
        ///         <para>Write Mode when file exist.</para>
        ///         <para>Chinese Simplified:文件已存在时的写入模式</para>
        ///     </param>
        /// </summary>
        public static void WriteData(ushort[] data, WriteMode writeMode = WriteMode.OverLap)
        {
            string filePath = FileUtil.GetSaveFilePathFromDialog(FileExtName);

            WriteData(filePath, data, writeMode);
        }
コード例 #8
0
 /// <summary>
 /// 将数据写入WORD模板页眉页尾
 /// </summary>
 /// <param name="key">打印模板参考位置</param>
 /// <param name="value">待输出到WORD文档中的字符串</param>
 /// <param name="mode">写入时的辅助参考值</param>
 public override void WriteHeaderFooter(string key, string[] value, WriteMode mode)
 {
     if (value.Length != 3) return;
     for (int i = 1; i <= m_doc.Sections.Count; i++)
     {
         m_doc.Sections[i].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Paragraphs[2].Range.Text = value[0];
         m_doc.Sections[i].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Paragraphs[3].Range.Text = "编码:" + value[1] + "\r";
         //m_doc.Sections[i].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Paragraphs[4].Range.Text = "页码: 2 / 3\r";
         m_doc.Sections[i].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Paragraphs[5].Range.Text = "版次: " + value[2] + "版";
     }
 }
コード例 #9
0
        public static void InitBinWriteStream(ref FileStream stream, string filePath, WriteMode writeMode)
        {
            FileMode mode = (WriteMode.Append == writeMode) ? FileMode.Append : FileMode.Create;

            stream = new FileStream(filePath, mode);
        }
コード例 #10
0
        internal Stream OpenWrite(string virtualPath, WriteMode mode)
        {
            Action<byte[]> onClose = (data) => ConnectedClient.WriteAllBytes(virtualPath, data);

            if (mode == WriteMode.Truncate)
            {
                ConnectedClient.DeleteFile(virtualPath);
                return new InMemory.InMemoryStream(onClose);
            }
            else if (mode == WriteMode.Overwrite)
            {
                return new InMemory.InMemoryStream(onClose);
            }
            else
            {
                var bytes = default(byte[]);
                using(var readStream = GetStream(virtualPath))
                {
                    bytes = StreamExtensions.ReadStreamToEnd(readStream);
                }
                var stream = new InMemory.InMemoryStream(onClose, bytes);
                stream.Seek(stream.Length, System.IO.SeekOrigin.Begin);
                return stream;
            }
        }
コード例 #11
0
        public override Stream OpenWrite(WriteMode mode)
        {
            if (mode == WriteMode.Truncate)
            {
                return new InMemoryStream((data) =>
                {
                    ByteContents = data;
                });
            }
            else
            {
                var stream = new InMemoryStream((data) =>
                {
                    ByteContents = data;
                }, ByteContents ?? new byte[0]);

                if (mode == WriteMode.Append)
                {
                    stream.Seek(stream.Length, SeekOrigin.Begin);
                }

                return stream;
            }
        }
コード例 #12
0
 public abstract void DocLayout(string LayoutZone, WriteMode mode);
コード例 #13
0
        internal Stream OpenWrite(string virtualPath, string fileName, WriteMode mode)
        {
            Action<byte[]> onClose = (data) => Client.UploadFile(virtualPath, fileName, data);

            if (mode == WriteMode.Truncate)
            {
                return new InMemory.InMemoryStream(onClose);
            }
            else
            {
                var bytes = GetBytes(CombineVirtualPath(virtualPath, fileName));
                var stream = new InMemory.InMemoryStream(onClose, bytes);
                if (mode == WriteMode.Append)
                {
                    stream.Seek(stream.Length, System.IO.SeekOrigin.Begin);
                }
                return stream;
            }
        }
コード例 #14
0
 public abstract void WriteFile(string Key, string sFile, WriteMode mode, int offset);
コード例 #15
0
 public abstract void WriteHeaderFooter(string key, string[] value, WriteMode mode);
コード例 #16
0
 public abstract void Write(string key, string value, WriteMode mode, int offset);
コード例 #17
0
 public abstract void Write(string key, string value, WriteMode mode);
コード例 #18
0
ファイル: OutputWriters.cs プロジェクト: jesterret/FarNet
 public sealed override void WriteLine(ConsoleColor foregroundColor, ConsoleColor backgroundColor, string value)
 {
     _mode = WriteMode.None;
     AppendLine(value);
 }
コード例 #19
0
 /// <summary>
 /// to create a WriteRaw request packet.
 /// </summary>
 /// <param name="uid">This field SHOULD identify the authenticated instance of the user.</param>
 /// <param name="treeId">This field identifies the subdirectory (or tree) on the server that the client is
 /// accessing.</param>
 /// <param name="fid">This field MUST be a valid 16-bit signed integer indicating the file to which the data
 /// should be written.</param>
 /// <param name="offset">The offset in bytes from the start of the file at which the write SHOULD begin.
 /// </param>
 /// <param name="writeMode">A 16-bit field containing flags defined as follows. </param>
 /// <param name="offsetHigh">If WordCount is 14, this is the upper 32 bits of the 64-bit offset in bytes from
 /// the start of the file at which the write MUST start.</param>
 /// <param name="data">Array of UCHAR The bytes to be written to the file.</param>
 /// <returns>a WriteRaw request packet</returns>
 /// <exception cref="System.NullReferenceException">There is no connection in context. </exception>
 public SmbWriteRawRequestPacket CreateWriteRawRequest(
     ushort uid,
     ushort treeId,
     ushort fid,
     uint offset,
     WriteMode writeMode,
     uint offsetHigh,
     byte[] data)
 {
     return this.CreateWriteRawRequest(this.Context.GetMessageId(this.connectionId),
         uid, treeId, this.defaultParameters.Flag, this.defaultParameters.Flag2, fid, offset, this.defaultParameters.Timeout,
         writeMode, offsetHigh, data);
 }
コード例 #20
0
ファイル: OutputWriters.cs プロジェクト: pezipink/FarNet
 public override sealed void WriteErrorLine(string value)
 {
     if (_mode != WriteMode.Error)
     {
         _mode = WriteMode.Error;
         AppendLine("ERROR:");
     }
     AppendLine(value);
 }
コード例 #21
0
        protected Task Write(WriteMode mode, string[] streams, int eventsPerStream)
        {
            Func <int, EventData> createEvent = TestEvent.NewTestEvent;

            return(Write(mode, streams, eventsPerStream, createEvent));
        }
コード例 #22
0
ファイル: OutputWriters.cs プロジェクト: pezipink/FarNet
 public override sealed void WriteVerboseLine(string message)
 {
     if (_mode != WriteMode.Verbose)
     {
         _mode = WriteMode.Verbose;
         AppendLine("VERBOSE:");
     }
     AppendLine(message);
 }
コード例 #23
0
ファイル: VirtualFileEntry.cs プロジェクト: naomiEve/Nano.VFS
 /// <summary>
 /// Writes the given buffer into the entry.
 /// </summary>
 /// <param name="buffer">The buffer to write</param>
 /// <param name="fileMode">The file mode</param>
 public abstract void Write(byte[] buffer, WriteMode fileMode);
コード例 #24
0
 public void SetMode(WriteMode mode)
 {
     // do nothing
 }
コード例 #25
0
ファイル: XMPP.cs プロジェクト: remobjects/ipxmpp
 private void DoSendItem(Element element, WriteMode mode, Action done)
 {
     fInSending = true;
     sb.Length = 0;
     element.ToString(sb, new WriteOptions { Mode = mode, StreamPrefix = "stream" });
     byte[] data = Encoding.UTF8.GetBytes(sb.ToString());
     //Console.WriteLine("Sending: " + sb);
     try
     {
         Connection cn = fConnection;
         if (cn != null)
             cn.BeginWrite(data, 0, data.Length, new AsyncCallback(ItemSent), done);
     }
     catch
     {
     }
 }
コード例 #26
0
ファイル: VirtualFileEntry.cs プロジェクト: naomiEve/Nano.VFS
 /// <summary>
 /// Writes the given string into the entry.
 /// </summary>
 /// <param name="value">The string to write</param>
 /// <param name="fileMode">The file mode</param>
 public abstract void Write(string value, WriteMode fileMode);
コード例 #27
0
ファイル: OutputWriters.cs プロジェクト: pezipink/FarNet
 public override sealed void WriteLine(string value)
 {
     _mode = WriteMode.None;
     AppendLine(value);
 }
コード例 #28
0
 public System.IO.Stream OpenWrite(WriteMode mode)
 {
     return(this.provider.OpenWrite(this.path, mode));
 }
コード例 #29
0
        /// <summary>
        /// <para>Create a new file with the contents provided in the request.</para>
        /// </summary>
        /// <param name="path">Path in the user's Dropbox to save the file.</param>
        /// <param name="mode">Selects what to do if the file already exists.</param>
        /// <param name="autorename">If there's a conflict, as determined by <paramref
        /// name="mode" />, have the Dropbox server try to autorename the file to avoid
        /// conflict.</param>
        /// <param name="clientModified">The value to store as the <paramref
        /// name="clientModified" /> timestamp. Dropbox automatically records the time at which
        /// the file was written to the Dropbox servers. It can also record an additional
        /// timestamp, provided by Dropbox desktop clients, mobile clients, and API apps of
        /// when the file was actually created or modified.</param>
        /// <param name="mute">Normally, users are made aware of any file modifications in
        /// their Dropbox account via notifications in the client software. If <c>true</c>,
        /// this tells the clients that this modification shouldn't result in a user
        /// notification.</param>
        /// <param name="body">The document to upload</param>
        /// <returns>The task that represents the asynchronous send operation. The TResult
        /// parameter contains the response from the server.</returns>
        /// <exception cref="Dropbox.Api.ApiException{UploadError}">Thrown if there is an error
        /// processing the request; This will contain a <see cref="UploadError"/>.</exception>
        public t.Task<FileMetadata> UploadAsync(string path,
                                                WriteMode mode = null,
                                                bool autorename = false,
                                                sys.DateTime? clientModified = null,
                                                bool mute = false,
                                                io.Stream body = null)
        {
            var commitInfo = new CommitInfo(path,
                                            mode,
                                            autorename,
                                            clientModified,
                                            mute);

            return this.UploadAsync(commitInfo, body);
        }
コード例 #30
0
        /// <summary>
        /// 在csv文件中写入数据,通过弹窗选择文件路径,需指定数据类型
        /// </summary>
        /// <typeparam name="T">数据类型</typeparam>
        /// <param name="data">待写入文件的二维数组</param>
        /// <param name="writeMode">文件已存在时的写入模式</param>
        /// <param name="encoding">文件的编码格式。encoding为null时使用系统默认的编码格式</param>
        public static void WriteData <T>(T[,] data, WriteMode writeMode = WriteMode.OverLap, Encoding encoding = null)
        {
            string filePath = FileUtil.GetSaveFilePathFromDialog(FileExtName);

            WriteData(filePath, data, writeMode, encoding);
        }
コード例 #31
0
        internal static void InitWriteStream(ref StreamWriter writer, string filePath, WriteMode writeMode, Encoding encode = null)
        {
            bool isAppend = (WriteMode.Append == writeMode);

            writer = (null != encode) ? new StreamWriter(filePath, isAppend, encode) : new StreamWriter(filePath, isAppend);
        }
コード例 #32
0
 /// <summary>
 /// 在csv文件中写入数据,通过弹窗选择文件路径,需指定数据类型
 /// </summary>
 /// <typeparam name="T">数据类型</typeparam>
 /// <param name="filePath">待写入文件的完整路径和名称</param>
 /// <param name="data">待写入文件的二维数组</param>
 /// <param name="writeMode">文件已存在时的写入模式</param>
 /// <param name="encoding">文件的编码格式。encoding为null时使用系统默认的编码格式</param>
 public static void WriteData <T>(string filePath, T[,] data, WriteMode writeMode = WriteMode.OverLap, Encoding encoding = null)
 {
     FileUtil.CheckFilePath(filePath, FileExtName);
     StreamWriteData(filePath, data.GetEnumerator(), data.GetLength(0), data.GetLength(1), writeMode, encoding);
 }
コード例 #33
0
        private static void StreamWriteData(string filePath, Array data, long byteSize, WriteMode writeMode)
        {
            FileStream stream = null;

            try
            {
                FileUtil.InitBinWriteStream(ref stream, filePath, writeMode);
                FileUtil.StreamwriteDataToFile(stream, data, byteSize, 0);
            }
            catch (SeeSharpFileException)
            {
                throw;
            }
            catch (ApplicationException ex)
            {
                throw new SeeSharpFileException(SeeSharpFileErrorCode.RuntimeError,
                                                i18n.GetFStr("Runtime.WriteFail", ex.Message), ex);
            }
            finally
            {
                FileUtil.ReleaseResource(stream);
            }
        }
コード例 #34
0
ファイル: OutputWriter.cs プロジェクト: waynedenier/FizzBuzz
 public void SetMode(WriteMode mode)
 {
     _mode = mode;
 }
コード例 #35
0
 /// <summary>
 /// 在bin文件中写入double类型一维数据,通过弹窗选择文件路径
 /// Write one dimensional data to binary file.
 ///     <param name="filePath">
 ///         <para>The full path of the file to write.</para>
 ///         <para>Chinese Simplified:待写入文件的完整路径。</para>
 ///     </param>
 ///     <param name="data">
 ///         <para>One dimension datas to be write.</para>
 ///         <para>Chinese Simplified:待写入文件的一维数组</para>
 ///     </param>
 ///     <param name="writeMode">
 ///         <para>Write Mode when file exist.</para>
 ///         <para>Chinese Simplified:文件已存在时的写入模式</para>
 ///     </param>
 /// </summary>
 public static void WriteData(string filePath, short[] data, WriteMode writeMode = WriteMode.OverLap)
 {
     FileUtil.CheckFilePath(filePath, FileExtName);
     FileUtil.CheckDataSize(data);
     StreamWriteData(filePath, data, data.Length * sizeof(short), writeMode);
 }
コード例 #36
0
 public abstract void DocLayout(string LayoutZone, WriteMode mode);
コード例 #37
0
        /// <summary>
        /// Write data to file.
        /// For some files, the data need to write after the last record if file exsited, the WriteMode is Append.
        /// For some files, if the file exsits, backup it and create a new file, WriteMode is Overwrite .
        /// </summary>
        /// <param name="filepath">file path</param>
        /// <param name="data">data to write, contain seperators(eg. '\t' or ',') in each string, without '\r\n'</param>
        /// <param name="title">columns title</param>
        /// <param name="mode">if overwrite</param>
        public static void WriteOutputFile(string filepath, string[] data, string title, WriteMode mode)
        {
            List <string> content = data.ToList();

            WriteOutputFile(filepath, content, title, mode);
        }
コード例 #38
0
 public abstract void Write(string key, string value, WriteMode mode, int offset);
コード例 #39
0
        /// <summary>
        /// to create a WriteRaw request packet.
        /// </summary>
        /// <param name="messageId">This field SHOULD be the multiplex ID that is used to associate a response with a
        /// request.</param>
        /// <param name="uid">This field SHOULD identify the authenticated instance of the user.</param>
        /// <param name="treeId">This field identifies the subdirectory (or tree) on the server that the client is
        /// accessing.</param>
        /// <param name="flags">An 8-bit field of 1-bit flags describing various features in effect for the
        /// message</param>
        /// <param name="flags2">A 16-bit field of 1-bit flags that represent various features in effect for the
        /// message. Unspecified bits are reserved and MUST be zero.</param>
        /// <param name="fid">This field MUST be a valid 16-bit signed integer indicating the file to which the data
        /// should be written.</param>
        /// <param name="offset">The offset in bytes from the start of the file at which the write SHOULD begin.
        /// </param>
        /// <param name="timeout">This field is the timeout in milliseconds to wait for the write to complete.</param>
        /// <param name="writeMode">A 16-bit field containing flags defined as follows. </param>
        /// <param name="offsetHigh">If WordCount is 14, this is the upper 32 bits of the 64-bit offset in bytes from
        /// the start of the file at which the write MUST start.</param>
        /// <param name="data">Array of UCHAR The bytes to be written to the file.</param>
        /// <returns>a WriteRaw request packet</returns>
        public SmbWriteRawRequestPacket CreateWriteRawRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort fid,
            uint offset,
            uint timeout,
            WriteMode writeMode,
            uint offsetHigh,
            byte[] data)
        {
            if (data == null)
            {
                data = new byte[0];
            }

            SmbWriteRawRequestPacket packet = new SmbWriteRawRequestPacket();

            packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_WRITE_RAW,
                messageId, uid, treeId, flags, flags2);

            SMB_COM_WRITE_RAW_Request_SMB_Parameters smbParameters = new SMB_COM_WRITE_RAW_Request_SMB_Parameters();
            smbParameters.FID = fid;
            smbParameters.CountOfBytes = (ushort)data.Length;
            smbParameters.Reserved1 = 0;
            smbParameters.Offset = offset;
            smbParameters.Timeout = timeout;
            smbParameters.WriteMode = writeMode;
            smbParameters.Reserved2 = 0;
            smbParameters.DataLength = (ushort)data.Length;
            smbParameters.OffsetHigh = offsetHigh;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_WRITE_RAW_Request_SMB_Data smbData = new SMB_COM_WRITE_RAW_Request_SMB_Data();

            // The size of the preceding SmbParameters part plus Header part is an odd number for all cifs messages
            // If the format is Unicode, needs to add one 16 bits align pad
            if ((flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE)
            {
                // pad 1 byte for 16-bits align:
                smbData.Pad = new byte[1];
            }
            else
            {
                smbData.Pad = new byte[0];
            }
            smbData.Data = data;
            smbData.ByteCount = (ushort)(smbData.Data.Length + smbData.Pad.Length);

            smbParameters.DataOffset = (ushort)(Marshal.SizeOf(packet.SmbHeader) + Marshal.SizeOf(smbParameters)
                + Marshal.SizeOf(smbData.ByteCount) + smbData.Pad.Length);

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;

            return packet;
        }
コード例 #40
0
 public abstract void WriteEx(string key, string value, WriteMode mode);
コード例 #41
0
 public Task <FileMetadata> UploadAsync(string path, WriteMode mode, bool autorename, DateTime?clientModified, bool mute, Stream body) => _client.Files.UploadAsync(path, mode, autorename, clientModified, mute, null, false, body);
コード例 #42
0
 public abstract void WriteFile(string Key, string sFile, WriteMode mode, int offset);
コード例 #43
0
 public WriteResult(WriteMode requiredMode, int writtenFields)
 {
     RequiredMode  = requiredMode;
     WrittenFields = writtenFields;
 }
コード例 #44
0
 public abstract void WriteHeaderFooter(string key, string[] value, WriteMode mode);
コード例 #45
0
 public override System.IO.Stream OpenWrite(WriteMode mode)
 {
     return Provider.OpenWrite(this.Directory.VirtualPath, this.Name, mode);
 }
コード例 #46
0
        private void Update(EvaluationContext context)
        {
            var maxLength     = MaxLength.GetValue(context);
            var stringBuilder = InputBuffer.GetValue(context);
            var lastIndex     = _index;

            if (maxLength <= 0)
            {
                Result.Value = String.Empty;
                return;
            }

            if (!InputBuffer.IsConnected || stringBuilder == null)
            {
                stringBuilder = _fallbackBuffer;
            }

            if (ClearTrigger.GetValue(context))
            {
                stringBuilder.Clear();
                _index = 0;
            }

            //var mode = (Modes)WriteMode.GetValue(context);

            try
            {
                if (Insert.GetValue(context))
                {
                    if (TriggerRandomPos.GetValue(context))
                    {
                        _index = (int)_random.NextLong(0, stringBuilder.Length);
                    }

                    var separator = Separator.GetValue(context);;
                    if (!string.IsNullOrEmpty(separator))
                    {
                        separator = separator.Replace("\\n", "\n");
                    }

                    var str           = InsertString.GetValue(context);
                    var insertString  = str + separator;
                    var insertLength  = insertString.Length;
                    var currentLength = stringBuilder.Length;
                    var lineWrap      = (WrapLinesModes)WrapLines.GetValue(context);
                    var mode          = (Modes)WriteMode.GetValue(context);

                    if (_index > maxLength)
                    {
                        _index = 0;
                    }

                    var pos = _index;
                    if (pos + insertLength > maxLength)
                    {
                        insertLength = maxLength - pos;
                    }

                    if (mode != Modes.Insert && pos < currentLength - insertLength)
                    {
                        stringBuilder.Remove(pos, insertLength);
                    }

                    if (pos > currentLength)
                    {
                        var fillString = FillCharacter.GetValue(context);
                        var fillChar   = string.IsNullOrEmpty(fillString) ?  '_' : fillString[0];
                        stringBuilder.Append(new string(fillChar, pos - currentLength));
                    }

                    stringBuilder.Insert(pos, insertString);

                    InsertLineWraps(lineWrap, stringBuilder, pos, insertLength, WrapLineColumn.GetValue(context).Clamp(1, 1000));
                    switch (mode)
                    {
                    case Modes.Insert:
                    {
                        _index += insertLength;
                        break;
                    }

                    case Modes.Overwrite:
                    {
                        _index += insertLength;
                        _index %= maxLength;
                        break;
                    }

                    case Modes.OverwriteAtFixedOffset:
                        _index += FillOffset.GetValue(context);
                        if (_index > maxLength)
                        {
                            _index = _index % maxLength;
                        }
                        else if (_index < 0)
                        {
                            _index += maxLength - insertLength;
                        }

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }


                    //InsertLineWraps(lineWrap, stringBuilder);

                    if (stringBuilder.Length > maxLength)
                    {
                        stringBuilder.Length = maxLength;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Warning($"Failed to manipulate string at index {_index} " + e.Message);
            }

            //

            Builder.Value = stringBuilder;
            Result.Value  = stringBuilder.ToString();
        }
コード例 #47
0
 public override System.IO.Stream OpenWrite(WriteMode mode)
 {
     return Provider.OpenWrite(VirtualPath, mode);
 }
コード例 #48
0
ファイル: Writter.cs プロジェクト: momak/PortScanner
 public Writter(WriteMode wm, string outputFile)
 {
     _wm         = wm;
     _outputFile = outputFile;
 }
コード例 #49
0
ファイル: XMPP.cs プロジェクト: remobjects/ipxmpp
        private void BeginSend(Element element, WriteMode wm, Action done)
        {
            lock (fItems) {

                    fItems.AddLast(new QueuedItem
                    {
                        Element = element,
                        Mode = wm,
                        Done = done
                    });
                if (!fInSending)
                    DoSendItem(element, wm, done);
            }
        }
コード例 #50
0
ファイル: SoundSequence.cs プロジェクト: nnn1590/Audinfo
        /// <summary>
        /// Write the sequence file.
        /// </summary>
        /// <param name="writeMode">Write mode.</param>
        /// <param name="bw">The writer.</param>
        public void Write(WriteMode writeMode, BinaryDataWriter bw)
        {
            //Update sequence data if write mode changed.
            if (this.writeMode != writeMode)
            {
                UpdateSeqData(writeMode);
            }

            //Set write mode.
            this.writeMode = writeMode;

            //Init file.
            FileWriter FileWriter = new FileWriter();

            FileWriter.InitFile(bw, writeMode, "SEQ", 2, Version);

            //Data block.
            FileWriter.InitBlock(bw, ReferenceTypes.SEQ_Block_Data, "DATA");

            //Write sequence data.
            Syroot.BinaryData.ByteOrder bo = Syroot.BinaryData.ByteOrder.BigEndian;
            if (writeMode == WriteMode.NX || writeMode == WriteMode.C_BE)
            {
                bo = Syroot.BinaryData.ByteOrder.LittleEndian;
            }
            //bw.Write(SequenceData.ToBytes(bo));
            bw.Write(goodData);

            //Align.
            FileWriter.Align(bw, 0x20);

            //Close data block.
            FileWriter.CloseBlock(bw);

            //Label block.
            FileWriter.InitBlock(bw, ReferenceTypes.SEQ_Block_Label, "LABL");

            //Label table.
            FileWriter.InitReferenceTable(bw, Labels.Count, "Labels");

            //Write each label.
            foreach (SequenceLabel l in Labels)
            {
                //Label is null.
                if (l == null)
                {
                    FileWriter.AddReferenceTableNullReference("Labels");
                }

                //Not null.
                else
                {
                    //Add reference.
                    FileWriter.AddReferenceTableReference(bw, ReferenceTypes.SEQ_LabelInfo, "Labels");

                    //Write data.
                    bw.Write(ReferenceTypes.General);
                    bw.Write((UInt16)0);
                    bw.Write(l.Offset);
                    bw.Write((UInt32)l.Label.Length);
                    bw.Write(l.Label.ToCharArray());

                    //Add null terminator.
                    bw.Write('\0');

                    //Align to 4 bytes.
                    FileWriter.Align(bw, 4);
                }
            }

            //Close labels.
            FileWriter.CloseReferenceTable(bw, "Labels");

            //Align.
            FileWriter.Align(bw, 0x20);

            //Close label block.
            FileWriter.CloseBlock(bw);

            //Close file.
            FileWriter.CloseFile(bw);
        }
コード例 #51
0
ファイル: OutputWriters.cs プロジェクト: pezipink/FarNet
 public override sealed void WriteDebugLine(string message)
 {
     if (_mode != WriteMode.Debug)
     {
         _mode = WriteMode.Debug;
         AppendLine("DEBUG:");
     }
     AppendLine(message);
 }
 public void Write(string storagePointer, Stream stream, WriteMode writeMode)
 {
     WriteAsync(storagePointer, stream, writeMode, CancellationToken.None).Wait();
 }
コード例 #53
0
ファイル: OutputWriters.cs プロジェクト: pezipink/FarNet
 public override sealed void WriteLine()
 {
     _mode = WriteMode.None;
     AppendLine();
 }
コード例 #54
0
ファイル: DataHandler.cs プロジェクト: veserine/CASCHost
        public static CASResult Write(WriteMode mode, params CASFile[] entries)
        {
            CASContainer.Logger.LogInformation("Writing data...");

            var    path     = Path.Combine(CASContainer.Settings.OutputPath, "Data", "data");
            string filename = "dummy.000";

            // calculate local data file
            if (mode.HasFlag(WriteMode.Data))
            {
                Directory.CreateDirectory(path);

                long requiredBytes = entries.Sum(x => x.Data.Length) + 38 + (entries.Count() > 1 ? 5 : 0) + (entries.Count() * 24);
                if (mode.HasFlag(WriteMode.Data))
                {
                    filename = GetDataFile(requiredBytes);
                }
            }

            using (var md5 = MD5.Create())
                using (MemoryStream ms = new MemoryStream())
                    using (BinaryWriter bw = new BinaryWriter(ms, Encoding.ASCII))
                    {
                        bw.Seek(0, SeekOrigin.End);
                        long posStart = bw.BaseStream.Position;

                        uint headersize = entries.Length == 1 ? 0 : 24 * (uint)entries.Length + 12;

                        // Archive Header
                        bw.Write(new byte[16]);    // MD5 hash
                        bw.Write((uint)0);         // Size
                        bw.Write(new byte[0xA]);   // Unknown

                        // Header
                        bw.Write(BLTEStream.BLTE_MAGIC);
                        bw.WriteUInt32BE(headersize);

                        // Chunkinfo
                        if (headersize > 0)
                        {
                            bw.Write((byte)15);             // Flags
                            bw.WriteUInt24BE((uint)entries.Count());

                            // Entries
                            foreach (var entry in entries)
                            {
                                bw.WriteUInt32BE(entry.CompressedSize);
                                bw.WriteUInt32BE(entry.DecompressedSize);
                                bw.Write(md5.ComputeHash(entry.Data));                 // Checksum
                            }
                        }

                        // Write data
                        foreach (var entry in entries)
                        {
                            bw.Write(entry.Data);
                            Array.Resize(ref entry.Data, 0);
                        }

                        // Compute header hash
                        bw.BaseStream.Position = posStart + 30;
                        byte[] buffer = new byte[(headersize == 0 ? bw.BaseStream.Length - bw.BaseStream.Position : headersize)];
                        bw.BaseStream.Read(buffer, 0, buffer.Length);
                        var hash = md5.ComputeHash(buffer);

                        CASResult blte = new CASResult()
                        {
                            DecompressedSize = (uint)entries.Sum(x => x.DecompressedSize),
                            CompressedSize   = (uint)(bw.BaseStream.Length - posStart),
                            Hash             = new MD5Hash(hash)
                        };

                        bw.BaseStream.Position = posStart;
                        bw.Write(hash.Reverse().ToArray());    // Write Hash
                        bw.Write(blte.CompressedSize);         // Write Length

                        // Update .data file
                        if (mode.HasFlag(WriteMode.Data))
                        {
                            Directory.CreateDirectory(path);

                            using (FileStream fs = new FileStream(Path.Combine(path, filename), FileMode.OpenOrCreate, FileAccess.ReadWrite))
                            {
                                fs.Seek(0, SeekOrigin.End);
                                blte.Offset = (ulong)fs.Position;

                                ms.Position = 0;
                                ms.CopyTo(fs);
                                fs.Flush();
                            }
                        }

                        // Output raw
                        if (mode.HasFlag(WriteMode.CDN))
                        {
                            blte.OutPath = Path.Combine(CASContainer.Settings.OutputPath, Helper.GetCDNPath(blte.Hash.ToString(), "data"));
                            using (FileStream fs = new FileStream(blte.OutPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                            {
                                ms.Position = 30;                 // Skip header
                                ms.CopyTo(fs);
                                fs.Flush();
                            }
                        }

                        return(blte);
                    }
        }
コード例 #55
0
ファイル: OutputWriters.cs プロジェクト: pezipink/FarNet
 public override sealed void WriteLine(ConsoleColor foregroundColor, ConsoleColor backgroundColor, string value)
 {
     _mode = WriteMode.None;
     AppendLine(value);
 }
コード例 #56
0
ファイル: VirtualIrDevice.cs プロジェクト: pos0637/codec
 public override bool Write(WriteMode mode, object data)
 {
     return(true);
 }
コード例 #57
0
ファイル: OutputWriters.cs プロジェクト: pezipink/FarNet
 public override sealed void WriteWarningLine(string message)
 {
     if (_mode != WriteMode.Warning)
     {
         _mode = WriteMode.Warning;
         AppendLine("WARNING:");
     }
     AppendLine(message);
 }
コード例 #58
0
        public virtual void ToString(StringBuilder builder, WriteOptions wm)
        {
            if (wm.Mode != WriteMode.Close)
            {
                builder.Append('<');
                if (Prefix != null)
                {
                    builder.Append(Prefix);
                    builder.Append(':');
                }
                builder.Append(Name);

                for (int i = 0; i < Attributes.Count; i++)
                {
                    builder.Append(' ');
                    Attribute at = Attributes[i];
                    if (at.Prefix != null)
                    {
                        builder.Append(at.Prefix);
                        builder.Append(':');
                    }
                    builder.Append(at.Name);
                    builder.Append("='");
                    builder.UriEscape(at.Value);
                    builder.Append('\'');
                }
            }
            if (wm.Mode == WriteMode.Close)
            {
                builder.Append("</");
                if (Prefix != null)
                {
                    builder.Append(Prefix);
                    builder.Append(':');
                }
                builder.Append(Name);
                builder.Append(">");
            }
            else
            if (!String.IsNullOrEmpty(Text) || Elements.Count > 0 || wm.Mode == WriteMode.Open)
            {
                builder.Append('>');
                WriteMode oldwm = wm.Mode;
                wm.Mode = WriteMode.None;
                for (int i = 0; i < Elements.Count; i++)
                {
                    Elements[i].ToString(builder, wm);
                }
                wm.Mode = oldwm;
                if (wm.Mode == WriteMode.None && Text != null)
                {
                    builder.UriEscape(Text);
                }
                if (wm.Mode != WriteMode.Open)
                {
                    builder.Append("</");
                    if (Prefix != null)
                    {
                        builder.Append(Prefix);
                        builder.Append(':');
                    }
                    builder.Append(Name);
                    builder.Append('>');
                }
            }
            else
            {
                builder.Append(" />");
            }
        }
コード例 #59
0
        /// <summary>
        /// <para>Begins an asynchronous send to the upload route.</para>
        /// </summary>
        /// <param name="path">Path in the user's Dropbox to save the file.</param>
        /// <param name="mode">Selects what to do if the file already exists.</param>
        /// <param name="autorename">If there's a conflict, as determined by <paramref
        /// name="mode" />, have the Dropbox server try to autorename the file to avoid
        /// conflict.</param>
        /// <param name="clientModified">The value to store as the <paramref
        /// name="clientModified" /> timestamp. Dropbox automatically records the time at which
        /// the file was written to the Dropbox servers. It can also record an additional
        /// timestamp, provided by Dropbox desktop clients, mobile clients, and API apps of
        /// when the file was actually created or modified.</param>
        /// <param name="mute">Normally, users are made aware of any file modifications in
        /// their Dropbox account via notifications in the client software. If <c>true</c>,
        /// this tells the clients that this modification shouldn't result in a user
        /// notification.</param>
        /// <param name="body">The document to upload</param>
        /// <param name="callback">The method to be called when the asynchronous send is
        /// completed.</param>
        /// <param name="callbackState">A user provided object that distinguished this send
        /// from other send requests.</param>
        /// <returns>An object that represents the asynchronous send request.</returns>
        public sys.IAsyncResult BeginUpload(string path,
                                            WriteMode mode = null,
                                            bool autorename = false,
                                            sys.DateTime? clientModified = null,
                                            bool mute = false,
                                            io.Stream body = null,
                                            sys.AsyncCallback callback = null,
                                            object callbackState = null)
        {
            var commitInfo = new CommitInfo(path,
                                            mode,
                                            autorename,
                                            clientModified,
                                            mute);

            return this.BeginUpload(commitInfo, body, callback, callbackState);
        }
コード例 #60
0
 /// <summary>
 /// 将数据写入设备
 /// </summary>
 /// <param name="mode">写入方式</param>
 /// <param name="data">数据</param>
 /// <returns></returns>
 public abstract Boolean Write(WriteMode mode, Object data);