Exemplo n.º 1
0
        public async Task ExecuteAsync(object opts, CancellationToken cancellationToken)
        {
            var options = (DumpOptions)opts;

            // Use the internal PageFile class to open up the specified file.
            var pageFile = new PageFile();

            await pageFile.OpenAsync(options.DBFileName, cancellationToken);

            // If they want to dump a specific page, do so.
            if (options.PageNum.HasValue)
            {
                var page = await pageFile.ReadPageAsync(options.PageNum.Value, cancellationToken);

                DumpPage(options.PageNum.Value, page);
            }
            else
            {
                // Get the number of pages
                var numPages = pageFile.NumPages;

                Console.WriteLine("Num Pages: {0}", numPages);
                Console.WriteLine();
                Console.WriteLine("Page  Description");
                Console.WriteLine("----  -----------");

                // Iterate through all the pages, and print a summary of each
                for (var i = 0; i < numPages; i++)
                {
                    var page = await pageFile.ReadPageAsync(i, cancellationToken);

                    Console.WriteLine("{0,4}  {1}", i, page.ToString());
                }
            }
        }
Exemplo n.º 2
0
        public PageFile StepPrevious(StepSize step)
        {
            if (this.Previous == null)
            {
                return(null);
            }

            //if current is 'first page', first goto previous 'book'
            PageFile lpfFile = this.Previous;

            switch (step)
            {
            case StepSize.small:
                break;

            case StepSize.large:
                for (int i = 0; i < 9 && lpfFile.Previous != null && lpfFile.Series.Equals(this.Series) && lpfFile.SeriesNumberTag.Equals(this.SeriesNumberTag); i++)
                {
                    lpfFile = lpfFile.Previous;
                }
                break;

            case StepSize.seriesTag:
                lpfFile = lpfFile.Book.First;
                break;

            case StepSize.series:
                lpfFile = lpfFile.Book.Series.First.First;
                break;
            }

            return(lpfFile);
        }
Exemplo n.º 3
0
 public PagePicture(PageFile pfFile, double dScrnHeight, double dScrnWidth)
     : base()
 {
     PictureFile = pfFile;
     Height      = dScrnHeight;
     Width       = dScrnWidth;
 }
Exemplo n.º 4
0
 public XQueryDocumentBuilder(XQueryDocument doc)
 {            
     m_document = doc;
     if (doc.pagefile == null)
     {
         m_pageFile = new PageFile(false);
         m_pageFile.HasSchemaInfo = true;
         doc.pagefile = m_pageFile;
     }
     else
         m_pageFile = doc.pagefile;
     NameTable = doc.nameTable;
     xmlns = NameTable.Get(XmlReservedNs.NsXmlNs);
     _state = WriteState.Start;
     if (doc.input == null)
     {
         _normalize = true;
         hs = new HashSet<object>();
         NamespaceManager = new XmlNamespaceManager(NameTable);
     }
     SchemaInfo = null;
     DocumentRoot = new DmRoot();
     _parent = DocumentRoot;
     _text = null;
 }
Exemplo n.º 5
0
    protected void OpenFile(object sender, EventArgs e)
    {
        FileChooserDialog fc = new FileChooserDialog("Choose the directory containing the hives to open",
                                                     this,
                                                     FileChooserAction.Open,
                                                     "Cancel", ResponseType.Cancel,
                                                     "Open", ResponseType.Accept);

        if (fc.Run() == (int)ResponseType.Accept)
        {
            string filename = fc.Filename;
            fc.Destroy();

            _currentStrs = null;

            new Thread(new ThreadStart(delegate {
                _pagefile    = new PageFile(filename);
                _strs        = _pagefile.GetASCIIStrings(6);
                _currentStrs = _pagefile.GetPossibleEnvironmentVariables(_strs, 10);
            })).Start();

            new Thread(new ThreadStart(delegate {
                Populate();
            })).Start();
        }
        else
        {
            fc.Destroy();
        }
    }
