Пример #1
0
        public void TestIOMonadBindingFluent()
        {
            string data = "Testing 123";

            var result = GetTempFileName()
                         .Then(tmpFileName => { WriteFile(tmpFileName, data)(); return(tmpFileName); })
                         .Then(tmpFileName => { return(new { tmpFileName, data = ReadFile(tmpFileName)() }); })
                         .Then(context => { DeleteFile(context.tmpFileName)(); return(context.data); });

            Assert.True(result.Invoke() == "Testing 123");
        }
Пример #2
0
        /// <summary>
        /// Run method for process file in try catch and return elapsed time in totalMilliseconds
        /// </summary>
        /// <param name="readFile"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        internal static double RunFileReader(ReadFile readFile, string filePath)
        {
            double processTime = 0;

            try
            {
                var time = readFile?.Invoke(filePath);
                processTime = time == null ? 0 : time.Value;
            }
            catch (OutOfMemoryException)
            {
                Console.WriteLine("Not enough memory. Couldn't perform this test.");
                processTime = 0;
            }
            catch (Exception)
            {
                Console.WriteLine("EXCEPTION. Couldn't perform this test.");
                processTime = 0;
            }

            GC.Collect();
            Thread.Sleep(1000);

            return(processTime);
        }
        public void RefreshList()
        {
            ListOfPlaces.Clear();
            ReadFile readFile = new ReadFile();

            readFile.LoadData(ListOfPlaces);
        }
Пример #4
0
        public void dataTest()
        {
            string   path     = @"D:\resource\test.txt";
            ReadFile readfile = new ReadFile(path);

            string[] data1 = readfile.data();

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

            System.IO.StreamReader file = new System.IO.StreamReader(path);
            string line;

            try
            {
                while ((line = file.ReadLine()) != null)
                {
                    list.Add(line);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            file.Close();
            string[] data2 = list.ToArray();

            Assert.AreEqual(data1[0], data2[0]);
        }
Пример #5
0
        public static string ReadPropertyValue(ReadFile input)
        {
            string lValue   = string.Empty;
            bool   lEscaped = false;

            while (!input.EOF)
            {
                char c = input.Get();

                if ((c == ']') && (!lEscaped))
                {
                    return(lValue);
                }

                lValue = lValue + c.ToString();

                if (lEscaped)
                {
                    lEscaped = false;
                }
                else
                if (c == EscapeCharacter)
                {
                    lEscaped = true;
                }
            }

            return(lValue);
        }
Пример #6
0
        /// <summary>
        /// click to display the dictionery
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            stemming    = Stemming.IsChecked.Value;
            postingPath = DataPostingPath_Box.Text;
            path        = DataFilesPath_Box.Text;
            if (DataPostingPath_Box.Text.Length == 0)//case there is no path
            {
                System.Windows.MessageBox.Show("Please enter Posting Files path");
            }
            else//there is a path
            {//case its not valid
                if (!Directory.Exists(DataPostingPath_Box.Text))
                {
                    System.Windows.MessageBox.Show("Your posting files path is not valid, Please enter a new one.");
                }
                //case its not valid
                else
                {                   //case valid
                    if (rd == null) //called after reset or without building
                    {
                        rd = new ReadFile(path, postingPath, stemming);
                    }
                    if (!dictioneryInMemory)// case its without indexind...
                    {
                        rd.getTermsToDictionaryR();
                    }

                    DisplayPosting.Text = rd.getDisplayR();
                    System.Windows.MessageBox.Show("The Dictionery was loaded");
                }
            }
        }
        public static void Main(string[] args)
        {
            IExeStack <IStatement> stack = new ExeStack <IStatement>();

            Utils.IDictionary <string, int> dict = new MyDictionary <string, int>();
            IMyList <int>             output     = new MyList <int>();
            FileTable <int, FileData> fileTable  = new FileTable <int, FileData>();

            IStatement s1     = new OpenRFile("var_f", "C:\\Users\\Emy\\RiderProjects\\lab7\\text1.txt");
            IStatement s2     = new ReadFile(new VarExp("var_f"), "var_c");
            IStatement thenS1 = new ReadFile(new VarExp("var_f"), "var_c");
            IStatement thenS2 = new PrintStmt(new VarExp("var_c"));
            IStatement thenS  = new CompStmt(thenS1, thenS2);
            IStatement elseS  = new PrintStmt(new ConstExp(0));

            IStatement s3 = new IfStmt(new VarExp("var_c"), thenS, elseS);
            IStatement s4 = new CloseRFile(new VarExp("var_f"));

            IStatement s5 = new CompStmt(s1, s2);
            IStatement s6 = new CompStmt(s3, s4);
            IStatement s7 = new CompStmt(s5, s6);

            stack.push(s7);

            PrgState state = new PrgState(dict, stack, output, fileTable);

            Controller.Controller ctrl = new Controller.Controller(state);


            TextMenu menu = new TextMenu();

            menu.addCommand(new ExitCommand("0", "exit"));
            menu.addCommand(new RunExample("1", "example_1", ctrl));
            menu.show();
        }
    void Start()     // Use this for initialization
    {
        //for the comp time leaderboard
        CompTimeColum1 = GameObject.Find("CompTimeRow1");
        CompTimeColum2 = GameObject.Find("CompTimeRow2");
        CompTimeColum3 = GameObject.Find("CompTimeRow3");
        CompTimeLine2  = GameObject.Find("CompTimeLine2");

        //for the enemies killed leaderboard
        EnemieskilledColum1 = GameObject.Find("EnemiesKilledRow1");
        EnemieskilledColum2 = GameObject.Find("EnemiesKilledRow2");
        EnemieskilledColum3 = GameObject.Find("EnemiesKilledRow3");
        EnemieskilledLine2  = GameObject.Find("EnemiesKilledLine2");

        //for the least damage leaderboard
        LeastDamageColum1 = GameObject.Find("LeastDamageRow1");
        LeastDamageColum2 = GameObject.Find("LeastDamageRow2");
        LeastDamageColum3 = GameObject.Find("LeastDamageRow3");
        LeastDamageLine2  = GameObject.Find("LeastDamageLine2");

        ReadFile.Load("Assets/Data Files/Leaderboard.txt");          // the file that is loaded

        CompletionTime();
        EnemiesKilled();
        LeastDamage();

        //not needed on the leaderboard for the main menu, but will be needed when accessed from the end of game
        CompTimeLine2.SetActive(false);
        EnemieskilledLine2.SetActive(false);
        LeastDamageLine2.SetActive(false);
    }
Пример #9
0
        public void ReadCSVFile_WithoutError()
        {
            //Arrange
            IReadFile  irf          = new ReadFile();
            string     filePath     = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "Test_Files", "depthvalues.csv");
            List <int> expectedData = new List <int>();

            using (var reader = new StreamReader(@"" + filePath))
            {
                while (!reader.EndOfStream)
                {
                    var line    = reader.ReadLine();
                    var numbers = line.Split(' ');

                    numbers.ToList().ForEach(n =>
                    {
                        expectedData.Add(Convert.ToInt32(n));
                    });
                }
            }

            //Act
            List <int> actualData = irf.Read(filePath);

            //Assert
            CollectionAssert.AreEqual(expectedData, actualData);
        }
