Exemplo n.º 1
0
 public FileExtensionColumn(FileDB db) : base()
 {
     _db             = db;
     this.ReadOnly   = false;
     this.HeaderText = "拡張子";
     this.Width      = 50;
 }
Exemplo n.º 2
0
    public static void Load(string path, FileDB db)
    {
        ConsoleUtil.WriteColor(String.Format("Loading '{0}'...\n", path), ConsoleColor.White);
        db.ResetFileStatistics();

        try
        {
            bool firstLine = true;
            foreach (string line in File.ReadLines(path))
            {
                if (firstLine)
                {
                    firstLine = false;   // And do nothing more with the first line which contains the header of column labels
                }
                else
                {
                    FileDescription fd = FileDescription.ParseRecord(line);
                    if (fd != null)
                    {
                        db.AddRecord(fd);
                    }
                }
            }
        }
        catch (Exception e)
        {
            ConsoleUtil.WriteLineColor(String.Format("*** Exception loading report file '{0}' - {1}", path, e.Message),
                                       ConsoleColor.Red);
        }
    }
Exemplo n.º 3
0
 public PathColumn(FileDB db) : base()
 {
     _db             = db;
     this.ReadOnly   = true;
     this.HeaderText = "フォルダ";
     this.Width      = 200;
 }
Exemplo n.º 4
0
        public FileDB SaveFile(FileDB file, string action)
        {
            FileManagerDAL fmDAL = new FileManagerDAL();
            FileDB         target;

            if (file.FileId != 0)
            {
                target = fmDAL.Files.Find(file.FileId);
            }
            else
            {
                target = file;
            }

            switch (action)
            {
            case "upload":
            {
                target.UploadTime   = DateTime.Now;
                target.ModifiedTime = DateTime.Now;
                target.Version      = 1;
                target.FormerId     = null;

                fmDAL.Entry(target).State = EntityState.Added;
                break;
            }

            case "mark delete":
            {
                target.isDelete     = true;
                target.ModifiedTime = DateTime.Now;

                fmDAL.Entry(target).State = EntityState.Modified;
                break;
            }

            case "delete":
            {
                target.FilePath     = null;
                target.ModifiedTime = DateTime.Now;

                fmDAL.Entry(target).State = EntityState.Modified;
                break;
            }

            case "modify":
            {
                file.UploadTime   = target.UploadTime;
                file.ModifiedTime = DateTime.Now;
                file.FormerId     = target;
                target.isDelete   = true;

                fmDAL.Entry(file).State   = EntityState.Added;
                fmDAL.Entry(target).State = EntityState.Modified;
                break;
            }
            }
            fmDAL.SaveChanges();
            return(file);
        }
Exemplo n.º 5
0
 public FileNameColumn(FileDB db) : base()
 {
     _db             = db;
     this.ReadOnly   = false;
     this.HeaderText = "ファイル名";
     this.Width      = 100;
 }
Exemplo n.º 6
0
        public ActionResult Details(int id)
        {
            FileBusinessLayer fbl  = new FileBusinessLayer();
            FileDB            file = fbl.GetFile(id);

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

            FileViewModel fvm = new FileViewModel();

            fvm.FileId       = file.FileId;
            fvm.FileName     = file.FileName;
            fvm.Creater      = file.Creater;
            fvm.Version      = file.Version;
            fvm.UploadTime   = file.UploadTime;
            fvm.ModifiedTime = file.ModifiedTime;
            if (file.FilePath != "")
            {
                fvm.FileContent = System.IO.File.ReadAllText(Path.Combine(_uploadsFolder, file.FilePath));
            }
            else
            {
                fvm.FileContent = "File content is empty. Please check the file path!";
            }
            return(View("Details", fvm));
        }
