public void SelectAndLog()
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName = ""; // Default file name
            dlg.Filter = "geocache_visits.txt|geocache_visits.txt"; // Filter files by extension 

            // Show open file dialog box
            Nullable<bool> result = dlg.ShowDialog();

            // Process open file dialog box results 
            if (result == true)
            {
                try
                {
                    List<GeocacheVisitsItem> lst = processGeocacheVisitsFile(System.IO.File.ReadAllLines(dlg.FileName));
                    LogWindow dlg2 = new LogWindow(lst);
                    dlg2.ShowDialog();
                }
                catch (Exception e)
                {
                    Core.ApplicationData.Instance.Logger.AddLog(this, e);
                }
            }
        }
Beispiel #2
0
 private void ViewLogWindow()
 {
     var log = new LogWindow(new LogViewModel());
     log.ShowDialog();
 }
 public void ShowChatLog()
 {
     logWindow = new LogWindow() { DataContext = logs, Owner = Application.Current.MainWindow };
     logWindow.Show();
     logWindow.Closed += (s, e) => logWindow = null;
 }
Beispiel #4
0
 public static void newWindow(LogWindow lw)
 {
     _lw = lw;
 }
Beispiel #5
0
 public void ShowWindow()
 {
     window = new LogWindow();
     window.DataContext = this;
     window.Show();
 }
 void logWindow_Closed(object sender, EventArgs e)
 {
     logWindow = null;
 }
        private void LogClick(object sender, RoutedEventArgs e)
        {
            if (logWindow != null)
            {
                logWindow.Activate();
                return;
            }

            logWindow = new LogWindow();
            logWindow.Closed += new EventHandler(logWindow_Closed);
            logWindow.Show();
        }
        private void bgwCopier_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker SelfWorker = sender as BackgroundWorker;

            object[] bgwArgs  = e.Argument as object[];
            string   fromPath = bgwArgs[0] as string;
            string   concurrentDataFilesPath = bgwArgs[1] as string;
            string   toPath = bgwArgs[2] as string;
            string   imagesStatsXMLfilesDir = bgwArgs[3] as string;

            DirectoryInfo dir           = new DirectoryInfo(fromPath);
            String        destDirectory = toPath +
                                          ((toPath.Last() == Path.DirectorySeparatorChar)
                                       ? ("")
                                       : (Path.DirectorySeparatorChar.ToString()));

            if (!dir.Exists)
            {
                theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                     "Операция не выполнена. Не найдена директория:" + Environment.NewLine + fromPath +
                                                     Environment.NewLine);
                //ThreadSafeOperations.SetTextTB(tbLog, "Операция не выполнена. Не найдена директория:" + Environment.NewLine + fromPath + Environment.NewLine, true);
                return;
            }


            FileInfo[] FileList2Process = dir.GetFiles("*.jpg", SearchOption.AllDirectories);
            List <Tuple <string, string> > imagesStatsXMLfiles = new List <Tuple <string, string> >();

            if (Directory.Exists(imagesStatsXMLfilesDir))
            {
                imagesStatsXMLfiles =
                    (new DirectoryInfo(imagesStatsXMLfilesDir)).EnumerateFiles(
                        ConventionalTransitions.ImageGrIxYRGBstatsFileNamesPattern(), SearchOption.AllDirectories)
                    .ToList()
                    .ConvertAll(fInfo => new Tuple <string, string>(fInfo.Name, fInfo.FullName));
            }


            DirectoryInfo dirConcurrentDataFiles = new DirectoryInfo(concurrentDataFilesPath);
            List <Tuple <string, DateTime> > lConcurrentDataFiles =
                dirConcurrentDataFiles.EnumerateFiles(ConventionalTransitions.ImageConcurrentDataFilesNamesPattern(),
                                                      SearchOption.AllDirectories).ToList().ConvertAll(fInfo =>
            {
                // data-2015-12-15T06-12-56.0590302Z.xml
                string strDateTimeOfFile = Path.GetFileNameWithoutExtension(fInfo.Name).Substring(5, 28);
                strDateTimeOfFile        = strDateTimeOfFile.Substring(0, 11) +
                                           strDateTimeOfFile.Substring(11).Replace('-', ':');
                DateTime currFileDT = DateTime.Parse(strDateTimeOfFile, null, System.Globalization.DateTimeStyles.AdjustToUniversal);
                currFileDT          = DateTime.SpecifyKind(currFileDT, DateTimeKind.Utc);
                return(new Tuple <string, DateTime>(fInfo.FullName, currFileDT));
            });



            int filesCount = FileList2Process.Length;

            theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                 "searching in directory: " + dir.FullName + Environment.NewLine);
            //ThreadSafeOperations.SetTextTB(tbLog, "searching in directory: " + dir.FullName + Environment.NewLine, true);
            theLogWindow = ServiceTools.LogAText(theLogWindow, "files found count: " + filesCount + Environment.NewLine);
            //ThreadSafeOperations.SetTextTB(tbLog, "files found count: " + filesCount + Environment.NewLine, true);

            String usedDateTimes = "";

            List <DateTime> listUsedHours = new List <DateTime>();

            int counter = 0;

            foreach (FileInfo fileInfo in FileList2Process)
            {
                if (SelfWorker.CancellationPending)
                {
                    break;
                }
                counter++;
                double percCounter = (double)counter * 1000.0d / (double)filesCount;
                SelfWorker.ReportProgress(Convert.ToInt32(percCounter));


                Image     anImage  = Image.FromFile(fileInfo.FullName);
                ImageInfo newIInfo = new ImageInfo(anImage);
                //ThreadSafeOperations.SetTextTB(tbLog, "processing file " + fileInfo.Name + Environment.NewLine, true);


                //String curDateTime = "";
                int minute = 0;
                //String dateTime = (String)newIInfo.getValueByKey("DateTime");
                String strDateTimeEXIF = (String)newIInfo.getValueByKey("ExifDTOrig");
                if (strDateTimeEXIF == null)
                {
                    //попробуем вытащить из имени файла
                    string strDateTime = fileInfo.Name;
                    strDateTime     = strDateTime.Substring(4, 19);
                    strDateTimeEXIF = strDateTime;
                }


                //curDateTime = dateTime;
                DateTime curImgDateTime;
                DateTime theHour = RoundToHour(DateTime.UtcNow);
                try
                {
                    //curImgDateTime = DateTimeOfString(strDateTimeEXIF);
                    curImgDateTime = ConventionalTransitions.DateTimeOfSkyImageFilename(fileInfo.Name);
                    theHour        = RoundToHour(curImgDateTime);
                }
                catch (Exception ex)
                {
                    continue;
                }


                //minute = Convert.ToInt32(strDateTimeEXIF.Substring(14, 2));

                //if ((minute == 0) && (!listUsedHours.Contains(theHour)))
                if (new TimeSpan(Math.Abs((theHour - curImgDateTime).Ticks)) <= filterTolerance)
                {
                    #region copy the image file itself
                    listUsedHours.Add(theHour);

                    string dateDirectorySuffix   = curImgDateTime.ToString("yyyy-MM-dd");
                    string currDateDestDirectory = destDirectory + dateDirectorySuffix + Path.DirectorySeparatorChar;
                    if (!ServiceTools.CheckIfDirectoryExists(currDateDestDirectory))
                    {
                        currDateDestDirectory = destDirectory;
                    }



                    String newFileName = currDateDestDirectory + fileInfo.Name;
                    File.Copy(fileInfo.FullName, newFileName);
                    theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                         "COPY: " + fileInfo.FullName + "   >>>   " + newFileName + Environment.NewLine);
                    //ThreadSafeOperations.SetTextTB(tbLog, "COPY: " + fileInfo.FullName + "   >>>   " + newFileName + Environment.NewLine, true);
                    #endregion copy the image file itself


                    #region find and copy the GrIx,YRGB stats data file
                    if (imagesStatsXMLfiles.Any())
                    {
                        string xmlStatsFileName =
                            ConventionalTransitions.ImageGrIxYRGBstatsDataFileName(fileInfo.FullName, "", false);

                        Tuple <string, string> foundXMLfile =
                            imagesStatsXMLfiles.Find(tpl => tpl.Item1 == xmlStatsFileName);

                        if (foundXMLfile != null)
                        {
                            string sStatsXMLfilename   = foundXMLfile.Item2;
                            string newStatsXMLfilename = currDateDestDirectory + foundXMLfile.Item1;
                            File.Copy(sStatsXMLfilename, newStatsXMLfilename);
                            theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                                 "COPY: " + sStatsXMLfilename + "   >>>   " + newStatsXMLfilename + Environment.NewLine);
                            //ThreadSafeOperations.SetTextTB(tbLog,
                            //    "COPY: " + sStatsXMLfilename + "   >>>   " + newStatsXMLfilename + Environment.NewLine,
                            //    true);
                        }
                        else
                        {
                            theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                                 "========== ERROR: couldn`t find GrIx,YRGB stats XML file" + Environment.NewLine);
                            //ThreadSafeOperations.SetTextTB(tbLog,
                            //    "========== ERROR: couldn`t find GrIx,YRGB stats XML file" + Environment.NewLine, true);
                        }
                    }
                    #endregion find and copy the GrIx,YRGB stats data file


                    #region find and copy concurrent data XML file
                    if (lConcurrentDataFiles.Any())
                    {
                        //найдем ближайший по времени
                        List <Tuple <string, TimeSpan> > lCurrFileConcurrentDataNearest =
                            lConcurrentDataFiles.ConvertAll(
                                tpl =>
                                new Tuple <string, TimeSpan>(tpl.Item1,
                                                             new TimeSpan(Math.Abs((tpl.Item2 - curImgDateTime).Ticks))));
                        lCurrFileConcurrentDataNearest.Sort(new Comparison <Tuple <string, TimeSpan> >((tpl1, tpl2) =>
                        {
                            if (tpl1 == null)
                            {
                                if (tpl2 == null)
                                {
                                    return(0);
                                }
                                else
                                {
                                    return(-1);
                                }
                            }
                            else
                            {
                                if (tpl2 == null)
                                {
                                    return(1);
                                }
                                else
                                {
                                    return(tpl1.Item2.CompareTo(tpl2.Item2));
                                }
                            }
                        }));

                        GPSdata gps = new GPSdata();
                        Tuple <string, TimeSpan> nearestConcurrentDataFile = null;
                        int concurrentDataFileIdx = 0;

                        while (!gps.validGPSdata)
                        {
                            nearestConcurrentDataFile = lCurrFileConcurrentDataNearest[concurrentDataFileIdx];

                            Dictionary <string, object> dictSavedData = ServiceTools.ReadDictionaryFromXML(nearestConcurrentDataFile.Item1);

                            gps = new GPSdata((string)dictSavedData["GPSdata"],
                                              GPSdatasources.CloudCamArduinoGPS,
                                              DateTime.Parse((string)dictSavedData["GPSDateTimeUTC"], null,
                                                             System.Globalization.DateTimeStyles.RoundtripKind));

                            concurrentDataFileIdx++;
                        }

                        string currValidConcurrentDataFile         = nearestConcurrentDataFile.Item1;
                        string currValidConcurrentDataFileToCopyTo = currDateDestDirectory + "data-" +
                                                                     Path.GetFileNameWithoutExtension(fileInfo.FullName) + ".xml";
                        File.Copy(currValidConcurrentDataFile, currValidConcurrentDataFileToCopyTo);
                        theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                             "COPY: " + currValidConcurrentDataFile + "   >>>   " + currValidConcurrentDataFileToCopyTo +
                                                             Environment.NewLine);
                        //ThreadSafeOperations.SetTextTB(tbLog,
                        //    "COPY: " + currValidConcurrentDataFile + "   >>>   " + currValidConcurrentDataFileToCopyTo +
                        //    Environment.NewLine, true);
                    }
                    else
                    {
                        theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                             "========== ERROR: couldn`t find concurrent data file for " + fileInfo.FullName +
                                                             Environment.NewLine);
                        //ThreadSafeOperations.SetTextTB(tbLog, "========== ERROR: couldn`t find concurrent data file for " + fileInfo.FullName + Environment.NewLine, true);
                    }
                    #endregion find and copy concurrent data XML file


                    theLogWindow.ClearLog();
                }
            }
        }