Пример #10
0
        public virtual ActionResult UploadPost(HttpPostedFileBase file)
        {
            var listStudents = new List <ListStudent>();

            if (file == null)
            {
                ModelState.AddModelError("Fichier", StudentResources.NoFileToUpload);
                ViewBag.Message = StudentResources.NoFileToUpload;
            }
            else
            {
                {
                    if (!file.FileName.Contains(".csv"))
                    {
                        ModelState.AddModelError("Fichier", StudentResources.NoFileToUpload);
                        ViewBag.Message = StudentResources.WrongFileType;
                    }
                }
            }

            if (ModelState.IsValid)
            {
                var readFile = new ReadFile();

                listStudents            = readFile.ReadFileCsv(file);
                TempData["listStudent"] = listStudents;

                return(RedirectToAction(MVC.Coordinator.CreateList()));
            }
            return(View(""));
        }
Пример #11
0
        public void return_empty_entry_if_information_isnt_there()
        {
            ReadFile test          = new ReadFile();
            var      resultContent = test.LoadEntries("");

            Assert.AreEqual(null, resultContent);
        }
        public void WelcomeMat(int difficulty)
        {
            switch (difficulty)
            {
            case 1:
                lib.ReadFile easy = new ReadFile();
                easy.TextFileManager("assets/data/difficulty/EasyDifficulty.txt", "Yellow");
                break;

            case 2:
                lib.ReadFile medium = new ReadFile();
                medium.TextFileManager("assets/data/difficulty/MediumDifficulty.txt", "Cyan");
                break;

            case 3:
                lib.ReadFile hard = new ReadFile();
                hard.TextFileManager("assets/data/difficulty/HardDifficulty.txt", "Magenta");
                break;

            default:
                Console.WriteLine("I did not understand that input");
                break;
            }
            Console.ReadLine();
        }
