/// <summary>
    /// 保存されている再生オプションをロードする
    /// </summary>
    public void TickStateLoad()
    {
        JFile _File;

        _File = JFile.CreateBinary(_PatternTickRelatedFileName, true);
        if (_File != null)
        {
            try
            {
                var reader = _File._binaryReader;
                _NormalStatePatternTick = reader.ReadSingle();
                _PatternTickRate        = reader.ReadSingle();
                _File.Close();
            }
            catch //(Exception e)
            {
                _File.Close();
                File.Delete(_PatternTickRelatedFileName);
            }
        }
        else
        {
            //デフォルトでは、ファイルを一つにしてくれる
            TickStateSave();
        }
    }
Exemple #2
0
        /// <summary>
        /// بروزرسانی آرشیو بر اساس محتوای جدید
        /// </summary>
        /// <param name="pFile">محتوای جدید</param>
        /// <param name="pCode">کد آرشیو</param>
        /// <param name="pUserCode">کد کاربر ارسال کننده</param>
        /// <param name="pDesc">شرح آرشیو</param>
        /// <param name="pDeleteOdlContent">حذف محتویات قبلی</param>
        /// <returns>یک یا صفر برمیگرداند</returns>
        public int UpdateArchive(JFile pFile, int pCode, string pDesc, bool pDeleteOdlContent)
        {
            _GetData(pCode);
            /// محتوای جدید درج میشود
            int newArchiveCode = _ArchiveContent(pFile, this.ArchiveCode);
            int newCode        = 0;

            if (newArchiveCode > 0)
            {
                newCode = _UpdateArchive(pCode, newArchiveCode, JMainFrame.CurrentUserCode, pDesc);
                /// در صورتی که بروزرسانی انجام نشد، محتوای درج شده حذف میشود
                if (newCode <= 0)
                {
                    _DeleteContent(newArchiveCode);
                    return(0);
                }
                _AutoChangeArchive(this.ArchiveCode, newArchiveCode);
                _DeleteContent(this.ArchiveCode, false);                //// <------pDeleteOdlContent  /// از محتوا چیزی حذف نمیشود
                /// 1 یا 0 برمیگرداند
                return(newCode);
            }
            else
            {
                return(0);
            }
        }
Exemple #3
0
        private void OpenFromDialog()
        {
            if (IDEWindow.Instance.ViewModel.CurrentProject is null)
            {
                string path = this.CommonFileDialog();
                if (path is null)
                {
                    return;
                }
                ProjectFile file = JFile.Load <ProjectFile>(Path.GetDirectoryName(path), "project.json");
                IDEWindow.Instance.ViewModel.CurrentProject = file.CreateModel();
                App.Metadata.RecentlyOpenedProjects.Add(new RecentItem {
                    Name = IDEWindow.Instance.ViewModel.CurrentProject.Name, Path = IDEWindow.Instance.ViewModel.CurrentProject.FilePath
                });
                IDEWindow.Instance.ViewModel.CurrentProject.LoadMods();
                App.Metadata.Save();
            }
            else
            {
                MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show($"Changes have been made to {IDEWindow.Instance.ViewModel.CurrentProject.Name}. Would you like to save these changes before closing the project?", "Save Changes?", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning);
                if (result == MessageBoxResult.Yes)
                {
                    string path = this.CommonFileDialog();
                    if (path is null)
                    {
                        return;
                    }

                    IDEWindow.Instance.ViewModel.CurrentProject.Close(true);
                    ProjectFile file = JFile.Load <ProjectFile>(Path.GetDirectoryName(path), "project.json");
                    IDEWindow.Instance.ViewModel.CurrentProject = file.CreateModel();
                    App.Metadata.RecentlyOpenedProjects.Add(new RecentItem {
                        Name = IDEWindow.Instance.ViewModel.CurrentProject.Name, Path = IDEWindow.Instance.ViewModel.CurrentProject.FilePath
                    });
                    IDEWindow.Instance.ViewModel.CurrentProject.LoadMods();
                    App.Metadata.Save();
                }
                else if (result == MessageBoxResult.No)
                {
                    string path = this.CommonFileDialog();
                    if (path is null)
                    {
                        return;
                    }

                    IDEWindow.Instance.ViewModel.CurrentProject.Close(false);
                    ProjectFile file = JFile.Load <ProjectFile>(Path.GetDirectoryName(path), "project.json");
                    IDEWindow.Instance.ViewModel.CurrentProject = file.CreateModel();
                    App.Metadata.RecentlyOpenedProjects.Add(new RecentItem {
                        Name = IDEWindow.Instance.ViewModel.CurrentProject.Name, Path = IDEWindow.Instance.ViewModel.CurrentProject.FilePath
                    });
                    IDEWindow.Instance.ViewModel.CurrentProject.LoadMods();
                    App.Metadata.Save();
                }
                else
                {
                    return;
                }
            }
        }
