public AnalizedTestUI(CoreFile coreFile)
 {
     InitializeComponent();
     this.coreFile  = coreFile;
     analizedRowUis = new List <AnalizedRowUI>();
     coreFile.IRowChangedObservers.Add(this);
     coreFile.ITestChangedObservers.Add(this);
 }
Example #2
0
        protected void RepairIncompleteSessions()
        {
            ArchiveFileMgr.MoveAwayBadFiles();

            string sArcPath = AppCfg.ArchivePath_Core;

            DirectoryInfo arcDi = new DirectoryInfo(sArcPath);

            FileInfo[] file_Arr = arcDi.GetFiles("*.cor*",
                                                 SearchOption.TopDirectoryOnly).OrderBy(f => f.Name).ToArray();

            //if (file_Arr.Length > 0)
            //  throw new Exception("Error! .. Some incomplete sessions found!");

            //Array.CreateInstance(

            SqlBatchMgr sbm1 = new SqlBatchMgr(
                SqlBatchMgr.ExecutionType.ExecNonQuery);

            sbm1.AddStatment(" Delete from Incomplete_CoreFiles ");

            CoreFile [] coreFile_Arr = new CoreFile[file_Arr.Length];

            for (int i = 0; i < file_Arr.Length; i++)
            {
                string sName = file_Arr[i].Name;

                int nID = int.Parse(sName.Substring(0, 10));

                coreFile_Arr[i] = new CoreFile
                {
                    FileInfo = file_Arr[i],
                    ID       = nID
                };


                string stmt =

                    " INSERT INTO Incomplete_CoreFiles " +
                    " (Incomplete_CoreFile_ID, Name) " +
                    " VALUES " +
                    " (%Incomplete_CoreFile_ID, '%Name') ";


                stmt = stmt.Replace("%Incomplete_CoreFile_ID", nID.ToString());

                stmt = stmt.Replace("%Name", sName);

                sbm1.AddStatment(stmt);
            }

            sbm1.AddStatment(" exec Sp_FixLast_FileAddingSession ");

            sbm1.ExecuteNonQuery();


            ArchiveFileMgr.MoveCoreTo_BackupFolders();
        }
Example #3
0
 public NativeRowUI(RowNative rowNative, CoreFile coreFile)
 {
     InitializeComponent();
     this.rowNative     = rowNative;
     this.coreFile      = coreFile;
     RowNumberText.Text = (rowNative.rowNumber + 1).ToString();
     NativeText.Text    = this.rowNative.content;
     coreFile.IRowChangedObservers.Add(this);
     Root.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#003300"));
 }
Example #4
0
        /// <summary>
        /// Dumps to a UTF8 encoded file.
        /// </summary>
        /// <returns>The object or a copy of the reference type.</returns>
        /// <param name="obj"></param>
        /// <param name="filename"></param>
        /// <param name="directory"></param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public static async Task <IFile> DumpToFileAsync <T>(this T obj, string filename = null, string directory = null)
        {
            try
            {
                if (filename == null)
                {
                    filename = DateTime.Now.Ticks + ".json";
                }

                var json = JsonConvert.SerializeObject(obj, Formatting.Indented);
#if NET46
                var storage = FileSystem.Current.LocalStorage;

                IFolder folder;

                if (directory != null)
                {
                    folder = await storage.CreateFolderAsync(directory, CreationCollisionOption.OpenIfExists);
                }
                else
                {
                    folder = storage;
                }

                var file = await folder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);

                await file.WriteAllTextAsync(json);

                return(file);
#else
                return(await Task.Run(() =>
                {
                    var fi = new FileInfo(filename);

                    var di = directory != null ? new DirectoryInfo(directory) : fi.Directory;

                    var path = Path.Combine(di.FullName, fi.Name);

                    IFile file = new CoreFile(path);

                    File.WriteAllText(path, json, Encoding.UTF8);

                    return file;
                }));
#endif
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                throw;
            }
        }
        public AnalizedRowUI(RowAnalized rowAnalized, CoreFile coreFile, int rowNumber, AnalizedTestUI analizedTestUi)
        {
            InitializeComponent();
            this.rowAnalized           = rowAnalized;
            this.coreFile              = coreFile;
            this.analizedTestUi        = analizedTestUi;
            WrongRadio.GroupName       = "RowType" + rowAnalized.rowId;
            CorrectRadio.GroupName     = "RowType" + rowAnalized.rowId;
            TaskRadio.GroupName        = "RowType" + rowAnalized.rowId;
            CommentRadio.GroupName     = "RowType" + rowAnalized.rowId;
            VisibleEditingTextBox.Text = rowAnalized.visibleEditedContent;
            switch (rowAnalized.rowType)
            {
            case RowType.WRONG_ANSWER:
                WrongRadio.IsChecked             = true;
                VisibleEditingTextBox.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#665f2222"));
                break;

            case RowType.CORRECT_ANSWER:
                CorrectRadio.IsChecked           = true;
                VisibleEditingTextBox.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#66003300"));
                break;

            case RowType.TASK:
                TaskRadio.IsChecked = true;
                VisibleEditingTextBox.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#66263238"));
                break;

            case RowType.COMMENT:
                CommentRadio.IsChecked           = true;
                VisibleEditingTextBox.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#66543e00"));
                break;
            }
            HiddenText.Text    = rowAnalized.hiddenContent;
            inited             = true;
            rowId              = rowAnalized.rowId;
            RowNumberText.Text = (rowNumber + 1).ToString();
            coreFile.IRowChangedObservers.Add(this);
        }
        private void OpenButton_OnClick(object sender, RoutedEventArgs e)
        {
            string json = File.ReadAllText(Path.Combine(SpecialDirectories.Desktop, "sv.json"));

            coreFile = CoreFile.Decode(json);
        }
 public MainWindow()
 {
     InitializeComponent();
     coreFile = CoreFile.GetInstance(null, tr, this);
     coreFile.AI_Analize(new FilterPatterns(FilterPatterns.task, FilterPatterns.trueAns, FilterPatterns.falseAns, false), ParseType.LINEAR);
 }
 public Stream OpenReadStream()
 {
     return(CoreFile.OpenReadStream());
 }