Пример #13
0
        private static void UpsertDatasetsIntoDB()
        {
            Initialize("datacop-ppe");
            Console.WriteLine("Upsert Datasets Into DB:");
            AzureCosmosDBClient azureCosmosDBClient = new AzureCosmosDBClient("DataCop", "Dataset");
            var datasetIds = new HashSet <string>()
            {
                @"618319c3-e263-4f02-bb24-041476954dc9",
            };
            var datasetJsonFilePaths = ReadFile.GetAllFilePath(FolderPath);

            foreach (var datasetJsonFilePath in datasetJsonFilePaths)
            {
                if (datasetJsonFilePath.ToLower().Contains(@"\dataset"))
                {
                    string fileContent = ReadFile.ThirdMethod(datasetJsonFilePath);
                    JsonSerializerSettings serializer = new JsonSerializerSettings
                    {
                        DateParseHandling = DateParseHandling.None
                    };
                    JObject gitDatasetJObject = JsonConvert.DeserializeObject <JObject>(fileContent, serializer);
                    string  id = gitDatasetJObject["id"].ToString();
                    if (datasetIds.Contains(id))
                    {
                        Console.WriteLine(id);
                        azureCosmosDBClient.UpsertDocumentAsync(gitDatasetJObject).Wait();
                    }
                }
            }
        }
Пример #14
0
 /// <summary>
 /// click to delete the posing file and free the memory
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Reset_Click(object sender, RoutedEventArgs e)
 {
     if (DataPostingPath_Box.Text.Length == 0)
     {
         System.Windows.MessageBox.Show("Please enter Posting Files path");
     }
     else if (DataPostingPath_Box.Text.Length != 0)
     {
         if (!Directory.Exists(DataPostingPath_Box.Text))
         {
             System.Windows.MessageBox.Show("Your posting files path is not valid, Please enter a new one.");
         }
         else
         {
             try
             {
                 Reset.IsEnabled = false;
                 //     deletePosting(!stemming);
                 // deletePosting(stemming);
                 deleteDocs(stemming);
                 deleteDocs(!stemming);
                 System.Windows.MessageBox.Show("The Posting Files have been removed");
                 Reset.IsEnabled = true;
                 rd = null;
                 // Start.IsEnabled = true;
             }
             catch (Exception)
             {
                 Reset.IsEnabled = true;
                 System.Windows.MessageBox.Show("Somthing get wrong, The Posting Files have not been removed");
                 return;
             }
         }
     }
 }
Пример #15
0
        public static void Run(SvPlayer player, string message)
        {
            string arg1 = GetArgument.Run(1, false, true, message);

            if (string.IsNullOrEmpty(arg1))
            {
                player.SendChatMessage(ArgRequired);
                return;
            }
            var currPlayer = GetShByStr.Run(arg1);

            if (currPlayer == null)
            {
                player.SendChatMessage(NotFoundOnline);
                return;
            }
            ReadFile.Run(MuteListFile);
            if (!MutePlayers.Contains(currPlayer.username))
            {
                MutePlayers.Add(currPlayer.username);
                File.AppendAllText(MuteListFile, currPlayer.username + Environment.NewLine);
                player.SendChatMessage($"<color={infoColor}>Muted </color><color={argColor}>{currPlayer.username}</color><color={infoColor}>.</color>");
                return;
            }
            RemoveStringFromFile.Run(MuteListFile, currPlayer.username);
            ReadFile.Run(MuteListFile);
            player.SendChatMessage($"<color={infoColor}>Unmuted </color><color={argColor}>{currPlayer.username}</color><color={infoColor}>.</color>");
        }
Пример #16
0
        public void ReadWordsListTests()
        {
            ReadFile      file = new ReadFile();
            List <String> list = file.ReadWordsList("word list.txt");

            Assert.AreEqual(true, list.Contains("kyles"));
        }