Exemple #4
0
        private void btnGetWebCam_Click(object sender, EventArgs e)
        {
            ClassLibrary.WebCam.GetWebCam FWeb = new ClassLibrary.WebCam.GetWebCam();
            FWeb.ShowDialog();
            if (FWeb.current != null)
            {
                Image img = Image.FromHbitmap(FWeb.current.GetHbitmap());
                img.Save(System.IO.Path.GetTempPath() + "\\webcam.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

                JFile _file = new JFile();
                _file.FileName = System.IO.Path.GetTempPath() + "\\webcam.jpg";
                DataRow row = _DataTable.NewRow();
                row[JArchiveFields.ArchiveDate.ToString()] = ClassLibrary.JDateTime.Now();
                row[JArchiveFields.ArchiveDesc.ToString()] = "";
                row[JArchiveFields.Action.ToString()]      = FileActions.Insert;
                row[JArchiveFields.JFile.ToString()]       = _file;
                _DataTable.Rows.Add(row);

                if (_file.Extension.ToLower() == ".jpg" && _file.Content != null)
                {
                    CreateThumbLine(_file, row);
                }
                FWeb.current.Dispose();
                FWeb.current = null;
            }
        }
Exemple #5
0
 private void mnuImages_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     //if (this.ObjectCode == 0 || this.ClassName == null)
     //    return;
     //if (this.Description == null)
     //    this.Description = "";
     /// تصویر جدید
     if (e.ClickedItem == newItem)
     {
         if (OnAddFile != null)
         {
             OnAddFile(sender, e);
         }
         //JArchiveDocument archive = new JArchiveDocument(SubjectCode, PlaceCode);
         JImageForm image = new JImageForm();
         if (image.ShowDialog() == DialogResult.OK)
         {
             //this.ArchiveCode = archive.ArchiveDocument(image.SelectedFile, this.ClassName, this.ObjectCode, this.Description, this.AutoChange);
             //if (this.ArchiveCode > 0)
             {
                 this.Image     = image.SelectedImage;
                 this.ImageFile = image.SelectedFile;
                 this.State     = JFormState.Insert;
                 if (AfterFileAdded != null)
                 {
                     AfterFileAdded(sender, e);
                 }
             }
         }
         //JMessages.Information(this.ArchiveCode.ToString(), "");
     }
     /// ویرایش تصویر
     if (e.ClickedItem == editMenuItem)
     {
         //JArchiveDocument archive = new JArchiveDocument(SubjectCode, PlaceCode);
         JImageForm image = new JImageForm();
         if (image.ShowDialog() == DialogResult.OK)
         {
             //archive.UpdateArchive(image.SelectedFile, this.ArchiveCode, this.Description, DeleteCompeletly);
             //if (this.ArchiveCode > 0)
             {
                 Changed        = true;
                 this.Image     = image.SelectedImage;
                 this.ImageFile = image.SelectedFile;
                 this.State     = JFormState.Update;
             }
         }
     }
     /// حذف تصویر
     if (e.ClickedItem == deleteImageItem)
     {
         if (JMessages.Question("YouWantToDeletePicture?", "Question") == DialogResult.Yes)
         {
             //JArchiveDocument archive = new JArchiveDocument(SubjectCode, PlaceCode);
             //if (archive.DeleteArchive(this.ArchiveCode, DeleteCompeletly))
             this.Image = null;
             this.State = JFormState.Delete;
         }
     }
 }