Beispiel #9
0
 public WindowFileEntry(LogWindow logWindow)
 {
     LogWindow = logWindow;
 }
Beispiel #10
0
    public SampleWindow(DebugUiManager manager) : base(manager, "SampleWindow")
    {
        frameTimeWatcher = new FrameTimeWatcher();

        var button = new Button("ボタン", 100f)
        {
            OnClick = () =>
            {
                log.Add("ボタンが押された!");
            }
        };

        AddAuto(button);

        var toggleGroup = new ToggleGroup();
        var toggles     = new Toggle[2];

        toggles[0] = new Toggle("トグルA", 100f, 50f, toggleGroup)
        {
            OnChangeToOn = () =>
            {
                log.Add("Aが有効になった");
            }
        };
        AddAuto(toggles[0]);
        toggles[1] = new Toggle("トグルB", 100f, 50f, toggleGroup)
        {
            OnChangeToOn = () =>
            {
                log.Add("Bが有効になった");
            }
        };
        AddAuto(toggles[1]);

        var text = new Text("テキスト", fontSize: 20f, width: 80f, height: 25f);

        AddAuto(text);

        BreakLine();

        log = new LogWindow(
            fontSize: 20f,
            width: 600f,
            height: 220f,
            borderEnabled: true,
            captureUnityLog: true); // Unityのログも出しちゃうよ
        AddAuto(log);

        graph = new Graph(5, 200f, 220f);
        graph.AddSeries(new Color32(255, 64, 64, 255));
        AddAuto(graph);

        BreakLine();

        var frameTimeGauge = new FrameTimeGauge(200f, 30f, frameTimeWatcher);

        AddAuto(frameTimeGauge);

        var slider = new Slider("スライダー", -100f, 100f, 400f);

        slider.OnDragEnd = () =>
        {
            log.Add("スライダーが" + slider.Value + "に変更された");
        };
        AddAuto(slider);

        BreakLine();

        var table = new Table(
            16f,
            new List <float>()
        {
            80f, 80f, 120f
        },
            3,
            20f);

        table.Cells[0, 0] = "列A";
        table.Cells[0, 1] = "列B";
        table.Cells[0, 2] = "列C";
        table.Cells[1, 0] = "データ10";
        table.Cells[1, 1] = "データ11";
        table.Cells[1, 2] = "データ12";
        table.Cells[2, 0] = "データ20";
        table.Cells[2, 1] = "データ21";
        table.Cells[2, 2] = "データ23";
        AddAuto(table);

        FitSize();
    }
 public FilterListChangedEventArgs(LogWindow logWindow)
 {
     this.LogWindow = logWindow;
 }
