public LabelSettings(FileList form_instance)
 {
     InitializeComponent();
     form1 = form_instance;
     waitTime.Value = form1.wait_time/1000;
     if (form1.move_to_archive == true)
     {
         moveOnButton.Enabled = false;
         moveOffButton.Enabled = true;
     }
     else
     {
         moveOnButton.Enabled = true;
         moveOffButton.Enabled = false;
     }
     width.Value = System.Convert.ToDecimal(form1.width);
     height.Value = System.Convert.ToDecimal(form1.height);
     if (System.Convert.ToDecimal(form1.dpmm) < 8)
     {
         dpi.SelectedIndex = 0;
     }
     else if (System.Convert.ToDecimal(form1.dpmm) < 10)
     {
         dpi.SelectedIndex = 1;
     }
     else if (System.Convert.ToDecimal(form1.dpmm) < 18)
     {
         dpi.SelectedIndex = 2;
     }
     else
     {
         dpi.SelectedIndex = 3;
     }
 }
Esempio n. 2
0
 public static ISet<FileDetails> GetEntireDirectoryTreeFileNames()
 {
     var fs = new FileList();
     fs.AddChildFiles(CurrentDir);
     fs._files.TrimExcess();
     return fs._files;
 }
Esempio n. 3
0
 public FileListVM(OpenFileListVM owner, FileList fileList, bool isExistingList, bool isUserList)
 {
     this.owner = owner;
     this.fileList = fileList;
     this.isExistingList = isExistingList;
     this.isUserList = isUserList;
 }
Esempio n. 4
0
        public FileListCommands(FileList flist, FileListViewModel rootModel)
        {
            Func<ExModel[]> getSelectionFunc = new Func<ExModel[]>(() =>
            { return (from vm in rootModel.CurrentDirectoryModel.SelectedViewModels select vm.EmbeddedModel).ToArray(); });
            Func<DirectoryModel> getCurrentFunc = new Func<DirectoryModel>(() => { return rootModel.CurrentDirectoryModel.EmbeddedDirectoryModel; });
            Func<System.Drawing.Point> getMousePositionFunc = new Func<System.Drawing.Point>(() =>
            { Point pt = flist.PointToScreen(Mouse.GetPosition(flist)); return new System.Drawing.Point((int)pt.X, (int)pt.Y); });

            SetupCommands(getSelectionFunc, getCurrentFunc, getMousePositionFunc);
            SetupCommands(flist, rootModel);

            SimpleRoutedCommand.Register(typeof(FileList), RefreshCommand);
            SimpleRoutedCommand.Register(typeof(FileList), ContextMenuCommand);
            SimpleRoutedCommand.Register(typeof(FileList), NewFolderCommand);
            SimpleRoutedCommand.Register(typeof(FileList), OpenCommand, new KeyGesture(Key.Enter));
            SimpleRoutedCommand.Register(typeof(FileList), CopyCommand);
            SimpleRoutedCommand.Register(typeof(FileList), PasteCommand);
            SimpleRoutedCommand.Register(typeof(FileList), SelectAllCommand, new KeyGesture(Key.A, ModifierKeys.Control));
            SimpleRoutedCommand.Register(typeof(FileList), DeleteCommand, new KeyGesture(Key.Delete));
            SimpleRoutedCommand.Register(typeof(FileList), PropertiesCommand);
            SimpleRoutedCommand.Register(typeof(FileList), RenameCommand, new KeyGesture(Key.F2));
            SimpleRoutedCommand.Register(typeof(FileList), FindCommand, new KeyGesture(Key.F, ModifierKeys.Control));

            flist.AddHandler(TreeViewItem.MouseRightButtonUpEvent, new MouseButtonEventHandler(
                (MouseButtonEventHandler)delegate(object sender, MouseButtonEventArgs args)
                {
                    ApplicationCommands.ContextMenu.Execute(null, flist);
                }));
        }
Esempio n. 5
0
        private void fileListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (FileListForm == null)
                FileListForm = new FileList();

            FileListForm.ShowDialog();
        }
 public static IAppsClient ThatGetsFileList(this IAppsClient @this, AppIdentifier app, string version,
     FileListingOptions options, FileList fileList)
 {
     Mock.Get(@this).Setup(x => x.ListFilesAsync(app, version,
         It.Is<FileListingOptions>(arg => arg.Equals(options)),
         It.IsAny<CancellationToken>()))
         .ReturnsAsync(fileList);
     return @this;
 }
Esempio n. 7
0
 public FileSelectWindow()
 {
     complete = filter = false;
     draw = false;
     location = previousLocation = Application.dataPath;
     directorySelection = new DirectoryInfo(location);
     DirectoryList = new FileList("Directories");
     FileList = new FileList("Files");
 }
 public static IExtendedWorkspacesClient ThatGetsFileList(this IExtendedWorkspacesClient @this, string account,
     string workspace, FileListingOptions options, FileList fileList)
 {
     Mock.Get(@this).Setup(x => x.ListFilesAsync(account, workspace,
         It.Is<FileListingOptions>(arg => arg.Equals(options)),
         It.IsAny<CancellationToken>()))
         .ReturnsAsync(fileList);
     return @this;
 }
Esempio n. 9
0
 public static string CKPlayer(FileList file, string ParentPath = "", int width = 600, int height = 480)
 {
     StringBuilder stringBuilder = new StringBuilder();
     bool flag = Operators.CompareString(SafeData.s_string(file.IndexImagePath), "", false) == 0;
     if (flag)
     {
         file.IndexImagePath = "images/video.jpg";
     }
     flag = file.Path.Contains("../");
     if (flag)
     {
         file.Path = file.Path.Replace("../", ParentPath);
     }
     else
     {
         file.Path = ParentPath + file.Path;
     }
     flag = file.IndexImagePath.Contains("../");
     if (flag)
     {
         file.IndexImagePath = file.IndexImagePath.Replace("../", ParentPath);
     }
     else
     {
         file.IndexImagePath = ParentPath + file.IndexImagePath;
     }
     stringBuilder.AppendLine(" <div id=\"a1" + Conversions.ToString(file.FileId) + "\"></div>");
     stringBuilder.AppendLine(" <script type=\"text/javascript\">");
     stringBuilder.AppendLine(" var flashvars" + Conversions.ToString(file.FileId) + " = {");
     stringBuilder.AppendLine(" f:      '" + file.Path + "',");
     stringBuilder.AppendLine(" c: 0,");
     stringBuilder.AppendLine(" loaded:  'loadedHandler'");
     stringBuilder.AppendLine(" };");
     stringBuilder.AppendLine(string.Concat(new string[]
     {
         "  var video",
         Conversions.ToString(file.FileId),
         " = ['",
         file.Path,
         "->video/mp4'];"
     }));
     stringBuilder.AppendLine(string.Concat(new string[]
     {
         " CKobject.embed('Plugins/ckplayer6.6/ckplayer/ckplayer.swf', 'a1",
         Conversions.ToString(file.FileId),
         "', 'ckplayer_a1",
         Conversions.ToString(file.FileId),
         "', '990', '480', false, flashvars",
         Conversions.ToString(file.FileId),
         ", video",
         Conversions.ToString(file.FileId),
         ");"
     }));
     stringBuilder.AppendLine(" </script>");
     return stringBuilder.ToString();
 }
Esempio n. 10
0
 public Screen(IMDbgShell shell)
 {
     Console.WindowWidth = 100;
     _Shell = shell;
     _OldIo = _Shell.IO;
     _CurrentMenu = _MainMenu;
     _FileList = new FileList(shell, Console.WindowHeight - 7);
     _VariableView = new VariableViewer(_Shell, "#vars#");
     _Buffers.Add(_CommandView);
 }
Esempio n. 11
0
        static ConnectionManager()
        {
            config = new NetPeerConfiguration("CWRUShare");
            config.AutoFlushSendQueue = true;
            config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
            config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
            config.EnableMessageType(NetIncomingMessageType.Data);
            config.SetMessageTypeEnabled(NetIncomingMessageType.UnconnectedData, true);
            currentListView = new FileList();
            isListUpdated = false;

            config.Port = 14242;
            isConnected = false;

            server = new NetServer(config);
            server.Start();
        }
            public async Task Return_from_archive()
            {
                // Arrange
                var archive = new FileList(new Dictionary<string, FileListItem>
                {
                    ["some/file.txt"] = new FileListItem(AnyHash, AnySize, "abc 123", ContentEncoding.Utf8)
                });
                var connector = new TestableAppsContextConnector("some", new string[0])
                    .WithApp(new App("acme", "vanilla", "1.2.3"))
                    .WithArchive("acme.vanilla", "1.2.3", archive);

                // Act
                var file = await connector.GetFileAsync("acme.vanilla", "some/file.txt", None);

                // Assert
                file.App.ShouldBe("acme.vanilla");
                file.Path.ShouldBe("some/file.txt");
                file.Content.ShouldBe(Encoding.UTF8.GetBytes("abc 123"));
                connector.CachedFiles["acme.vanilla:some/file.txt"].ShouldBeSameAs(file);
            }
    private TreeNode AddNodes(string path,TreeNode parentNode)
    {
        FileList objList = new FileList(path, "*.*");
        TreeNode node = new TreeNode(path,path);
        for(int index = 0 ; index < objList.Directories.Length ; index++)
        {
            string directory = objList.Directories[index];
            TreeNode objChildNode = new TreeNode(directory, path + "\\" + directory + "\\");
            objChildNode.PopulateOnDemand = true;
            objChildNode.Target = "_blank";

            parentNode.ChildNodes.Add(objChildNode);
        }
        foreach (string file in objList.Files)
        {
            TreeNode objChildNode = new TreeNode(file, path + "\\" + file);
            parentNode.ChildNodes.Add(objChildNode);
        }
        return node;
    }
Esempio n. 14
0
 public static IEnumerable<string> GetFiles(Dictionary<string, string> filterAttrs, int maxCount = int.MaxValue)
 {
     string type;
     if (!filterAttrs.TryGetValue("type", out type) || !new[] { "narrowPeak", "broadPeak" }.Contains(type))
         throw new ArgumentException("Тип данных эксперимента должен быть narrowPeak либо broadPeak.");
     var flistPath = GetFileListPath();
     var flist = new FileList(flistPath);
     var dir = GetDir();
     int cnt = 0;
     foreach (var item in flist.Items.Where(p => p.Filter(filterAttrs)))
     {
         Console.Write("[" + ++cnt + "], " + item.FileName + ":");
         var path = DownloadFile(item, dir);
         if (path.EndsWith(".gz"))
             path = UnpackFile(path);
         Console.WriteLine();
         yield return path;
         if(cnt == maxCount)
             yield break;
     }
 }