Пример #17
0
        private void openButton_Click(object sender, EventArgs e)
        {
            using (var openFileDialog1 = new OpenFileDialog())
            {
                openFileDialog1.Filter           = "Eyeshot (*.eye)|*.eye";
                openFileDialog1.Multiselect      = false;
                openFileDialog1.AddExtension     = true;
                openFileDialog1.CheckFileExists  = true;
                openFileDialog1.CheckPathExists  = true;
                openFileDialog1.DereferenceLinks = true;

                _openFileAddOn = new OpenFileAddOn();
                _openFileAddOn.EventFileNameChanged += OpenFileAddOn_EventFileNameChanged;

                if (openFileDialog1.ShowDialog(_openFileAddOn, this) == DialogResult.OK)
                {
                    model.Clear();
                    ReadFile readFile = new ReadFile(openFileDialog1.FileName, (contentType)_openFileAddOn.ContentOption);
                    model.StartWork(readFile);
                    model.SetView(viewType.Trimetric, true, model.AnimateCamera);
                    setFileButtonEnabled(false);
                }

                _openFileAddOn.EventFileNameChanged -= OpenFileAddOn_EventFileNameChanged;
                _openFileAddOn.Dispose();
                _openFileAddOn = null;
            }
        }
        public async void Process()
        {
            var        startTime           = DateTime.Now;
            ReadFile   readFile            = new ReadFile();
            String     fileData            = readFile.ReadFileAsync(this.file).Result;
            FileCopier fileCopier          = new FileCopier();
            String     lockFileName        = this.file.Substring(this.file.LastIndexOf(Path.DirectorySeparatorChar) + 1);
            String     fileNameWithoutLock = lockFileName.Substring(0, lockFileName.Length - 5);
            await fileCopier.copy(Config.GetRawPath() + Path.DirectorySeparatorChar + fileNameWithoutLock, fileData);

            JsonToObjectConverter converter = new JsonToObjectConverter();
            var  jsonObject = converter.Convert(fileData);
            Stat stat       = new Stat(fileNameWithoutLock);
            ValidationApplier validationApplier = new ValidationApplier();
            List <bool>       validationResult  = validationApplier.Validate(jsonObject, this.validators);
            EventSeparator    eventSeparator    = new EventSeparator();

            eventSeparator.Separate(jsonObject, validationResult);
            var    endTime             = DateTime.Now;
            Double elapsedMilliseconds = ((TimeSpan)(endTime - startTime)).TotalMilliseconds;

            stat.UpdateStat(jsonObject, validationResult, elapsedMilliseconds);
            EventLog log = new EventLog();

            Console.WriteLine(log.Generate(stat));
            Console.WriteLine("---------------------------------");
            File.Delete(file);
        }
Пример #19
0
        public static void Run(SvPlayer player, string message)
        {
            string arg1 = GetArgument.Run(1, false, true, message);

            if (string.IsNullOrEmpty(arg1))
            {
                arg1 = player.player.username;
            }
            var currPlayer = GetShByStr.Run(arg1);

            if (currPlayer == null)
            {
                player.SendChatMessage(NotFoundOnline);
                return;
            }
            ReadFile.Run(GodListFile);
            var msg = $"<color={infoColor}>Godmode</color> <color={argColor}>{{0}}</color> <color={infoColor}>for</color> <color={argColor}>'{arg1}'</color><color={infoColor}>.</color>";

            if (GodListPlayers.Contains(currPlayer.username))
            {
                RemoveStringFromFile.Run(GodListFile, currPlayer.username);
                ReadFile.Run(GodListFile);
                player.SendChatMessage(string.Format(msg, "disabled"));
                return;
            }
            File.AppendAllText(GodListFile, currPlayer.username + Environment.NewLine);
            GodListPlayers.Add(currPlayer.username);
            player.SendChatMessage(string.Format(msg, "enabled"));
        }
Пример #20
0
 protected void AddTool()
 {
     if (Application.MainMenu.InvokeRequired)
     {
         var s = new Simple(AddTool);
         Application.MainMenu.Invoke(s, null);
     }
     else
     {
         string name = ReadFile.getIniStr("MonitorNum", "MonitorName", "");
         foreach (ToolStripMenuItem v in Application.MainMenu.Items)
         {
             if (v.Text == "工具(&T)")
             {
                 v.DropDownItems.Add(_tsbMonitor);
                 _tsbMonitor.Text         = name;
                 _tsbMonitor.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                 //  _tsbMonitor.Click += new EventHandler(_tsbMonitor_Click);
                 break;
             }
         }
         _tsbMonitorb.Text = name;
         for (int i = 1; i <= number; i++)
         {
             ToolStripMenuItem _tsbmo1 = new ToolStripMenuItem();
             _tsbmo1.Tag = i;
             LoadInfo info = dicLoad[i];
             _tsbmo1.Text   = info.MonitorName;
             _tsbmo1.Click += new EventHandler(_tsbmo1_Click);
             _tsbMonitorb.DropDownItems.Add(_tsbmo1);
             _tsbMonitor.DropDownItems.Add(_tsbmo1);
         }
     }
 }