Beispiel #12
0
        public string UploadSubtitle(long userImdbId, string subLanguageId, string subFileNamePath, Action <int> progress)
        {
            string finalUrl;

            subFileNamePath = new ChangeEncoding().TryReduceRtlLargeFileContent(subFileNamePath);
            var fileInfo = new MovieFileInfo(_movieFileName, subFileNamePath);

            //login
            if (progress != null)
            {
                progress(10);
            }

            LogWindow.AddMessage(LogType.Info, "TryLogin ...");
            tryLogin();

            if (progress != null)
            {
                progress(25);
            }

            LogWindow.AddMessage(LogType.Info, "TryUploadSubtitle ...");

            TryUploadResult res = null;

            try
            {
                res = _client.TryUploadSubtitles(_loginToken,
                                                 new[]
                {
                    new TryUploadInfo
                    {
                        subhash       = fileInfo.SubtitleHash,
                        subfilename   = fileInfo.SubFileName,
                        moviehash     = fileInfo.MovieHash,
                        moviebytesize = fileInfo.MovieFileLength,
                        moviefilename = fileInfo.MovieFileName
                    }
                }
                                                 );
            }
            catch (Exception ex)
            {
                if (!processNewMovieFile(ref userImdbId, fileInfo, ref res, ex))
                {
                    throw;
                }
            }

            if (res == null)
            {
                throw new InvalidOperationException("Bad response ...");
            }

            if (progress != null)
            {
                progress(50);
            }

            if (res.status != "200 OK")
            {
                throw new Exception("Bad response ...");
            }

            if (res.alreadyindb == 0)
            {
                if ((userImdbId == 0) && (res.data == null || res.data.Length == 0))
                {
                    throw new Exception("Bad format ...");
                }

                LogWindow.AddMessage(LogType.Info, string.Format("CheckSubHash({0})", fileInfo.SubtitleHash));
                var checkSubHashRes = _client.CheckSubHash(_loginToken, new[] { fileInfo.SubtitleHash });

                if (progress != null)
                {
                    progress(75);
                }

                var idSubtitleFile = int.Parse(checkSubHashRes.data[fileInfo.SubtitleHash].ToString());
                if (idSubtitleFile > 0)
                {
                    throw new Exception("Duplicate subHash, alreadyindb.");
                }

                LogWindow.AddMessage(LogType.Info, "PostData ...");
                //xml-rpc.net dll does not work here so, ...
                var post = PostXml.PostData(
                    ConfigSetGet.GetConfigData("OpensubtitlesOrgApiUri"),
                    UploadData.CreateUploadXml(_loginToken,
                                               new UploadBaseinfo
                {
                    idmovieimdb      = res.data != null ? res.data[0]["IDMovieImdb"].ToString() : userImdbId.ToString(),
                    sublanguageid    = subLanguageId,
                    movieaka         = string.Empty,
                    moviereleasename = fileInfo.MovieReleaseName,
                    subauthorcomment = string.Empty
                },
                                               new UploadCDsInfo
                {
                    moviebytesize = fileInfo.MovieFileLength.ToString(),
                    moviefilename = fileInfo.MovieFileName,
                    moviehash     = fileInfo.MovieHash,
                    subfilename   = fileInfo.SubFileName,
                    subhash       = fileInfo.SubtitleHash,
                    subcontent    = fileInfo.SubContentToUpload,
                    moviefps      = string.Empty,
                    movieframes   = string.Empty,
                    movietimems   = string.Empty
                }));

                LogWindow.AddMessage(LogType.Info, "Done!");
                finalUrl = RegexHelper.GetUploadUrl(post);
                LogWindow.AddMessage(LogType.Announcement, string.Format("Url: {0}", finalUrl));
            }
            else
            {
                throw new Exception("Duplicate file, alreadyindb");
            }

            if (progress != null)
            {
                progress(100);
            }
            return(finalUrl.Trim());
        }
