Esempio n. 1
0
        public static void CreateTraceFile(DatasList dataList, string traceFileNamePath, string logFileName, string traceFileName)
        {
            int filesCount = dataList.Data.Count() / 100;

            if (dataList.Data.Count() % 100 > 0)
            {
                filesCount++;
            }

            FileTraceModel model = new FileTraceModel()
            {
                FileName = logFileName, FileItemsList = new List <FileItemModel>(), FilesItemCount = filesCount
            };

            for (int i = 0; i < filesCount; i++)
            {
                StringBuilder itemName = new StringBuilder(logFileName);
                FileItemModel fileItem = new FileItemModel()
                {
                    FileItemName = itemName.Replace(".log", "-000" + (i + 1)).Append(".log").ToString(), FileState = FileStatus.Empty
                };
                model.FileItemsList.Add(fileItem);
            }

            model.TotalCount = dataList.Data.Count();
            FileHelper.WriteTextFile(traceFileNamePath, string.Empty, false);
            FileHelper.WriteTextFile(traceFileNamePath, JsonConvert.SerializeObject(model), false);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the item.
        /// </summary>
        /// <param name="barcode">The barcode.</param>
        /// <returns></returns>
        public FileItemModel GetItem(string barcode)
        {
            SQLiteConnection _con = OpenConnect();

            try
            {
                FileItemModel        item = new FileItemModel();
                List <FileItemModel> allItems;
                allItems = _con.Query <FileItemModel>("Select * from FileItemModel where Barecode=?", barcode);
                for (int i = 0; i < allItems.Count; i++)
                {
                    item = new FileItemModel
                    {
                        Barecode             = allItems[i].Barecode,
                        File_Number          = allItems[i].File_Number,
                        Dismounting_type     = allItems[i].Dismounting_type,
                        Reassembling_type    = allItems[i].Reassembling_type,
                        Mechanical_statement = allItems[i].Mechanical_statement,
                        Comments_loading     = allItems[i].Comments_loading
                    };
                }
                CloseConenct(_con);
                return(item);
            }
            catch (Exception ex)
            {
                CloseConenct(_con);
                throw ex;
            }
        }
 internal static FileItemViewModel CreateFileItemVM(FileItemModel fileItemModel,
                                                    IExplorerTreeItemModelViewModelParser explorerTreeItemModelViewModelParser,
                                                    IConfiguration configuration,
                                                    IExplorerTreeItemViewModel parentItemVM)
 {
     return(new FileItemViewModel(fileItemModel, explorerTreeItemModelViewModelParser, configuration, parentItemVM));
 }
Esempio n. 4
0
        public IActionResult Index()
        {
            //视频文件列表
            string        dirPath = Path.Combine(Environment.CurrentDirectory, @"wwwroot/videos");
            FileItemModel model   = GetFileIteration(new DirectoryInfo(dirPath));

            return(View(model));
        }
Esempio n. 5
0
        /// <summary>
        /// Update existing records
        /// </summary>
        /// <param name="fileItem"></param>

        public void UpdateLoadingData(FileItemModel fileItem)
        {
            SQLiteConnection _con = OpenConnect();

            try
            {
                _con.Update(fileItem);
                CloseConenct(_con);
            }
            catch (Exception ex)
            {
                CloseConenct(_con);
                throw ex;
            }
        }
Esempio n. 6
0
        public FileItemModel GetFileIteration(DirectoryInfo directory)
        {
            FileItemModel model = new FileItemModel
            {
                Directory         = directory,
                Files             = FileHelper.GetFiles(directory.FullName, new string[] { "*.mp4", "*.flv", "*.m3u8", "*.rtmp", "*.mp3" }),
                ChildFileItemList = new List <FileItemModel>()
            };

            foreach (var dir in DirectoryHelper.GetDirectories(directory.FullName))
            {
                model.ChildFileItemList.Add(GetFileIteration(dir));
            }
            return(model);
        }
Esempio n. 7
0
        /// <summary>
        /// Insert new loading details
        /// </summary>
        /// <param name="fileItem"></param>
        public void InsertLoading(FileItemModel fileItem)
        {
            SQLiteConnection _con = OpenConnect();

            try
            {
                _con.Insert(fileItem);

                CloseConenct(_con);
            }
            catch (Exception ex)
            {
                CloseConenct(_con);
                //throw ex;
            }
        }
Esempio n. 8
0
        public List <AExplorerTreeChildItemModel> FilesToFileItemModel(List <string> files, IExplorerTreeItemModel parentItem)
        {
            List <AExplorerTreeChildItemModel> returnList = new List <AExplorerTreeChildItemModel>();

            foreach (var file in files)
            {
                FileItemModel fileItemModel = new FileItemModel();
                fileItemModel.FileInfo   = new FileInfo(file);
                fileItemModel.IsHidden   = this.CheckIfFileOrDirectoryIsHidden(fileItemModel.FileInfo.Attributes);
                fileItemModel.FullName   = file;
                fileItemModel.Name       = Path.GetFileName(file);
                fileItemModel.IconModel  = IconModelParser.ParseIconModel(fileItemModel.IconModel, file);
                fileItemModel.ParentItem = parentItem;
                returnList.Add(fileItemModel);
            }
            return(returnList);
        }
 public IHttpActionResult RemoveFile(FileItemModel obj)
 {
     if (obj != null && obj.Id == 0)
     {
         string webPath = HttpContext.Current.Server.MapPath("~");
         bool   re      = DirFileHelper.DeleteFile(webPath + obj.Url);
         if (!re)
         {
             return(NotFound());
         }
         return(Ok());
     }
     else
     {
         return(BadRequest());
     }
 }
Esempio n. 10
0
 /// <summary>
 ///
 /// <para>
 /// Exclusively use <see cref="ExplorerTreeItemViewModelsFactory"/>
 /// to instantiate this class.
 /// -> Except for test purposes.
 /// </para>
 /// </summary>
 internal FileItemViewModel(FileItemModel fileItemModel,
                            IExplorerTreeItemModelViewModelParser explorerTreeItemModelViewModelParser,
                            IConfiguration configuration,
                            IExplorerTreeItemViewModel parentItemVM) : base()
 {
     this.Configuration    = configuration;
     this.ChildTreeItemVMs = new ObservableCollection <AExplorerTreeChildItemViewModel>();
     this.ExplorerTreeItemModelViewModelParser = explorerTreeItemModelViewModelParser;
     this.ExplorerTreeVM = configuration.ExplorerTreeVM;
     this.FileItemModel  = fileItemModel;
     this.FontVM         = new FontViewModel(this.Configuration.File.Font);
     this.FullName       = fileItemModel.FullName;
     this.IsExpanded     = false;
     this.IsSelected     = false;
     this.IsHidden       = fileItemModel.IsHidden;
     this.IconVM         = new IconViewModel(fileItemModel.IconModel, this.Configuration.File.Icon);
     this.Name           = fileItemModel.Name;
     this.ParentItem     = parentItemVM;
     this.SetVisibilityAccordingToConfigruation(configuration.HiddenOverall);
 }
Esempio n. 11
0
        public static void UpdateTraceFile(DatasList dataList, string traceFileNamePath, string fileName, string traceFileName)
        {
            FileTraceModel model = ReadTraceFile(traceFileNamePath);
            //model.Data.AddRange(dataList.Data);

            int filesCount = 0;
            int itemsCount = dataList.Data.Count();

            while (itemsCount >= 100)
            {
                filesCount++;
                itemsCount -= 100;
            }
            if (itemsCount % 100 > 0 || itemsCount > 0)
            {
                filesCount++;
            }



            for (int i = model.FilesItemCount + 1; i <= filesCount; i++)
            {
                StringBuilder itemName   = new StringBuilder(fileName);
                int           nameNumber = model.FilesItemCount + 1;
                FileItemModel fileItem   = new FileItemModel()
                {
                    FileItemName = itemName.Replace(".log", "-000" + (nameNumber)).Append(".log").ToString(), FileState = FileStatus.Empty
                };
                model.FileItemsList.Add(fileItem);
                model.FilesItemCount = filesCount;
            }

            model.TotalCount = dataList.Data.Count();
            FileHelper.WriteTextFile(traceFileNamePath, string.Empty, false);
            FileHelper.WriteTextFile(traceFileNamePath, JsonConvert.SerializeObject(model), false);
        }
        /// <summary>
        /// Saves the loading.
        /// </summary>
        public async void SaveLoading()
        {
            if (_status.Equals("loading"))
            {
                _loading.FileItemModel.Comments_loading = PhotoComment;

                if (_loading.Search == false)
                {
                    int count = _db.GetCountOfPhotoPathLoading(_loading.FileItemModel.Barecode);
                    if (count != 0)
                    {
                        _db.UpdateLoadingData(_loading.FileItemModel);
                    }
                    else
                    {
                        _db.InsertLoading(_loading.FileItemModel);
                    }
                }

                if (_loading.Search == true)
                {
                    FileItemModel singleItem = _db.GetSelectedItemDetails(_loading.SelectedBarcode);

                    if (singleItem != null)
                    {
                        if ((_loading.FileItemModel.Barecode).Equals(_loading.SelectedBarcode))
                        {
                            singleItem.Idrubric             = _loading.FileItemModel.Idrubric;
                            singleItem.RubricsName          = _loading.FileItemModel.RubricsName;
                            singleItem.IdItem               = _loading.FileItemModel.IdItem;
                            singleItem.ItemName             = _loading.FileItemModel.ItemName;
                            singleItem.Name                 = _loading.FileItemModel.Name;
                            singleItem.Packed_by            = _loading.FileItemModel.Packed_by;
                            singleItem.Dismounting_type     = _loading.FileItemModel.Dismounting_type;
                            singleItem.Cub_dismount         = _loading.FileItemModel.Cub_dismount;
                            singleItem.Mechanical_statement = _loading.FileItemModel.Mechanical_statement;
                            singleItem.Reassembling_type    = _loading.FileItemModel.Reassembling_type;
                            singleItem.Cub_reassembly       = _loading.FileItemModel.Cub_reassembly;
                            singleItem.PhotoPath            = _loading.FileItemModel.PhotoPath;
                            singleItem.Comments_loading     = _loading.FileItemModel.Comments_loading;
                            singleItem.Telephone_loading    = _loading.FileItemModel.Telephone_loading;
                            singleItem.Branche_loading      = _loading.FileItemModel.Branche_loading;
                            singleItem.Sent_Loading         = _loading.FileItemModel.Sent_Loading;
                            singleItem.PhotoPath            = _loading.FileItemModel.PhotoPath;

                            if (_fileInfoLoading != null && _fileInfoLoading.Info_Cubage && _loading.ItemsFiles != null)
                            {
                                singleItem.IdFileRoom = _loading.SelectedIdRoom;
                                singleItem.RoomName   = _loading.SelectedData;
                                singleItem.IdFileItem = _loading.FileItemModel.IdFileItem;
                            }
                            else
                            {
                                singleItem.IdRoom   = _loading.SelectedIdRoom;
                                singleItem.RoomName = _loading.SelectedData;
                            }
                            _db.UpdateLoadingData(singleItem);
                        }
                        else
                        {
                            _db.DeleteItem(_loading.SelectedBarcode);
                            if (_fileInfoLoading != null && _fileInfoLoading.Info_Cubage && _loading.ItemsFiles != null)
                            {
                                _loading.FileItemModel.IdFileRoom = _loading.SelectedIdRoom;
                                _loading.FileItemModel.RoomName   = _loading.SelectedData;
                            }
                            else
                            {
                                _loading.FileItemModel.IdRoom   = _loading.SelectedIdRoom;
                                _loading.FileItemModel.RoomName = _loading.SelectedData;
                            }

                            _db.InsertLoading(_loading.FileItemModel);
                        }
                    }
                    else
                    {
                        //selected item barcode already deleted  .... NEW barcode scanned ! ... to perform insert ou update on new changed barcode
                        if (!_loading.FileItemModel.Barecode.Equals(_loading.SelectedBarcode))
                        {
                            int count = _db.GetCountOfPhotoPathLoading(_loading.FileItemModel.Barecode);
                            if (count != 0)
                            {
                                _db.UpdateLoadingData(_loading.FileItemModel);
                            }
                            else
                            {
                                _db.InsertLoading(_loading.FileItemModel);
                            }
                        }
                    }
                }
            }
        }