Пример #21
0
        public void ReadFileTest()
        {
            ReadFile dictionary;

            dictionary = new ReadFile();
            Assert.AreEqual(dictionary.GetDictionaryLength(), 1081);
        }
Пример #22
0
        private static void UpdateCosmosViewScripts()
        {
            var datasetTestJsonFilePaths = ReadFile.GetAllFilePath(FolderPath);
            int count = 0;

            foreach (var datasetTestJsonFilePath in datasetTestJsonFilePaths)
            {
                if (datasetTestJsonFilePath.ToLower().Contains(@"\monitor"))
                {
                    string fileContent = ReadFile.ThirdMethod(datasetTestJsonFilePath);
                    JsonSerializerSettings serializer = new JsonSerializerSettings
                    {
                        DateParseHandling = DateParseHandling.None
                    };
                    JObject gitDatasetTestJObject = JsonConvert.DeserializeObject <JObject>(fileContent, serializer);
                    if (gitDatasetTestJObject["dataFabric"]?.ToString().ToLower().Equals("cosmosview") == true)
                    {
                        count++;
                        var cosmosScriptContent = gitDatasetTestJObject["testContent"]["cosmosScriptContent"].ToString();
                        var index = cosmosScriptContent.IndexOf("OUTPUT ViewSamples");
                        cosmosScriptContent  = cosmosScriptContent.Substring(0, index);
                        cosmosScriptContent += " Count = SELECT COUNT() AS NumSessions FROM ViewSamples; OUTPUT Count TO SSTREAM \"/my/output.ss\"";
                        gitDatasetTestJObject["testContent"]["cosmosScriptContent"] = cosmosScriptContent;
                        WriteFile.FirstMethod(datasetTestJsonFilePath, gitDatasetTestJObject.ToString());
                    }
                }
            }

            Console.WriteLine($"count: {count}");
        }
Пример #23
0
        private static void UpdateAllSqlKeyVaultName()
        {
            var datasetJsonFilePaths = ReadFile.GetAllFilePath(FolderPath);

            foreach (var datasetJsonFilePath in datasetJsonFilePaths)
            {
                if (datasetJsonFilePath.ToLower().Contains("dataset"))
                {
                    string fileContent = ReadFile.ThirdMethod(datasetJsonFilePath);
                    JsonSerializerSettings serializer = new JsonSerializerSettings
                    {
                        DateParseHandling = DateParseHandling.None
                    };
                    JObject gitDatasetJObject = JsonConvert.DeserializeObject <JObject>(fileContent, serializer);
                    if (gitDatasetJObject["dataFabric"]?.ToString().ToLower().Equals("sql") == true)
                    {
                        if (gitDatasetJObject["connectionInfo"]["auth"]["keyVaultName"]?.ToString().ToLower().Equals("datacopprod") == true)
                        {
                            gitDatasetJObject["connectionInfo"]["auth"]["keyVaultName"] = "datacop-prod";
                            WriteFile.FirstMethod(datasetJsonFilePath, gitDatasetJObject.ToString());
                            Console.WriteLine(datasetJsonFilePath);
                        }
                        else if (gitDatasetJObject["connectionInfo"]["auth"]["keyVaultName"]?.ToString().ToLower().Equals("datacop-prod") == true)
                        {
                        }
                        else
                        {
                            Console.WriteLine(gitDatasetJObject["id"]);
                            Console.WriteLine(gitDatasetJObject["connectionInfo"]["auth"]["keyVaultName"]);
                        }
                    }
                }
            }
        }
Пример #24
0
        public void GetDictionaryLengthTest()
        {
            ReadFile  dictionary = new ReadFile();
            const int NUMBER     = 1081;

            Assert.AreEqual(dictionary.GetDictionaryLength(), NUMBER);
        }
