Exemplo n.º 1
0
        public Guid AddOutput(TextOutputManager newOutputWriter, LoggingLevel newLevel = LoggingLevel.Standard, LoggingMode newMode = LoggingMode.Minimum)
        {
            output newOutput = new output(this, Foundation.TimeStamp, newOutputWriter, newLevel, newMode);

            outputs.Add(newOutput);
            return(newOutput.Identifier);
        }
Exemplo n.º 2
0
        public Object[] Exec(func f, output output, Object[] p_j, int nth)
        {
            _f = f;
            _output = output;
            _nth = nth;
            _job = new SJobQueue();
            _job.p_j = p_j;
            _job.nj = p_j.Length;
            _job.submitted_j = new bool[_job.nj];
            _job.completed_j = new bool[_job.nj];
            _job.outputted_j = new bool[_job.nj];
            _job.th_j = new int[_job.nj];
            _job.ret_j = new Object[_job.nj];
            for (int j = 0; j < _job.nj; j++) _job.submitted_j[j] = false;
            for (int j = 0; j < _job.nj; j++) _job.completed_j[j] = false;
            for (int j = 0; j < _job.nj; j++) _job.outputted_j[j] = false;

            System.Threading.Thread[] thread_th = new System.Threading.Thread[nth];

            for (int th = 0; th < nth; th++)
            {
                thread_th[th] = new System.Threading.Thread(Iterate);
                thread_th[th].Name = "CJobQueue Worker Thread " + th;
                thread_th[th].Start();
                System.Threading.Thread.Sleep(10);
            }

            Output();
            for (int th = 0; th < nth; th++)
            {
                thread_th[th].Join();
            }
            return _job.ret_j;
        }
        public output PostRegister([FromBody] User user)
        {
            // var samplejson = [{​​​​​​​​ "name":"John", "age":30, "car":null }​​​​​​​​];


            var    myresult   = new output();
            int    returnId   = _login.CheckLogin(user.userName, user.password);
            string validation = _login.PasswordValidation(user.password, user.cpass);

            if (validation == "valid password" && returnId == -1)
            {
                _login.AddNewUser(user.userName, user.password, user.cpass, user.gender, user.address, user.phone);
                //JObject json = JObject.Parse("new user added");

                myresult.result = "user added";
                return(myresult);
            }
            else if (returnId != -1)
            {
                //return JsonResult(new {​​​​​​​​Student }​​​​​​​​, JsonRequestBehavior.AllowGet);
                myresult.result = "user already exists";
                return(myresult);
            }
            else
            {
                myresult.result = validation;
                return(myresult);
            }
        }
Exemplo n.º 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            output output = db.outputs.Find(id);

            db.outputs.Remove(output);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        private bool CompareRows(InstanceReport baseRep, InstanceReport newRep, DateTime reportDate, out string error)
        {
            error = string.Empty;
            output     op        = new output(Output);
            bool       retval    = true;
            RowCounter baseCount = BuildRowCount(baseRep);
            RowCounter newCount  = BuildRowCount(newRep);

            //"Row property {0} mismatched counts: <br>Expected Results: '{1}' Actual Results: '{2}'"
            //Compare results of each dictionary:
            foreach (string key in baseCount.Keys)
            {
                if (baseCount[key] != newCount[key])
                {
                    retval = false;
                    this.htmlStarter(string.Format(mismatchRows,
                                                   key, baseCount[key], newCount[key]), reportDate, out error);

                    //RLogger.Info(string.Format(debugParameters, baseRep.ReportLongName, newRep.ReportLongName, errorID, 433));
                    using (BaselineRules baseL = new BaselineRules(baseRep, newRep, errorID))
                    {
                        baseL.EvaluateIsAbstractGroupRule();
                    }
                }
            }

            if (baseRep.Rows.Count != newRep.Rows.Count)
            {
                retval = false;
                this.htmlStarter(string.Format("Row counts do not match " + expectedResults, baseRep.Rows.Count, newRep.Rows.Count), reportDate, out error);
            }

            int min = Math.Min(baseRep.Rows.Count, newRep.Rows.Count);

            for (int r = 0; r < min; r++)
            {
                InstanceReportRow baseRow = baseRep.Rows[r];
                InstanceReportRow newRow  = newRep.Rows[r];

                string baseLabel = WHITE_SPACE.Replace(baseRow.Label, " ");
                string newLabel  = WHITE_SPACE.Replace(newRow.Label, " ");
                if (!string.Equals(baseLabel, newLabel))
                {
                    retval = false;
                    this.htmlStarter(string.Format("Row '" + r + "' labels do not match " + expectedResults, baseLabel, newLabel), reportDate, out error);
                }

                if (!string.Equals(baseRow.FootnoteIndexer, newRow.FootnoteIndexer))
                {
                    retval = false;
                    htmlStarter(string.Format(mismatchCell,
                                              r.ToString(), baseLabel, "Footnotes: " + baseRow.FootnoteIndexer, "Footnotes: " + newRow.FootnoteIndexer), reportDate, out error);
                }
            }

            return(retval);
        }
Exemplo n.º 6
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!validator.Validate())
         return;
     NewOutput = (output)bdgOutput.Current;
     NewOutput.customer_name = customer.SingleOrDefault(NewOutput.customer_id).corporate_name;
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Exemplo n.º 7
0
        public output PostMethodRegister([FromBody] Product productInput)
        {
            string result = _register.register(productInput);

            var myresult = new output();

            myresult.result = result;
            return(myresult);
        }
Exemplo n.º 8
0
 public device(Controllable c)
 {
     this.cont = c;
     Outputs   = new output[c.GetParams().Length];
     for (int i = 0; i < c.GetParams().Length; i++)
     {
         Outputs[i] = new output(ref c.GetParams()[i]);
     }
 }