Esempio n. 15
0
    public Solution(string path)
    {
      string baseDir = Path.GetDirectoryName(path);
      

      FileList solution = new FileList("Project(", ".csproj", ',');

      string[] projectFiles = solution.GetList(path);

      FileList project = new FileList("Compile Include=", ".cs", '"');

      _projects = new List<CSProject>();

      for(int i=0; i < projectFiles.Length; i++)
      {
        CSProject csProject = new CSProject();
        csProject.dir = Path.GetDirectoryName(Path.Combine(baseDir, projectFiles[i]));
        csProject.name = projectFiles[i];
        csProject.csList = project.GetList(Path.Combine(baseDir, projectFiles[i]));
        _projects.Add(csProject);
      }
    }
Esempio n. 16
0
        public MainWindow()
        {
            InitializeComponent();

          
            upload.DoWork += new DoWorkEventHandler(upload_DoWork);
            upload.RunWorkerCompleted += new RunWorkerCompletedEventHandler(upload_RunWorkerCompleted);

            download.DoWork += new DoWorkEventHandler(download_DoWork);
            download.RunWorkerCompleted += new RunWorkerCompletedEventHandler(download_RunWorkerCompleted);

            downloadDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\CWRUShare\\";
            // Get the c:\ directory.

            users = new UserList();

            //users.AddUser("192.168.1.1");

            fileList = new FileList();

            fileList.PopulateFileList(downloadDirectory);

            thisAddress = (Dns.GetHostEntry(Dns.GetHostName())).AddressList[0];

            foreach (IPAddress address in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
            {
                if (address.AddressFamily == AddressFamily.InterNetwork)
                {
                    thisAddress = address;
                    break;
                }
            }

            ConnectionManager.Listen(new SendOrPostCallback(Listener));
            ConnectionManager.SetUserList(users);
            ConnectionManager.SetThisFileList(fileList);

        }
Esempio n. 17
0
        void TestDataAssay()
        {
            List<string> exts = new List<string>() { ".dat", ".cnn" };
            FileList<TestDataFile> hdlr = new FileList<TestDataFile>();
            hdlr.Init(exts, ctrllog);
            FileList<TestDataFile> files = null;

            // initialize operation timer here
            NC.App.Opstate.ResetTimer(0, filegather, files, 170, (int)NC.App.AppContext.StatusTimerMilliseconds);
            FireEvent(EventType.ActionPrep, this);
            NC.App.Opstate.StampOperationStartTime();

            if (NC.App.AppContext.FileInputList == null)
                files = (FileList<TestDataFile>)hdlr.BuildFileList(NC.App.AppContext.FileInput, NC.App.AppContext.Recurse, true);
            else
                files = (FileList<TestDataFile>)hdlr.BuildFileList(NC.App.AppContext.FileInputList);
            if (files == null || files.Count < 1)
            {
                NC.App.Opstate.StopTimer(0);
                NC.App.Opstate.StampOperationStopTime();
                FireEvent(EventType.ActionStop, this);
                ctrllog.TraceEvent(LogLevels.Warning, 33085, "No useable Test data/Disk .dat files found");
                return;
            }

            AcquireParameters orig_acq = new AcquireParameters(NC.App.Opstate.Measurement.AcquireState);
            Detector curdet = NC.App.Opstate.Measurement.Detectors[0];
            AssaySelector.MeasurementOption mo = NC.App.Opstate.Measurement.MeasOption;

            // Each .dat file is a separate measurement 
            foreach (TestDataFile td in files)
            {
                Measurement meas = null;
                ResetMeasurement();

                try
                {
                    if (!td.OpenForReading())
                        continue;
                    if (NC.App.Opstate.IsQuitRequested)
                        break;
                    UInt32 run_seconds;

                    UInt16 number_good_runs = 0;
                    UInt16 total_number_runs = 0;
                    double run_count_time = 0;
                    double total_good_count_time = 0;

                    if (mo != AssaySelector.MeasurementOption.holdup)
                    {
                        /* number of good runs */
                        string l = td.reader.ReadLine();
                        UInt16.TryParse(l, out number_good_runs);
                        if (number_good_runs == 0)
                        {
                            ctrllog.TraceEvent(LogLevels.Error, 440, "This measurement has no good cycles.");
                            continue;
                        }
                        /* run count time */
                        l = td.reader.ReadLine();
                        Double.TryParse(l, out run_count_time);
                        if (run_count_time <= 0.0)
                        {
                            ctrllog.TraceEvent(LogLevels.Error, 441, "Count time is <= 0.");
                            continue;
                        }
                    }

                    // update acq and then meas here
                    AcquireParameters newacq = ConfigureAcquireState(curdet, orig_acq, DateTimeOffset.Now, number_good_runs, td.Filename);
                    IntegrationHelpers.BuildMeasurement(newacq, curdet, mo);
                    meas = NC.App.Opstate.Measurement;
                    meas.MeasDate = newacq.MeasDateTime;
                    meas.Persist();  // preserve the basic results record

                    /* convert to total count time */
                    total_number_runs = number_good_runs;
                    total_good_count_time = (double)number_good_runs *
                        run_count_time;
                    meas.RequestedRepetitions = total_number_runs;

                    // update the acq status and do the persist

                    /* read in run data */
                    for (int i = 0; i < number_good_runs; i++)
                    {
                        /* run date and time (IAEA format) */
                        run_seconds = (UInt32)(i * (UInt16)run_count_time); // from start time
                        AddTestDataCycle(i, run_seconds, run_count_time, meas, td);
                        if (i % 8 == 0)
                            FireEvent(EventType.ActionInProgress, this);
                    }
                    FireEvent(EventType.ActionInProgress, this);

                    if (meas.MeasOption == AssaySelector.MeasurementOption.verification &&
                        meas.INCCAnalysisState.Methods.Has(AnalysisMethod.AddASource) &&
                        meas.AcquireState.well_config == WellConfiguration.Passive)
                    {
                        AddASourceSetup aass = IntegrationHelpers.GetCurrentAASSParams(meas.Detectors[0]);
                        for (int n = 1; n <= aass.number_positions; n++)
                        {
                            /* number of good runs */
                            string l = td.reader.ReadLine();
                            if (td.reader.EndOfStream)
                            {
                                ctrllog.TraceEvent(LogLevels.Error, 440, "No add-a-source data found in disk file. " + "AAS p" + n.ToString());
                            }
                            UInt16.TryParse(l, out number_good_runs);
                            if (number_good_runs == 0)
                            {
                                ctrllog.TraceEvent(LogLevels.Error, 440, "This measurement has no good cycles. " + "AAS p" + n.ToString());
                                continue;
                            }
                            /* run count time */
                            l = td.reader.ReadLine();
                            Double.TryParse(l, out run_count_time);
                            if (run_count_time <= 0.0)
                            {
                                ctrllog.TraceEvent(LogLevels.Error, 441, "Count time is <= 0. " + "AAS p" + n.ToString());
                                continue;
                            }
                            /* read in run data */
                            for (int i = 0; i < number_good_runs; i++)
                            {
                                /* run date and time (IAEA format) */
                                run_seconds = (UInt32)((n + 1) * (i + 1) * (UInt16)run_count_time); // from start time
                                AddTestDataCycle(i, run_seconds, run_count_time, meas, td, " AAS p" + n.ToString(), n);
                                if (i % 8 == 0)
                                    FireEvent(EventType.ActionInProgress, this);
                            }
                            FireEvent(EventType.ActionInProgress, this);
                        }
                    }
                }
                catch (Exception e)
                {
                    NC.App.Opstate.SOH = NCC.OperatingState.Trouble;
                    ctrllog.TraceException(e, true);
                    ctrllog.TraceEvent(LogLevels.Error, 437, "Test data file processing stopped with error: '" + e.Message + "'");
                }
                finally
                {
                    td.CloseReader();
                    NC.App.Loggers.Flush();
                }
                FireEvent(EventType.ActionInProgress, this);
                ComputeFromINCC5SRData(meas);
                FireEvent(EventType.ActionInProgress, this);
            }

            NC.App.Opstate.ResetTokens();
            NC.App.Opstate.SOH = NCC.OperatingState.Stopping;
            NC.App.Opstate.StampOperationStopTime();
            FireEvent(EventType.ActionStop, this);
        }
Esempio n. 18
0
 internal static IEnumerable<FileEntry> ProcessIncludes(FileList thisInstance, dynamic rule, string name,IEnumerable<Rule> fileRules, string root)
 {
     return ProcessIncludes(thisInstance, rule, name, "include", fileRules, root);
 }
Esempio n. 19
0
        private static IEnumerable<FileEntry> ProcessExcludes(IEnumerable<FileEntry> fileEntries, FileList thisInstance, dynamic rule, string name, IEnumerable<Rule> fileRules, string root)
        {
            var excludes = rule.exclude.Values;

            foreach (string exclude in excludes) {
                // first check to see if the exclude is another file list
                if (fileRules.GetRulesByParameter(exclude).Any()) {
                    var excludedList = GetFileList(exclude, fileRules);
                    if (excludedList == null) {
                        AutopackageMessages.Invoke.Error(
                            MessageCode.DependentFileListUnavailable, rule.SourceLocation,
                            "File list '{0}' depends on file list '{1}' which is not availible.", name, exclude);
                        continue;
                    }
                    if (excludedList == thisInstance) {
                        // already complained about circular reference.
                        continue;
                    }

                    // get just the file names
                    var excludedFilePaths = excludedList.FileEntries.Select(each => each.SourcePath);

                    // remove any files in our list that are in the list we're given
                    fileEntries = fileEntries.Where(fileEntry => !excludedFilePaths.Contains(fileEntry.SourcePath));
                    continue;
                }

                // otherwise, see if the the exclude string is a match for anything in the fileset.
                fileEntries = fileEntries.Where(each => !each.SourcePath.NewIsWildcardMatch(exclude, true, root));
            }
            return fileEntries;
        }
Esempio n. 20
0
        private string?GetFilenameInternal(int index)
        {
            var prefix      = string.Empty;
            var entry       = default(RDBEntry);
            var selectedRdb = default(RDB);

            foreach (var rdb in RDBs)
            {
                if (index >= rdb.Entries.Count)
                {
                    index -= rdb.Entries.Count;
                    continue;
                }

                prefix      = rdb.Name;
                entry       = rdb.GetEntry(index);
                selectedRdb = rdb;
                break;
            }

            if (selectedRdb == null)
            {
                return(null);
            }

            if (!selectedRdb.NameDatabase.ExtMap.TryGetValue(entry.TypeInfoKTID, out var ext) && (!ExtList.TryGetValue(entry.TypeInfoKTID, out ext) || string.IsNullOrEmpty(ext)))
            {
                ext = selectedRdb.NameDatabase.HashMap.TryGetValue(entry.TypeInfoKTID, out ext) ? ext.Split(':').Last() : entry.TypeInfoKTID.ToString("x8");
            }

            prefix += $@"\{ext}";

            if ((!selectedRdb.NameDatabase.NameMap.TryGetValue(entry.FileKTID, out var path) || string.IsNullOrWhiteSpace(path)) && (!FileList.TryGetValue(entry.FileKTID, out path) || string.IsNullOrWhiteSpace(path)))
            {
                path = $"{entry.FileKTID:x8}.{ext}";
            }
Esempio n. 21
0
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new FileList();
 }
            public void Throw_error_when_file_does_not_exist_in_archive()
            {
                // Arrange
                var archive = new FileList(new Dictionary<string, FileListItem>());
                var connector = new TestableAppsContextConnector("some", new string[0])
                    .WithApp(new App("acme", "vanilla", "1.2.3"))
                    .WithArchive("acme.vanilla", "1.2.3", archive);

                // Act & Assert
                Should.Throw<AppFileNotFoundException>(() =>
                    connector.GetFileAsync("acme.vanilla", "some/file.txt", None));
            }
Esempio n. 23
0
		public OpenFileListVM(bool syntaxHighlight, FileListManager fileListManager, Func<string, string> askUser) {
			this.syntaxHighlight = syntaxHighlight;
			this.fileListManager = fileListManager;
			this.askUser = askUser;
			this.fileListColl = new ObservableCollection<FileListVM>();
			this.collectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(fileListColl);
			this.collectionView.CustomSort = new FileListVM_Comparer();
			this.selectedItems = new FileListVM[0];
			this.removedFileLists = new HashSet<FileListVM>();
			this.addedFileLists = new List<FileListVM>();
			this.cancellationTokenSource = new CancellationTokenSource();
			this.searchingForDefaultLists = true;

			var hash = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			foreach (var fileList in fileListManager.FileLists) {
				hash.Add(fileList.Name);
				fileListColl.Add(new FileListVM(this, fileList, true, true));
			}
			Refilter();

			Task.Factory.StartNew(() => new DefaultFileListFinder(cancellationTokenSource.Token).Find(), cancellationTokenSource.Token)
			.ContinueWith(t => {
				var ex = t.Exception;
				SearchingForDefaultLists = false;
				if (!t.IsCanceled && !t.IsFaulted) {
					foreach (var defaultList in t.Result) {
						if (hash.Contains(defaultList.Name))
							continue;
						var fileList = new FileList(defaultList);
						fileListColl.Add(new FileListVM(this, fileList, false, false));
					}
					Refilter();
				}
			}, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
		}
Esempio n. 24
0
 private void ItemManipulationModel_FocusSelectedItemsInvoked(object sender, EventArgs e)
 {
     FileList.ScrollIntoView(FileList.Items.Last());
 }
Esempio n. 25
0
 public override void OnDirectory(FileList fileList, string dir, uint directoriesRemaining)
 {
     RakNetPINVOKE.CSharp_RakNet_FLP_Printf_OnDirectory(swigCPtr, FileList.getCPtr(fileList), dir, directoriesRemaining);
 }
Esempio n. 26
0
 protected void Page_Init(object sender, EventArgs e)
 {
     if (!(CurrentUser = Request.GetUser()).Browse)
     {
         Response.StatusCode = 401;
         return;
     }
     if (InfoDirectory.Exists)
     {
         Views.SetActiveView(DirectoryView);
         if (IsPostBack)
         {
             return;
         }
         var dirs = InfoDirectory.EnumerateDirectories().ToList();
         DirectoryList.DataSource = dirs;
         DirectoryList.DataBind();
         DirectoryCount = dirs.Count.ToString(CultureInfo.InvariantCulture);
         var files = InfoDirectory.EnumerateFiles().ToList();
         FileList.DataSource = files;
         FileList.DataBind();
         FileCount            = files.Count.ToString(CultureInfo.InvariantCulture);
         ArchiveFilePath.Text = string.IsNullOrWhiteSpace(RelativePath) ? "Files.7z" : (RelativePath + ".7z");
     }
     else if (InfoFile.Exists)
     {
         string dataPath = FileHelper.GetDataFilePath(RelativePath), state = FileHelper.GetFileValue(dataPath, "state");
         Task = GenerateFileTask.Create(RelativePath);
         if (Task == null)
         {
             if (state == TaskType.NoTask)
             {
                 if (Request.IsAjaxRequest())
                 {
                     Response.Redirect(Request.RawUrl, true);                          // processing is finished
                 }
                 Views.SetActiveView(FileView);
                 Mime = FileHelper.GetDefaultMime(dataPath);
                 RefreshFile();
             }
             else
             {
                 Views.SetActiveView(GeneralTaskProcessingView);
             }
         }
         else if (state == TaskType.UploadTask)
         {
             Views.SetActiveView(FileUploadingView);
         }
         else
         {
             Viewer.SetTask(Task);
             Views.SetActiveView(FileProcessingView);
         }
     }
     else
     {
         Views.SetActiveView(GoneView);
         Response.StatusCode = 404;
     }
 }
Esempio n. 27
0
 public static IEnumerable <File> AsEnumerable(this FileList f)
 {
     return(Enumerable.Range(0, (int)f.length).Select(k => f[(uint)k]));
 }
Esempio n. 28
0
 private void ItemManipulationModel_FocusFileListInvoked(object sender, EventArgs e)
 {
     FileList.Focus(FocusState.Programmatic);
 }
Esempio n. 29
0
 private void ItemManipulationModel_SelectAllItemsInvoked(object sender, EventArgs e)
 {
     FileList.SelectAll();
 }
Esempio n. 30
0
 private void ItemManipulationModel_ScrollIntoViewInvoked(object sender, ListedItem e)
 {
     FileList.ScrollIntoView(e);
 }
 public TestableAppsContextConnector WithArchive(AppIdentifier id, string appVersion, FileList archive)
 {
     this.archives[string.Join(":", id, appVersion)] = archive;
     return this;
 }
Esempio n. 32
0
        private void UploadDatabase(DriveService driveservice)
        {
            if (upload_thread != null && upload_thread.ThreadState == ThreadState.Running)
            {
            }
            else
            {
                try
                {
                    upload_thread = new Thread(() =>
                    {
                        try
                        {
                            upload_stream             = new System.IO.FileStream(upload_file_name, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite);
                            current_time              = System.DateTime.Now.ToString();
                            string client_folderid_lc = "";
                            string client_folderid_gd = "";
                            this.muiBtnOK.Dispatcher.Invoke((Action)(() => { this.muiBtnOK.Visibility = System.Windows.Visibility.Hidden; }));
                            this.mpr.Dispatcher.Invoke((Action)(() => { this.mpr.IsActive = true; }));
                            this.tblConfirm.Dispatcher.Invoke((Action)(() => { this.tblConfirm.Text = "Please wait..."; }));

                            //get all file from google drive
                            FileList file_list = driveservice.Files.List().Execute();

                            //get client folder info
                            this.Dispatcher.Invoke((Action)(() =>
                            {
                                using (System.IO.StreamReader streamreader = StaticClass.GeneralClass.DecryptFileGD("ClientFolderInfo", StaticClass.GeneralClass.key_register_general))
                                {
                                    if (streamreader != null)
                                    {
                                        //if database type is sqlite
                                        if (StaticClass.GeneralClass.flag_database_type_general == false)
                                        {
                                            client_folderid_lc = streamreader.ReadLine().Split(':')[1];
                                        }

                                        //if database type is sqlserver
                                        else
                                        {
                                            streamreader.ReadLine();
                                            client_folderid_lc = streamreader.ReadLine().Split(':')[1];
                                        }
                                        streamreader.Close();
                                    }
                                }
                            }));


                            for (int i = 0; i < file_list.Items.Count; i++)
                            {
                                if ((file_list.Items[i].Id == client_folderid_lc) && (file_list.Items[i].ExplicitlyTrashed == false))
                                {
                                    clientid_folder_flag = true;
                                    client_folderid_gd   = file_list.Items[i].Id;
                                }
                            }

                            //add new folder CashierRegister_Backup if not exist
                            if ((clientid_folder_flag == false) && client_folderid_gd == "")
                            {
                                File folder_client = new File();

                                //if database type is sqlite
                                if (StaticClass.GeneralClass.flag_database_type_general == false)
                                {
                                    folder_client.Title = "CashierRegister_Backup";
                                }
                                else
                                {
                                    folder_client.Title = "CashierRegister_Ser_Backup";
                                }

                                folder_client.Description = "This folder using for backup database";
                                folder_client.MimeType    = "application/vnd.google-apps.folder";
                                //insert folder
                                File response_folder = driveservice.Files.Insert(folder_client).Execute();
                                if (response_folder != null)
                                {
                                    System.IO.StreamWriter streamwriter = new System.IO.StreamWriter("ClientFolder");

                                    //get FolderID
                                    if (System.IO.File.Exists(current_directory + @"\ClientFolderInfo") == true)
                                    {
                                        System.IO.StreamReader stream_reader_temp = StaticClass.GeneralClass.DecryptFileGD(current_directory + @"\ClientFolderInfo", StaticClass.GeneralClass.key_register_general);

                                        //if database type is sqlite
                                        if (StaticClass.GeneralClass.flag_database_type_general == false)
                                        {
                                            streamwriter.WriteLine("FolderID:" + response_folder.Id.ToString());
                                            stream_reader_temp.ReadLine();
                                            streamwriter.WriteLine("FolderID:" + stream_reader_temp.ReadLine().Split(':')[1].ToString());
                                        }

                                        //if database tupe is sqlserver
                                        else
                                        {
                                            streamwriter.WriteLine("FolderID:" + stream_reader_temp.ReadLine().Split(':')[1].ToString());
                                            streamwriter.WriteLine("FolderID:" + response_folder.Id.ToString());
                                        }

                                        //close stream_reader_temp
                                        if (stream_reader_temp != null)
                                        {
                                            stream_reader_temp.Close();
                                        }
                                    }

                                    streamwriter.Close();
                                    StaticClass.GeneralClass.EncryptFileGD("ClientFolder", "ClientFolderInfo", StaticClass.GeneralClass.key_register_general);
                                    client_folderid_gd = response_folder.Id;
                                }
                            }
                            else
                            {
                                clientid_folder_flag = false;
                            }

                            //get client folder info
                            this.Dispatcher.Invoke((Action)(() =>
                            {
                                System.IO.StreamReader streamreader = streamreader = StaticClass.GeneralClass.DecryptFileGD("ClientFolderInfo", StaticClass.GeneralClass.key_register_general);

                                if (streamreader != null)
                                {
                                    //if database type is sqlite
                                    if (StaticClass.GeneralClass.flag_database_type_general == false)
                                    {
                                        client_folderid_lc = streamreader.ReadLine().Split(':')[1];
                                    }

                                    //if database type is sqlserver
                                    else
                                    {
                                        streamreader.ReadLine();
                                        client_folderid_lc = streamreader.ReadLine().Split(':')[1];
                                    }
                                    streamreader.Close();
                                }
                            }));

                            if (client_folderid_gd != "" && (client_folderid_gd == client_folderid_lc))
                            {
                                var file_name = upload_file_name;
                                if (file_name.LastIndexOf("\\") != -1)
                                {
                                    //if database type is sqlite
                                    if (StaticClass.GeneralClass.flag_database_type_general == false)
                                    {
                                        file_name = "Backup_CashierRegister_" + current_time + ".db";
                                    }
                                    else
                                    {
                                        file_name = "Backup_CashierRegister_" + current_time + ".bak";
                                    }
                                    file_name = file_name.Trim().Replace(" ", "_");
                                }

                                //var upload_stream = new System.IO.FileStream(upload_file_name, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite);

                                File file_upload  = new File();
                                file_upload.Title = file_name;

                                FilesResource.InsertMediaUpload request = driveservice.Files.Insert(new File {
                                    Title = file_name, Parents = new List <ParentReference>()
                                    {
                                        new ParentReference()
                                        {
                                            Id = client_folderid_gd,
                                        }
                                    }
                                }, upload_stream, content_type);
                                request.Upload();
                                upload_stream.Dispose();

                                File response_file = request.ResponseBody;

                                this.tblNotification.Dispatcher.Invoke((Action)(() =>
                                {
                                    tblNotification.Text = FindResource("backup_success").ToString();
                                }));
                                if (muitbnbackup_delegate != null)
                                {
                                    this.mpr.Dispatcher.Invoke((Action)(() => { mpr.IsActive = false; }));
                                    this.muiBtnOK.Dispatcher.Invoke((Action)(() => { muiBtnOK.Visibility = System.Windows.Visibility.Visible; }));

                                    muitbnbackup_delegate();
                                    this.Dispatcher.Invoke((Action)(() =>
                                    {
                                        this.Close();
                                    }));
                                }
                            }

                            //open connect
                            if (StaticClass.GeneralClass.flag_database_type_general == false)
                            {
                                ConnectionDB.OpenConnect();
                            }
                        }
                        catch (AggregateException)
                        {
                            //open connect
                            if (StaticClass.GeneralClass.flag_database_type_general == false)
                            {
                                ConnectionDB.OpenConnect();
                            }

                            this.tblConfirm.Dispatcher.Invoke((Action)(() => { this.tblConfirm.Text = FindResource("want_backup_database").ToString(); }));
                            this.tblNotification.Dispatcher.Invoke((Action)(() => { this.tblNotification.Text = FindResource("have_not_access").ToString(); }));
                        }

                        catch (Exception)
                        {
                            //open connect
                            if (StaticClass.GeneralClass.flag_database_type_general == false)
                            {
                                ConnectionDB.OpenConnect();
                            }

                            this.tblConfirm.Dispatcher.Invoke((Action)(() => { FindResource("want_backup_database").ToString(); }));
                            this.tblNotification.Dispatcher.Invoke((Action)(() => { this.tblNotification.Text = FindResource("have_not_access").ToString(); }));
                        }
                    });
                    upload_thread.SetApartmentState(ApartmentState.STA);
                    upload_thread.Start();
                }
                catch (Exception ex)
                {
                    //open connect
                    if (StaticClass.GeneralClass.flag_database_type_general == false)
                    {
                        ConnectionDB.OpenConnect();
                    }

                    this.tblConfirm.Dispatcher.Invoke((Action)(() => { this.tblConfirm.Text = FindResource("want_backup_database").ToString(); }));
                    this.tblNotification.Dispatcher.Invoke((Action)(() => { this.tblNotification.Text = ex.Message; }));
                }
            }
        }
Esempio n. 33
0
        private async void Button_Convert_ClickAsync(object sender, RoutedEventArgs e)
        {
            if ((string)((Button)e.Source).Content == "停止中...")
            {
                return;
            }
            else if ((string)((Button)e.Source).Content == "停止")
            {
                cts.Cancel();
                ((Button)e.Source).Content = "停止中...";
                return;
            }
            else if ((string)((Button)e.Source).Content == "轉換")
            {
                cts = new CancellationTokenSource();
                ((Button)e.Source).Content = "停止";
            }
            Stopwatch stopwatch = new Stopwatch();

            switch (FileMode)
            {
            case true:
            {
                FileList.ToList().ForEach(x => x.IsReplace = false);
                var    temp = FileList.Where(x => x.IsChecked).ToList();
                double count_total = temp.Count, count_current = 0.0;
                DismissButtonProgress = 0;
                bool replaceALL = false;
                bool skip       = false;
                foreach (var _temp in temp)
                {
                    string TargetPath = Path.Combine(Path.Combine(OutputPath, _temp.Path.Substring(_temp.ParentPath.Length + (_temp.Path.Length == _temp.ParentPath.Length ? 0 : 1))), _temp.Name);
                    if (!replaceALL && File.Exists(TargetPath))
                    {
                        if (!skip)
                        {
                            switch (Moudle.Window_MessageBoxEx.Show(string.Format("{0}發生檔名衝突,是否取代?", _temp.Name), "警告", "取代", "略過", "取消", "套用到全部"))
                            {
                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.A:
                                break;

                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.B:
                                continue;

                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.C:
                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.CO:
                                DismissButtonProgress = 100.0;
                                return;

                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.AO:
                                replaceALL = true;
                                break;

                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.BO:
                                skip = true;
                                continue;

                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.NONE:
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    _temp.IsReplace = true;
                }
                temp                  = FileList.Where(x => x.IsChecked && x.IsReplace).ToList();
                count_current         = count_total - temp.Count;
                DismissButtonProgress = count_current / count_total * 100.0;
                Mouse.OverrideCursor  = Cursors.Wait;
                stopwatch.Start();
                foreach (var _temp in temp)
                {
                    if (cts.IsCancellationRequested)
                    {
                        ResetConvertButton((Button)e.Source); return;
                    }
                    string TargetPath = Path.Combine(Path.Combine(OutputPath, _temp.Path.Substring(_temp.ParentPath.Length + (_temp.Path.Length == _temp.ParentPath.Length ? 0 : 1))), _temp.Name);
                    await Task.Run(() =>
                        {
                            string str = "";
                            using (StreamReader sr = new StreamReader(Path.Combine(_temp.Path, _temp.Name), encoding[0], false))
                            {
                                str = sr.ReadToEnd();
                                sr.Close();
                            }
                            str = ConvertHelper.Convert(str, ToChinese);
                            if (!string.IsNullOrWhiteSpace(App.Settings.FileConvert.FixLabel))
                            {
                                var list = App.Settings.FileConvert.FixLabel.Split('|').Select(x => x.ToLower()).ToList();
                                list.ForEach(x =>
                                {
                                    if (Path.GetExtension(_temp.Name).ToLower() == x)
                                    {
                                        switch (x)
                                        {
                                        //"*.htm|*.html|*.shtm|*.shtml|*.asp|*.apsx|*.php|*.pl|*.cgi|*.js"
                                        case ".html":
                                        case ".htm":
                                        case ".php":
                                        case ".shtm":
                                        case ".shtml":
                                        case ".asp":
                                        case ".aspx":
                                            //html5
                                            str = Regex.Replace(str, "<meta(\\s+.*?)charset=\"(.*?)\"(.*?)>", string.Format("<meta$1charset=\"{0}\"$3>", encoding[1].WebName), RegexOptions.IgnoreCase);
                                            //html4
                                            str = Regex.Replace(str, "<meta\\s+(.*?)content=\"(.*?)charset=(.*?)\"(.*?)>", string.Format("<meta $1content=\"$2charset={0}\"$4>", encoding[1].WebName), RegexOptions.IgnoreCase);
                                            //php
                                            str = Regex.Replace(str, @"header(""Content-Type:text/html;\s*charset=(.*?)"");", string.Format(@"header(""Content-Type:text/html; charset={0}"");", encoding[1].WebName), RegexOptions.IgnoreCase);
                                            break;

                                        case "css":
                                            str = Regex.Replace(str, "@charset \"(.*?)\"", string.Format("@charset \"{0}\"", encoding[1].WebName), RegexOptions.IgnoreCase);
                                            break;
                                        }
                                    }
                                });
                            }
                            if (cts.IsCancellationRequested)
                            {
                                ResetConvertButton((Button)e.Source); return;
                            }
                            Directory.CreateDirectory(Path.GetDirectoryName(TargetPath));
                            using (StreamWriter sw = new StreamWriter(TargetPath, false, encoding[1] == Encoding.UTF8 ? new UTF8Encoding(App.Settings.FileConvert.UnicodeAddBom) : encoding[1]))
                            {
                                sw.Write(str);
                                sw.Flush();
                            }
                        }, cts.Token);

                    count_current++;
                    DismissButtonProgress = count_current / count_total * 100.0;
                }
                DismissButtonProgress = 0.0;
                stopwatch.Stop();
                Mouse.OverrideCursor = null;
            }
            break;

            case false:
            {
                stopwatch.Start();
                treeview_nodes.ForEach(x =>
                    {
                        if (x.Nodes != null)
                        {
                            var childlist = GetAllChildNode(x);
                            childlist.OrderByDescending(y => y.Generation).ToList().ForEach(y =>
                            {
                                if (y.IsChecked)
                                {
                                    string temp    = "";
                                    string path    = GetParentSum(y, ref temp);
                                    string newpath = Path.Combine(Path.GetDirectoryName(path), ConvertHelper.Convert(Path.GetFileName(path), encoding, ToChinese));
                                    try
                                    {
                                        if (y.IsFile)
                                        {
                                            File.Move(path, newpath);
                                        }
                                        else
                                        {
                                            Directory.Move(path, newpath);
                                        }
                                    }
                                    catch { }
                                }
                            });
                        }
                    });
                stopwatch.Stop();
            }
            break;
            }
            if (App.Settings.Prompt)
            {
                new Toast(string.Format("轉換完成\r\n耗時:{0} ms", stopwatch.ElapsedMilliseconds)).Show();
            }
            ((Button)e.Source).Content = "轉換";
            Listview_SelectionChanged(null, null);
        }
Esempio n. 34
0
 public override void ScrollIntoView(ListedItem item)
 {
     FileList.ScrollIntoView(item);
 }
Esempio n. 35
0
        private void Button_Convert_Click(object sender, RoutedEventArgs e)
        {
            switch (FileMode)
            {
            case true:
            {
                var  temp       = FileList.Where(x => x.isChecked).ToList();
                bool replaceALL = false;
                bool skip       = false;
                foreach (var _temp in temp)
                {
                    if (!replaceALL && File.Exists(Path.Combine(OutputPath, _temp.Name)))
                    {
                        if (!skip)
                        {
                            switch (Moudle.Window_MessageBoxEx.Show(string.Format("{0}發生檔名衝突,是否取代?", _temp.Name), "警告", "取代", "略過", "取消", "套用到全部"))
                            {
                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.A:
                                break;

                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.B:
                                continue;

                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.C:
                                return;

                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.AO:
                                replaceALL = true;
                                break;

                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.BO:
                                skip = true;
                                continue;

                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.CO:
                                return;

                            case Moudle.Window_MessageBoxEx.MessageBoxExResult.NONE:
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    string str = "";
                    using (StreamReader sr = new StreamReader(Path.Combine(_temp.Path, _temp.Name), encoding[0]))
                    {
                        str = sr.ReadToEnd();
                        sr.Close();
                    }
                    str = ConvertHelper.Convert(str, encoding, ToChinese);
                    if (!string.IsNullOrWhiteSpace(App.Settings.FileConvert.FixLabel))
                    {
                        var list = App.Settings.FileConvert.FixLabel.Split('|').ToList();
                        list.ForEach(x => {
                                if (Path.GetExtension(_temp.Name) == x)
                                {
                                    switch (x)
                                    {
                                    //"*.htm|*.html|*.shtm|*.shtml|*.asp|*.apsx|*.php|*.pl|*.cgi|*.js"
                                    case ".html":
                                    case ".htm":
                                    case ".php":
                                    case ".shtm":
                                    case ".shtml":
                                    case ".asp":
                                    case ".aspx":
                                        str = Regex.Replace(str, "<meta\\s*charset=\"(.*?)\"\\s*\\/?>", string.Format("<meta charset=\"{0}\">", encoding[1].WebName), RegexOptions.IgnoreCase);
                                        str = Regex.Replace(str, @"<meta\s*http-equiv\s*=\s*""Content-Type""\s*content\s*=\s*""text\/html;charset=(.*?)""\s*\/?>", string.Format(@"<meta http-equiv=""Content-Type"" content=""text/html;charset={0}"">", encoding[1].WebName), RegexOptions.IgnoreCase);
                                        str = Regex.Replace(str, @"header(""Content-Type:text/html;\s*charset=(.*?)"");", string.Format(@"header(""Content-Type:text/html; charset={0}"");", encoding[1].WebName), RegexOptions.IgnoreCase);
                                        break;
                                    }
                                }
                            });
                    }
                    using (StreamWriter sw = new StreamWriter(Path.Combine(OutputPath, _temp.Name), false, encoding[1] == Encoding.UTF8 ? new UTF8Encoding(App.Settings.FileConvert.UnicodeAddBom) : encoding[1]))
                    {
                        sw.Write(str);
                        sw.Flush();
                    }
                }
            }
            break;

            case false:
            {
                treeview_nodes.ForEach(x => {
                        if (x.Nodes != null)
                        {
                            var childlist = GetAllChildNode(x);
                            childlist.OrderByDescending(y => y.Generation).ToList().ForEach(y => {
                                if (y.IsChecked)
                                {
                                    string temp    = "";
                                    string path    = GetParentSum(y, ref temp);
                                    string newpath = Path.Combine(Path.GetDirectoryName(path), ConvertHelper.Convert(Path.GetFileName(path), encoding, ToChinese));
                                    try
                                    {
                                        if (y.isFile)
                                        {
                                            File.Move(path, newpath);
                                        }
                                        else
                                        {
                                            Directory.Move(path, newpath);
                                        }
                                    }
                                    catch { }
                                }
                            });
                        }
                    });
            }
            break;
            }
        }
Esempio n. 36
0
 public override void FocusSelectedItems()
 {
     FileList.ScrollIntoView(FileList.Items.Last());
 }
Esempio n. 37
0
 /// <summary>
 /// Resets the form control to its initial value.
 /// </summary>
 internal override void Reset()
 {
     base.Reset();
     _checked = null;
     _files   = new FileList();
 }
Esempio n. 38
0
        private async void SelectionRectangle_SelectionEnded(object sender, EventArgs e)
        {
            await Task.Delay(200);

            FileList.Focus(FocusState.Programmatic);
        }
Esempio n. 39
0
 /// <inheritdoc />
 public Dictionary <string, string> LoadFileList(string?filename = null, DataGame?game = null)
 {
     FileList = LoadKTIDFileListShared(filename, game ?? GameId);
     return(FileList.ToDictionary(x => x.Key.ToString(CultureInfo.InvariantCulture), y => y.Value));
 }
Esempio n. 40
0
 public override void OnAddFilesFromDirectoryStarted(FileList fileList, string dir)
 {
     RakNetPINVOKE.CSharp_RakNet_FLP_Printf_OnAddFilesFromDirectoryStarted(swigCPtr, FileList.getCPtr(fileList), dir);
 }
Esempio n. 41
0
        private async void Button_Convert_Click(object sender, RoutedEventArgs e)
        {
            ((Button)e.Source).IsEnabled = false;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            var    temp         = FileList.Where(x => x.IsChecked).ToList();
            string ErrorMessage = null;

            foreach (var _temp in temp)
            {
                Mouse.OverrideCursor = Cursors.Wait;
                stopwatch.Start();
                try
                {
                    var tfile = TagLib.File.Create(Path.Combine(_temp.Path, _temp.Name));
                    tfile.RemoveTags((Enable_ID3v1 ? TagLib.TagTypes.None : TagLib.TagTypes.Id3v1) | (Enable_ID3v2 ? TagLib.TagTypes.None : TagLib.TagTypes.Id3v2));
                    TagLib.Id3v1.Tag t  = (TagLib.Id3v1.Tag)tfile.GetTag(TagLib.TagTypes.Id3v1, Enable_ID3v1 ? true : false);
                    TagLib.Id3v2.Tag t2 = (TagLib.Id3v2.Tag)tfile.GetTag(TagLib.TagTypes.Id3v2, Enable_ID3v2 ? true : false);
                    SetID3v2Encoding(Encoding_Output_ID3v2);
                    if (t != null)
                    {
                        var TagList = GetAllStringProperties(t);
                        var Dic     = TagList.ToDictionary(x => x.TagName, x => StringToUnicode.TryToConvertLatin1ToUnicode(x.Value, encoding[0]));
                        var resoult = ConvertEncoding ? await ConvertHelper.ConvertDictionary(Dic, encoding, ToChinese1) : await ConvertHelper.ConvertDictionary(Dic, ToChinese1);

                        resoult.ToList().ForEach(x => t.SetPropertiesValue(x.Key, Encoding.GetEncoding("ISO-8859-1").GetString(encoding[1].GetBytes(x.Value))));
                    }
                    if (t2 != null)
                    {
                        var TagList = GetAllStringProperties(t2);
                        var Dic     = TagList.ToDictionary(x => x.TagName, x =>
                        {
                            if (tfile.TagTypesOnDisk.HasFlag(TagLib.TagTypes.Id3v2))
                            {
                                return(StringToUnicode.TryToConvertLatin1ToUnicode(x.Value, encoding2[0]));
                            }
                            else
                            {
                                var _ = ID3v1_TagList.Where(y => y.TagName == x.TagName).FirstOrDefault();
                                return(_ != null ? _.Value_Preview : "");
                            }
                        });
                        var resoult = await ConvertHelper.ConvertDictionary(Dic, ToChinese2);

                        resoult.ToList().ForEach(x => t.SetPropertiesValue(x.Key, x.Value));
                        t2.Version = (Combobox_ID3v2_Version.Text == "2.3") ? (byte)3 : (byte)4;
                    }
                    tfile.Save();
                }
                catch (TagLib.UnsupportedFormatException) { ErrorMessage = string.Format("轉換{0}時出現錯誤,該檔案並非音訊檔", _temp.Name); }
                catch (FanhuajiException val)
                {
                    ErrorMessage = ((Exception)val).Message;
                    break;
                }
                catch { ErrorMessage = string.Format("轉換{0}時出現未知錯誤", _temp.Name); }
            }
            Mouse.OverrideCursor = null;
            stopwatch.Stop();
            if (!string.IsNullOrEmpty(ErrorMessage))
            {
                Window_MessageBoxEx.ShowDialog(ErrorMessage, "轉換過程中出現錯誤", "我知道了");
            }
            else if (App.Settings.Prompt)
            {
                new Toast(string.Format("轉換完成\r\n耗時:{0} ms", stopwatch.ElapsedMilliseconds)).Show();
            }
            ((Button)e.Source).IsEnabled = true;
            Listview_SelectionChanged(null, null);
        }
Esempio n. 42
0
        private void Button_SelectFile_Clicked(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog()
            {
                Multiselect = true, CheckFileExists = false, CheckPathExists = true, ValidateNames = false
            };

            fileDialog.InitialDirectory = App.Settings.FileConvert.DefaultPath;
            fileDialog.FileName         = " ";
            if (fileDialog.ShowDialog() == true)
            {
                OutputPath = Path.GetDirectoryName(fileDialog.FileNames.First());
                if (!FileMode)
                {
                    treeview_nodes = new List <Node>()
                    {
                        GetChildPath(OutputPath, AccordingToChild, UseFilter ? App.Settings.FileConvert.TypeFilter : "*")
                    };
                    treeview.ItemSources = treeview_nodes;
                    treeview_CheckedChanged(null);
                }
                else
                {
                    foreach (string str in fileDialog.FileNames)
                    {
                        if (Path.GetFileName(str) == " " && System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(str)))
                        {
                            string folderpath = System.IO.Path.GetDirectoryName(str);
                            if (UseFilter)
                            {
                                App.Settings.FileConvert.TypeFilter.Split('|').ToList().ForEach(filter =>
                                {
                                    List <string> childFileList = System.IO.Directory.GetFiles(folderpath, filter.Trim(), AccordingToChild ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).ToList();
                                    childFileList.ForEach(x =>
                                    {
                                        FileList.Add(new FileList_Line()
                                        {
                                            isChecked = true, isFile = true, Name = System.IO.Path.GetFileName(x), Path = Path.GetDirectoryName(x)
                                        });
                                    });
                                });
                            }
                            else
                            {
                                List <string> childFileList = System.IO.Directory.GetFiles(folderpath, "*", AccordingToChild ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).ToList();
                                childFileList.ForEach(x =>
                                {
                                    FileList.Add(new FileList_Line()
                                    {
                                        isChecked = true, isFile = true, Name = System.IO.Path.GetFileName(x), Path = Path.GetDirectoryName(x)
                                    });
                                });
                            }
                            FileList = new ObservableCollection <FileList_Line>(FileList.OrderBy(x => x.Name).Distinct().OrderBy(x => x.isFile).OrderBy(x => x.Path));
                        }
                        else if (File.Exists(str))
                        {
                            FileList.Add(new FileList_Line()
                            {
                                isChecked = true, Name = Path.GetFileName(str), Path = Path.GetDirectoryName(str)
                            });
                        }
                    }
                }
            }
        }
Esempio n. 43
0
        internal static IEnumerable<FileEntry> ProcessIncludes(FileList thisInstance, dynamic rule, string name, string includePropertyName, IEnumerable<Rule> fileRules, string root)
        {
            var fileEntries = Enumerable.Empty<FileEntry>();
            var property = rule[includePropertyName];

            if( property != null ) {
                foreach (string include in property.Values ) {
                    // first check to see if the include is another file list
                    if (fileRules.GetRulesByParameter(include).Any()) {
                        // there is one? Great. Add that to the list of our files
                        var inheritedList = GetFileList(include, fileRules);

                        if (inheritedList == null) {
                            AutopackageMessages.Invoke.Error(
                                MessageCode.DependentFileListUnavailable, rule.SourceLocation,
                                "File list '{0}' depends on file list '{1}' which is not availible.", name, include);
                            continue;
                        }

                        if (inheritedList == thisInstance) {
                            // already complained about circular reference.
                            continue;
                        }

                        fileEntries = fileEntries.Union(inheritedList.FileEntries.Select(each => new FileEntry(each)));
                        continue;
                    }

                    // it's not a reference include. lets see if we can pick up some files with it.
                    var foundFiles = root.FindFilesSmarter(include).ToArray();

                    if (!foundFiles.Any()) {
                        AutopackageMessages.Invoke.Warning(
                            MessageCode.IncludeFileReferenceMatchesZeroFiles, rule.include.SourceLocation,
                            "File include reference '{0}' matches zero files in path '{1}'", include, root);
                    }
                    fileEntries = fileEntries.Union(foundFiles.Select(each => new FileEntry(each, root.GetSubPath(each))));
                }
            }
            return fileEntries;
        }
Esempio n. 44
0
        private static File GetProjectFolder(ModelInfo modelInfo)
        {
            File projectFolder = null;

            try
            {
                FilesResource.ListRequest request = service.Files.List();
                request.Q = "title = \'Project Replication\'";
                FileList files = request.Execute();

                if (files.Items.Count > 0)
                {
                    string projectReplicationFolderId = files.Items.First().Id;

                    if (modelInfo.HOKStandard)
                    {
                        request   = service.Files.List();
                        request.Q = "title = \'HOK Offices\' and \'" + projectReplicationFolderId + "\' in parents";
                        files     = request.Execute();

                        if (files.Items.Count > 0)
                        {
                            string hokFolderId = files.Items.First().Id;
                            string location    = (!string.IsNullOrEmpty(modelInfo.FileLocation)) ? modelInfo.FileLocation : modelInfo.UserLocation;

                            request   = service.Files.List();
                            request.Q = "title = \'" + location + "\' and \'" + hokFolderId + "\' in parents";
                            files     = request.Execute();

                            if (files.Items.Count > 0)
                            {
                                string locationFolderId  = files.Items.First().Id;
                                string projectFolderName = modelInfo.ProjectNumber + " " + modelInfo.ProjectName;

                                request   = service.Files.List();
                                request.Q = "title = \'" + projectFolderName + "\' and \'" + locationFolderId + "\' in parents";
                                files     = request.Execute();

                                if (files.Items.Count > 0)
                                {
                                    projectFolder = files.Items.First();
                                }
                                else
                                {
                                    //create project folder
                                    File body = new File();
                                    body.Title       = projectFolderName;
                                    body.Description = "Project Number: " + modelInfo.ProjectNumber + ", Project Name: " + modelInfo.ProjectName;
                                    body.MimeType    = "application/vnd.google-apps.folder";
                                    body.Parents     = new List <ParentReference>()
                                    {
                                        new ParentReference()
                                        {
                                            Id = locationFolderId
                                        }
                                    };

                                    FilesResource.InsertRequest insertRequest = service.Files.Insert(body);
                                    projectFolder = insertRequest.Execute();
                                }
                            }
                        }
                    }
                    else
                    {
                        //External Users
                        request   = service.Files.List();
                        request.Q = "title = \'External Users\' and \'" + projectReplicationFolderId + "\' in parents";
                        files     = request.Execute();

                        if (files.Items.Count > 0)
                        {
                            string externalFolderId = files.Items.First().Id;
                            string companyName      = modelInfo.CompanyName;

                            request   = service.Files.List();
                            request.Q = "title = \'" + companyName + "\' and \'" + externalFolderId + "\' in parents";
                            files     = request.Execute();

                            if (files.Items.Count > 0)
                            {
                                projectFolder = files.Items.First();
                            }
                            else
                            {
                                request   = service.Files.List();
                                request.Q = "title = \'Unknown\' and \'" + externalFolderId + "\' in parents";
                                files     = request.Execute();

                                if (files.Items.Count > 0)
                                {
                                    projectFolder = files.Items.First();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to get project folder.\n" + ex.Message, "Find Project Folder", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(projectFolder);
        }
Esempio n. 45
0
        /// <summary>
        /// Process one or more .NCC Review measurement data files, with related .NOP/.COP files.
        /// see Import Operator Declarations from Operator Review and Measurements from Radiation Review p. 24,
        /// See Operator Declaration File Format p. 87, 
        /// See Operator Declaration File Format for Curium Ratio Measurements p. 88, 
        /// See Radiation Review Measurement Data File Format p. 93, INCC Software Users Manual, March 29, 2009
        /// </summary>
        void INCCReviewFileProcessing()
        {

            FireEvent(EventType.ActionPrep, this);
            NC.App.Opstate.StampOperationStartTime();
            // This code would be the same for an interactive version of this operation
            //  > Start here
            // first find and process and .NOP files 
            List<string> exts = new List<string>() { ".nop", ".cop" };
            FileList<CSVFile> hdlr = new FileList<CSVFile>();
            hdlr.Init(exts, ctrllog);
            FileList<CSVFile> files = null;

            // The INCC5 semantics
            if (NC.App.AppContext.FileInputList == null)
                files = (FileList<CSVFile>)hdlr.BuildFileList(NC.App.AppContext.FileInput, NC.App.AppContext.Recurse, true);
            else
                files = (FileList<CSVFile>)hdlr.BuildFileList(NC.App.AppContext.FileInputList);

            // construct lists of isotopics and items from the NOP and COP files
            OPFiles opfiles = new OPFiles();
            opfiles.Process(files);

            ctrllog.TraceEvent(LogLevels.Verbose, 33085, "NOP items " + opfiles.NOPItemIds.Count);

            // process the NCC files only
            INCCFileOrFolderInfo foo = new INCCFileOrFolderInfo(ctrllog, "*.NCC");
            if (NC.App.AppContext.FileInputList == null)
                foo.SetPath(NC.App.AppContext.FileInput);
            else
                foo.SetFileList(NC.App.AppContext.FileInputList);
            List<INCCTransferBase> res = foo.Restore();
            // use RemoveAll to cull those NCC files that reference a non-existent detector
            DetectorList dl = NC.App.DB.Detectors;
            foreach (INCCReviewFile rf in res)
            {
                List<Detector> tdk = dl.FindAll(d => 0 == string.Compare(d.Id.DetectorName, rf.detector, true));
                if (tdk.Count < 1)
                {
                    rf.skip = true;
                    ctrllog.TraceEvent(LogLevels.Warning, 33085, "No detector " + rf.detector + " defined, cannot complete processing NCC review file " + System.IO.Path.GetFileName(rf.Path));
                }
            }
            res.RemoveAll(rf => (rf as INCCReviewFile).skip);
            res.Sort((rf1, rf2) => // sort chronologically
            {
                return DateTime.Compare((rf1 as INCCReviewFile).dt, (rf2 as INCCReviewFile).dt);
            });
            /// end here > The sorted, filtered and processed list here would be returned to the UI for display and interactive selection

            if (res == null || res.Count < 1)
            {
                NC.App.Opstate.StopTimer(0);
                NC.App.Opstate.StampOperationStopTime();
                FireEvent(EventType.ActionStop, this);
                ctrllog.TraceEvent(LogLevels.Warning, 33085, "No useable NCC review files found in " + System.IO.Path.GetFullPath(foo.GetPath()));
                return;
            }

            AcquireParameters orig_acq = new AcquireParameters(NC.App.Opstate.Measurement.AcquireState);

            // Each NCC file is a separate measurement 
            foreach (INCCReviewFile irf in res)
            {
                ResetMeasurement();
                if (NC.App.Opstate.IsQuitRequested)
                    break;
                // Find the detector named in the NCC file (existence shown in earlier processing above)
                Detector curdet = NC.App.DB.Detectors.Find(d => string.Compare(d.Id.DetectorName, irf.detector, true) == 0);

                // set up acquire state based on the NCC file content
                AcquireParameters newacq = ConfigureAcquireState(curdet, orig_acq, irf);

                AssaySelector.MeasurementOption mo = NCCMeasOption(irf);
                // make a temp MeasId
                MeasId thisone = new MeasId(mo, newacq.MeasDateTime);
                // get the list of measurement Ids for this detector
                List<MeasId> list = NC.App.DB.MeasurementIds(curdet.Id.DetectorName, mo.PrintName());
                MeasId already = list.Find(mid => mid.Equals(thisone));
                if (already != null)
                {
                    // URGENT: do the replacement as it says 
                    ctrllog.TraceEvent(LogLevels.Warning, 33085, "Replacing the matching {0} measurement, timestamp {1} (in a future release)", already.MeasOption.PrintName(), already.MeasDateTime.ToString());
                }

                IntegrationHelpers.BuildMeasurement(newacq, curdet, mo);
                Measurement meas = NC.App.Opstate.Measurement;
                meas.MeasDate = newacq.MeasDateTime; // use the date and time from the NCC file content      

                meas.Persist();  // preserve the basic results record
                if (AssaySelector.ForMass(meas.MeasOption) && !meas.INCCAnalysisState.Methods.AnySelected())
                    ctrllog.TraceEvent(LogLevels.Warning, 437, "No mass methods for " + meas.INCCAnalysisState.Methods.selector.ToString());

                try
                {

                    UInt16 total_number_runs = 0;
                    double run_count_time = 0;
                    double total_good_count_time = 0;

                    if (irf.num_runs == 0)
                    {
                        ctrllog.TraceEvent(LogLevels.Error, 440, "This measurement has no good cycles.");
                        continue;
                    }
                    if (meas.MeasOption == AssaySelector.MeasurementOption.holdup)
                        continue;

                    /* convert to total count time */
                    total_number_runs = irf.num_runs;
                    total_good_count_time = (double)irf.num_runs *
                        run_count_time;
                    meas.RequestedRepetitions = total_number_runs;

                    // convert runs to cycles
                    for (int i = 0; i < irf.num_runs; i++)
                    {
                        /* run date and time (IAEA format) */
                        AddReviewFileCycle(i, irf.runs[i], irf.times[i], meas, irf.Path);
                        if (i % 8 == 0)
                            FireEvent(EventType.ActionInProgress, this);
                    }
                    FireEvent(EventType.ActionInProgress, this);

                    // NEXT: handle true AAS cycles as in INCC5
                    if (meas.MeasOption == AssaySelector.MeasurementOption.verification &&
                        meas.INCCAnalysisState.Methods.Has(AnalysisMethod.AddASource) &&
                        meas.AcquireState.well_config == WellConfiguration.Passive)
                    {
                        ctrllog.TraceEvent(LogLevels.Error, 440, "No add-a-source data processed because I am lame. " + "AAS ");
                        //AddASourceSetup aass = IntegrationHelpers.GetCurrentAASSParams(meas.Detectors[0]);
                        //for (int n = 1; n <= aass.number_positions; n++)
                        //{
                        //    /* number of good runs */
                        //    string l = td.reader.ReadLine();
                        //    if (td.reader.EndOfStream)
                        //    {
                        //        ctrllog.TraceEvent(LogLevels.Error, 440, "No add-a-source data found in disk file. " + "AAS p" + n.ToString());

                        //    }
                        //}
                    }
                }
                catch (Exception e)
                {
                    NC.App.Opstate.SOH = NCC.OperatingState.Trouble;
                    ctrllog.TraceException(e, true);
                    ctrllog.TraceEvent(LogLevels.Error, 437, "NCC file processing stopped with error: '" + e.Message + "'");
                }
                finally
                {
                    NC.App.Loggers.Flush();
                }
                FireEvent(EventType.ActionInProgress, this);
                ComputeFromINCC5SRData(meas);
                FireEvent(EventType.ActionInProgress, this);
            }


            NC.App.Opstate.ResetTokens();
            NC.App.Opstate.SOH = NCC.OperatingState.Stopping;
            NC.App.Opstate.StampOperationStopTime();
            FireEvent(EventType.ActionStop, this);
        }
Esempio n. 46
0
        public override void Write(YukaGraphic ykg, string baseName, FileSystem fs, FileList files)
        {
            // write animaton data
            if (ykg.Animation != null)
            {
                Encode(ykg.Animation, baseName, fs, ykg.AnimationExportFormat, files);
            }

            if (!ykg.IsDecoded)
            {
                if (!Options.YkgMergeAlphaChannelOnExport || ykg.AlphaData == null)
                {
                    if (ykg.ColorData.StartsWith(Bmp.Signature))
                    {
                        // data is already in the correct format, so no re-encoding is needed
                        string bmpFileName = baseName.WithExtension(Bmp.Extension);
                        using (var s = fs.CreateFile(bmpFileName)) {
                            files?.Add(bmpFileName, Bmp);
                            s.WriteBytes(ykg.ColorData);
                        }

                        // no alpha channel to save, so we can just return
                        if (ykg.AlphaData == null)
                        {
                            return;
                        }

                        if (ykg.AlphaData.StartsWith(Bmp.Signature))
                        {
                            string alphaFileName = baseName.WithExtension(Bmp.AlphaExtension);
                            using (var s = fs.CreateFile(alphaFileName)) {
                                files?.Add(alphaFileName, Bmp);
                                s.WriteBytes(ykg.AlphaData);
                            }
                        }
                        else
                        {
                            using (var bitmap = FileReader.Decode <Bitmap>("?" + nameof(ykg.AlphaBitmap), ykg.AlphaData)) {
                                Encode(bitmap, baseName.WithExtension(Bmp.AlphaExtension), fs, new FormatPreference(Bmp), files);
                            }
                        }

                        return;
                    }
                }

                // the current format is not the requested output format, so we need to re-encode everything
                ykg.Decode();
                if (!ykg.IsDecoded)
                {
                    // TODO Warning
                    Console.WriteLine("Decode failed for graphic: " + baseName);
                    // decode failed -> don't write any file
                    return;
                }
            }

            // merge or write alpha channel
            if (ykg.AlphaBitmap != null)
            {
                if (Options.YkgMergeAlphaChannelOnExport)
                {
                    // merge alpha channel into color bitmap
                    ykg.MergeChannels();
                }
                else
                {
                    // save alpha channel on its own
                    Encode(ykg.AlphaBitmap, baseName.WithExtension(Bmp.AlphaExtension), fs, new FormatPreference(Bmp), files);
                }
            }

            // write color data
            if (ykg.ColorBitmap != null)
            {
                Encode(ykg.ColorBitmap, baseName, fs, new FormatPreference(Bmp), files);
            }
        }
Esempio n. 47
0
 public void DeleteFiles(List<FileStruct> fileList)
 {
     string[] argv = new string[1];
     List<FileStruct> localFileList = null;
     if (options.cvsExclude)
     {
         Exclude.AddCvsExcludes();
     }
     for (int j = 0; j < fileList.Count; j++)
     {
         if ((fileList[j].mode & Options.FLAG_TOP_DIR) == 0 || !Util.S_ISDIR(fileList[j].mode))
         {
             continue;
         }
         argv[0] = options.dir + fileList[j].GetFullName();
         FileList fList = new FileList(options);
         if ((localFileList = fList.sendFileList(null, argv)) == null)
         {
             continue;
         }
         for (int i = localFileList.Count - 1; i >= 0; i--)
         {
             if (localFileList[i].baseName == null)
             {
                 continue;
             }
             localFileList[i].dirName = localFileList[i].dirName.Substring(options.dir.Length);
             if (FileList.fileListFind(fileList, (localFileList[i])) < 0)
             {
                 localFileList[i].dirName = options.dir + localFileList[i].dirName;
                 deleteOne(localFileList[i].GetFullName(), Util.S_ISDIR(localFileList[i].mode));
             }
         }
     }
 }
 public TaskSummary()
 {
     FileList      = new FileList();
     langQueryList = new LangQueryList();
     MainUserName  = string.Empty;
 }
            public async Task Return_from_sandbox()
            {
                // Arrange
                var archive = new FileList(new Dictionary<string, FileListItem>
                {
                    ["a"] = new FileListItem("A", 1, AnyContent, AnyEncoding),
                    ["b"] = new FileListItem("B", 2, AnyContent, AnyEncoding),
                    ["c"] = new FileListItem("C", 3, AnyContent, AnyEncoding)
                });
                var appsClient = Substitute.For<IAppsClient>();
                var sandboxesClient = Substitute.For<ISandboxesClient>();
                sandboxesClient.ListFilesAsync("acme", "cool", "vanilla", Arg.Any<FileListingOptions>(), None)
                    .Returns(Task.FromResult(archive));
                
                var sandboxes = new SandboxCollection(new[] {new Sandbox("acme", "cool", new[] {"vanilla"})});
                var connector = new TestableAppsContextConnector(appsClient, sandboxesClient, sandboxes);

                // Act
                var files = await connector.ListFilesAsync("acme.vanilla", "1.2.3");

                // Assert
                files.ShouldBe(new[]
                {
                    new AppFileDescriptor("acme.vanilla", "a", "A", 1),
                    new AppFileDescriptor("acme.vanilla", "b", "B", 2),
                    new AppFileDescriptor("acme.vanilla", "c", "C", 3),
                });
                connector.CachedFileLists["acme.vanilla"].ShouldBe(files);
            }
Esempio n. 50
0
        public void GETRWGLLIST(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            string userName = UserInfo.User.UserName;
            string strWhere = " bg.ComId =" + UserInfo.User.ComId.Value;

            if (P1 != "")
            {
                if (P1 == "2")
                {
                    //  strWhere += string.Format(" And datediff(day,bg.RWJZDate,getdate())>0");
                    strWhere += string.Format(" And bg.RWJZDate < CONVERT(char(10), GETDATE(), 120) And RWStatus='0'");
                }
                else if (P1 == "1")
                {
                    strWhere += string.Format(" And RWStatus={0}", P1);
                }
                else if (P1 == "0")
                {
                    //strWhere += string.Format(" And bg.RWJZDate >= CONVERT(char(10), GETDATE(), 120) And RWStatus={0}", P1);
                    strWhere += string.Format(" And RWStatus={0}", P1);
                }
            }
            if (P2 != "")
            {
                switch (P2)
                {
                case "0":
                    strWhere += string.Format(" And (bg.CRUser='******' or  ','+RWFZR+','  like '%,{0},%'  or ','+RWCYR+','  like '%,{0},%'  or ','+KHFXRS+','  like '%,{0},%' )", userName);
                    break;

                case "1":
                    strWhere += string.Format(" And (','+RWFZR+','  like '%," + userName + ",%' )");
                    break;

                case "2":
                    strWhere += string.Format(" And bg.CRUser='******'", UserInfo.User.UserName);
                    break;

                case "3":
                    strWhere += string.Format(" And (','+RWCYR+','  like '%," + userName + ",%' )");
                    break;

                case "4":
                    strWhere += string.Format(" And (','+KHFXRS+','  like '%," + userName + ",%' )");
                    break;
                }
            }
            string leibie = context.Request["lb"] ?? "";

            if (leibie != "")
            {
                strWhere += string.Format(" And LeiBie='{0}' ", leibie);
            }
            string strContent = context.Request["Content"] ?? "";

            strContent = strContent.TrimEnd();
            if (strContent != "")
            {
                strWhere += string.Format(" And ( RWTitle like '%{0}%' )", strContent);
            }
            //根据时间查询数据
            string time = context.Request["time"] ?? "";

            if (time != "")
            {
                if (time == "1")   //近一周
                {
                    strWhere += string.Format(" And datediff(day,bg.CRDate,getdate())<7");
                }
                else if (time == "2")
                {  //近一月
                    strWhere += string.Format(" And datediff(day,bg.CRDate,getdate())<30");
                }
                else if (time == "3")  //自定义时间
                {
                    string strTime = context.Request["starTime"] ?? "";
                    string endTime = context.Request["endTime"] ?? "";
                    if (strTime != "")
                    {
                        strWhere += string.Format(" And convert(varchar(10),bg.CRDate,120) >='{0}'", strTime);
                    }
                    if (endTime != "")
                    {
                        strWhere += string.Format(" And convert(varchar(10),bg.CRDate,120) <='{0}'", endTime);
                    }
                }
            }
            int DataID = -1;

            int.TryParse(context.Request["ID"] ?? "-1", out DataID);//记录Id
            if (DataID != -1)
            {
                string strIsHasDataQX = new JH_Auth_QY_ModelB().ISHASDATAREADQX("RWGL", DataID, UserInfo);
                if (strIsHasDataQX == "Y")
                {
                    strWhere += string.Format(" And bg.ID = '{0}'", DataID);
                }
                //更新消息为已读状态
                new JH_Auth_User_CenterB().ReadMsg(UserInfo, DataID, "RWGL");
            }
            DataTable dtList    = new DataTable();
            int       page      = 0;
            int       pagecount = 8;

            int.TryParse(context.Request["p"] ?? "1", out page);              //页码
            int.TryParse(context.Request["pagecount"] ?? "8", out pagecount); //页数
            page = page == 0 ? 1 : page;
            int recordCount = 0;

            dtList = new SZHL_GZBGB().GetDataPager(" SZHL_RWGL  bg LEFT JOIN JH_Auth_ZiDian zd on LeiBie= zd.ID and Class=7  LEFT JOIN JH_Auth_User jau ON bg.RWFZR = jau.UserName AND jau.ComId=bg.ComId ", @" [CRUserName],
	jau.UserRealName,
	zd.TypeName,
	[RWJZDate],
	[RWTitle],
	[RWContent],
	[LeiBie],
	[RWFZR],
	[RWCYR],
	[RWStatus],
	[BiaoQian],
	[BeiZhu],
	[IsSend],
	[IsComPlete],
	[IsCancel],
	[CancelDate],
	bg.[CRDate],
	bg.[CRUser],
	bg.[Files],
	bg.[Remark],
	bg.[ID],
	[intProcessStanceid],
	[KHFXRS],
	[TopID],
	bg.[ComId],
	[TaskJD],
	[IsTX],CASE WHEN RWJZDate<CONVERT(char(20), GETDATE(), 23) THEN 1 else 0 END AS jzstatus"    , pagecount, page, "bg.RWJZDate desc", strWhere, ref recordCount);
            string Ids     = "";
            string fileIDs = "";

            foreach (DataRow row in dtList.Rows)
            {
                Ids += row["ID"].ToString() + ",";
                if (!string.IsNullOrEmpty(row["Files"].ToString()))
                {
                    fileIDs += row["Files"].ToString() + ",";
                }
            }
            Ids     = Ids.TrimEnd(',');
            fileIDs = fileIDs.TrimEnd(',');
            if (Ids != "")
            {
                List <FT_File> FileList = new List <FT_File>();
                DataTable      dtPL     = new JH_Auth_TLB().GetDTByCommand(string.Format("SELECT tl.* FROM JH_Auth_TL tl WHERE tl.MSGType='RWGL' AND  tl.MSGTLYID in ({0})", Ids));
                dtPL.Columns.Add("FileList", Type.GetType("System.Object"));
                foreach (DataRow dr in dtPL.Rows)
                {
                    if (dr["MSGisHasFiles"] != null && dr["MSGisHasFiles"].ToString() != "")
                    {
                        int[] fileIds = dr["MSGisHasFiles"].ToString().SplitTOInt(',');
                        dr["FileList"] = new FT_FileB().GetEntities(d => fileIds.Contains(d.ID));
                    }
                }


                if (!string.IsNullOrEmpty(fileIDs))
                {
                    int[] fileId = fileIDs.SplitTOInt(',');
                    FileList = new FT_FileB().GetEntities(d => fileId.Contains(d.ID)).ToList();
                }
                dtList.Columns.Add("PLList", Type.GetType("System.Object"));
                dtList.Columns.Add("FileList", Type.GetType("System.Object"));
                foreach (DataRow row in dtList.Rows)
                {
                    row["PLList"] = dtPL.FilterTable("MSGTLYID='" + row["ID"] + "'");
                    if (FileList.Count > 0)
                    {
                        string[] fileIds = row["Files"].ToString().Split(',');
                        row["FileList"] = FileList.Where(d => fileIds.Contains(d.ID.ToString()));
                    }
                }
            }
            msg.Result  = dtList;
            msg.Result1 = recordCount;
        }
            public async Task Return_from_cache()
            {
                // Arrange
                var expectedArchive = new FileList(new Dictionary<string, FileListItem>());

                var appsClient = Mock.Of<IAppsClient>();
                var sandboxesClient = Mock.Of<ISandboxesClient>();

                var connector = new TestableAppsContextConnector(appsClient, sandboxesClient,
                    null, "a", new[] { "b" });
                connector.CachedArchives["acme.vanilla"] = expectedArchive;

                // Act
                var archive = await connector.GetArchiveAsync("acme.vanilla", "1.2.3");

                // Assert
                archive.ShouldBeSameAs(expectedArchive);
            }
Esempio n. 52
0
 private void GenerateImageCommands()
 {
     ImageCommands =
         FileList.ToDictionary(f => System.Text.RegularExpressions.Regex.Match(f, @"[^\\\/]+(?=\..+$)").Value);
 }
Esempio n. 53
0
        private void searchButton_Click(object sender, EventArgs e)
        {
            source_path = directoryText.Text;
            archive_path = archiveText.Text;

            if (!Directory.Exists(source_path))
            {
                MessageBox.Show(source_path + " is not a path to a valid directory." +
                    " Please provide a valid path to the source directory", "Invalid Source Path");
            }

            else if (!Directory.Exists(archive_path))
            {
                MessageBox.Show(archive_path + " is not a path to a valid directory." +
                    " Please provide a valid path to the archive directory", "Invalid Archive Path");
            }

            else
            {

                List<string> file_ext = new List<string>();

                if (extensionsList.CheckedItems.Contains("Zebra Labels: .zpl"))
                {
                    file_ext.Add(".zpl");
                }

                if (extensionsList.CheckedItems.Contains("Intermec Labels: .ipl"))
                {
                    file_ext.Add(".ipl");
                }

                if (extensionsList.CheckedItems.Contains("Sato Labels: .lbl"))
                {
                    file_ext.Add(".lbl");
                }

                if (extensionsList.CheckedItems.Contains("Datamax Labels: .dpl"))
                {
                    file_ext.Add(".dpl");
                }

                FileList next_form = new FileList(source_path, archive_path, file_ext);

                next_form.ShowDialog();

            }
        }
 public override void SelectAllItems()
 {
     ClearSelection();
     FileList.SelectAll();
 }
Esempio n. 55
0
        /// <summary>
        /// Scan a set of nop and cop files.
        /// Creates a list of Items and a list Isotopics from the nop files.
        /// Creates a list of CmPu Ratio records from the cop files.
        /// </summary>
        /// <param name="files">List of nop and cop files to process</param>
        public void Process(FileList<CSVFile> files)
        {
			if (files == null)
				return;
            foreach (CSVFile csv in files)
            {
                if (0 == String.Compare(csv.ThisSuffix, ".nop", true))
                    mPathToNOPFile.Add(csv.Filename, csv);
                else if (0 == String.Compare(csv.ThisSuffix, ".cop", true))
                    mPathToCOPFile.Add(csv.Filename, csv);
                else continue;
                csv.ProcessFile();  // split lines with scanner, construct istopics, item id and CmPu ratios
                mlogger.TraceEvent(LogLevels.Info, 34100, "Processed " + System.IO.Path.GetFileName(csv.Filename));
            }
            foreach (CSVFile csv in mPathToNOPFile.Values)
            {
                GenerateIsotopics(csv);
                // Isotopic data sets are created for each unique set of isotopics and 
                GenerateItemIds(csv);
                // An entry is made in the item data entry table for each unique item id.
            }
            foreach (CSVFile csv in mPathToCOPFile.Values)
            {
                GenerateCmPuRatioRecs(csv); // these are mapped by item id for use by NCC CmPuRatio operations
            }
			ApplyContent();
        }
Esempio n. 56
0
 public FileInputType(IHtmlInputElement input, String name)
     : base(input, name, validate: true)
 {
     _files = new FileList();
 }
Esempio n. 57
0
 public override void FocusFileList()
 {
     FileList.Focus(FocusState.Programmatic);
 }
Esempio n. 58
0
 /// <summary>
 /// Creates a new HTML input element.
 /// </summary>
 internal HTMLInputElement()
 {
     _name        = Tags.Input;
     WillValidate = true;
     _files       = new FileList();
 }
Esempio n. 59
0
 public override void SelectAllItems()
 {
     FileList.SelectAll();
 }
Esempio n. 60
0
 private void Button_Clear_Clicked(object sender, RoutedEventArgs e)
 {
     FileList.Clear();
     treeview_nodes.Clear();
     treeview.ItemSources = null;
 }