Example #1
0
 private void AddWorkFile(WorkFile workFile)
 {
     BMTools.BmDebug.Debug.InfoAsync("add file=" + workFile.FileName);
     if (
         !WorkFiles.Exists(
             w =>
             w.Path == workFile.Path && w.FileName == workFile.FileName &&
             w.HomeOrBaseText == workFile.HomeOrBaseText && w.VersionName == workFile.VersionName))
     {
         //one etalon diff h/b selector
         if (WorkFiles.Exists(
                 w =>
                 w.Path == workFile.Path && w.FileName == workFile.FileName &&
                 w.VersionName == workFile.VersionName))
         {
             if (MessageBox.Show(@"File Exist in Work List =" + workFile.FileName, @"Ignore file?", MessageBoxButtons.YesNo) == DialogResult.No)
             {
                 WorkFiles.Add(workFile);
             }
         }
         else
         {
             WorkFiles.Add(workFile);
         }
     }
     else
     {
         MessageBox.Show(@"File Exist in Work List =" + workFile.FileName);
     }
 }
Example #2
0
        private void CreateTimetable_OnClick(object sender, RoutedEventArgs e)
        {
            var type      = (Event.Types)TypesTimetableComboBox.SelectedIndex;
            var timetable = new Timetable(NameTimetableTextBox.Text, type);
            var workFile  = new WorkFile(new WorkFile().FilePath + timetable.Name);

            workFile.SaveTimetable(timetable);
            DialogResult = true;
        }
Example #3
0
        public Course(int id)
        {
            string st = WorkFile.ReadLine(id);

            string[] ss = st.Split(';');
            id    = Convert.ToInt32(ss[0]);
            Name  = ss[1];
            kkal  = Convert.ToInt32(ss[2]);
            prise = Convert.ToInt32(ss[3]);
        }
        /// <summary>
        /// Luu work file
        /// </summary>
        /// <param name="item"></param>
        /// <param name="fileContent"></param>
        void SaveWorkFileOnDisk(WorkFile item, byte[] fileContent)
        {
            string _pathStore = item.CreatedDate.ToPathFolderStore();

            _pathStore = _fileProvider.Combine(_fileProvider.MapPath(GSDataSettingsDefaults.FolderWorkFiles), _pathStore);
            _fileProvider.CreateDirectory(_pathStore);
            var _fileStore = _fileProvider.Combine(_pathStore, item.FileGuid.ToString() + item.Extension);

            _fileProvider.WriteAllBytes(_fileStore, fileContent);
        }
Example #5
0
 public MainWindow()
 {
     InitializeComponent();
     time.Elapsed          += Time_Elapsed;
     readLogsTimer.Elapsed += ReadLogsTimer_Elapsed;
     this.DataContext       = this;
     string[] data = (string[])WorkFile.Do("data.dat", WorkFileMode.ReadArrayString);
     AdminPass           = data[0];
     SerialPort.PortName = data[1];
 }