Exemplo n.º 9
0
    public void Bubblesort(double[] data, string[] yearLines, string[] monthLines, int menuChoiceTime, string month, string year, int menuChoiceDo, int menuChoiceOutput)
    {
        //Initalise the temporary variables
        double temp        = 0;
        string tmpYear     = "";
        string tmpMonth    = "";
        int    stepCounter = 0;

        //Initialise object
        output outputObject = new output();

        //Do swapping
        //Sorts 3 lists at once based upon the comparison
        for (int write = 0; write < data.Length; write++)
        {
            for (int sort = 0; sort < data.Length - 1; sort++)
            {
                if (data[sort] > data[sort + 1])
                {
                    //Assign the temporary variables
                    temp     = data[sort + 1];
                    tmpYear  = yearLines[sort + 1];
                    tmpMonth = monthLines[sort + 1];

                    //Swap the data
                    data[sort + 1]       = data[sort];
                    yearLines[sort + 1]  = yearLines[sort];
                    monthLines[sort + 1] = monthLines[sort];

                    //Swap the temp variables back in
                    data[sort]       = temp;
                    yearLines[sort]  = tmpYear;
                    monthLines[sort] = tmpMonth;

                    //Increases the step counter
                    stepCounter++;
                }
            }
        }

        //Reverse the arrays if viewing as descending
        if (menuChoiceDo == 2)
        {
            Array.Reverse(data);
            Array.Reverse(monthLines);
            Array.Reverse(yearLines);
        }

        //Output the steps the algorithm took
        Console.WriteLine("------------------------------------------");
        Console.WriteLine("This Algorithm took {0} steps", stepCounter);
        Console.WriteLine("------------------------------------------");

        //Calls the output class and the output method to output the data
        outputObject.doOutput(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);
    }
Exemplo n.º 10
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!validator.Validate())
     {
         return;
     }
     NewOutput = (output)bdgOutput.Current;
     NewOutput.customer_name = customer.SingleOrDefault(NewOutput.customer_id).corporate_name;
     this.DialogResult       = DialogResult.OK;
     this.Close();
 }
Exemplo n.º 11
0
    public void InsertionSort(double[] data, string[] yearLines, string[] monthLines, int menuChoiceTime, string month, string year, int menuChoiceDo, int menuChoiceOutput)
    {
        //Initalise the count variables
        int numSorted = 1;
        int index;
        int stepCounter = 0;

        //Initialise object
        output outputObject = new output();

        while (numSorted < data.Length)
        {
            //Assign the temporary data
            double temp     = data[numSorted];
            string tmpYear  = yearLines[numSorted];
            string tmpMonth = monthLines[numSorted];
            //Do the swapping
            for (index = numSorted; index > 0; index--)
            {
                if (temp < data[index - 1])
                {
                    data[index]       = data[index - 1];
                    yearLines[index]  = yearLines[index - 1];
                    monthLines[index] = monthLines[index - 1];
                    stepCounter++;
                }
                else
                {
                    break;
                }
            }
            //Swap the temp elements back in
            data[index]       = temp;
            yearLines[index]  = tmpYear;
            monthLines[index] = tmpMonth;
            numSorted++;
        }

        //Reverse the array if viewing descending
        if (menuChoiceDo == 2)
        {
            Array.Reverse(data);
            Array.Reverse(monthLines);
            Array.Reverse(yearLines);
        }

        Console.WriteLine("------------------------------------------");
        Console.WriteLine("This Algorithm took {0} steps", stepCounter);
        Console.WriteLine("------------------------------------------");

        //Call the output method to output the data
        outputObject.doOutput(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);
    }
Exemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "id,Data,Depid,productid,Qty,Description")] output output)
 {
     if (ModelState.IsValid)
     {
         db.Entry(output).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Depid     = new SelectList(db.Departments, "Id", "Name", output.Depid);
     ViewBag.productid = new SelectList(db.products, "id", "ProductName", output.productid);
     return(View(output));
 }
Exemplo n.º 13
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (bdgOutputs.Current != null)
     {
         output p = (output)bdgOutputs.Current;
         if (p.id > 0)
         {
             output.Delete(p.id);
         }
         bdgOutputs.RemoveCurrent();
     }
 }
Exemplo n.º 14
0
 public OutputForm(output o)
 {
     InitializeComponent();
     loadReasons();
     if (o == null)
     {
         o = new output() { date = null };
         IsNew = true;
     }
     tfDate.Properties.MaxValue = output.Now();
     bdgOutput.DataSource = o;
 }
Exemplo n.º 15
0
 void proc_OutputDataReceived(object sender, DataReceivedEventArgs e)
 {
     if (this.InvokeRequired)
     {
         output end = new output(setOutput);
         this.Invoke(end, new object[] { e.Data });
     }
     else
     {
         setOutput(e.Data);
     }
 }
Exemplo n.º 16
0
        public ActionResult Create([Bind(Include = "id,Data,Depid,productid,Qty,Description,iscancel")] output output)
        {
            if (ModelState.IsValid)
            {
                db.outputs.Add(output);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Depid     = new SelectList(db.Departments, "Id", "Name", output.Depid);
            ViewBag.productid = new SelectList(db.products, "id", "ProductName", output.productid);
            return(View(output));
        }
Exemplo n.º 17
0
        // GET: outputs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            output output = db.outputs.Find(id);

            if (output == null)
            {
                return(HttpNotFound());
            }
            return(View(output));
        }