Beispiel #13
0
        public SubtitlesSearchResult GetListOfAllSubtitles(Action <int> progress, string subLanguageId = "all")
        {
            var fileInfo = new MovieFileInfo(_movieFileName, subFileName: string.Empty);
            //get file info
            var movieHash = fileInfo.MovieHash;

            LogWindow.AddMessage(LogType.Info, string.Format("MovieHash: {0}", movieHash));
            var fileLen = fileInfo.MovieFileLength;

            //login
            if (progress != null)
            {
                progress(25);
            }

            LogWindow.AddMessage(LogType.Info, "TryLogin ...");
            tryLogin();

            if (progress != null)
            {
                progress(50);
            }

            //has any subtitle?
            var token              = _loginToken;
            var hashInfo           = _client.CheckMovieHash2(token, new[] { movieHash });
            var tryConvertToObjArr = hashInfo.data as object[];

            if ((tryConvertToObjArr != null) && (tryConvertToObjArr.Length == 0))
            {
                throw new Exception("This movie has not any subtitle.");
            }

            if (progress != null)
            {
                progress(75);
            }

            LogWindow.AddMessage(LogType.Info, "SearchSubtitles ... ");

            //get more info
            SubtitlesSearchResult result;

            try
            {
                result = _client.SearchSubtitles(
                    token,
                    new[]
                {
                    new SearchInfo
                    {
                        moviehash     = movieHash,
                        sublanguageid = subLanguageId,
                        moviebytesize = fileLen
                    }
                }
                    );
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogExceptionToFile(ex);
                LogWindow.AddMessage(LogType.Alert, "Found Nothing!");
                if (progress != null)
                {
                    progress(100);
                }
                return(null);
            }

            if (result != null && result.data != null && result.data.Length > 0)
            {
                LogWindow.AddMessage(LogType.Announcement, string.Format("Found {0} Subtitle(s).", result.data.Length));
            }
            else
            {
                LogWindow.AddMessage(LogType.Alert, "Found Nothing!");
            }

            if (progress != null)
            {
                progress(100);
            }

            return(result);
        }