Exemplo n.º 7
0
        void GMtotown(string name)         // need to rework...
        {
            byte number = FileDB.GetTeleport(name);

            if (number == 255)
            {
                return;
            }
            if (Timer.Movement != null)
            {
                Timer.Movement.Dispose();
            }
            BuffAllClose();
            client.Send(Packet.TeleportOtherStart());

            //ObjectDeSpawn();
            ObjectDeSpawnCheck();
            DeSpawnMe();

            Character.InGame = false;
            Teleport_UpdateXYZ(number);
            client.Send(Packet.TeleportImage(ObjData.Manager.PointBase[number].xSec, ObjData.Manager.PointBase[number].ySec));

            Character.Teleport = true;
            ObjectSpawnCheck();
        }
Exemplo n.º 8
0
        public ActionResult Edit(int id = 0)
        {
            FileBusinessLayer fbl  = new FileBusinessLayer();
            FileDB            file = fbl.GetFile(id);

            return(View("Edit", new CreateFileViewModel()));
        }
        public async Task <File> SaveMeetupFileAsync(IFormFile file, int userId)
        {
            var userInfo = await _appDbContext.UserInfos.Include(k => k.User).FirstOrDefaultAsync(k => k.Id == userId);

            var data = new File()
            {
                IdGuid       = Guid.NewGuid(),
                SizeMb       = GetFileSize(file.Length),
                Name         = file.FileName,
                ProviderName = "SqlProvider",
                ExtraParams  = "",
                Created      = DateTime.UtcNow,
                MimeType     = file.ContentType,
                Modified     = DateTime.UtcNow,
                CreatedBy    = userInfo.Email,
                ModifiedBy   = userInfo.Email
            };

            var savedEntity = (await _appDbContext.Files.AddAsync(data)).Entity;
            await _appDbContext.SaveChangesAsync();

            var fileDb = new FileDB()
            {
                Id    = savedEntity.IdGuid,
                Bytes = StreamToBytes(file.OpenReadStream())
            };

            await _fileDbContext.FileDB.AddAsync(fileDb);

            await _fileDbContext.SaveChangesAsync();

            return(savedEntity);
        }
Exemplo n.º 10
0
        public FileInfo ValueChanged(FileInfo orgFile, string newValue)
        {
            var path = orgFile.FullName;

            using (var connection = _db.GetConnection()) {
                var data = FileDataDao.GetDataByPath(connection, orgFile.FullName);
                if (data == null)
                {
                    //データがない場合
                    data       = new FileData();
                    data.title = newValue;       //タイトル
                    data.memo  = "";             //メモ
                    data.path  = path;           //ファイルのフルパス
                    data.size  = orgFile.Length; //ファイルサイズ
                }
                else
                {
                    //データがある場合
                    data.title = newValue;        //タイトル
                }

                //データを更新します
                FileDB.SaveData(connection, data);

                //キャッシュに反映します
                _cache[orgFile.FullName] = data.title.ToString();
            }

            return(orgFile);
        }