Exemple #6
0
        /// <summary>
        /// بازیابی لیست آرشیوها
        /// </summary>
        /// <returns></returns>
        public bool LoadDataFromArchive()
        {
            JArchiveDocument archive = new JArchiveDocument(SubjectCode, PlaceCode);

            try
            {
                if (ClassName == null)
                {
                    ClassName = "";
                }
                archive.GetData(_ArchiveCode);
                JFile image = archive.RetrieveContent(archive.ArchiveCode);
                if (image == null)
                {
                    return(false);
                }
                ClassName  = archive.ClassName;
                ObjectCode = archive.ObjectCode;
                this.Image = System.Drawing.Image.FromStream(image.Stream);
                object tObject = this.Image;
                JSystem.AddObject(ref tObject);

                return(true);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(false);
            }
            finally
            {
                archive.Dispose();
            }
        }
        /// <summary>
        /// Creates a set of directories based on a treenode information.
        /// </summary>
        /// <param name="parentDirectory">Parent directory.</param>
        /// <param name="treeNode">Tree node to map.</param>
        public static void CreateDirectories(JDirectory parentDirectory, JStoreFileTreeNode treeNode)
        {
            //List<FileListViewItem> fileItems;
            JFile      file;
            JDirectory childDirectory;
            List <JSoreFileItemInfo> fileItems = treeNode.Tag;

            // Create the files of the directory
            //fileItems = (List<FileListViewItem>)treeNode.Tag;
            foreach (JSoreFileItemInfo fileItem in fileItems)
            {
                file          = new JFile(fileItem.fileName);
                file.Filters  = fileItem.Filters;
                file.FileInfo = fileItem.Info;

                parentDirectory.AddFile(file);
            }

            // Create the subdirectories
            foreach (JStoreFileTreeNode node in treeNode.Nodes)
            {
                childDirectory = new JDirectory(node.DirName);
                parentDirectory.AddDirectory(childDirectory);

                CreateDirectories(childDirectory, node);
            }
        }
        void ExportType(ITypeDefinition ce, JFile jsFile)
        {
            var unit  = ExportType(ce);
            var unit2 = new JCompilationUnit {
                PackageName = ce.GetPackageName(), Declarations = { unit }
            };

            jsFile.Units.Add(unit2);//[0].Statements.AddRange(unit2);
        }
Exemple #9
0
        /// <summary>
        /// درج محتوای فایل
        /// </summary>
        /// <param name="pFile">فایل</param>
        /// <param name="pParentCode">کد سند قبلی برای اسنادی که بروز میشوند</param>
        /// <returns>کد سند آرشیو شده را برمیگرداند</returns>
        private int _ArchiveContent(JFile pFile, int pParentCode)
        {
            ///  بررسی سایز فایل
            if (pFile.Content != null && pFile.Size / 1024 > FileSizeLimit)
            {
                JMessages.Error("FileIsTooLarg", "Error");
                return(0);
            }

            /// بررسی وجود فایل در آرشیو
            bool deleted = false;
            int  repeat  = SearchFile(pFile, ref deleted);

            if (repeat > 0)
            {
                /// در صورتی که فایل وجود دارد ولی حذف شده، آنرا از حالت حذف خارج میکند
                if (deleted)
                {
                    _UnDeleteContent(repeat);
                }
                return(repeat);
            }


            JDataBase db = this._Database;

            try
            {
                string InsertSQL =
                    @"DECLARE @Code INT " +
                    JDataBase.GetInsertSQL(JTableNameArchive.ContentTable, "0", false) +

                    @"INSERT INTO " + JTableNameArchive.ContentTable +
                    @"(Code, FileType , FileExtension, Contents, Size, Status, ParentCode, ArchiveDate, LastAccess, FileText) VALUES
                        (@Code, @FileType , @FileExtension, @Contents, @Size, @Status, @ParentCode, GetDate(), GetDate(), @FileText ) 
                        SELECT @Code";
                db.setQuery(InsertSQL);
                db.Params.Clear();
                db.AddParams("FileType", pFile.FileType.GetHashCode());
                db.AddParams("FileExtension", pFile.Extension);
                db.AddParams("Contents", pFile.Content);
                db.AddParams("Size", pFile.Size);
                db.AddParams("ParentCode", pParentCode);
                db.AddParams("Status", 1);
                db.AddParams("FileText", pFile.FileText);
                int ContentCode = Convert.ToInt32(db.Query_ExecutSacler());
                return(ContentCode);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(0);
            }
            finally
            {
            }
        }
