Example #1
0
        public static FILE_FS_ATTRIBUTE_INFORMATION FromBuffer(IntPtr buffer)
        {
            FILE_FS_ATTRIBUTE_INFORMATION ret = new FILE_FS_ATTRIBUTE_INFORMATION();

            ret.VolumeAttributes           = (VolumeCaps)IOhelper.PtrToUint(buffer, 0);
            ret.MaximumComponentNameLength = Marshal.ReadInt32(buffer, 4);
            ret.FileSystemNameLength       = IOhelper.PtrToUint(buffer, 8);
            ret.FileSystemName             = IOhelper.PtrToStringUni(buffer, 12, ((int)ret.FileSystemNameLength) / 2);

            return(ret);
        }
Example #2
0
 private void CopytoAwaypath(List <string> filepaths)
 {
     filepaths.ForEach(X =>
     {
         string changhost = X.Replace(Settings.Mainhost.hostname, Settings.Awayhost.hostname);
         string awaypath  = changhost.Replace(Settings.Mainhost.path, Settings.Awayhost.path);
         if (!IOhelper.FileExists(awaypath))
         {
             IOhelper.FileCopy(X, awaypath);
         }
     });
 }
Example #3
0
        public static FILE_FS_VOLUME_INFORMATION FromBuffer(IntPtr buffer)
        {
            FILE_FS_VOLUME_INFORMATION ret = new FILE_FS_VOLUME_INFORMATION();

            ret.VolumeCreationTime = Marshal.ReadInt64(buffer, 0);
            ret.VolumeSerialNumber = IOhelper.PtrToUint(buffer, 8);
            ret.VolumeLabelLength  = Marshal.ReadInt32(buffer, 12);
            ret.SupportsObjects    = Marshal.ReadByte(buffer, 13);

            //pack=4
            ret.VolumeLabel = IOhelper.PtrToStringUni(buffer, 18, ret.VolumeLabelLength / 2);

            return(ret);
        }
Example #4
0
        public List <TmpSave> FileToTmptable(string hostname, string filepath, DateTime savedate)
        {
            List <TmpSave> tmpTable = new List <TmpSave>();

            IOhelper.getallfilename(filepath).ForEach((S) =>
            {
                tmpTable.Add(new TmpSave()
                {
                    SaveDate = savedate,
                    Filename = S,
                    Filepath = filepath,
                    Hostname = hostname,
                    Note     = ""
                });
            });
            return(tmpTable);
        }
Example #5
0
        public void AddDiffDBFile(EMRN emrn, Hostlocate host, string type)
        {
            DateTime     transdate = DateTime.ParseExact(emrn.TransNo.Substring(1, 8), "yyyyMMdd", null);
            string       hostpath  = PublicMethod.pathhead(host) + PublicMethod.pathdate(transdate);
            string       Filename  = @"\" + type;
            Compair_DIFF tmpdiff   = new Compair_DIFF();

            if (!IOhelper.FileExists(hostpath + Filename))
            {
                tmpdiff.Datetime = transdate;
                tmpdiff.Filename = Filename;
                tmpdiff.FilePath = hostpath + Filename;
                tmpdiff.Hostname = host.hostname;
                tmpdiff.Note     = "比對TransNo缺少檔案";
                difflist.Add(tmpdiff);
            }
        }
        public async Task <IActionResult> DownloadDataset(int datasetId)
        {
            var datatable = await _datasetService.ConsolidateDataset(datasetId);

            byte[] outputBuffer = null;

            using (MemoryStream tempStream = new MemoryStream())
            {
                using (StreamWriter writer = new StreamWriter(tempStream))
                {
                    IOhelper.WriteDataTable(datatable, writer, true);
                }

                outputBuffer = tempStream.ToArray();
            }
            //Response.Headers.Add("Content-Disposition", "inline; filename="+datatable.TableName + ".csv");
            return(File(outputBuffer, "text/csv", datatable.TableName + ".csv"));
        }
Example #7
0
        /// <summary>
        /// currently BUGGY - not use, use CreateFile instead
        /// </summary>
        /// <param name="file_name"></param>
        /// <param name="file_access"></param>
        /// <param name="file_share"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static IntPtr CreateFileHandle
            (string file_name,
            Win32FileAccess file_access,
            FileShare file_share,
            CreateFileOptions options)
        {
            IntPtr            ret                  = IntPtr.Zero;
            IntPtr            obj_attr_ptr         = IntPtr.Zero;
            IntPtr            file_name_struct_ptr = IntPtr.Zero;
            OBJECT_ATTRIBUTES obj_attr             = new OBJECT_ATTRIBUTES();

            try
            {
                //выделяем память под OBJECT_ATTRIBUTES
                int obj_attr_len = Marshal.SizeOf(typeof(OBJECT_ATTRIBUTES));
                obj_attr_ptr = Marshal.AllocHGlobal(obj_attr_len);

                //инициализируем OBJECT_ATTRIBUTES
                obj_attr = new OBJECT_ATTRIBUTES(IOhelper.GetKernelFileName(file_name), (uint)ntApiFS.OBJ_CASE_INSENSITIVE);
                Marshal.StructureToPtr(obj_attr, obj_attr_ptr, true);

                //инициализируем IO_STATUS_BLOCK
                IO_STATUS_BLOCK status_block = new IO_STATUS_BLOCK();

                //открываем...
                uint res = ntApiFS.NtOpenFile
                               (ref ret,
                               file_access,
                               obj_attr_ptr,
                               ref status_block,
                               (ulong)file_share,
                               (ulong)options);

                NTSTATUS_helper.ThrowOnError(res, status_block, NTSTATUS_severity.Warning);
                return(ret);
            }
            finally
            {
                obj_attr.Dispose();
            }
        }