Exemplo n.º 18
0
        private void ZipFiles(DirectoryInfo directory, string zipName)
        {
            output op = new output(compare.Output);

            string[] fileNames = BuildString(directory.GetFiles());

            try
            {
                ZipUtilities.TryZipAndCompressFiles(zipName, directory.FullName, fileNames);
            }
            catch (Exception ex)
            {
                op(string.Format(Program.zipCopyErr, zipName, ex.Message));
            }
        }
Exemplo n.º 19
0
        // GET: outputs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            output output = db.outputs.Find(id);

            if (output == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Depid     = new SelectList(db.Departments, "Id", "Name", output.Depid);
            ViewBag.productid = new SelectList(db.products, "id", "ProductName", output.productid);
            return(View(output));
        }
Exemplo n.º 20
0
    void zf_TickEvent(object sender, ZenFire.TickEventArgs e)
    {
        output myoutput = new output();

        myoutput.time    = e.TimeStamp;
        myoutput.product = e.Product.ToString();
        myoutput.type    = Enum.GetName(typeof(ZenFire.TickType), e.Type);
        myoutput.price   = e.Price;
        myoutput.volume  = e.Volume;


        _writer.Write(myoutput.time.ToString(timeFmt) + ",");
        _writer.Write(myoutput.product + ",");
        _writer.Write(myoutput.type + ",");
        _writer.Write(myoutput.price + ",");
        _writer.Write(myoutput.volume + ",");
    }
Exemplo n.º 21
0
    static void Main(string[] args)
    {
        Dictionary <long, Tuple <input, output> > dict = new Dictionary <long, Tuple <input, output> > ();

        for (long i = 0; i < (long)(2 ^ 28); i++)
        {
            input  ip = new input( );
            output op = new output( );
            for (int j = 0; j < 8; j++)
            {
                //you have to write your own lodic for creating input and output
                unit isp = new unit( );
                unit osp = new unit( );
                ip.iData[j] = isp;
                op.oData[j] = osp;
            }
            dict.Add(i, Tuple.Create(ip, op));
        }
    }
Exemplo n.º 22
0
        private void DeleteFiles(DirectoryInfo directory, out string filingName)
        {
            FileInfo[] allFiles = directory.GetFiles();
            string[]   temp     = new string[2];
            filingName = string.Empty;
            output op = new output(compare.Output);

            foreach (FileInfo file in allFiles)
            {//Delete the files
                if (Regex.IsMatch(file.Name, defnref) ||
                    Regex.IsMatch(file.Name, rFileSearch))
                {
                    try
                    {
                        file.Delete();
                    }
                    catch (IOException ex)
                    {
                        op(string.Format(Program.fileDelErr, file.Name, ex.Message));
                    }
                    catch (System.Security.SecurityException ex)
                    {
                        op(string.Format(Program.fileDelErr, file.Name, ex.Message));
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        op(string.Format(Program.fileDelErr, file.Name, ex.Message));
                    }
                }
            }

            foreach (FileInfo file in allFiles)
            {//Grab the name of the instance doc
                if (Regex.IsMatch(file.Name, filingSearch))
                {
                    Match match = Regex.Match(file.Name, filingSearch);
                    filingName = match.Value.Remove(match.Value.Length - 4) + "_" + file.Directory.Name;
                    break;
                }
            }
        }
Exemplo n.º 23
0
        private bool CompareColumns(InstanceReport baseRep, InstanceReport newRep, DateTime reportDate, out string error)
        {
            error = string.Empty;
            //Column# {0}: '{1}' has mismatched property: {2}. <br>Expected Results: '{3}' Actual Results: '{4}'
            output op     = new output(Output);
            bool   retval = true;
            int    x      = 0;
            string labelText1;
            string labelText2;

            for (int i = 0; i < baseRep.NumberOfCols; i++)
            {
                x = i + 1;
                if (baseRep.Columns[i].CurrencySymbol != newRep.Columns[i].CurrencySymbol)
                {
                    labelText1 = WHITE_SPACE.Replace(baseRep.Columns[i].Label.Trim(), " ");

                    htmlStarter(string.Format(mismatchCol,
                                              x.ToString(), labelText1, "CurrencySymbol", baseRep.Columns[i].CurrencySymbol, newRep.Columns[i].CurrencySymbol),
                                reportDate, out error);

                    retval = false;
                }

                if (!baseRep.Columns[i].Label.Equals(newRep.Columns[i].Label))
                {
                    labelText1 = WHITE_SPACE.Replace(baseRep.Columns[i].Label.Trim(), " ");
                    labelText2 = WHITE_SPACE.Replace(newRep.Columns[i].Label.Trim(), " ");

                    htmlStarter(string.Format(mismatchCol,
                                              x.ToString(), labelText1, "Label", labelText1, labelText2), reportDate, out error);
                    retval = false;
                }
            }
            return(retval);
        }