Exemple #10
0
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            if (OnAddFile != null)
            {
                OnAddFile(sender, e);
            }
            if (this.ClassName == null)
            {
                return;
            }
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                foreach (string _FileName in openFileDialog1.FileNames)
                {
                    JFile file = new JFile();
                    file.FileName   = _FileName;
                    file.FileSource = JFile.JFileSource.FromDisk;

                    if (_DataTable == null)
                    {
                        _LoadDataFromArchive();
                    }
                    DataRow row = _DataTable.NewRow();
                    row[JArchiveFields.ArchiveDate.ToString()] = ClassLibrary.JDateTime.Now();
                    row[JArchiveFields.ArchiveDesc.ToString()] = "";
                    row[JArchiveFields.Action.ToString()]      = FileActions.Insert;
                    row[JArchiveFields.JFile.ToString()]       = file;
                    _DataTable.Rows.Add(row);

                    try
                    {
                        if (file.Extension.ToLower() == ".jpg")
                        {
                            CreateThumbLine(file, row);
                        }
                    }
                    catch
                    {
                    }
                }
            }

            if (AfterFileAdded != null)
            {
                AfterFileAdded(sender, e);
            }

            //if (this.ObjectCode == 0 || this.ClassName == null)
            //    return;
            //if (openFileDialog1.ShowDialog() == DialogResult.OK)
            //{
            //    JFile file = new JFile();
            //    file.FileName = openFileDialog1.FileName;
            //    file.FileSource = JFile.JFileSource.FromDisk;
            //    _ArchiveFile(file);
            //}
        }
Exemple #11
0
 public void LoadMods()
 {
     foreach (string x in Directory.GetDirectories(Path.Combine(this.FilePath, "mods")))
     {
         MetadataFile metadataFile = JFile.Load <MetadataFile>(x, ".metadata");
         Mod          mod          = metadataFile.CreateModel();
         this.Mods.Add(mod);
     }
 }
 public static HFile ToHFile(this JFile jFile)
 {
     return(new HFile
     {
         Name = jFile.Name,
         Size = jFile.Size,
         Hash = jFile.Hash,
         LastModifiedTime = jFile.LastModifiedTime
     });
 }
Exemple #13
0
        private void AppStartup(object sender, StartupEventArgs args)
        {
            Instance = this;

            Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly());

            Metadata = JFile.Load <UserMetaFile>(AssemblyDirectory, "metadata.json").CreateModel();

            bool?_ = new Splash().ShowDialog();
        }
Exemple #14
0
        /// <exception cref="Org.Apache.Hadoop.Record.Compiler.Generated.ParseException"/>
        public JFile Include()
        {
            string fname;
            Token  t;

            Jj_consume_token(IncludeTkn);
            t = Jj_consume_token(CstringTkn);
            JFile ret = null;

            fname = t.image.ReplaceAll("^\"", string.Empty).ReplaceAll("\"$", string.Empty);
            FilePath file    = new FilePath(curDir, fname);
            string   tmpDir  = curDir;
            string   tmpFile = curFileName;

            curDir      = file.GetParent();
            curFileName = file.GetName();
            try
            {
                FileReader reader = new FileReader(file);
                Org.Apache.Hadoop.Record.Compiler.Generated.Rcc parser = new Org.Apache.Hadoop.Record.Compiler.Generated.Rcc
                                                                             (reader);
                try
                {
                    ret = parser.Input();
                    System.Console.Out.WriteLine(fname + " Parsed Successfully");
                }
                catch (ParseException e)
                {
                    System.Console.Out.WriteLine(e.ToString());
                    System.Environment.Exit(1);
                }
                try
                {
                    reader.Close();
                }
                catch (IOException)
                {
                }
            }
            catch (FileNotFoundException)
            {
                System.Console.Out.WriteLine("File " + fname + " Not found.");
                System.Environment.Exit(1);
            }
            curDir      = tmpDir;
            curFileName = tmpFile;
            {
                if (true)
                {
                    return(ret);
                }
            }
            throw new Error("Missing return statement in function");
        }
Exemple #15
0
        private static void InitializePreferences()
        {
            if (!Directory.Exists(Metadata.AppDataDirectory))
            {
                Directory.CreateDirectory(Metadata.AppDataDirectory);
            }

            Preferences = JFile.Load <PreferencesFile>(Metadata.AppDataDirectory, "preferences.json").CreateModel();
            Preferences.Save();
            Preferences.Load();
        }