Example #6
0
        /// <summary>
        /// Inserts a WorkFile
        /// </summary>
        /// <param name="WorkFile">WorkFile</param>
        public virtual void InsertWorkFile(WorkFile item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            _workFileRepository.Insert(item);

            _eventPubisher.EntityInserted(item);
        }
 void DoSave(object sender, ExecutedRoutedEventArgs e)
 {
     fsw.EnableRaisingEvents = false;
     if (string.IsNullOrEmpty(WorkFile) || !WorkFile.StartsWith(Configuration.InstalledPath, StringComparison.OrdinalIgnoreCase))
     {
         DoSavePromptForFilename();
     }
     else
     {
         DoSave();
     }
 }
        //do not validate request token (XSRF)
        public virtual IActionResult AsyncUpload()
        {
            var httpPostedFile = Request.Form.Files.FirstOrDefault();

            if (httpPostedFile == null)
            {
                return(Json(new
                {
                    success = false,
                    message = "No file uploaded",
                    downloadGuid = Guid.Empty
                }));
            }

            var fileBinary = _workfileService.GetWorkFileBits(httpPostedFile);

            var qqFileNameParameter = "qqfilename";
            var fileName            = httpPostedFile.FileName;

            if (string.IsNullOrEmpty(fileName) && Request.Form.ContainsKey(qqFileNameParameter))
            {
                fileName = Request.Form[qqFileNameParameter].ToString();
            }
            //remove path (passed in IE)
            fileName = _fileProvider.GetFileName(fileName);

            var contentType = httpPostedFile.ContentType;

            var fileExtension = _fileProvider.GetFileExtension(fileName);

            if (!string.IsNullOrEmpty(fileExtension))
            {
                fileExtension = fileExtension.ToLowerInvariant();
            }

            var fwork = new WorkFile
            {
                FileGuid    = Guid.NewGuid(),
                FileContent = fileBinary,
                MimeType    = contentType,
                //we store filename without extension for downloads
                FileName    = _fileProvider.GetFileNameWithoutExtension(fileName),
                Extension   = fileExtension,
                CreatedDate = DateTime.Now,
                CreatorId   = _workContext.CurrentCustomer.Id
            };

            _workfileService.InsertWorkFile(fwork);

            //when returning JSON the mime-type must be set to text/plain
            //otherwise some browsers will pop-up a "Save As" dialog.
            return(Json(fwork.ToModel <WorkFileModel>()));
        }
 private void PrintToFile_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         WorkFile workFile = new WorkFile(new WorkFile().ReportPath);
         workFile.SaveReport(text.ToString());
         MessageBox.Show("Файл записан по пути:\n" + workFile.ReportPath);
     }
     catch (FileNotFoundException exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
Example #10
0
        private WorkFile UploadFile(IFormFile httpPostedFile)
        {
            if (httpPostedFile == null)
            {
                return(null);
            }

            var fileBinary = _workfileService.GetWorkFileBits(httpPostedFile);

            var qqFileNameParameter = "qqfilename";
            var fileName            = httpPostedFile.FileName;

            if (string.IsNullOrEmpty(fileName) && Request.Form.ContainsKey(qqFileNameParameter))
            {
                fileName = Request.Form[qqFileNameParameter].ToString();
            }
            //remove path (passed in IE)
            fileName = _fileProvider.GetFileName(fileName);

            var contentType = httpPostedFile.ContentType;

            var fileExtension = _fileProvider.GetFileExtension(fileName);

            if (!string.IsNullOrEmpty(fileExtension))
            {
                fileExtension = fileExtension.ToLowerInvariant();
            }

            var fwork = new WorkFile
            {
                FileGuid    = Guid.NewGuid(),
                FileContent = null,
                MimeType    = contentType,
                //we store filename without extension for downloads
                FileName      = _fileProvider.GetFileNameWithoutExtension(fileName),
                Extension     = fileExtension,
                CreatedDate   = DateTime.Now,
                CreatorId     = _workContext.CurrentCustomer.Id,
                ContentLength = Convert.ToInt32(fileBinary.LongLength / 1024) //luu thanh kb
            };

            _workfileService.InsertWorkFile(fwork);
            //luu file content ra ngoai
            SaveWorkFileOnDisk(fwork, fileBinary);
            //when returning JSON the mime-type must be set to text/plain
            //otherwise some browsers will pop-up a "Save As" dialog.
            return(fwork);
        }
Example #11
0
 private void NextEtalon(WorkFile workFile)
 {
     if (Pathes.Count > 1)
     {
         for (var i = 0; i < Pathes.Count; i++)
         {
             if (workFile.VersionName == Pathes[i].Name)
             {
                 var index = i == Pathes.Count - 1 ? 0 : i + 1;
                 workFile.VersionName = Pathes[index].Name;
                 workFile.Path        = workFile.Path.Replace(Pathes[i].PathLocal, Pathes[index].PathLocal);
                 return;
             }
         }
     }
 }
Example #12
0
        public TimetableWindow(string filePath)
        {
            InitializeComponent();
            _workFile   = new WorkFile(filePath);
            _eventsCard = new List <TextBlock>();
            try
            {
                _timetable = _workFile.LoadTimetable();
            }
            catch (FileLoadException exception)
            {
                MessageBox.Show(exception.Message);
            }

            MessageBox.Show(filePath + "\n" + _timetable.Events.Count);
            Title = filePath + " - " + _timetable.Type;
        }
Example #13
0
        public void Start()
        {
            Random random = new Random();

            // заполнение из файла
            try
            {
                WorkFile.ReadFile(Flights);
            }
            catch
            {
                WorkFile.GenerateFile();
                WorkFile.ReadFile(Flights);
            }
            // запуск таймера
            CustomTimer.Timer.Tick += Move;
            CustomTimer.Start();
        }
Example #14
0
 private void OpenCreateTimetableWindowMenuItem_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var newTimetable = new NewTimetable();
         if (newTimetable.ShowDialog() == true)
         {
             WorkFile workFile  = new WorkFile();
             var      timetable = new TimetableWindow(workFile.FilePath +
                                                      newTimetable.NameTimetableTextBox.Text);
             timetable.Show();
         }
     }
     catch (FileLoadException exception)
     {
         MessageBox.Show(exception.Message + '\n' + exception);
     }
 }