Пример #25
0
        private static void UpsertDatasetTestsIntoDB()
        {
            Console.WriteLine("Upsert DatasetTests Into DB:");
            Initialize("datacop-ppe");
            AzureCosmosDBClient azureCosmosDBClient = new AzureCosmosDBClient("DataCop", "DatasetTest");
            var datasetTestIds = new HashSet <string>()
            {
                @"d2e33866-5d1c-4670-90c2-dd8d0c29fcdc",
            };
            var datasetTestJsonFilePaths = ReadFile.GetAllFilePath(FolderPath);

            foreach (var datasetTestJsonFilePath in datasetTestJsonFilePaths)
            {
                if (datasetTestJsonFilePath.ToLower().Contains(@"\monitor"))
                {
                    string fileContent = ReadFile.ThirdMethod(datasetTestJsonFilePath);
                    JsonSerializerSettings serializer = new JsonSerializerSettings
                    {
                        DateParseHandling = DateParseHandling.None
                    };
                    JObject gitDatasetTestJObject = JsonConvert.DeserializeObject <JObject>(fileContent, serializer);
                    string  id = gitDatasetTestJObject["id"].ToString();
                    if (datasetTestIds.Contains(id))
                    {
                        Console.WriteLine(id);
                        azureCosmosDBClient.UpsertDocumentAsync(gitDatasetTestJObject).Wait();
                    }
                }
            }
        }
Пример #26
0
        private static void DisableAllDatasetTests()
        {
            Initialize("datacop-prod");
            string fileFolder = FolderPath + @"\PROD\DataVC\Monitor";
            var    filePaths  = ReadFile.GetFolderSubPaths(fileFolder, ReadType.File, PathType.Absolute);
            AzureCosmosDBClient azureCosmosDBClient = new AzureCosmosDBClient("DataCop", "DatasetTest");

            foreach (var filePath in filePaths)
            {
                var fileContentString = ReadFile.ThirdMethod(filePath);
                var json = JObject.Parse(fileContentString);
                var id   = json["id"].ToString();
                if (id.Equals("01883b87-5b20-40f4-90f2-2ce6cbdfa766"))
                {
                    var jObjectInCosmosDb = azureCosmosDBClient.FindFirstOrDefaultItemAsync <JObject>($"SELECT * FROM c where c.id = '{id}'").Result;
                    if (jObjectInCosmosDb != null)
                    {
                        jObjectInCosmosDb["status"] = "Disabled";
                        //jObjectInCosmosDb["testContent"]["isStreamSet"] = true;
                        Console.WriteLine(jObjectInCosmosDb);
                        //azureCosmosDBClient.UpsertDocumentAsync(json).Wait();
                    }
                }
            }
        }
 // these could be mocked for convinience
 //
 private static ReadFile getFileReader(string file_name)
 {
     // this is not the proper way but I couldn't findhow to find a file
     string path = Environment.CurrentDirectory + "/../../tests/" + @file_name;
     ReadFile file_reader = new ReadFile(path);
     return file_reader;
 }
Пример #28
0
 /// <summary>
 ///Read Json file words
 /// </summary>
 /// <returns></returns>
 private List <Word> ReadJSonWords()
 {
     using (ReadFile fileUtil = new ReadFile())
     {
         return(fileUtil.WordsResolver(Environment.CurrentDirectory + @"\Files\json\words.json"));
     }
 }
Пример #29
0
        public static void Bunny(Model model)
        {
            ReadFile readFile = new ReadFile(MainWindow.GetAssetsPath() + "Bunny.eye");

            readFile.DoWork();

            // scales file contents by 100
            foreach (Entity entity in readFile.Entities)
            {
                entity.Scale(100, 100, 100);
            }

            readFile.AddToScene(model);

            if (model.Entities.Count > 0 && model.Entities[0] is FastPointCloud)
            {
                FastPointCloud fpc = (FastPointCloud)model.Entities[0];

                fpc.Rotate(Math.PI / 2, Vector3D.AxisX, Point3D.Origin);

                model.Entities.Regen();

                model.ZoomFit();

                BallPivoting bp = new BallPivoting(fpc);

                model.StartWork(bp);
            }
        }