Exemple #16
0
        /// <summary>
        /// Gets a stream to read a <see cref="JFile"/> contents
        /// </summary>
        /// <remarks>
        /// The stream can be a <see cref="JVirtualFileStream"/> if no
        /// filters are used or a <see cref="System.IO.MemoryStream"/> if they are
        /// </remarks>
        /// <param name="file">File to read the contents</param>
        /// <returns>A stream to read the file</returns>
        private Stream GetStream(JFile file)
        {
            JVirtualFileStream baseStream;

            if (file == null)
            {
                return(null);
            }

            baseStream = new JVirtualFileStream(_storageFileStream, file.Offset, file.Length);
            return(file.ApplyFiltersForRead(baseStream));
        }
Exemple #17
0
        /// <summary>
        /// جستجوی یک فایل در آرشیو بر اساس سایز، پسوند و محتوای فایل -
        /// در صورتی که فایل حذف شده پارامتر خروجی ترو میشود Deleted
        /// </summary>
        /// <param name="pFile">فایل ورودی</param>
        /// <returns>کد فایل آرشیو شده را برمیگرداند</returns>
        public int SearchFile(JFile pFile, ref bool Deleted)
        {
            return(0);

            JDataBase DB = this._Database;

            if (pFile.Content == null)
            {
                return(0);
            }
            DB.setQuery("SELECT Code,Status FROM " + JTableNameArchive.ContentTable + " WHERE Size=" + pFile.Size +
                        " AND FileExtension=" + JDataBase.Quote(pFile.Extension) + " AND Contents=@Content");
            try
            {
                DB.Params.Clear();
                DB.AddParams("Content", pFile.Content);
                DB.Query_DataSet();
                if (DB.DataSet.Tables[0].Rows.Count == 0)
                {
                    return(0);
                }
                /// در صورتی که فایل حذف (منطقی) شده
                if ((int)DB.DataSet.Tables[0].Rows[0]["Status"] == 0)
                {
                    Deleted = true;
                }
                else
                {
                    Deleted = false;
                }

                object result = DB.DataSet.Tables[0].Rows[0]["Code"];
                if (result == null)
                {
                    return(0);
                }
                else
                {
                    return(Convert.ToInt32(result));
                }
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(0);
            }
        }
Exemple #18
0
    /// <summary>
    /// 最後に接続した機器の情報を保存
    /// </summary>
    private void DataSave()
    {
        //すべてのデータを一度に保存する
        JFile _File;

        _File = JFile.CreateBinary(_FileName, false);
        if (_File == null)
        {
        }
        else
        {
            var writer = _File._binaryWriter;
            writer.Write(_LastAccessAddress);
            writer.Write(_LastAccessDeviceName);

            _File.Close();
        }
    }
Exemple #19
0
        private void SetPreviewImage(JFile pContent)
        {
            try
            {
                Image  image   = System.Drawing.Image.FromStream(pContent.Stream);
                object tObject = image;
                JSystem.AddObject(ref tObject);

                pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
                pictureBox2.Height   = image.Height;
                pictureBox2.Width    = image.Width;
                pictureBox2.Image    = image;
            }
            catch
            {
                pictureBox1.Image = null;
            }
        }
Exemple #20
0
    /// <summary>
    /// 最後に接続した機器の情報をロード
    /// </summary>
    private void DataLoad()
    {
        JFile _File;

        _File = JFile.CreateBinary(_FileName, true);
        if (_File != null)
        {
            var reader = _File._binaryReader;
            _LastAccessAddress    = reader.ReadString();
            _LastAccessDeviceName = reader.ReadString();
            _File.Close();
        }
        else
        {
            _LastAccessAddress    = "null";
            _LastAccessDeviceName = "null";
        }
    }