Example #15
0
        public ActionResult Download(int?id, string typeName, DownloadAs?type)
        {
            var typeInfo = new TypeInfo
            {
                Id       = id.GetValueOrDefault(0),
                TypeName = typeName ?? "",
                Type     = type.GetValueOrDefault(DownloadAs.Excel),
            };

            WorkFile   output = null;
            IOperation operation;

            if (typeInfo.Type == DownloadAs.Excel)
            {
                var builder = FluentOperationBuilder
                              .Receive <InvokeMethodReceiver <TypeInfo> >().WithOption(x => x.Method = () => typeInfo)
                              .Transform <TypeInfoToProductListCog>()
                              .Transform <ProductListToDataTable>()
                              .Transform <FromDataTableToExcelStream>()
                              .Transform <NamingCog>().WithOption(a => a.Extension = ".xlsx")
                              .Send <InvokeMethodSender <WorkFile> >().WithOption(x => x.Method = (value) => output = value);
                operation = builder.ToOperation();
            }
            else
            {
                var builder = FluentOperationBuilder
                              .Receive <InvokeMethodReceiver <TypeInfo> >().WithOption(x => x.Method = () => typeInfo)
                              .Transform <TypeInfoToProductListCog>()
                              .Transform <ProductListToDataTable>()
                              .Transform <FromDataTableToCsvStream>()
                              .Transform <NamingCog>().WithOption(a => a.Extension = ".csv")
                              .Send <InvokeMethodSender <WorkFile> >().WithOption(x => x.Method = (value) => output = value);
                operation = builder.ToOperation();
            }

            var runner = new OperationEngine();

            runner.Execute(operation);
            output.Stream.Flush();
            output.Stream.Position = 0;
            return(File(output.Stream, MediaTypeNames.Application.Octet, output.Name));
        }
Example #16
0
        public async Task <IActionResult> Getdriverpic()
        {
            var           files = HttpContext.Request.Form.Files;
            List <string> AllowedFileExtention = new List <string>()
            {
                ".png",
                ".jpg"
            };

            if (files != null)
            {
                var s = files[0];
                var(state, name) = await WorkFile.UploadFileAsync(s, "Dynamics/Drivers", FileType.image, AllowedFileExtention, _env);

                if (state)
                {
                    return(Ok(name));
                }
                return(Ok(name));
            }
            return(Ok("false"));
        }
Example #17
0
 private string GetRemotePath(WorkFile workFile)
 {
     return(GetRemotePath(workFile.Path, workFile.VersionName, workFile.HomeOrBaseText));
 }
Example #18
0
        byte[] GetWorkFileContentOnDisk(WorkFile item)
        {
            var _fileStore = _fileProvider.Combine(_fileProvider.MapPath(GSDataSettingsDefaults.FolderWorkFiles), item.CreatedDate.ToPathFolderStore(), item.FileGuid.ToString() + item.Extension);

            return(_fileProvider.ReadAllBytes(_fileStore));
        }
Example #19
0
        void DeleteWorkFileOnDisk(WorkFile item)
        {
            var _fileStore = _fileProvider.Combine(_fileProvider.MapPath(GSDataSettingsDefaults.FolderWorkFiles), item.CreatedDate.ToPathFolderStore(), item.FileGuid.ToString() + item.Extension);

            _fileProvider.DeleteFile(_fileStore, true);
        }
Example #20
0
 public WorkController(WorkRepository repository, WorkFile workFile)
 {
     this.repository = repository;
     this.workFile   = workFile;
 }
Example #21
0
 public void Save()
 {
     WorkFile.AddUpdate(id, Name, kkal, prise);
 }
Example #22
0
 private void FillData()
 {
     dataGridView1.DataSource = WorkFile.ReadTable();
 }