Exemplo n.º 24
0
    public static void Main(string[] args)
    {
        //Creates objects to call functions and methods from
        menuSystem menuObject      = new menuSystem();
        textFiles  textFilesObject = new textFiles();
        sort       algorithmObject = new sort();
        output     outputObject    = new output();

        //Uses the menu class to get the input options from the user
        string weatherStation   = menuObject.getWeatherStation();
        string whatToView       = menuObject.getWhatToView();
        int    menuChoiceTime   = menuObject.getWhatTime();
        int    menuChoiceDo     = menuObject.getWhatToDo();
        int    menuChoiceOutput = menuObject.getOutputType();

        //Initialise  variables
        string year  = "";
        string month = "";

        //Reads in the year and months
        string[] yearLines  = System.IO.File.ReadAllLines(@"CMP1124M_Weather_Data/Year.txt");
        string[] monthLines = System.IO.File.ReadAllLines(@"CMP1124M_Weather_Data/Month.txt");

        //Gets the year and month from the user and validates it
        if (menuChoiceTime == 1)
        {
            year = menuObject.getYear(yearLines);
        }
        else if (menuChoiceTime == 2)
        {
            year  = menuObject.getYear(yearLines);
            month = menuObject.getMonth(year, yearLines, monthLines, menuChoiceTime);
        }
        else if (menuChoiceTime == 4)
        {
            month = menuObject.getMonth(year, yearLines, monthLines, menuChoiceTime);
        }

        //Assigns an array the correct text file based on what the user wants to view
        double[] data = textFilesObject.loadInData(weatherStation, whatToView);

        //Initliases variables
        int menuAlgorithmChoice;

        object[] returnArrays;

        int stepCounter;

        //Switch for doing what the user has specified
        switch (menuChoiceDo)
        {
        //If user chosen to sort
        case 1:
        case 2:
            //Get which sorting algorithm the user wants to use
            menuAlgorithmChoice = menuObject.getSortingAlgorithm();

            //Selects what algorithm to use via a nested switch statement
            switch (menuAlgorithmChoice)
            {
            case 1:     //Use Insertion Sort
                algorithmObject.InsertionSort(data, yearLines, monthLines, menuChoiceTime, month, year, menuChoiceDo, menuChoiceOutput);
                break;

            case 2:     //Use QuickSort

                //Initialise the step counter
                stepCounter = 0;

                returnArrays = algorithmObject.Quicksort(data, 0, data.Length - 1, yearLines, monthLines, menuChoiceTime, month, year, menuChoiceDo, stepCounter);

                //Retrieve the arrays from the object array created by the quicksort function
                data        = (double[])returnArrays[0];
                yearLines   = (string[])returnArrays[1];
                monthLines  = (string[])returnArrays[2];
                stepCounter = (int)returnArrays[3];

                //If the user wants to view the data backwards then reverse the array
                if (menuChoiceDo == 2)
                {
                    Array.Reverse(data);
                    Array.Reverse(monthLines);
                    Array.Reverse(yearLines);
                }

                //output the steps the algorithm took
                Console.WriteLine("This Algorithm took {0} steps", stepCounter);

                //Call the output method
                outputObject.doOutput(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);

                break;

            case 3:     //Use Bubblesort
                algorithmObject.Bubblesort(data, yearLines, monthLines, menuChoiceTime, month, year, menuChoiceDo, menuChoiceOutput);
                break;

            //default class
            default:
                Console.WriteLine("Error");
                break;
            }

            break; //End of outside case 1 and 2

        case 3:    //Find the Median value

            //Initialise the step counter
            stepCounter = 0;

            //Gets the sorted data
            returnArrays = algorithmObject.Quicksort(data, 0, data.Length - 1, yearLines, monthLines, menuChoiceTime, month, year, menuChoiceDo, stepCounter);

            //Retrieves the data from the object as needed to return 3 vairbales
            data        = (double[])returnArrays[0];
            yearLines   = (string[])returnArrays[1];
            monthLines  = (string[])returnArrays[2];
            stepCounter = (int)returnArrays[3];

            //output the steps the algorithm took
            Console.WriteLine("This Algorithm took {0} steps", stepCounter);

            //Call the output method to output the median values
            outputObject.doOutputMedian(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);

            break;

        //Max and Min
        case 4:

            //Initialise the step counter
            stepCounter = 0;

            //Retrieve sorted array
            returnArrays = algorithmObject.Quicksort(data, 0, data.Length - 1, yearLines, monthLines, menuChoiceTime, month, year, menuChoiceDo, stepCounter);

            //Retrieves and assigns individual lists
            data        = (double[])returnArrays[0];
            yearLines   = (string[])returnArrays[1];
            monthLines  = (string[])returnArrays[2];
            stepCounter = (int)returnArrays[3];

            //output the steps the algorithm took
            Console.WriteLine("This Algorithm took {0} steps", stepCounter);

            //Call the output method to output the data
            outputObject.doOutputMinMax(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);

            break;

        case 5: //Sort Chronoligcally
            //Calls the output method to output the data
            outputObject.doOutput(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);
            break;

        case 6: //Sort Chronoligcally Backwards

            //Reveres the arrays to display them from old to new
            Array.Reverse(data);
            Array.Reverse(yearLines);
            Array.Reverse(monthLines);

            //use the output class and the user selected output to output the data
            outputObject.doOutput(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);
            break;

        default:
            Console.WriteLine("Error");
            break;
        }
    }
Exemplo n.º 25
0
 => _allCommands = new CommandsWithHelp(output, commands);