Exemple #21
0
 public void ItemFile_should_be_savable_and_loadable_without_error(ItemFile itemFile)
 {
     "Assume we have a file"
     .Hypothesize(x =>
     {
         itemFile = new ItemFile {
             FilePath = Path.Combine(Testing.AssemblyDirectory, "testfiles"), FileName = "testitem.item"
         };
         itemFile.Category    = "TestCategory";
         itemFile.Description = "Test Description";
         itemFile.ID          = "testitem";
         itemFile.ImageName   = "\testimage.png";
         itemFile.Name        = "Test Item";
         itemFile.Price       = 30;
         itemFile.Rarity      = "Rare";
         itemFile.Tags        = new List <string>()
         {
             "reagent"
         };
         itemFile.UnlocksBlueprint = new List <string> {
             "testitem2", "testitem3"
         };
     });
     "If we save the file"
     .Observe(x =>
     {
         itemFile.Save();
     });
     "Then we should be able to load it with the information intact"
     .Conclude(x =>
     {
         ItemFile loadedFile = JFile.Load <ItemFile>(Path.Combine(Testing.AssemblyDirectory, "testfiles"), "testitem.item");
         itemFile.Category.Should().Be(loadedFile.Category);
         itemFile.Description.Should().Be(loadedFile.Description);
         itemFile.ID.Should().Be(loadedFile.ID);
         itemFile.ImageName.Should().Be(loadedFile.ImageName);
         itemFile.Name.Should().Be(loadedFile.Name);
         itemFile.Price.Should().Be(loadedFile.Price);
         itemFile.Rarity.Should().Be(loadedFile.Rarity);
         itemFile.Tags.Should().Contain(loadedFile.Tags);
         itemFile.UnlocksBlueprint.Should().Contain(loadedFile.UnlocksBlueprint);
     });
 }
    /// <summary>
    /// 現在の再生オプションを保存する
    /// </summary>
    public void TickStateSave()
    {
        //すべてのデータを一度に保存する
        JFile _File;

        _File = JFile.CreateBinary(_PatternTickRelatedFileName, false);
        if (_File == null)
        {
            //例外処理
        }
        else
        {
            var writer = _File._binaryWriter;
            writer.Write(_NormalStatePatternTick);
            writer.Write(_PatternTickRate);

            _File.Close();
        }
    }
Exemple #23
0
        private void CreateThumbLine(JFile pContent, DataRow DR)
        {
            try
            {
                Panel P = new Panel();
                P.BorderStyle = BorderStyle.FixedSingle;
                ThumbLinepanel.Controls.Add(P);
                P.Parent = ThumbLinepanel;
                P.Width  = ThumbLinepanel.Width - 50;
                P.Height = (int)(P.Width * 1.5);
                P.Left   = 25;
                P.Top    = _OldTop + 25;
                _OldTop  = P.Top + P.Height;

                PictureBox PB = new PictureBox();
                P.Controls.Add(PB);
                PB.Parent = P;
                PB.Dock   = DockStyle.Fill;
                Image image;
                if (pContent.Stream != null)
                {
                    image = System.Drawing.Image.FromStream(pContent.Stream);
                    object t1Object = image;
                    JSystem.AddObject(ref t1Object);
                    image.Tag = DR;
                    PB.Tag    = image;
                    Image.GetThumbnailImageAbort ImageAbort = new Image.GetThumbnailImageAbort(ThumbnailCallback);
                    PB.Image = image.GetThumbnailImage(P.Width, P.Height, ImageAbort, IntPtr.Zero);
                    object t2Object = PB.Image;
                    JSystem.AddObject(ref t2Object);
                    PB.Click += new EventHandler(ThumbLineClick);


                    Array.Resize(ref ImagePanelList, ImagePanelList.Length + 1);
                    ImagePanelList[ImagePanelList.Length - 1] = P;
                }
            }
            catch
            {
            }
        }
Exemple #24
0
 /// <summary>
 /// آرشیو سند بر اساس محتوا
 /// </summary>
 /// <param name="pFile">محتوای آرشیو</param>
 /// <param name="pClassName">نام کلاس</param>
 /// <param name="pObjectCode">کد شیء</param>
 /// <param name="pOwner">کاربر ارسال کننده</param>
 /// <param name="pDesc">شرح آرشیو</param>
 /// <param name="pAutoChange">تغییر بصورت خودکار</param>
 /// <returns></returns>
 public int ArchiveDocument(JFile pFile, string pClassName, int pObjectCode, string pDesc, bool pAutoChange)
 {
     try
     {
         if (pClassName.Length == 0 || pObjectCode == 0)
         {
             return(0);
         }
         int ArchiveCode = _ArchiveContent(pFile, 0);
         if (ArchiveCode <= 0)
         {
             return(0);
         }
         return(_Archive(ArchiveCode, pClassName, pObjectCode, pDesc, 1, pAutoChange));
     }
     catch (Exception ex)
     {
         JSystem.Except.AddException(ex);
         return(0);
     }
 }
