Пример #1
0
        /// <summary>
        /// Triggered when user refreshes the page
        /// </summary>
        /// <returns></returns>
        public async Task GetUpdatedReports()
        {
            ReportList.Clear();

            List <Report> reports = new List <Report>();

            if (CrossConnectivity.IsSupported && CrossConnectivity.Current.IsConnected)
            {
                var remoteReports = await ServerDatabaseService.GetReportsByEmployee(UserDataCache.CurrentEmployeeData);

                await DatabaseService.InsertListReportData(remoteReports);

                reports = await GetReportsByEmployee(UserDataCache.CurrentEmployeeData);
            }
            else if (!CrossConnectivity.IsSupported || !CrossConnectivity.Current.IsConnected)
            {
                // update from the local database
                reports = await GetReportsByEmployee(UserDataCache.CurrentEmployeeData);
            }

            foreach (var report in reports)
            {
                ReportList.Add(report);
            }

            // update the cached list
            InspectionDataCache.CachedReportsList = reports;
        }
Пример #2
0
        public Report()
        {
            InitializeComponent();
            comboBoxModel.Items.Clear();
            ReportList.Clear();
            DateTime startFilterTime = DateTime.Now;
            DateTime endFilterTime   = DateTime.Now;

            while (DateTime.Compare(endFilterTime, startFilterTime) >= 0)
            {
                string folderReport = @"C:\DaeyoungVN\FCT\History\" + startFilterTime.ToString("yyyy") + "\\" + startFilterTime.ToString("MMMM") + "\\" + startFilterTime.ToString("dd") + "\\";
                if (Directory.Exists(folderReport))
                {
                    string[] fileReport = Directory.GetFiles(folderReport, "*.txt");
                    for (int i = 0; i < fileReport.Length; i++)
                    {
                        ReportList.Add(fileReport[i]);
                        string fileName = Path.GetFileNameWithoutExtension(fileReport[i]);
                        comboBoxModel.Items.Add(fileName);
                    }
                }
                startFilterTime = startFilterTime.AddDays(1);
            }
            if (comboBoxModel.Items.Count > 0)
            {
                comboBoxModel.SelectedIndex = 0;
            }
        }
Пример #3
0
        public MainWindowViewModel()
        {
            GetCrash.Execute(null);

            reportBaseContext = new ReportBaseContext();

            string login = Environment.UserName;

            if (string.IsNullOrEmpty(login))
            {
                throw new Exception("Логин пользователя не может быть пустым!");
            }
            var _rpt_lst = (from r in reportBaseContext.Reports
                            join ur in reportBaseContext.UsersReports on r.RptId equals ur.RptId
                            where ur.UsrLogin.Equals(login)
                            select r).ToList();

            if (_rpt_lst.Count <= 0)
            {
                throw new Exception("Для указанного пользователя нет доступных отчётов");
            }
            foreach (var item in _rpt_lst)
            {
                ReportList.Add(item);
            }

            LoadingText = "Открыто окно отчёта. Для просмотра другого отчёта, закройте окно текущего отчёта";
        }
Пример #4
0
        private void ReportAdd(string id, string name)
        {
            var report = ReportInit(id, name);

            ReportList.Add(report);
            SaveReportList();
            SelectedReport = report;
        }
Пример #5
0
        public ReportList GetReportsByTag(string _tag, bool exist, Flag _type)
        {
            ReportList re = new ReportList();

            foreach (Report report in Reports)
            {
                if (report.Flag == _type)
                {
                    if (report.Tags.Contains(_tag) == exist)
                    {
                        re.Add(report);
                    }
                }
            }
            return(re);
        }
Пример #6
0
        public async Task GetReports()
        {
            ReportList.Clear();

            // check if the inspection list has already been fetched before in this session
            if (!InspectionDataCache.IsReportListFetched)
            {
                InspectionDataCache.CachedReportsList = await GetReportsByEmployee(UserDataCache.CurrentEmployeeData);

                InspectionDataCache.IsReportListFetched = true;
            }

            foreach (var cachedReport in InspectionDataCache.CachedReportsList)
            {
                ReportList.Add(cachedReport);
            }
        }
Пример #7
0
        private void LoadReportList()
        {
            var filePath = $"{Funs.StoreFolder}/Reports.json";

            if (File.Exists(filePath))
            {
                var json    = File.ReadAllText(filePath);
                var reports = JsonConvert.DeserializeObject <List <Report> >(json);
                foreach (var report in reports)
                {
                    ReportList.Add(ReportInit(report.Id, report.ReportName));
                }
                if (ReportList.Count > 0)
                {
                    SelectedReport = ReportList[0];
                }
            }
        }
Пример #8
0
        private static void LoadFromDir(string dir, Flag defaultFlag)
        {
            DirectoryInfo di        = new DirectoryInfo(dir);
            List <string> unstarred = Manager.GetUnstarredBulk();

            foreach (FileInfo fi in di.GetFileSystemInfos("*.zip"))
            {
                Report report = new Report(fi.FullName);
                if (!report.IsLoaded)
                {
                    continue;
                }

                report.SetFlag(defaultFlag);
                if (unstarred.Exists(r => r == report.Name))
                {
                    report.Starred = false;
                }
                Reports.Add(report);
            }
        }