Exemplo n.º 26
0
    public void doOutput(int menuChoiceOutput, double[] data, int menuChoiceTime, string year, string month, string[] yearLines, string[] monthLines)
    {
        //Creates the object to use
        output outputObject = new output();

        //Display the data based on the user input earlier
        if (menuChoiceOutput != 1)
        {
            string text = "";
            //Get filename from user
            string fileName = outputObject.nameFile();

            if (menuChoiceOutput == 2) //If searching for year
            {
                for (int x = 0; x < data.Length; x++)
                {
                    if (menuChoiceTime == 1)
                    {
                        if (yearLines[x] == year)
                        {
                            text += yearLines[x] + " " + monthLines[x] + " " + data[x];
                            text += "\n";
                        }
                    }
                    else if (menuChoiceTime == 2) //If searching for year and month
                    {
                        if (monthLines[x] == month && yearLines[x] == year)
                        {
                            text += yearLines[x] + " " + monthLines[x] + " " + data[x];
                            text += "\n";
                        }
                    }
                    else if (menuChoiceTime == 3) //If searching for all
                    {
                        text += yearLines[x] + " " + monthLines[x] + " " + data[x];
                        text += "\n";
                    }
                    else if (menuChoiceTime == 4)
                    {
                        if (monthLines[x] == month)
                        {
                            text += yearLines[x] + " " + monthLines[x] + " " + data[x];
                            text += "\n";
                        }
                    }
                }

                //Write the variables to the file
                File.WriteAllText(fileName + ".txt", text);
                Console.WriteLine("Done");
            }
            else if (menuChoiceOutput == 3)
            {
                for (int x = 0; x < data.Length; x++)
                {
                    if (menuChoiceTime == 1)
                    {
                        if (yearLines[x] == year)
                        {
                            text += yearLines[x] + " " + monthLines[x] + " " + data[x];
                            text += "<br>";
                        }
                    }
                    else if (menuChoiceTime == 2)
                    {
                        if (monthLines[x] == month && yearLines[x] == year)
                        {
                            text += yearLines[x] + " " + monthLines[x] + " " + data[x];
                            text += "<br>";
                        }
                    }
                    else if (menuChoiceTime == 3)
                    {
                        text += yearLines[x] + " " + monthLines[x] + " " + data[x];
                        text += "<br>";
                    }
                    else if (menuChoiceTime == 4)
                    {
                        if (monthLines[x] == month)
                        {
                            text += yearLines[x] + " " + monthLines[x] + " " + data[x];
                            text += "<br>";
                        }
                    }
                }

                //Write the variable to the html file
                File.WriteAllText(fileName + ".html", text);
                Console.WriteLine("Done");
            }
        }
        else
        {
            //Display the text normally to the console
            for (int x = 0; x < data.Length; x++)
            {
                if (menuChoiceTime == 1)
                {
                    if (yearLines[x] == year)
                    {
                        Console.WriteLine(yearLines[x] + " " + monthLines[x] + " " + data[x]);
                    }
                }
                else if (menuChoiceTime == 2)
                {
                    if (monthLines[x] == month && yearLines[x] == year)
                    {
                        Console.WriteLine(yearLines[x] + " " + monthLines[x] + " " + data[x]);
                    }
                }
                else if (menuChoiceTime == 3)
                {
                    Console.WriteLine(yearLines[x] + " " + monthLines[x] + " " + data[x]);
                }
                else if (menuChoiceTime == 4)
                {
                    if (monthLines[x] == month)
                    {
                        Console.WriteLine(yearLines[x] + " " + monthLines[x] + " " + data[x]);
                    }
                }
            }
        }
    }
Exemplo n.º 27
0
    public void doOutputMedian(int menuChoiceOutput, double[] data, int menuChoiceTime, string year, string month, string[] yearLines, string[] monthLines)
    {
        //Creates output object to access the methods of the class
        output outputObject = new output();

        //Finds the midpoint of the list to find the middle element
        int midPoint = data.Length / 2;

        //Initalise text variable
        string text     = "";
        string fileName = "";

        //Display the correct data
        if (menuChoiceOutput != 1)
        {
            //Get the user input for the filename
            fileName = outputObject.nameFile();

            //Create the text to add to files
            if (menuChoiceOutput == 2)
            {
                if (menuChoiceTime == 1)
                {
                    text = "The Median Value for " + year + " is " + data[midPoint];
                }
                else if (menuChoiceTime == 2)
                {
                    text = "The Median Value for " + month + " " + year + " is " + data[midPoint];
                }
                else if (menuChoiceTime == 3)
                {
                    text = "The Median Value for all data is " + data[midPoint];
                }
                else if (menuChoiceTime == 4)
                {
                    text = "The Median Value for " + month + " is " + data[midPoint];
                }
            }

            //Writes to text file
            File.WriteAllText(fileName + ".txt", text);
            Console.WriteLine("Done");
        }
        else if (menuChoiceOutput == 3)
        {
            if (menuChoiceTime == 1)
            {
                text = "The Median Value for " + year + " is " + data[midPoint];
            }
            else if (menuChoiceTime == 2)
            {
                text = "The Median Value for " + month + " " + year + " is " + data[midPoint];
            }
            else if (menuChoiceTime == 3)
            {
                text = "The Median Value for all data is " + data[midPoint];
            }
            else if (menuChoiceTime == 4)
            {
                text = "The Median Value for " + month + " is " + data[midPoint];
            }

            //Writes to HTML file
            File.WriteAllText(fileName + ".html", text);
            Console.WriteLine("Done");
        }
        else
        {
            //Displays the data to the console
            if (menuChoiceTime == 1)
            {
                Console.WriteLine("The Median Value for {0} is {1}", year, data[midPoint]);
            }
            else if (menuChoiceTime == 2)
            {
                Console.WriteLine("The Median Value for {0} {1} is {2}", month, year, data[midPoint]);
            }
            else if (menuChoiceTime == 3)
            {
                Console.WriteLine("The Median Value for all data is {0}", data[midPoint]);
            }
            else
            {
                Console.WriteLine("The Median Value for {0} is {1}", month, data[midPoint]);
            }
        }
    }
Exemplo n.º 28
0
 Render(namedMessageProperties, positionalMessageProperties, output, logEventInfo, contextualLogEvent, renderingOptions, provider);
Exemplo n.º 29
0
        private void ZipFiles(DirectoryInfo directory, string zipName)
        {
            output op = new output(compare.Output);
            string[] fileNames = BuildString(directory.GetFiles());

            try
            {
                ZipUtilities.TryZipAndCompressFiles(zipName, directory.FullName, fileNames);
            }
            catch (Exception ex)
            {
                 op(string.Format(Program.zipCopyErr, zipName, ex.Message));
            }
        }