Exemplo n.º 6
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public InvokeResult <PageFile> Insert(PageFile entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException();
            }
            InvokeResult <PageFile> result = new InvokeResult <PageFile>();

            try
            {
                this._ctx.PageFiles.InsertOnSubmit(entity);

                this._ctx.SubmitChanges();

                return(new InvokeResult <PageFile> {
                    Status = Status.Successful, Value = entity
                });
            }
            catch (Exception ex)
            {
                result.Status  = Status.Failed;
                result.Message = ex.Message;
            }
            result.Value = entity;
            return(result);
        }
Exemplo n.º 7
0
        private async void mainImage_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
        {
            if (Math.Abs(e.Velocities.Linear.X) > .1 || Math.Abs(e.Velocities.Linear.Y) > .1)
            {
                PagePicture lpCurrent = (PagePicture)mainImage.Items[0];
                PageFile    lpfFile   = null;
                if (lpCurrent != null)
                {
                    var step        = StepSize.small;
                    var directionUp = true;

                    if (Math.Abs(e.Velocities.Linear.X) > Math.Abs(e.Velocities.Linear.Y))
                    {
                        directionUp = (e.Velocities.Linear.X < 0);
                        if (Math.Abs(e.Velocities.Linear.X) > 2)
                        {
                            step = StepSize.large;
                        }
                    }
                    else
                    {
                        directionUp = (e.Velocities.Linear.Y < 0);
                        if (Math.Abs(e.Velocities.Linear.Y) > 2)
                        {
                            step = StepSize.series;
                        }
                        else
                        {
                            step = StepSize.seriesTag;
                        }
                    }

                    if (directionUp)
                    {
                        lpfFile = lpCurrent.StepNext(step);
                    }
                    else
                    {
                        lpfFile = lpCurrent.StepPrevious(step);
                    }

                    if (lpfFile != null)
                    {
                        await LibraryView.PictureImageLoad(lpfFile, mainImage);

                        LibraryView.onPictureChanged(sender, new OnPictureChangedArgs(lpfFile, "grid"));
                    }
                    else
                    {
                        e.Handled = false;
                    }
                }
            }
        }
Exemplo n.º 8
0
        // TODO: Refactor
        private static void GetAndDisplayProcessInformation(ManagementScope scope, bool displayProcessesAsGroup, bool showStats)
        {
            // TODO: Keep?
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            // Get console dimensions
            int height = Console.WindowHeight;
            int width  = Console.WindowWidth;

            // Get data from WMI
            Memory   memory   = new Memory(scope);
            PageFile pageFile = new PageFile(scope);

            // Write information gathered so far to the console
            Console.SetCursorPosition(0, 0);
            Processor.WriteToConsole(scope, 1, memory.NumOfProcesses);
            memory.WriteToConsole(2);
            pageFile.WriteToConsole(memory.LastBootTime, 3);
            Console.WriteLine();

            // Get process data from WMI
            Process process = new Process(scope);

            // Write process information to the console
            if (displayProcessesAsGroup)
            {
                process.WriteToConsoleAsGroups(height, width);
            }
            else
            {
                process.WriteToConsoleAsList(height, width);
            }

            // Show usage hints
            Helper.ShowUsageHints(height, width);

            // Show statistics
            if (showStats)
            {
                Console.SetCursorPosition(2, height - 1);
                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.Write($"{stopwatch.ElapsedMilliseconds.ToString()} ms | X: {width} | Y: {height}");
                Console.ForegroundColor = ConsoleColor.Gray;
            }
            else
            {
                Console.SetCursorPosition(2, height - 1);
                Console.Write($"                             ");
            }
        }
Exemplo n.º 9
0
        private static async Task <PagePicture> LoadFile(PageFile aPic, double dScrnHeight, double dScrnWidth)
        {
            PagePicture lPic      = new PagePicture(aPic, dScrnHeight, dScrnWidth);
            string      sFileName = lPic.FullName;

            if (lPic.BMImage == null)
            {
                StorageFile sampleFile = await StorageFile.GetFileFromPathAsync(sFileName);

                lPic.BMImage = await LoadImage(sampleFile);
            }
            return(lPic);
        }