Пример #9
0
        public Boolean addNewReport(int numTransactions, double totalSales, double totalTax, DateTime startDate, DateTime endDate)
        {
            try
            {
                int maxId = 0;

                foreach (Report report in ReportList)
                {
                    if (report.ReportID > maxId)
                    {
                        maxId = report.ReportID;
                    }
                }
                IReport theReport = ReportFactory.GetReport(maxId + 1, numTransactions, totalSales, totalTax, startDate, endDate); // Using a Factory to create the user entity object. ie seperating object creation from business logic
                ReportList.Add(theReport);                                                                                         // Add a reference to the newly created object to the Models UserList
                DataLayer.addNewReportToDB(theReport);                                                                             //Gets the DataLayer to add the new user to the DB.
                return(true);
            }
            catch (System.Exception excep)
            {
                return(false);
            }
        }
Пример #10
0
        protected override void ItemTransfer(string inputPath, string outputPath)
        {
            string intermediaPath = Path.Combine(WorkFolder, Guid.NewGuid() + ".wav");

            try
            {
                if (ExistingFileDict.ContainsKey(outputPath))
                {
                    Console.WriteLine($"File exists: {outputPath}");
                    return;
                }
                string ext = inputPath.Split('.').Last().ToLower();
                if (ext.ToLower() == "ds_store" || ext.ToLower() == "pdf")
                {
                    return;
                }
                Sanity.Requires(ValidExtSet.Contains(ext), $"Invalid extension: {ext}");
                ConvertToWave(inputPath, intermediaPath, outputPath);
                Wave w = new Wave();
                w.ShallowParse(outputPath);
                string reportLine = $"{inputPath.Split('\\').Last()}\t{outputPath.Split('\\').Last()}\t{w.AudioLength}";
                string key        = w.DataChunk.Length.ToString();
                lock (LockObj)
                {
                    if (FileSizeDict.ContainsKey(key))
                    {
                        foreach (string existingFilePath in FileSizeDict[key])
                        {
                            if (LocalCommon.AudioIdenticalLocal(existingFilePath, outputPath))
                            {
                                ErrorList.Add($"{outputPath}\t{existingFilePath}");
                                if (File.Exists(outputPath))
                                {
                                    File.Delete(outputPath);
                                }
                                return;
                            }
                        }
                        FileSizeDict[key].Add(outputPath);
                    }
                    else
                    {
                        FileSizeDict[key] = new List <string> {
                            outputPath
                        }
                    };
                    try
                    {
                        string outputTimeStampPath = outputPath.Replace(".wav", ".txt");
                        if (File.Exists(outputTimeStampPath))
                        {
                            File.Delete(outputTimeStampPath);
                        }
                        SetTimeStamp(outputPath, outputTimeStampPath);
                        CheckTimeStamp(outputTimeStampPath);
                        Sanity.Requires(File.Exists(outputTimeStampPath));
                        string outputTextGridPath = outputPath.Replace(".wav", ".textgrid");
                        if (File.Exists(outputTextGridPath))
                        {
                            File.Delete(outputTextGridPath);
                        }
                        TextGrid.TimeStampToTextGrid(outputTimeStampPath, outputTextGridPath);
                    }
                    catch
                    {
                        ErrorList.Add($"{outputPath}\tNo time stamp file.");
                    }
                    ReportList.Add(reportLine);
                    NewFileList.Add($"{key}\t{outputPath}");
                    if (File.Exists(intermediaPath))
                    {
                        File.Delete(intermediaPath);
                    }
                }
            }
            catch (CommonException e)
            {
                string errorMessage = $"{inputPath}\t{e.Message}";
                ErrorList.Add(errorMessage);
                Logger.WriteLineWithLock(errorMessage);
                if (File.Exists(intermediaPath))
                {
                    File.Delete(intermediaPath);
                }
                if (File.Exists(outputPath))
                {
                    File.Delete(outputPath);
                }
            }
        }
Пример #11
0
 private void OnAddReportToList()
 {
     ReportList.Add(new Report());
     DeleteReportFromListE = true;
 }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            if (IsInDesignMode)
            {
                // code runs in blend --> create design time data.
                ReportList.Add(new ReportVM {
                    ReportName = "顺丰快递"
                });
                ReportList.Add(new ReportVM {
                    ReportName = "中通快递"
                });
                ReportList.Add(new ReportVM {
                    ReportName = "圆通快递"
                });
                ReportList.Add(new ReportVM {
                    ReportName = "汇通快递"
                });
            }
            else
            {
                // code runs "for real"
                if (!Directory.Exists(Funs.StoreFolder))
                {
                    Directory.CreateDirectory(Funs.StoreFolder);
                }

                if (!File.Exists(Path.Combine(Funs.StoreFolder, "Reports.json")))
                {
                    Encoding gbk = Encoding.GetEncoding("gbk");
                    ZipStrings.CodePage = gbk.CodePage;
                    ZipFile zipFile = new ZipFile("Reports.zip");
                    for (int i = 0; i < zipFile.Count; i++)
                    {
                        var zipEntry = zipFile[i];
                        if (zipEntry.IsDirectory)
                        {
                            var folderPath = $"{Funs.StoreFolder}/{zipEntry.Name}";
                            if (!Directory.Exists(folderPath))
                            {
                                Directory.CreateDirectory(folderPath);
                            }
                            continue;
                        }

                        var filePath = $"{Funs.StoreFolder}/{zipEntry.Name}";
                        using (FileStream fs = new FileStream(filePath, FileMode.Create))
                        {
                            using (Stream input = zipFile.GetInputStream(zipEntry))
                            {
                                byte[] buffer = new byte[10 * 1024];
                                int    length = 0;
                                while ((length = input.Read(buffer, 0, 10 * 1024)) > 0)
                                {
                                    fs.Write(buffer, 0, length);
                                }
                            }
                        }
                    }
                }
            }
        }