Exemplo n.º 30
0
    public void doOutputMinMax(int menuChoiceOutput, double[] data, int menuChoiceTime, string year, string month, string[] yearLines, string[] monthLines)
    {
        //Initalise the min and max value positions
        int    min          = 0;
        int    max          = data.Length - 1;
        output outputObject = new output();

        //Display the correct data
        if (menuChoiceOutput != 1)
        {
            string text     = "";
            string fileName = outputObject.nameFile();

            if (menuChoiceOutput == 2)
            {
                if (menuChoiceTime == 1)
                {
                    text += year + " " + " Min: " + data[min] + " Max: " + data[max];
                }
                else if (menuChoiceTime == 2)
                {
                    text += year + " " + month + " Min: " + data[min] + "Max: " + data[max];
                }
                else if (menuChoiceTime == 3)
                {
                    text += "All Data Min: " + data[min] + " " + yearLines[min] + " " + monthLines[min] + " Max: " + data[max] + " " + yearLines[max] + " " + monthLines[max];
                }
                else
                {
                    text += month + " " + " Min: " + data[min] + " Max: " + data[max];
                }

                // Writes to text file
                File.WriteAllText(fileName + ".txt", text);
                Console.WriteLine("Done");
            }
            else if (menuChoiceOutput == 3)
            {
                if (menuChoiceTime == 1)
                {
                    text += year + " Min: " + data[min] + " Max: " + data[max];
                }
                else if (menuChoiceTime == 2)
                {
                    text += year + " " + month + " Min: " + data[min] + " " + "Max: " + data[max];
                }
                else if (menuChoiceTime == 3)
                {
                    text += "All Data Min: " + data[min] + " " + yearLines[min] + " " + monthLines[min] + " Max: " + data[max] + " " + yearLines[max] + " " + monthLines[max];
                }
                else
                {
                    text += month + " " + " Min: " + data[min] + " Max: " + data[max];
                }

                //Writes to html file
                File.WriteAllText(fileName + ".html", text);
                Console.WriteLine("Done");
            }
        }
        else
        {
            if (menuChoiceTime == 1)
            {
                Console.WriteLine("{0} Min: {1} Max: {2}", year, data[min], data[max]);
            }
            else if (menuChoiceTime == 2)
            {
                Console.WriteLine("{0} {1} Min: {2} Max: {3}", year, month, data[min], data[max]);
            }
            else if (menuChoiceTime == 3)
            {
                Console.WriteLine("All Data Min: {0} {1} {2} Max: {3} {4} {5}", data[min], yearLines[min], monthLines[min], data[max], yearLines[max], monthLines[max]);
            }
            else
            {
                Console.WriteLine("{0} Min: {1} Max: {2}", month, data[min], data[max]);
            }
        }
    }
Exemplo n.º 31
0
        private void DeleteFiles(DirectoryInfo directory, out string filingName)
        {
            FileInfo[] allFiles = directory.GetFiles();
            string[] temp = new string[2];
            filingName = string.Empty;
            output op = new output(compare.Output);

            foreach (FileInfo file in allFiles)
            {//Delete the files
                if (Regex.IsMatch(file.Name, defnref)
                    || Regex.IsMatch(file.Name, rFileSearch))
                {
                    try
                    {
                        file.Delete();
                    }
                    catch (IOException ex)
                    {
                        op(string.Format(Program.fileDelErr, file.Name, ex.Message));
                    }
                    catch (System.Security.SecurityException ex)
                    {
                        op(string.Format(Program.fileDelErr, file.Name, ex.Message));
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        op(string.Format(Program.fileDelErr, file.Name, ex.Message));
                    }
                }
            }

            foreach (FileInfo file in allFiles)
            {//Grab the name of the instance doc
                if (Regex.IsMatch(file.Name, filingSearch))
                {
                    Match match = Regex.Match(file.Name, filingSearch);
                    filingName = match.Value.Remove(match.Value.Length - 4) + "_" + file.Directory.Name;
                    break;
                }
            }
        }
Exemplo n.º 32
0
 computed = computed ?? Grad(output, x);