Exemple #25
0
        public static List <Template> GetTemplates()
        {
            Directory.CreateDirectory(TemplateDirectory);
            List <Template> templates = new List <Template> {
                BlankTemplate, DefaultUITemplate
            };

            foreach (string directory in Directory.GetDirectories(TemplateDirectory))
            {
                Log.Information("Template found: {Directory}. Loading...", Path.GetDirectoryName(directory));
                string templateFile = Path.Combine(directory, "Template.json");
                if (!File.Exists(templateFile))
                {
                    Log.Warning("{Directory} Template could not be loaded. Template.json file is invalid or missing.", Path.GetDirectoryName(directory));
                    continue;
                }
                templates.Add(JFile.Load <TemplateFile>(templateFile).CreateModel());
                Log.Information("Load template {Directory} was successful.", Path.GetDirectoryName(directory));
            }
            Log.Information("Total templates loaded: {Templates}", templates.Count);
            return(templates);
        }
Exemple #26
0
        /// <summary>
        /// آرشیو فایل
        /// </summary>
        /// <param name="pFile"></param>
        /// <returns></returns>
        private bool _ArchiveFile(JFile pFile)
        {
            JArchiveDocument archive = new JArchiveDocument(SubjectCode, PlaceCode, DataBaseClassName, DataBaseObjectCode);

            try
            {
                if (archive.ArchiveDocument(pFile, this.ClassName, this.ObjectCode, "", false) > 0)
                {
                    _LoadDataFromArchive();
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(false);
            }
            finally
            {
                archive.Dispose();
            }
        }
Exemple #27
0
        /// <summary>
        /// بازیابی محتوای آرشیو بر اساس کد محتوا
        /// این تابع فقط در کامپوننت آرشیو لیست بعنوان تابع عمومی استفاده می شود
        /// </summary>
        /// <param name="pCode"></param>
        /// <returns></returns>
        public JFile _RetrieveContent(int pArchiveCode)
        {
            JDataBase DB = this._Database;

            try
            {
                /// ثبت تاریخ آخرین دسترسی
                if (_Access(pArchiveCode))
                {
                    string SelectQuery = "SELECT * FROM " +
                                         JTableNameArchive.ContentTable +
                                         " WHERE " + JContentFields.Status.ToString() + " = 1 " +
                                         " AND " + JContentFields.Code.ToString() +
                                         " = " + pArchiveCode.ToString();
                    DB.setQuery(SelectQuery);

                    if (DB.Query_DataSet())
                    {
                        if (DB.DataSet.Tables[0].Rows.Count > 0)
                        {
                            JFile file = new JFile();
                            file.FileSource = JFile.JFileSource.FromArchive;
                            file.Content    = (byte[])DB.DataSet.Tables[0].Rows[0][JContentFields.Contents.ToString()];
                            file.Extension  = DB.DataSet.Tables[0].Rows[0][JContentFields.FileExtension.ToString()].ToString();
                            file.FileName   = "Temp";
                            return(file);
                        }
                    }
                }
                return(null);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(null);
            }
        }
Exemple #28
0
    /// <summary>
    /// 受けてきたファイルから情報を抽出する(旧バージョン)
    /// </summary>
    private void CreateJFileAndAnalysis()
    {
        JFile _File = JFile.CreateBinary("temp.bin", true);

        if (_File != null)
        {
            var reader      = _File._binaryReader;
            int _iNumOfList = reader.ReadInt32();   //いくつかのデータが保存されているか確認する

            FavData dat;
            for (int i = 0; i < _iNumOfList; ++i)
            {
                dat = new FavData();
                dat.Init();
                dat.DataLoadTransfer(ref reader);
                _FavDataList.Add(dat);
            }
            _File.Close();
        }
        else
        {
            Debug.LogError("No File Exist. Error Occured");
        }
    }
Exemple #29
0
 /// <summary>
 /// بروزرسانی محتویات آرشیو با حذف محتویات قبلی
 /// </summary>
 /// <param name="pFile">محتوای جدید</param>
 /// <param name="pCode">کد آرشیو</param>
 /// <param name="pUserCode">کد کاربر ارسال کننده</param>
 /// <param name="pDesc">شرح آرشیو</param>
 /// <returns></returns>
 public int UpdateArchive(JFile pFile, int pCode, int pUserCode, string pDesc)
 {
     return(UpdateArchive(pFile, pCode, pDesc, true));
 }
Exemple #30
0
 void ValidateUnits(JFile file)
 {
     file.Units.ForEach(ValidateUnit);
 }