Пример #30
0
        public void InvokeViewComponent(string componentName, object parameters, out string viewHtml, out object model, out string viewPath, bool onlyModel = false)
        {
            viewHtml = null;
            model    = null;
            viewPath = null;
            var component = _viewComponentSelector.SelectComponent(componentName);

            if (component == null)
            {
                return;
            }
            if (!onlyModel)
            {
                var componentPath = $"Components/{component.FullName}/Default";
                viewPath = _viewAccountant.GetThemeViewPath(componentPath);
                if (viewPath.IsNullEmptyOrWhiteSpace())
                {
                    return;
                }
                viewHtml = ReadFile.From(viewPath).Content;
            }
            var instance            = DependencyResolver.ResolveOptional(component.TypeInfo.AsType(), true);
            var viewComponentResult = (ViewViewComponentResult)component.MethodInfo.Invoke(instance, new[] { parameters });

            model = viewComponentResult.ViewData.Model;
        }
Пример #31
0
        private static void UpdateCosmosVCToBuild()
        {
            var kenshoDatasetIds = GetKenshoDatasetIds();
            var jsonFilePaths    = ReadFile.GetAllFilePath(FolderPath);

            foreach (var jsonFilePath in jsonFilePaths)
            {
                if (jsonFilePath.ToLower().Contains(@"\dataset"))
                {
                    string fileContent = ReadFile.ThirdMethod(jsonFilePath);
                    JsonSerializerSettings serializer = new JsonSerializerSettings
                    {
                        DateParseHandling = DateParseHandling.None
                    };
                    JObject gitDatasetJObject = JsonConvert.DeserializeObject <JObject>(fileContent, serializer);
                    if (gitDatasetJObject["dataFabric"]?.ToString().ToLower().Equals("cosmosstream") == true)
                    {
                        if (kenshoDatasetIds.Contains(gitDatasetJObject["id"].ToString()))
                        {
                            Console.WriteLine($"Not update kensho dataset: {gitDatasetJObject["id"]?.ToString()}");
                            continue;
                        }

                        bool update = false;
                        if (gitDatasetJObject["connectionInfo"]["cosmosVC"]?.ToString().ToLower().Trim('/').Equals("https://cosmos14.osdinfra.net/cosmos/ideas.prod.build") == true)
                        {
                            update = true;
                        }
                        else if (gitDatasetJObject["connectionInfo"]["cosmosVC"]?.ToString().ToLower().Trim('/').Equals("https://cosmos14.osdinfra.net/cosmos/ideas.prod") == true ||
                                 gitDatasetJObject["connectionInfo"]["cosmosVC"]?.ToString().ToLower().Trim('/').Equals("https://cosmos14.osdinfra.net/cosmos/ideas.private.data") == true)
                        {
                            if (gitDatasetJObject["connectionInfo"]["streamPath"].ToString().ToLower().Trim('/').StartsWith("share"))
                            {
                                update = true;
                            }
                            else
                            {
                                var streamPath = gitDatasetJObject["connectionInfo"]["streamPath"].ToString();
                                Console.WriteLine($"Not update dataset: {gitDatasetJObject["id"]?.ToString()}, streamPath: {streamPath}");
                            }
                        }
                        else
                        {
                            var cosmosVC = gitDatasetJObject["connectionInfo"]["cosmosVC"].ToString();
                            Console.WriteLine($"Not update dataset: {gitDatasetJObject["id"]?.ToString()}, cosmosVC: {cosmosVC}");
                        }

                        if (update)
                        {
                            gitDatasetJObject["connectionInfo"]["cosmosVC"] = "https://cosmos14.osdinfra.net/cosmos/IDEAs.Prod.Build/";
                            if (gitDatasetJObject["connectionInfo"]["dataLakeStore"]?.ToString().Length > 0)
                            {
                                gitDatasetJObject["connectionInfo"]["dataLakeStore"] = "ideas-prod-build-c14.azuredatalakestore.net";
                            }
                            WriteFile.FirstMethod(jsonFilePath, gitDatasetJObject.ToString());
                        }
                    }
                }
            }
        }
Пример #32
0
 private void button1_Click(object sender, EventArgs e)
 {
     op.ShowDialog();
     op.Multiselect = true;
     //op.FileName
     ReadDataFile.Service.ReadFile read = new ReadFile();
     sheet = new OberveSheet();
     sheet.Lines = read.ReadTxtList(op.FileNames);
 }