Beispiel #14
0
 public void OpenLogWindow()
 {
     LogWindow     lw = new LogWindow();
     LogModel      lm = new LogModel(model.AdminPass, model.SetupInfo.Ip);
     LogController lc = new LogController(lw, lm);
 }
        private void BgwSnapshotsFilteringWithSunElevation_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker selfWorker = sender as BackgroundWorker;

            object[] bgwArgs                 = e.Argument as object[];
            string   SnapshotsBasePath       = bgwArgs[0] as string;
            string   concurrentDataFilesPath = bgwArgs[1] as string;
            string   directoryToMoveFilesTo  = bgwArgs[2] as string;

            DirectoryInfo srcDir = new DirectoryInfo(SnapshotsBasePath);

            if (!srcDir.Exists)
            {
                theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                     "Операция не выполнена. Не найдена директория:" + Environment.NewLine + SnapshotsBasePath +
                                                     Environment.NewLine);
                //ThreadSafeOperations.SetTextTB(tbLog, "Операция не выполнена. Не найдена директория:" + Environment.NewLine + fromPath + Environment.NewLine, true);
                return;
            }


            List <FileInfo> lFileList2Process = srcDir.GetFiles("*.jpg", SearchOption.AllDirectories).ToList();
            List <FileInfoWithSnapshotDateTime> lSnapshotsInfos =
                lFileList2Process.ConvertAll(finfo => new FileInfoWithSnapshotDateTime(finfo));


            #region read concurrent data from XML files

            theLogWindow = ServiceTools.LogAText(theLogWindow, "started concurrent data reading");

            List <Tuple <string, ConcurrentData> > lImagesConcurrentData = new List <Tuple <string, ConcurrentData> >();

            List <string> filesListConcurrentData =
                new List <string>(Directory.EnumerateFiles(concurrentDataFilesPath,
                                                           ConventionalTransitions.ImageConcurrentDataFilesNamesPattern(), SearchOption.AllDirectories));

            int totalFilesCountToRead = filesListConcurrentData.Count;
            int filesRead             = 0;
            int currProgressPerc      = 0;
            selfWorker.ReportProgress(0);
            List <Dictionary <string, object> > lDictionariesConcurrentData = new List <Dictionary <string, object> >();
            foreach (string strConcDataXMLFile in filesListConcurrentData)
            {
                Dictionary <string, object> currDict = ServiceTools.ReadDictionaryFromXML(strConcDataXMLFile);
                currDict.Add("XMLfileName", Path.GetFileName(strConcDataXMLFile));

                lDictionariesConcurrentData.Add(currDict);

                #region calculate and report progress

                filesRead++;
                double progress = 100.0d * (double)filesRead / (double)totalFilesCountToRead;
                if (progress - (double)currProgressPerc > 1.0d)
                {
                    currProgressPerc = Convert.ToInt32(progress);
                    selfWorker.ReportProgress(currProgressPerc);
                }

                if (selfWorker.CancellationPending)
                {
                    return;
                }

                #endregion calculate and report progress
            }
            lDictionariesConcurrentData.RemoveAll(dict => dict == null);


            List <ConcurrentData> lConcurrentData =
                lDictionariesConcurrentData.ConvertAll <ConcurrentData>(dict =>
            {
                ConcurrentData retVal = null;
                try
                {
                    retVal = new ConcurrentData(dict);
                    GPSdata gpsOfGPSstring = new GPSdata((string)dict["GPSdata"], GPSdatasources.CloudCamArduinoGPS,
                                                         retVal.datetimeUTC.Date);
                    if (!gpsOfGPSstring.validGPSdata)
                    {
                        throw new Exception("invalid GPS data");
                    }
                }
                catch (Exception ex)
                {
                    string strError = "couldn`t parse XML file " + dict["XMLfileName"] + " : " +
                                      Environment.NewLine + ex.Message;
                    return(null);
                }

                if (retVal.gps.validGPSdata)
                {
                    return(retVal);
                }
                else
                {
                    return(null);
                }
            });
            lConcurrentData.RemoveAll(val => val == null);



            // map obtained concurrent data to images by its datetime
            theLogWindow = ServiceTools.LogAText(theLogWindow, "started concurrent data mapping");
            int totalrecordsToMap = lSnapshotsInfos.Count;
            int recordsMapped     = 0;
            currProgressPerc = 0;
            selfWorker.ReportProgress(0);
            foreach (FileInfoWithSnapshotDateTime info in lSnapshotsInfos)
            {
                DateTime currImgDT = info.dateTime;

                ConcurrentData nearestConcurrentData = lConcurrentData.Aggregate((cDt1, cDt2) =>
                {
                    TimeSpan tspan1 = new TimeSpan(Math.Abs((cDt1.datetimeUTC - currImgDT).Ticks));
                    TimeSpan tspan2 = new TimeSpan(Math.Abs((cDt2.datetimeUTC - currImgDT).Ticks));
                    return((tspan1 <= tspan2) ? (cDt1) : (cDt2));
                });


                if (new TimeSpan(Math.Abs((nearestConcurrentData.datetimeUTC - currImgDT).Ticks)) <=
                    TimeSpanForConcurrentDataMappingTolerance)
                {
                    info.concurrentData = nearestConcurrentData;
                }

                #region calculate and report progress

                recordsMapped++;
                double progress = 100.0d * (double)recordsMapped / (double)totalrecordsToMap;
                if (progress - (double)currProgressPerc > 1.0d)
                {
                    currProgressPerc = Convert.ToInt32(progress);
                    selfWorker.ReportProgress(currProgressPerc);
                }

                if (selfWorker.CancellationPending)
                {
                    return;
                }

                #endregion calculate and report progress
            }

            #endregion read concurrent data from XML files

            List <FileInfo> filesToMove = new List <FileInfo>();
            filesToMove.AddRange(
                lSnapshotsInfos.Where(inf => inf.concurrentData == null).ToList().ConvertAll(inf => inf.finfo));
            lSnapshotsInfos.RemoveAll(inf => inf.concurrentData == null);

            filesToMove.AddRange(lSnapshotsInfos.Where(inf =>
            {
                GPSdata currGPS = new GPSdata(inf.concurrentData.GPSdata, GPSdatasources.CloudCamArduinoGPS,
                                              inf.dateTime.Date);
                var spa = currGPS.SunZenithAzimuth();
                return(spa.ZenithAngle >= 85.0);
            }).ToList().ConvertAll(inf => inf.finfo));


            totalFilesCountToRead = filesToMove.Count;
            filesRead             = 0;
            currProgressPerc      = 0;
            selfWorker.ReportProgress(0);
            foreach (FileInfo inf in filesToMove)
            {
                #region calculate and report progress

                filesRead++;
                double progress = 100.0d * (double)filesRead / (double)totalFilesCountToRead;
                if (progress - (double)currProgressPerc > 1.0d)
                {
                    currProgressPerc = Convert.ToInt32(progress);
                    selfWorker.ReportProgress(currProgressPerc);
                }

                if (selfWorker.CancellationPending)
                {
                    return;
                }

                #endregion calculate and report progress

                string strFilenameMoveTo = directoryToMoveFilesTo +
                                           ((directoryToMoveFilesTo.Last() == Path.DirectorySeparatorChar)
                    ? ("")
                    : (Path.DirectorySeparatorChar.ToString()));

                string currImgFilenameRelPath = ConventionalTransitions.MakeRelativePath(inf.FullName, SnapshotsBasePath);
                strFilenameMoveTo += currImgFilenameRelPath;

                theLogWindow = ServiceTools.LogAText(theLogWindow, "moving " + inf.FullName);

                if (!ServiceTools.CheckIfDirectoryExists(strFilenameMoveTo))
                {
                    theLogWindow = ServiceTools.LogAText(theLogWindow,
                                                         "Unable to move file " + Environment.NewLine + inf.FullName + Environment.NewLine + "to:" +
                                                         Environment.NewLine + strFilenameMoveTo + Environment.NewLine +
                                                         "Directory couldn`t be located or created");
                    continue;
                }

                File.Move(inf.FullName, strFilenameMoveTo);
            }

            selfWorker.ReportProgress(0);
        }
Beispiel #16
0
 private void logsButton_Click(object sender, RoutedEventArgs e)
 {
     var logsWindow = new LogWindow();
 }
 private void MenuItem_Log_Click(object sender, RoutedEventArgs e)
 {
     if (_logWindow == null)
     {
         _logWindow = new LogWindow();
         _logWindow.Closed += (sender2, e2) => { _logWindow = null; };
         _logWindow.Show();
     }
     else
     {
         _logWindow.Activate();
     }
 }
Beispiel #18
0
 public void SetWindow(LogWindow logWindow) => _logWindow = logWindow;