Exemplo n.º 10
0
        public PageFile StepNext(StepSize step)
        {
            if (this.Next == null)
            {
                return(null);
            }

            PageFile lpfFile = this.PictureFile;

            switch (step)
            {
            case StepSize.small:
                lpfFile = lpfFile.Next;
                break;

            case StepSize.large:
                for (int i = 0; i < 10 && lpfFile.Next != null && lpfFile.Series.Equals(this.Series) && lpfFile.SeriesNumberTag.Equals(this.SeriesNumberTag); i++)
                {
                    lpfFile = lpfFile.Next;
                }
                break;

            case StepSize.seriesTag:
                if (lpfFile.Book.Next == null)
                {
                    return(null);
                }

                lpfFile = lpfFile.Book.Next.First;
                for (int i = 0; lpfFile.Next != null && lpfFile.Series.Equals(this.Series) && lpfFile.SeriesNumberTag.Equals(this.SeriesNumberTag); i++)
                {
                    lpfFile = lpfFile.Next;
                }
                break;

            case StepSize.series:
                for (int i = 0; lpfFile.Next != null && lpfFile.Series.Equals(this.Series); i++)
                {
                    lpfFile = lpfFile.Next;
                }
                break;
            }

            return(lpfFile);
        }
Exemplo n.º 11
0
        async void OnOrientationChanged(DisplayInformation sender, object args)
        {
            //scrollView.Height = this.Height;
            //scrollView.Width = this.Width;

            if (mainImage.Items.Count > 0)
            {
                PageFile lpfFile = ((PagePicture)mainImage.Items[0]).PictureFile;

                mainImage.Items.Clear();

                if (lpfFile != null)
                {
                    await LibraryView.PictureImageLoad(lpfFile, mainImage);

                    LibraryView.onPictureChanged(sender, new OnPictureChangedArgs(lpfFile, "grid"));
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public InvokeResult <PageFile> Update(PageFile entity)
        {
            InvokeResult <PageFile> result = new InvokeResult <PageFile>();

            try
            {
                this._ctx.SubmitChanges();
                result.Status = Status.Successful;
            }
            catch (Exception ex)
            {
                result.Status  = Status.Failed;
                result.Message = ex.Message;
            }

            result.Value = entity;

            return(result);
        }
Exemplo n.º 13
0
        public static async Task PictureImageLoad(PageFile asPic, ItemsControl agvImages)
        {
            double           dScrnHeight = 0, dScrnWidth = 0;
            FrameworkElement dSizeFind = agvImages.Parent as FrameworkElement;

            while (dSizeFind as Page == null && dSizeFind.Parent != null)
            {
                dSizeFind = dSizeFind.Parent as FrameworkElement;
            }
            if (dSizeFind as Page != null)
            {
                dScrnHeight = dSizeFind.ActualHeight;
                dScrnWidth  = dSizeFind.ActualWidth;

                if (DisplayInformation.GetForCurrentView().CurrentOrientation == DisplayOrientations.Landscape ||
                    DisplayInformation.GetForCurrentView().CurrentOrientation == DisplayOrientations.LandscapeFlipped)
                {
                    if (dScrnHeight > dScrnWidth)
                    {
                        double dSwap = dScrnWidth;
                        dScrnWidth  = dScrnHeight;
                        dScrnHeight = dSwap;
                    }
                }
                else if (dScrnHeight < dScrnWidth)
                {
                    double dSwap = dScrnWidth;
                    dScrnWidth  = dScrnHeight;
                    dScrnHeight = dSwap;
                }
            }

            PagePicture lPic = await LoadFile(asPic, dScrnHeight, dScrnWidth);

            agvImages.Items.Clear();
            agvImages.Items.Add(lPic);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Database"/> class.
 /// </summary>
 public Database()
 {
     pageFile = new PageFile();
 }
Exemplo n.º 15
0
        /// <summary>
        /// 批量复制分项资料库图文档,作为任务书附件(没有历史版本)
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="pageId"></param>
        /// <param name="arrId"></param>
        /// <returns></returns>
        public InvokeResult <List <int> > BatchCopyProjectDoc(int userId, int pageId, int[] arrId, List <string> thumbsImages)
        {
            InvokeResult <List <int> > res = new InvokeResult <List <int> >();
            List <int> retIds = new List <int>();

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    StringBuilder thumbStr = new StringBuilder();

                    //thumbStr.Append("<root>");

                    foreach (int fileId in arrId)
                    {
                        var oldFile = this._ctx.FileLibraries.FirstOrDefault(r => r.fileId == fileId);
                        if (oldFile != null)
                        {
                            #region  制文件信息
                            FileLibrary fileLib = new FileLibrary
                            {
                                createData   = DateTime.Now,
                                createUserId = userId,
                                name         = oldFile.name,
                                ext          = oldFile.ext,
                                sysObjId     = 3,//已定义好的系统对象
                                localPath    = oldFile.localPath,
                                tags         = string.Empty,
                                lastVersion  = 1,
                                size         = oldFile.size,
                                hash         = oldFile.hash
                            };

                            _ctx.FileLibraries.InsertOnSubmit(fileLib);
                            _ctx.SubmitChanges();
                            #endregion

                            #region  制版本信息
                            FileLibVersion version = new FileLibVersion()
                            {
                                fileId       = fileLib.fileId,
                                fileName     = fileLib.name,
                                localPath    = fileLib.localPath,
                                createData   = DateTime.Now,
                                createUserId = fileLib.createUserId,
                                fileVersion  = 1,
                                ext          = fileLib.ext,
                                hash         = fileLib.hash
                            };
                            this._ctx.FileLibVersions.InsertOnSubmit(version);
                            this._ctx.SubmitChanges();
                            #endregion

                            #region 添加关联信息
                            PageFile pageFile = new PageFile()
                            {
                                pageId       = pageId,
                                fileId       = fileLib.fileId,
                                fileType     = 1,
                                bizFileLibId = oldFile.fileId
                            };

                            this._ctx.PageFiles.InsertOnSubmit(pageFile);
                            this._ctx.SubmitChanges();
                            #endregion
                            #region 拷贝文件
                            string appPath     = AppDomain.CurrentDomain.BaseDirectory;
                            string filePath    = CommonBll.GetSysObjDir(oldFile.sysObjId.Value.ToString(), oldFile.sysObjId.Value, oldFile.createData);
                            string oldFileName = CommonBll.GetSysObjDocImg(oldFile.fileId, oldFile.hash, oldFile.lastVersion, "m");

                            string descPath     = CommonBll.GetSysObjDir(fileLib.sysObjId.Value.ToString(), fileLib.sysObjId.Value, fileLib.createData);
                            string descPhyPath  = FileExtension.CreateFolder(string.Format("{0}{1}", appPath, descPath));
                            string descFileName = CommonBll.GetSysObjDocImg(fileLib.fileId, fileLib.hash, fileLib.lastVersion, "m");
                            foreach (var s in thumbsImages)
                            {
                                string sourcePhyFileName = string.Format("{0}{1}{2}", appPath, filePath, oldFileName.Replace("_m.", "_" + s + "."));
                                string descPhyFileName   = string.Format("{0}{1}", descPhyPath, descFileName.Replace("_m.", "_" + s + "."));
                                if (File.Exists(sourcePhyFileName) == true)
                                {
                                    File.Copy(sourcePhyFileName, descPhyFileName);
                                }
                            }
                            #endregion
                            retIds.Add(fileLib.fileId);

                            //thumbStr.AppendFormat("<file hash=\"{0}\" size=\"{1}\" param=\"sysObject@{2}-{3}\"  />", fileLib.hash, fileLib.size, fileLib.fileId, version.verId);
                        }
                    }
                    //thumbStr.Append("</root>");

                    trans.Complete();
                    res.Status  = Status.Successful;
                    res.Message = thumbStr.ToString();
                    res.Value   = retIds;
                }
            }
            catch (Exception ex)
            {
                res.Message = ex.Message;
                res.Status  = Status.Failed;
            }

            return(res);
        }
Exemplo n.º 16
0
 public void BindModel(PageFile pf)
 {
     txtReplacement.Text   = pf.Replacement;
     txtReplaceResult.Text = pf.ReplacementResult;
     cbAllowEmpty.Checked  = pf.AllowEmptyReplacement;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Asynchronously update the <see cref="PageFile" /> in the system.
 /// </summary>
 /// <param name="pageFile">Resource instance.</param>
 /// <returns>True if <see cref="PageFile" /> is successfully updated, false otherwise.</returns>
 public virtual Task <bool> UpdateAsync(PageFile pageFile)
 {
     return(UpdateAsync <PageFile>(pageFile));
 }
Exemplo n.º 18
0
        /// <summary>
        /// 批量上传
        /// </summary>
        /// <param name="supplierId"></param>
        /// <param name="filePath"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public InvokeResult <string> BatchUpload(int pageId, List <string> filePath, int userId)
        {
            InvokeResult <string> result = new InvokeResult <string>();

            try
            {
                List <FileParam> fileParams = new List <FileParam>();

                using (TransactionScope trans = new TransactionScope())
                {
                    foreach (var file in filePath)
                    {
                        #region 附件及版本
                        FileLibrary fileLib = new FileLibrary
                        {
                            createData   = DateTime.Now,
                            createUserId = userId,
                            name         = System.IO.Path.GetFileNameWithoutExtension(file),
                            ext          = System.IO.Path.GetExtension(file),
                            sysObjId     = 3,//已定义好的系统对象
                            localPath    = file,
                            tags         = string.Empty,
                            lastVersion  = 1
                        };


                        _ctx.FileLibraries.InsertOnSubmit(fileLib);
                        _ctx.SubmitChanges();
                        FileLibVersion version = new FileLibVersion()
                        {
                            fileId       = fileLib.fileId,
                            fileName     = fileLib.name,
                            localPath    = fileLib.localPath,
                            createData   = DateTime.Now,
                            createUserId = fileLib.createUserId,
                            fileVersion  = 1,
                            ext          = fileLib.ext
                        };
                        this._ctx.FileLibVersions.InsertOnSubmit(version);
                        this._ctx.SubmitChanges();

                        #endregion

                        //添加关联
                        PageFile pageFile = new PageFile()
                        {
                            pageId   = pageId,
                            fileId   = fileLib.fileId,
                            fileType = 1
                        };

                        this._ctx.PageFiles.InsertOnSubmit(pageFile);
                        this._ctx.SubmitChanges();

                        //生成参数
                        FileParam fp = new FileParam();
                        fp.docId       = fileLib.fileId;
                        fp.lastVersion = version.fileVersion;
                        fp.path        = fileLib.localPath;
                        fp.ext         = fileLib.ext;
                        fp.strParam    = "sysObject@" + fileLib.fileId + "-" + version.verId;

                        fileParams.Add(fp);
                    }

                    trans.Complete();

                    System.Web.Script.Serialization.JavaScriptSerializer script = new System.Web.Script.Serialization.JavaScriptSerializer();
                    string strJson = script.Serialize(fileParams);
                    result.Value = strJson;
                }
            }
            catch (Exception ex)
            {
                result.Status  = Status.Failed;
                result.Message = ex.Message;
            }

            return(result);
        }
Exemplo n.º 19
0
 public void BindModel(PageFile pf)
 {
 }
Exemplo n.º 20
0
 /// <summary>
 /// Asynchronously insert the <see cref="PageFile" /> into the system.
 /// </summary>
 /// <param name="pageFile">Resource instance.</param>
 /// <returns>Newly created <see cref="PageFile" /> .</returns>
 public virtual Task <PageFile> InsertAsync(PageFile pageFile)
 {
     return(InsertAsync <PageFile>(pageFile));
 }
Exemplo n.º 21
0
        async void gridView_Tapped(object sender, TappedRoutedEventArgs e)
        {
            {
                PagePicture lpCurrent = (PagePicture)mainImage.Items[0];
                PageFile    lpfFile   = null;
                var         up        = false;

                if (lpCurrent != null)
                {
                    var position = e.GetPosition(mainImage);
                    var height3  = mainImage.ActualHeight / 3;
                    var width2   = mainImage.ActualWidth / 2;
                    var stepSize = StepSize.small;

                    if (position.X < 50 || position.X > mainImage.ActualWidth - 75)
                    {
                        up = position.X > mainImage.ActualWidth - 75;
                        if (position.Y < height3)
                        {
                            stepSize = StepSize.small;
                        }
                        else if (position.Y < 2 * height3)
                        {
                            stepSize = StepSize.large;
                        }
                        else
                        {
                            stepSize = StepSize.seriesTag;
                        }
                    }
                    else if (position.Y < 50 || position.Y > mainImage.ActualHeight - 75)
                    {
                        up       = position.Y > mainImage.ActualHeight - 75;
                        stepSize = StepSize.series;
                    }
                    else
                    {
                        e.Handled = false;
                        return;
                    }

                    if (up)
                    {
                        lpfFile = lpCurrent.StepNext(stepSize);
                    }
                    else
                    {
                        lpfFile = lpCurrent.StepPrevious(stepSize);
                    }

                    if (lpfFile != null)
                    {
                        await LibraryView.PictureImageLoad(lpfFile, mainImage);

                        LibraryView.onPictureChanged(sender, new OnPictureChangedArgs(lpfFile, "grid"));
                    }
                    else
                    {
                        e.Handled = false;
                    }
                }
            }
        }
Exemplo n.º 22
0
 public void BindModel(PageFile pf)
 {
     this.matchResult1.BindModel(pf);
     replacePage1.BindModel(pf);
     templatePage1.BindModel(pf);
 }
Exemplo n.º 23
0
 public void BindModel(PageFile pf)
 {
     txtPathOrUrl.Text = pf.FileOrUrl;
     cbEncoding.Text   = pf.EncodingName;
 }
Exemplo n.º 24
0
 public PageFileManager(string path, long size)
 {
     pageFile = new PageFile(path, size);
 }
Exemplo n.º 25
0
 public void BindModel(PageFile pf)
 {
     this.txtTemplate.Text       = pf.Template;
     this.txtTemplateResult.Text = pf.TemplateResult;
 }
Exemplo n.º 26
0
 public void BindModel(PageFile pf)
 {
     bodyLeft.BindModel(pf);
     bodyRight.BindModel(pf);
 }
Exemplo n.º 27
0
 public void BindModel(PageFile pf)
 {
     txtInput.Text = pf.SourceText;
     sourceBar1.BindModel(pf);
 }
Exemplo n.º 28
0
 public void Open(Uri uri, XmlReaderSettings settings, XmlSpace space, CancellationToken token)
 {
     bool large = false;
     if (uri.Scheme == "file")
     {
         FileInfo fi = new FileInfo(uri.LocalPath);
         if (fi.Exists && fi.Length > XQueryLimits.LargeFileLength)
             large = true;
     }
     pagefile = new PageFile(large);
     input = XmlReader.Create(uri.AbsoluteUri, settings);
     nameTable = input.NameTable;
     builder = new XQueryDocumentBuilder(this);
     builder.SchemaInfo = input.SchemaInfo;
     pagefile.HasSchemaInfo = (input.SchemaInfo != null);
     baseUri = input.BaseURI;
     preserveSpace = (space == XmlSpace.Preserve);
     this.token = token;
 }
Exemplo n.º 29
0
 public OnPictureChangedArgs(PageFile pagefile, string type)
 {
     File     = pagefile;
     FileType = type;
 }