Пример #33
0
        public FileCopy(string source, string destination, Action<UvArgs> completed)
        {
            _read = new ReadFile(source);
            _write = new WriteFile(destination);
            _completed = completed;

            _read.Opened += FileOpened;
            _write.Opened += FileOpened;
            _read.Closed += FileClosed;
            _write.Closed += FileClosed;

            _read.Open(_write);
            _write.Open(_read);
        }
        public void TestReadFilewithWordsinColons()
        {
            List<String> actual = new List<String>();
            List<String> expected = new List<String>();

            // this is not the proper way but I couldn't findhow to find a file
            string path = Environment.CurrentDirectory + "/../../tests/word1count1.txt";
            ReadFile file_reader = new ReadFile(path);
            foreach (string word in file_reader.getWord())
            {
                actual.Add(word);
            }
            expected.Add("word1");
            expected.Add("word2");

            Assert.AreEqual(expected, actual,
                "expected :" + expected + " did not match actual :" + actual);
        }
Пример #35
0
        public static string ReadLeicaDNA03(string[] files, string prjName, int RecNo, double iAngle)
        {
            ReadFile read = new ReadFile();
            OberveSheet sheet = new ReadDataFile.Model.OberveSheet();
            sheet.Lines = read.ReadTxtList(files);

            string exportname = string.Format("{0}工程水准观测记录{1}次", prjName, RecNo);
            string templateUrl = HttpContext.Current.Request.ApplicationPath + "/Template/DNA03_Template.xls";
            string exportUrl = HttpContext.Current.Request.ApplicationPath + "/Export/" + exportname + ".xls";
            string templetepath = HttpContext.Current.Server.MapPath(templateUrl);
            string exportpath =HttpContext.Current.Server.MapPath(exportUrl);

            OberveSheet.IAngle = iAngle;
            OberveSheet.PrjName = exportname;
            OberveSheet.RecordNo = RecNo;

            ExportFile ex = new ExportFile();
            ex.TemplateFilePath = templetepath;
            ex.ExportFilePath = exportpath;
            ex.Export(sheet);
            return exportname + ".xls";
        }
Пример #36
0
        private static void Main(string[] args)
        {
            System.Net.ServicePointManager.Expect100Continue = false;
            ServicePointManager.UseNagleAlgorithm = false;
            ServicePointManager.DefaultConnectionLimit = 100;
            //Variables for this method
            string[] url; //Array for user input file
            List<String> errors = new List<string>(); //List of errors - it's a list because I don't know how many errors there may be
            string[] errorArray; //Array of errors - I dump the list into an array before writing  errors.txt
            string filename;
            ReadFile reader = new ReadFile(); //Object of class ReadFile - the readfile class reads and writes to file. I should probably name it better
            //Read File
            if (args.Length == 0)
            {
                Console.Write("Please enter the filename: ");
                filename = Console.ReadLine();
            }
            else
            { filename = args[0]; }
            reader.Filename = filename; //This sends the filename that I just read to the object's private property _filename
            url = reader.Read(); //This reads the file and returns the array.

            for (int i = 0; i < url.Length; i++) //start to loop through the array
            {
                bool test = IsDomainAlive(url[i], 1); //Test with TCPclient to see if the domain exists at all
                if (test) //if it exists, then check for the rest of the URI path
                {
                    errors.Add(url[i] + " " + testURL(url[i]));
                }
                else
                { errors.Add(url[i] + " " + "No such domain exists"); }
            }

            errorArray = errors.ToArray(); //Convert the list to an array - this helps with writing the error file
            reader.Write(errorArray);

            Console.WriteLine("Done! Check errors.txt for errors.");
        }
Пример #37
0
 /// <summary>
 /// Initialize form
 /// </summary>
 public MainForm()
 {
     InitializeComponent();
     //InitializeDatabaseSelector();
     InitializeSettings();
     //files = fileAccess.GetFileList("");
     ReadFile textFile = new ReadFile("C:\\Users\\PROFIMEDICA\\Downloads\\ocx_sfv_030a.ctl", "C:\\Users\\PROFIMEDICA\\Downloads\\ocx_sfv_030a.csv");
 
     //serverAccess.CreateSymbol("rrrrrrr");
 }
Пример #38
0
 public void Open(ReadFile read)
 {
     _read = read;
     this.OpenWrite(_path);
 }
Пример #39
0
 private void fileToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     ReadFile textFile = new ReadFile("C:\\Users\\PROFIMEDICA\\Downloads\\ocx_sfv_030a.ctl", "C:\\Users\\PROFIMEDICA\\Downloads\\ocx_sfv_030a.csv");
 }