Exemplo n.º 1
0
        /// <summary>
        /// Call the XML Generate method and displays the location of the stored path
        /// </summary>
        private void GenerateXML()
        {
            XmlGenerator xm   = new XmlGenerator();
            string       path = xm.generateXML(repos);

            XMLLabel.Text = "XML File Path: " + path;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generates the xml.
        /// </summary>
        /// <returns>Generated xml.</returns>
        public XElement GenerateXml()
        {
            var questionIds = _view.GetQuestionIds();
            var questions   = _model.GetQuestions(questionIds);

            return(XmlGenerator.GenerateXml(questions));
        }
Exemplo n.º 3
0
        public void CreateOSGARastriginScriptTest()
        {
            var    script = CreateOSGARastriginScript();
            string path   = Path.Combine(ScriptingUtils.ScriptsDirectory, ScriptFileName + ScriptingUtils.ScriptFileExtension);

            XmlGenerator.Serialize(script, path);
        }
Exemplo n.º 4
0
        public void CreateAlpsGaSymRegSampleTest()
        {
            var    alpsGa = CreateAlpsGaSymRegSample();
            string path   = Path.Combine(SamplesUtils.SamplesDirectory, SymRegSampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(alpsGa, path);
        }
Exemplo n.º 5
0
        protected override void OnStart(string[] args)
        {
            ThreadPool.QueueUserWorkItem(async state =>
            {
                logger = new Logger();
                string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                try
                {
                    var repositories          = new UnitOfWork(connectionString);
                    OrderService orderService = new OrderService(repositories);
                    var ordersInfo            = await orderService.GetOrders();

                    //making proper file name
                    DateTime now = DateTime.Now;
                    var currTime = now.ToString("yyyy_MM_dd_HH_mm_ss");

                    XmlGenerator <Order> orders = new XmlGenerator <Order>(logger.parsedOptions.options.PathsOptions.SourceDirectory + "Sales_" + currTime + ".txt");
                    await orders.XmlGenerate(ordersInfo);
                    this.OnStop();
                }
                catch (Exception trouble)
                {
                    var repositories2    = new UnitOfWork(connectionString);
                    ErrorService service = new ErrorService(repositories2);
                    service.AddErrors(new Error(trouble.GetType().Name, trouble.Message, DateTime.Now));
                }
                Thread loggerThread = new Thread(new ThreadStart(logger.Start));
                loggerThread.Start();
            });
        }
Exemplo n.º 6
0
        public ActionResult Index(string xmlFileName)
        {
            if (String.IsNullOrEmpty(xmlFileName))
            {
                ViewData["Error"] = "You have to provide file name!";
                return(View());
            }
            if (!(xmlFileName.EndsWith(".xml", true, null)))
            {
                xmlFileName += ".xml";
            }

            AspDatabase db   = new AspDatabase();
            Root        root = db.LoadDataFromXmlDatabase();

            if (root != null)
            {
                XmlGenerator generator = new XmlGenerator();

                string path = Server.MapPath("~/App_Data/" + xmlFileName).ToString();

                generator.Generate(path, root);

                ViewData["Message"] = "Download succesful! Xml saved to " + path;
            }
            else
            {
                ViewData["Error"] = "Download failed!";
            }
            return(View());
        }
        public void CreateSimulatedAnnealingRastriginSampleTest()
        {
            var    sa   = CreateSimulatedAnnealingRastriginSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(sa, path);
        }
        public void CreatePsoRastriginSampleTest()
        {
            var    pso  = CreatePsoRastriginSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(pso, path);
        }
Exemplo n.º 9
0
 public Task WriteInsightsToXmlAsync(string outputFolder)
 {
     return(Task.Run(async() =>
     {
         using (SqlConnection connection = new SqlConnection(connectionString))
         {
             connection.Open();
             SqlTransaction transaction = connection.BeginTransaction();
             SqlCommand command = new SqlCommand("sp_GetInsights", connection);
             command.CommandType = CommandType.StoredProcedure;
             command.Transaction = transaction;
             try
             {
                 SqlDataAdapter adapter = new SqlDataAdapter(command);
                 DataSet dataSet = new DataSet("Insights");
                 DataTable dataTable = new DataTable("Insight");
                 dataSet.Tables.Add(dataTable);
                 adapter.Fill(dataSet.Tables["Insight"]);
                 XmlGenerator xmlGenerator = new XmlGenerator(outputFolder);
                 await xmlGenerator.WriteToXmlAsync(dataSet, "appInsights");
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 using (StreamWriter sw = new StreamWriter(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Exceptions.txt"), true))
                 {
                     await sw.WriteLineAsync($"{DateTime.Now:dd/MM/yyyy HH:mm:ss} Exception: {ex.Message}");
                 }
                 transaction.Rollback();
             }
         }
     }));
 }
Exemplo n.º 10
0
        public void CreateGPSymbolicRegressionSampleWithOSTest()
        {
            var    osga = CreateGpSymbolicRegressionSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(osga, path);
        }
Exemplo n.º 11
0
        private static void ConvertDocxToXml(string inputFile, string docxToXmlFilePath, string outputFile)
        {
            Settings     settings = new Settings();
            XmlGenerator xg       = new XmlGenerator(inputFile, docxToXmlFilePath, outputFile, settings);

            xg.Read();
        }
Exemplo n.º 12
0
        private void SaveItems(object param)
        {
            Directory.Delete(ItemsPath, true);
            Directory.CreateDirectory(ItemsPath);
            // directory creation might take some time -> wait until it is definitively created
            while (!Directory.Exists(ItemsPath))
            {
                Thread.Sleep(100);
                Directory.CreateDirectory(ItemsPath);
            }

            int i = 0;

            T[] items = GetStorableItems(itemListViewItemMapping.Keys);

            foreach (T item in items)
            {
                try {
                    i++;
                    SetEnabledStateOfContentViews(item, false);
                    XmlGenerator.Serialize(item, ItemsPath + Path.DirectorySeparatorChar + i.ToString("00000000") + ".hl", CompressionLevel.Optimal);
                    OnItemSaved(item, progressBar.Maximum / listView.Items.Count);
                }
                catch (Exception) { }
                finally {
                    SetEnabledStateOfContentViews(item, true);
                }
            }
            OnAllItemsSaved();
        }
Exemplo n.º 13
0
        private void uiOuputFile_Click(object sender, EventArgs e)
        {
            List <ActiveRuleValidity> arv = new List <ActiveRuleValidity>();

            foreach (DataGridViewRow row in uiParameters.Rows)
            {
                string ruleName = (string)row.Cells["RuleName"].Value;
                bool   valid    = (bool)row.Cells["Valid"].Value;
                bool   active   = (bool)row.Cells["Active"].Value;
                if (active)
                {
                    arv.Add(new ActiveRuleValidity()
                    {
                        RuleName = ruleName, Valid = valid
                    });
                }
            }

            bool parse = uint.TryParse(uiMultiplication.Text, out uint scale);

            if (!parse)
            {
                scale = 1;
            }


            int UKPRN = int.Parse(uiUKPRN.Text);

            XmlGenerator.CreateAllFiles(_rfp, arv, UKPRN, @"D:\\", scale);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Exports the AST to Xml format.
        /// </summary>
        /// <param name="program">The AST root node</param>
        /// <param name="fileName">The path to the destination file</param>
        public static void ExportXml(Program program, string fileName)
        {
            var exporter = new XmlGenerator();

            program.AcceptCompiler(exporter);
            exporter.Document.Save(fileName);
        }
Exemplo n.º 15
0
        public void When_passing_result_with_no_content_it_is_not_exported()
        {
            IComparerResult result = new ComparerResult(ResultContext.Assembly, "Assembly");
            XElement        sut    = XmlGenerator.GenerateXml(result);

            Assert.AreEqual(0, sut.Elements(ChangedElement).Count());
        }
        public void CreateLocalSearchKnapsackSampleTest()
        {
            var    ls   = CreateLocalSearchKnapsackSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ls, path);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Exports the AST to Xml format.
        /// </summary>
        /// <param name="program">The AST root node</param>
        /// <param name="output">The destination output stream</param>
        public static void ExportXml(Program program, Stream output)
        {
            var exporter = new XmlGenerator();

            program.AcceptCompiler(exporter);
            exporter.Document.Save(output);
        }
        public void CreateOSESGriewankSampleTest()
        {
            var    es   = CreateOSESGriewankSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(es, path);
        }
Exemplo n.º 19
0
        public void CreateGridSearchSVMClassificationScriptTest()
        {
            var    script = CreateGridSearchSVMClassificationScript();
            string path   = Path.Combine(ScriptingUtils.ScriptsDirectory, ScriptFileName + ScriptingUtils.ScriptFileExtension);

            XmlGenerator.Serialize(script, path);
        }
        public void CreateGaussianProcessRegressionSampleTest()
        {
            var    gpr  = CreateGaussianProcessRegressionSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(gpr, path);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Saves the settings (i.e custom configurations).
        /// </summary>
        protected void SaveSettings()
        {
            Serializer serializer = new Serializer(
                customConfigurations,
                GetDefaultConfig(new XmlFormat()),
                "CustomConfigurations");
            XmlGenerator  generator           = new XmlGenerator();
            StringBuilder configurationString = new StringBuilder();

            foreach (ISerializationToken token in serializer)
            {
                configurationString.Append(generator.Format(token));
            }
            StringBuilder configurationTypeCacheString = new StringBuilder();

            foreach (string s in generator.Format(serializer.TypeCache))
            {
                configurationTypeCacheString.Append(s);
            }
            Properties.Settings.Default.CustomConfigurations =
                configurationString.ToString();
            Properties.Settings.Default.CustomConfigurationsTypeCache =
                configurationTypeCacheString.ToString();
            Properties.Settings.Default.Save();
        }
Exemplo n.º 22
0
 public Task GetCustomersAsync(string outputFolder, DataBaseWorker appInsights, string customersFileName)
 {
     return(Task.Run(async() =>
     {
         using (SqlConnection connection = new SqlConnection(connectionString))
         {
             connection.Open();
             SqlTransaction transaction = connection.BeginTransaction();
             SqlCommand command = new SqlCommand("sp_GetCustomers", connection);
             command.CommandType = CommandType.StoredProcedure;
             command.Transaction = transaction;
             try
             {
                 SqlDataAdapter adapter = new SqlDataAdapter(command);
                 DataSet dataSet = new DataSet("Customers");
                 DataTable dataTable = new DataTable("Customer");
                 dataSet.Tables.Add(dataTable);
                 adapter.Fill(dataSet.Tables["Customer"]);
                 XmlGenerator xmlGenerator = new XmlGenerator(outputFolder);
                 await xmlGenerator.WriteToXmlAsync(dataSet, customersFileName);
                 await appInsights.InsertInsightAsync("Customers were received successfully");
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 await appInsights.InsertInsightAsync("EXCEPTION: " + ex.Message);
                 transaction.Rollback();
             }
         }
     }));
 }
Exemplo n.º 23
0
        public void CreateVnsOpSampleTest()
        {
            var    vns  = CreateVnsOpSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(vns, path);
        }
        public void CreateGpSymbolicClassificationSampleTest()
        {
            var    ga   = CreateGpSymbolicClassificationSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ga, path);
        }
Exemplo n.º 25
0
        public void CreateScatterSearchVRPSampleTest()
        {
            var    ss   = CreateScatterSearchVRPSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ss, path);
        }
Exemplo n.º 26
0
        public void CreateRAPGASchedulingSampleTest()
        {
            var    ss   = CreateRAPGASchedulingSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ss, path);
        }
Exemplo n.º 27
0
        public void CreateTabuSearchTspSampleTest()
        {
            var    ts   = CreateTabuSearchTspSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ts, path);
        }
Exemplo n.º 28
0
        public void CreateGeArtificialAntSampleTest()
        {
            var    geaa = CreateGeArtificialAntSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, GeArtificialAntSampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(geaa, path);
        }
Exemplo n.º 29
0
        public void CreateGaGroupingProblemSampleTest()
        {
            var    ga   = CreateGaGroupingProblemSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ga, path);
        }
Exemplo n.º 30
0
        public void CreateGeSymbolicRegressionSampleTest()
        {
            var    geSymbReg = CreateGeSymbolicRegressionSample();
            string path      = Path.Combine(SamplesUtils.SamplesDirectory, GeSymbolicRegressionSampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(geSymbReg, path);
        }
        public void XmlGenerator_WithValidEmptyProducerList_ReturnsCorrectXml()
        {
            // Arrange
            ProducerListSettings settings = A.Fake<ProducerListSettings>();

            ProducerList producerList = new ProducerList();
            producerList.ApprovalNumber = "Approval Number";
            producerList.ComplianceYear = 2015;
            producerList.SchemaVersion = MemberRegistrationSchemaVersion.Version_3_06;
            producerList.SchemeBusiness.Company = new SchemeCompany();
            producerList.SchemeBusiness.Company.CompanyName = "Company Name";
            producerList.SchemeBusiness.Company.CompanyNumber = "Company Number";
            producerList.TradingName = "Trading Name";

            XmlGenerator xmlGenerator = new XmlGenerator();

            // Act
            XDocument xmlDocument = xmlGenerator.GenerateXml(producerList, settings);

            string actual;
            using (MemoryStream stream = new MemoryStream())
            {
                xmlDocument.Save(stream);
                stream.Position = 0;
                using (TextReader tr = new StreamReader(stream))
                {
                    actual = tr.ReadToEnd();
                }
            }

            // Assert
            string expected =
@"<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?>
<scheme xmlns=""http://www.environment-agency.gov.uk/WEEE/XMLSchema"">
  <XSDVersion>3.06</XSDVersion>
  <approvalNo>Approval Number</approvalNo>
  <complianceYear>2015</complianceYear>
  <tradingName>Trading Name</tradingName>
  <schemeBusiness>
    <company>
      <companyName>Company Name</companyName>
      <companyNumber>Company Number</companyNumber>
    </company>
  </schemeBusiness>
  <producerList />
</scheme>";

            Xunit.Assert.Equal(expected, actual);
        }
Exemplo n.º 32
0
        static void Main(string[] args)
        {
            var myNeatRepo = new MyNeatRepo();
            var someList = myNeatRepo.DoSomeQuerying();

            var xmlGenerator = new XmlGenerator();
            var generatedXml = xmlGenerator.GenerateSomeXml();

            var xmlCustomReader = new XmlCustomReader();

            xmlCustomReader.ReadOutTheXml(generatedXml);

            Console.WriteLine(generatedXml);

            Console.ReadLine();
        }