Exemplo n.º 11
0
 protected void SavePlayerPosition()
 {
     //Wrap our function inside a catcher
     try
     {
         //Update database
         if (!FileDB.CheckCave(Character.Position.xSec, Character.Position.ySec))
         {
             DB.query("update character set xsect='" + Character.Position.xSec +
                      "', ysect='" + Character.Position.ySec +
                      "', xpos='" + Formule.packetx(Character.Position.x, Character.Position.xSec) +
                      "', ypos='" + Formule.packety(Character.Position.y, Character.Position.ySec) +
                      "', zpos='" + Math.Round(Character.Position.z) +
                      "' where id='" + Character.Information.CharacterID + "'");
         }
         else
         {
             DB.query("update character set xsect='" + Character.Position.xSec +
                      "', ysect='" + Character.Position.ySec +
                      "', xpos='" + Formule.cavepacketx(Character.Position.x) +
                      "', ypos='" + Formule.cavepackety(Character.Position.y) +
                      "', zpos='" + Math.Round(Character.Position.z) +
                      "' where id='" + Character.Information.CharacterID + "'");
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
Exemplo n.º 12
0
        public ActionResult Details(int id)
        {
            FileBusinessLayer fbl  = new FileBusinessLayer();
            FileDB            file = fbl.GetFile(id);

            if (file == null)
            {
                return(JavaScript("Error" + id));
            }

            DisplayFileViewModel pfvm = new DisplayFileViewModel();

            pfvm.FileName     = file.FileName;
            pfvm.Creater      = file.Creater;
            pfvm.Version      = file.Version;
            pfvm.UploadTime   = file.UploadTime;
            pfvm.ModifiedTime = file.ModifiedTime;
            if (file.FilePath != "")
            {
                pfvm.FileContent = System.IO.File.ReadAllText(file.FilePath);
            }
            else
            {
                pfvm.FileContent = "File content is empty. Please check the file path!";
            }
            return(View("Details", pfvm));
        }
Exemplo n.º 13
0
        public FileDB SaveFile(FileDB file)
        {
            int id = file.FileId;

            FileManagerDAL fmDAL  = new FileManagerDAL();
            FileDB         record = fmDAL.Files.Find(id);

            if (record == null || id == null)
            {
                fmDAL.Files.Add(file);
            }
            else
            {
                //fmDAL.Files.Attach(file);
                //DbContext.Entry(file).State = System.Data.EntityState.Modified;

                record.FileName     = file.FileName;
                record.FilePath     = file.FilePath;
                record.isDelete     = file.isDelete;
                record.ModifiedTime = file.ModifiedTime;
                record.UploadTime   = file.UploadTime;
                record.Version      = file.Version;
            }
            fmDAL.SaveChanges();
            return(file);
        }
Exemplo n.º 14
0
        public async Task <int> UploadFile(FileDB file)
        {
            var newFileEntry = _context.Files.Add(file);

            _context.SaveChanges();
            return(newFileEntry.Entity.Id);
        }
Exemplo n.º 15
0
        public ActionResult History(int id)
        {
            FileListViewModel    flvm    = new FileListViewModel();
            FileBusinessLayer    fbl     = new FileBusinessLayer();
            List <FileDB>        files   = fbl.GetFiles();
            List <FileViewModel> evmlist = new List <FileViewModel>();

            FileDB filenow = fbl.GetFile(id);

            while (filenow != null)
            {
                FileViewModel fvm = new FileViewModel();
                fvm.FileId      = filenow.FileId;
                fvm.FileName    = filenow.FileName;
                fvm.Creater     = filenow.Creater;
                fvm.UploadTime  = filenow.UploadTime;
                fvm.Version     = filenow.Version;
                fvm.FileContent = filenow.FilePath;
                evmlist.Add(fvm);
                filenow = filenow.FormerId;
            }

            flvm.FileList   = evmlist;
            flvm.Permission = Convert.ToString(Session["Permission"]);
            return(View("Historys", flvm));
        }
Exemplo n.º 16
0
        //初期処理を行います
        public bool Initialize(PluginCreateParam param)
        {
            //プラグインマネージャーを保持します
            _pluginManager = PluginManager.GetInstance();

            //DBのパスを作成します
            var dbDirPath = FileUtils.AppendPath(PluginManager.GetCommonDataPath(), "file_info/");

            FileUtils.CreateDir(dbDirPath);
            var dbPath = FileUtils.AppendPath(dbDirPath, "file_info.db");

            //プロパティファイルを読み込みます
            Property = new IniFile();
            Property.Load(param.PropertyPath);

            //DB接続用オブジェクトを生成します
            _db = new FileDB(dbPath);

            //DBのバックアップを作成します
            File.Copy(dbPath, dbPath + "_old", true);

            //ビューのコントロールを生成します
            _control = new FileInfoManagerControl(this, dbPath);

            //イベントハンドラーを登録します
            _pluginManager.GetEventManager().AddEventHandler(FileNameChangedEventParam.Name, this);

            return(true);
        }
Exemplo n.º 17
0
        public async Task GetUserLocation()
        {
            try
            {
                var request  = new GeolocationRequest(GeolocationAccuracy.High);
                var location = await Geolocation.GetLocationAsync(request);

                if (location != null)
                {
                    // getting string address

                    Geocoder             geoCoder          = new Geocoder();
                    Position             p                 = new Position(location.Latitude, location.Longitude);
                    IEnumerable <string> possibleAddresses = await geoCoder.GetAddressesForPositionAsync(p);

                    loca = new CurrentLocation(location.Latitude, location.Longitude, possibleAddresses.FirstOrDefault(), DateTime.Now);

                    file = new FileDB();
                    file.saveData(loca);

                    locas = file.getData();
                    LocationList.ItemsSource = locas;
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 18
0
        public ActionResult Thumbnail(string id)
        {
            using (var db = new FileDB(pathDB, FileAccess.Read))
            {
                var info = db.Search(Guid.Parse(id));

                if (!info.MimeType.StartsWith("image", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(File(Server.MapPath("~/Content/no-picture.jpg"), "image/jpg"));
                }

                using (MemoryStream output = new MemoryStream())
                {
                    db.Read(info.ID, output);

                    Image image          = Image.FromStream(output);
                    Image thumbnailImage = image.GetThumbnailImage(64, 64, new Image.GetThumbnailImageAbort(delegate { return(true); }), IntPtr.Zero);

                    using (MemoryStream imageStream = new MemoryStream())
                    {
                        thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);

                        return(File(imageStream.ToArray(), "image/png"));
                    }
                }
            }
        }
Exemplo n.º 19
0
        public TitleColumn(string dbPath) : base()
        {
            this.ReadOnly   = false;
            this.HeaderText = "タイトル";

            //DB接続用オブジェクトを生成します
            _db = new FileDB(dbPath);
        }
Exemplo n.º 20
0
 public ActionResult Structure()
 {
     using (var db = new FileDB(pathDB, FileAccess.Read))
     {
         ViewData["DebugInfo"] = db.Debug.DisplayPages();
     }
     return(View());
 }
Exemplo n.º 21
0
 public FileSizeColumn(FileDB db) : base()
 {
     _db             = db;
     this.ReadOnly   = true;
     this.HeaderText = "サイズ";
     this.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
     this.SortMode = DataGridViewColumnSortMode.Automatic; //ヘッダークリック時にソート(プログラム)するようにする
     this.Width    = 65;
 }
Exemplo n.º 22
0
        public ActionResult Detail(string id)
        {
            var state = FileDB.AppState(id);

            return(Json(new {
                state = state.Item2,
                date = state.Item1.JSDate()
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 23
0
        public void TrieShouldUpdatable(int repeats)
        {
            const string path = "data1";

            // leveldb
            FileDB.Destroy(path);
            FileDB db = new FileDB(path, true);

            // 랜덤 키 생성 : 키의 길이는 1 - 64
            List <byte[]> keys = new List <byte[]>();

            for (int i = 0; i < repeats; i++)
            {
                keys.Add(SecureRandom.GetBytes(SecureRandom.Next(1, 65)));
            }

            ITrie trie = new Trie(db);

            // put
            foreach (var key in keys)
            {
                trie.Put(key, key.Hash256());
            }

            // update
            foreach (var key in keys)
            {
                trie.Put(key, key.Hash512());
            }

            H256 root = trie.Commit();

            trie.Dispose();

            // update된 내용이 맞는지 확인
            trie = new Trie(db, root);
            foreach (var key in keys)
            {
                Assert.Equal(key.Hash512(), trie.Get(key));
            }

            // 모든 키 삭제
            foreach (var key in keys)
            {
                trie.Del(key);
            }

            root = trie.Commit();
            trie.Dispose();

            // 키에 해당하는 내용이 있는지 확인
            trie = new Trie(db, root);
            foreach (var key in keys)
            {
                Assert.Null(trie.Get(key));
            }
        }
Exemplo n.º 24
0
        public ActionResult Detail(string id)
        {
            ViewBag.id         = id;
            ViewBag.state      = FileDB.AppState(id);
            ViewBag.config     = FileDB.AppConfig(id).SanitizeForDisplay();
            ViewBag.logcreated = FileDB.LogCreated(id);

            return(View());
        }
Exemplo n.º 25
0
        } = new Color[11];                                       //インデックス:評価(0 - 10)

        public ValueColumn(FileDB db) : base()
        {
            _db             = db;
            this.ReadOnly   = false; //編集可能
            this.HeaderText = "評価";
            this.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.SortMode = DataGridViewColumnSortMode.Automatic; //ヘッダークリック時にソート(プログラム)するようにする
            this.Width    = 40;
        }
Exemplo n.º 26
0
 public CreatedDateColumn(FileDB db) : base()
 {
     _db             = db;
     this.ReadOnly   = true;
     this.HeaderText = "作成日時";
     this.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
     this.SortMode = DataGridViewColumnSortMode.Automatic; //ヘッダークリック時にソート(プログラム)するようにする
     this.Width    = 120;
 }
Exemplo n.º 27
0
        /// <summary>
        /// ファイル情報テーブルにデータを保存します
        /// </summary>
        public void SaveData()
        {
            using (var connection = _db.GetConnection()) {
                FileDB.SaveData(connection, GetFileData());
            }

            //変更なしにします
            Modified = false;
        }
Exemplo n.º 28
0
        public Notify()
        {
            var fileDb        = new FileDB(HairAppBl.Constants.SchedulesStorageFile);
            var historyfileDb = new FileDB(HairAppBl.Constants.HistoryStorageFile);
            var settingsDb    = new FileDB(HairAppBl.Constants.SettingsStorageFile);

            mAlarmController = new AlarmController(fileDb, historyfileDb, settingsDb);

            SetCulture(mAlarmController.GetCulture().Culture);
        }
Exemplo n.º 29
0
        public ActionResult Index()
        {
            FileDB.CreateEmptyFile(pathDB, true);

            var files = FileDB.ListFiles(pathDB);

            ViewData["TotalFiles"] = files.Length;

            return(View(files.Take(200).ToArray()));
        }
Exemplo n.º 30
0
        /// <summary>
        /// 編集で値が変更された場合に呼ばれます
        /// </summary>
        /// <param name="orgFileData"></param>
        /// <param name="newValue"></param>
        /// <returns></returns>
        public FileData ValueChanged(FileData orgFileData, string newValue)
        {
            //タグを更新します
            using (var connection = _db.GetConnection()) {
                orgFileData._tags = newValue;
                FileDB.UpdateTag(connection, orgFileData);
            }

            return(orgFileData);
        }
Exemplo n.º 31
0
        static void Main(string[] args)
        {
            var qlikViewFiles = QlikViewObjectFactory.Create(@"C:\Users\Wiko\Documents\visual studio 2010\Projects\ConsoleApplication1\Knorr.Tests\TestFiles\");
            var db = new FileDB<QlikViewFile>(@"C:\Temp\");
            var dbNodes = new FileDB<Node>(@"C:\Temp\");
            var dbEdges = new FileDB<Edge>(@"C:\Temp\");

            db.DeleteAll();
            dbNodes.DeleteAll();
            dbEdges.DeleteAll();

            var nodes = NodeFactory.CreateNodes(qlikViewFiles);
            foreach (var node in nodes)
                dbNodes.Create(node);

            var edges = NodeFactory.CreateEdges(qlikViewFiles);
            foreach (var edge in edges)
                dbEdges.Create(edge);

            foreach (var qlikViewFile in qlikViewFiles)
                db.Create(qlikViewFile);

            var qlikviewObjects = db.Read();

            foreach (var qlikviewObject in qlikviewObjects)
            {
                Console.WriteLine("Filename " + qlikviewObject.FileInfo.FullName);
                foreach (var source in qlikviewObject.Script.Sources)
                {
                    Console.WriteLine("  Source " + source);
                }

                foreach (var target in qlikviewObject.Script.Targets)
                {
                    Console.WriteLine("  Target " + target);
                }
            }

            Console.Read();
        }
Exemplo n.º 32
0
 static void Main(string[] args)
 {
     var db = new FileDB();
     db.Open("test.sqb");
 }