Exemplo n.º 33
0
        public void Compare(bool SkipZip, bool baseHTML, out int totalRFiles, out int failedRFiles)
        {
            //Load list of files:
            string[] files;
            string   error = string.Empty;

            FileInfo[] baseRFiles = null;
            FileInfo[] newRFiles  = null;

            bool reportFailed = false;

            output op = new output(Output);

            totalRFiles  = 0;
            failedRFiles = 0;

            int totalFilings  = 0;
            int failedFilings = 0;

            baseList = new List <InstanceReport>();
            newList  = new List <InstanceReport>();

            //Allows the user to skip this proccess if they're simply rerunning the comparison.
            if (!SkipZip)
            {
                UnzipMove(baseDirs, out files, out error);
                UnzipMove(newDirs, out files, out error);
            }

            baseDirs = new DirectoryInfo(baseDirs.Parent.FullName + "\\Comparison");
            newDirs  = new DirectoryInfo(newDirs.Parent.FullName + "\\Comparison");

            DateTime renderStart = new DateTime();
            DateTime renderEnd   = new DateTime();

            int      renderCount = 0;
            TimeSpan totalRender = GetRenderTime(newDirs, out renderStart, out renderEnd, out renderCount);

            //List of unzipped instance doc directories:
            List <DirectoryInfo> allB = new List <DirectoryInfo>(baseDirs.GetDirectories());
            List <DirectoryInfo> allN = new List <DirectoryInfo>(newDirs.GetDirectories());

            allB.Sort(new CompareFileInfo());
            allN.Sort(new CompareFileInfo());

            //Sync the resources:
            Trace.TraceInformation("Information: Synchronizing resources. . .");
            XBRLReportBuilder.Utilities.RulesEngineUtils.SynchronizeResources();

            int minCount = Math.Min(allB.Count, allN.Count);

            DateTime compareStart = DateTime.Now;

            try
            {
                Trace.TraceInformation("Information: Starting the Comparison loop.");
                for (int i = 0; i <= minCount - 1; i++)
                {
                    reportFailed = false;
                    //Proccess current directory:
                    DirectoryInfo baseDirectory = allB.Find(ab => ab.Name == allN[i].Name);
                    DirectoryInfo newDirectory  = allN[i];

                    if (baseDirectory != null)
                    {
                        //get the Filing summary for the current filing.
                        List <ReportHeader> baseHeaders = returnHeaders(baseDirectory);
                        List <ReportHeader> newHeaders  = returnHeaders(newDirectory);

                        Trace.TraceInformation("Comparing report {0}:\t\t{1} of {2}", baseDirectory.Name, (i + 1).ToString(), minCount);

                        baseRFiles = gFiles(baseDirectory, "R*.xml");
                        newRFiles  = gFiles(newDirectory, "R*.xml");

                        reportName = baseDirectory.Name;
                        baseList.Clear();
                        newList.Clear();

                        try
                        {
                            //Trace.TraceInformation("Loading Files into memory.");
                            //Deserialize, load and sort the r files:
                            foreach (FileInfo file in baseRFiles)
                            {
                                LoadFiles(file, ref baseList);
                            }

                            foreach (FileInfo file in newRFiles)
                            {
                                LoadFiles(file, ref newList);
                            }
                        }
                        catch (Exception ex)
                        {
                            Trace.TraceInformation("The following error occured while trying to load the R files for {0}: \n{1}", baseDirectory.Name, ex.Message);
                            RLogger.Error(string.Format("The following error occured while trying to load the R files for {0}: \n{1}", baseDirectory.Name, ex.Message));
                        }

                        //baseList and newList now has the list of the R files:

                        for (int j = 0; j <= baseList.Count - 1; j++)
                        {
                            //Trace.TraceInformation("Starting Instance Report Comparison Inner Loop.");
                            //Compare the actual R Files:
                            swCompare.Reset();
                            swCompare.Start();

                            //find the exact R file.
                            InstanceReport currentBase  = baseList[j];
                            string         baseLongName = WHITE_SPACE.Replace(currentBase.ReportLongName.Trim(), " ");
                            //string baseShortName = WHITE_SPACE.Replace( currentBase.ReportName.Trim(), " " );

                            InstanceReport currentNew = newList.Find(
                                nl =>
                                WHITE_SPACE.Replace(nl.ReportLongName.Trim(), " ") == baseLongName);

                            //try to match by report long name if it's there. If not, try by report name
                            if (currentNew != null)
                            {
                                string newLongName  = WHITE_SPACE.Replace(currentNew.ReportLongName.Trim(), " ");
                                string newShortName = WHITE_SPACE.Replace(currentNew.ReportName.Trim(), " ");
                                if (!string.IsNullOrEmpty(newLongName))
                                {
                                    workingHeader = baseHeaders.Find(
                                        bh =>
                                        WHITE_SPACE.Replace(bh.LongName.Trim(), " ") == newLongName);
                                }

                                if (workingHeader == null)
                                {
                                    workingHeader = baseHeaders.Find(
                                        bh =>
                                        WHITE_SPACE.Replace(bh.ShortName.Trim(), " ") == newShortName);
                                }

                                if (workingHeader != null && baseHTML)
                                {
                                    //build base html files. Skip if this already exists.
                                    string xmlFilename  = allB[i].FullName + "\\" + workingHeader.XmlFileName;
                                    string htmlFilename = xmlFilename + ".html";
                                    if (!File.Exists(htmlFilename))
                                    {
                                        this.HTML(currentBase, xmlFilename, htmlFilename);
                                    }
                                }

                                if (currentNew != null && workingHeader != null)
                                {
                                    //html.RFile = workingHeader.XmlFileName;

                                    string newPath = Path.Combine(newDirectory.FullName, workingHeader.XmlFileName);
                                    this.rFileLoc1 = Path.Combine(newDirectory.FullName, Path.GetFileNameWithoutExtension(newPath) + ".html");

                                    string basePath = Path.Combine(baseDirectory.FullName, workingHeader.XmlFileName);
                                    this.rFileLoc2 = Path.Combine(baseDirectory.FullName, Path.GetFileNameWithoutExtension(basePath) + ".html");

                                    if (!this.ReportCompare(currentBase, currentNew, basePath, newPath, compareStart, out error))
                                    {
                                        failedRFiles++;
                                        reportFailed = true;
                                    }
                                }
                                else
                                {
                                    RLogger.Error("New report does not contain a matching report name.");
                                    htmlStarter("New report does not contain a matching report name<br>New Report does not contain a matching report name.",
                                                compareStart, out error);
                                    failedRFiles++;
                                    reportFailed = true;
                                }

                                totalRFiles++;
                                TimeSpan seconds = TimeSpan.FromMilliseconds(swCompare.ElapsedMilliseconds);
                                swCompare.Stop();
                            }
                            else //if (currentNew == null)
                            {
                                RLogger.Info("The 'Current' report was null. Setting appropriate variables and closing the current R report.");
                                //Set the variables, write the log entry and save the HTML
                                workingHeader = baseHeaders.Find(bh => bh.LongName == baseList[j].ReportLongName);

                                rFileLoc1 = allN[i].FullName + "\\" +
                                            workingHeader.XmlFileName.Remove(workingHeader.XmlFileName.Length - 4) + ".html";

                                rFileLoc2 = baseDirectory.FullName + "\\" +
                                            workingHeader.XmlFileName.Remove(workingHeader.XmlFileName.Length - 4) + ".html";

                                htmlStarter("Could not match report name for this report<br>The 'new' report name could not be matched", compareStart, out error);
                                failedRFiles++;
                                reportFailed = true;
                            }
                        }

                        //finish up the last report:
                        if (reportFailed)
                        {
                            failedFilings++;
                        }
                        totalFilings++;

                        if (html.reportStarted)
                        {
                            html.EndReport();
                        }
                    }
                    else
                    {
                        RLogger.Error("Could not find matching directory.");
                        Trace.TraceWarning("Warning: Could not find matching directory.");
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceInformation("Error: An error occured trying to compare the following report {0}: \n{1}", reportName, ex.Message);
                RLogger.Error(string.Format("An error occured trying to compare the following report {0}: \n{1}", reportName, ex.Message));
            }

            DateTime compareEnd    = DateTime.Now;
            TimeSpan timeToCompare = compareEnd.Subtract(compareStart);

            //get render time:

            if (html.reportStarted)
            {
                html.EndReport();
            }

            html.BuildSummary(compareStart, compareEnd, minCount, failedFilings, totalRFiles, failedRFiles, timeToCompare, renderStart,
                              renderEnd, totalRender, renderCount);
            //string path = string.Format("{0}\\Logs\\AutoTesterLog-{1}.html", newDirs.Root.FullName, DateTime.Now.ToString("yyyy-MM-dd_hhmmss"));
            DirectoryInfo logPath = new DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["logPath"]);

            if (logPath.Exists)
            {
                string path = string.Format("{0}\\AutoTesterLog-{1}.html", logPath.FullName, DateTime.Now.ToString("yyyy-MM-dd_hhmmss"));
                HTML(html.html.ToString(), path);
            }
            else
            {
                Trace.TraceError("Error: Unable to write the HTML log file. Check to make sure the specified log directory exists.");
                RLogger.Error("Unable to write the HTML log file. Check to make sure the specified log directory exists.");
            }
        }
Exemplo n.º 34
0
        private bool CompareRowCells(
            InstanceReportRow baseRow, InstanceReportRow newRow,
            InstanceReport baseReport, InstanceReport newReport,
            string basePath, string newPath,
            int rowCount, DateTime reportDate, out string error)
        {
            error = string.Empty;
            //Row# {0}:'{1}' has unmatched data.<br>Expected Results: '{2}' Actual Results: '{3}'
            output op        = new output(Output);
            bool   retval    = true;
            string labelText = baseRow.Label.Replace("\r\n", " ");


            //if (!string.Equals( baseRow.ToString(), newRow.ToString(), StringComparison.InvariantCultureIgnoreCase ) )
            //{
            for (int i = 0; i < baseRow.Cells.Count; i++)
            {
                Cell baseCell = baseRow.Cells[i];
                Cell newCell  = newRow.Cells[i];

                if (baseCell.HasEmbeddedReport == newCell.HasEmbeddedReport)
                {
                    if (newCell.HasEmbeddedReport)
                    {
                        this.ReportCompare(baseCell.EmbeddedReport.InstanceReport, newCell.EmbeddedReport.InstanceReport,
                                           basePath, newPath, reportDate, out error);
                        continue;
                    }
                }
                else
                {
                    if (baseCell.HasEmbeddedReport)
                    {
                        this.htmlStarter("Unmatched embedded reports<br>BaseRep cell has an embedded report, but NewRep cell does not.", reportDate, out error);
                    }
                    else
                    {
                        this.htmlStarter("Unmatched embedded reports<br>NewRep cell has an embedded report, but BaseRep cell does not.", reportDate, out error);
                    }
                }

                string baseText = WHITE_SPACE.Replace(baseCell.ToString().Trim(), " ");
                string newText  = WHITE_SPACE.Replace(newCell.ToString().Trim(), " ");
                if (!string.Equals(baseText, newText, StringComparison.InvariantCultureIgnoreCase))
                {
                    retval = false;


                    htmlStarter(string.Format(mismatchCell,
                                              i.ToString(), labelText, baseRow.Cells[i].ToString(), newRow.Cells[i].ToString()), reportDate, out error);

                    if (errorID > 0)
                    {
                        //RLogger.Info(string.Format(debugParameters, baseReport.ReportName, newReport.ReportName, errorID, 464));
                        using (BaselineRules baseL = new BaselineRules(baseReport, newReport, errorID))
                        {
                            baseL.EvaluateUnmatchedDataError(rowCount);
                        }
                    }
                    else if (errorID == 0)
                    {
                        RLogger.Error("No error ID on " + baseReport.ReportName + " " + workingHeader.XmlFileName + " SQL DB returned 0");
                    }
                }

                if (!string.Equals(baseCell.FootnoteIndexer, newCell.FootnoteIndexer))
                {
                    retval = false;
                    htmlStarter(string.Format(mismatchCell,
                                              i.ToString(), labelText, "Footnotes: " + baseCell.FootnoteIndexer, "Footnotes: " + newCell.FootnoteIndexer), reportDate, out error);
                }
            }
            //}
            return(retval);
        }
Exemplo n.º 35
0
 dumper p = new dumper(output: w, ptrmap: make(map[Node] int), last: '\n', );
Exemplo n.º 36
0
 WriteArgumentList(output, options, (IEnumerable <(ILInstruction, CSharpArgumentInfo)>)arguments);