Beispiel #1
0
        public void TestFormatJson()
        {
            var testJson =
                "[{\"ScheduleId\":5849,\"Uuid\":\"20012473\",\"ProgramId\":994564,\"Relation\":\"E\",\"FirstName\":\"Randall\",\"MiddleInitial\":null,\"LastName\":\"Perea's\",\"DateOfBirth\":\"1973-03-06T00:00:00\",\"Gender\":\"Male\",\"PhoneNumber\":\"2395730480\",\"Email\":null,\"AddressLine1\":\"3900 Cedar St\",\"AddressLine2\":null,\"City\":\"Arcadia\",\"State\":\"FL\",\"ZipCode\":\"33809\",\"ScheduledTime\":\"2013-10-30T07:30:00\"}]";
            var testResult = Etc.FormatJson(testJson);

            Assert.IsNotNull(testResult);

            testResult = Etc.FormatJson(testJson, true);
            Console.WriteLine(testResult);
        }
Beispiel #2
0
        public static DateTime?RandomChildBirthDate(DateTime motherDob, int numberOfSiblings, DateTime?atTime = null)
        {
            //put number of siblings in scope for equations
            if (numberOfSiblings <= 0)
            {
                numberOfSiblings = 0;
            }
            if (numberOfSiblings > 4)
            {
                numberOfSiblings = 3;
            }

            //default atTime to now
            var dt = atTime ?? DateTime.UtcNow;

            var motherAge = Etc.CalcAge(motherDob, dt);

            var meanAge = AmericanEquations.FemaleAge2FirstChild.SolveForY(motherDob.Year);

            //mother is too young for children
            if (motherAge < meanAge)
            {
                return(null);
            }

            switch (numberOfSiblings)
            {
            case 2:
                meanAge = AmericanEquations.FemaleAge2SecondChild.SolveForY(motherDob.Year);
                if (motherAge < meanAge)
                {
                    return(null);
                }
                break;

            case 3:
                meanAge = AmericanEquations.FemaleAge2ThirdChild.SolveForY(motherDob.Year);
                if (motherAge < meanAge)
                {
                    return(null);
                }
                break;

            case 4:
                meanAge = AmericanEquations.FemaleAge2ForthChild.SolveForY(motherDob.Year);
                if (motherAge < meanAge)
                {
                    return(null);
                }
                break;
            }

            return(Etx.RandomDate((int)Math.Round(meanAge), motherDob));
        }
Beispiel #3
0
        private void InitTime()
        {
            double interval = Double.Parse(ini.config.TiempoChequeo);

            time           = new Timer(Etc.minsToMS(interval));
            time.Elapsed  += Timer_Elapsed;
            time.AutoReset = true;
            time.Start();
            Log glog = new Log();

            glog.SaveLog("TIMER :: START ");
        }
Beispiel #4
0
        private void LoadLogoImg()
        {
            var hash = Etc.CalculateMD5(Constants.MainLogoPath);

            if (hash != Constants.MainLogoMD5)
            {
                return;
            }

            pictureBox1.WaitOnLoad    = true;
            pictureBox1.ImageLocation = Constants.MainLogoPath;
        }
Beispiel #5
0
        public static void CopyAll(DirectoryInfo source, DirectoryInfo target, Inicio _ini, FtpClient ftp, ScreensGuardian _screen = null)
        {
            ScreensGuardian screenAUX = _screen;

            var _screens = _ini.config.Screens.ToArray();

            // Copy each subdirectory using recursion.
            foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
            {
                foreach (ScreensGuardian screen in _screens)
                {
                    if ("p" + screen.Code == diSourceSubDir.Name)
                    {
                        DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name);
                        CopyAll(diSourceSubDir, nextTargetSubDir, _ini, ftp, screen);
                        Log TgLog = new Log();
                        TgLog.SaveLog("DIRECTORIO COPIADO " + diSourceSubDir.Name);
                    }
                }
            }

            {
                Directory.CreateDirectory(screenAUX.LocalPath);
                //cambio gonzalo
                try
                {
                    Etc.DeleteFiles(screenAUX.LocalPath);
                    System.Threading.Thread.Sleep(2000);
                }
                catch (Exception ex)
                {
                    Log logaux = new Log();
                    logaux.SaveLog("ERROR CLEAR " + ex.Message);
                }

                // Copy each file into the new directory.
                foreach (FileInfo fi in source.GetFiles())
                {
                    //Console.WriteLine(@"Copying {0}\{1}", target.FullName, fi.Name);

                    fi.CopyTo(Path.Combine(screenAUX.LocalPath, fi.Name), true);
                    Log TgLog = new Log();
                    TgLog.SaveLog("ARCHIVO COPIADO - " + Path.Combine(screenAUX.LocalPath, fi.Name));
                }

                int idx = _ini.config.Screens.FindIndex(s => s.Code == screenAUX.Code);
                //guardar version nueva
                screenAUX.VersionActual  = screenAUX.VersionRemota.ToString();
                _ini.config.Screens[idx] = screenAUX;
                _ini.db.Save(_ini.config);
            }
        }
Beispiel #6
0
        private SocketIO SetupSIOClient(string id, string scorebotURL = "")
        {
            //format with match/scorebot id
            const string hltvMatchFormat = "https://www.hltv.org/matches/{0}/allo";
            //remembers to add { and } before emitting
            const string hltvMatchData = "'token':'','listId':'{0}'";

            //new instances of scoreboard and match log
            this.log        = new Log(10);
            this.scoreboard = new ScoreBoard(logHeight: this.log.limit, quitLen: this.log.HINT.Length);

            //loads match page to retrieve scorebot uri
            if (scorebotURL == "")
            {
                string       hltvMatchURL = String.Format(hltvMatchFormat, id);
                HtmlDocument doc          = Etc.GetDocFromURL(hltvMatchURL);
                HtmlNode     el           = doc.DocumentNode.SelectSingleNode("//*[@id=\"scoreboardElement\"]");
                scorebotURL = el.GetAttributeValue("data-scorebot-url", "").Split(",")[0];
            }

            SocketIO client = new SocketIO(scorebotURL);

            client.OnConnected += async() => {
                await client.EmitAsync("readyForMatch", "{" + String.Format(hltvMatchData, id) + "}");

                client.On("scoreboard", data => {
                    this.scoreboard.LoadJSON(data.Text);
                });
                client.On("log", data => {
                    //waits for scoreboard to be setup before printing log
                    if (this.scoreboard.initialised)
                    {
                        this.log.LoadJSON(data.Text, this.scoreboard.bottom);
                    }
                    else
                    {
                        this.log.AddQueue(data.Text);
                    }
                });
                client.On("fullLog", data => {
                    //no clue when this is emitted
                    Console.Write("Catcher");
                });
            };

            client.OnClosed += (reason) => {
                Console.WriteLine("Client closed: " + reason.ToString());
            };

            return(client);
        }
Beispiel #7
0
 public override string ToString()
 {
     return(string.Format("({8}) {0}::{1}{2}{3}{7} {4}{5}{6} {9}",
                          Namespace,
                          TypeName,
                          FormatGenericArgsFull(GenericTypeArguments),
                          NestedType != null ? "+" + NestedType.ToString() : string.Empty,
                          MemberName ?? string.Empty,
                          FormatGenericArgsFull(GenericMemberArguments),
                          MemberArguments != null ? "(" + string.Join(",", MemberArguments.Select(m => m.ToString())) + ")" : string.Empty,
                          ArrayDimensions != null && ArrayDimensions.Count > 0 ? ArrayDimensions.Select(dim => "[" + new string (',', dim - 1) + "]").Aggregate(string.Concat) : string.Empty,
                          DescKind.ToString()[0],
                          Etc != 0 ? '(' + Etc.ToString() + ')' : string.Empty));
 }
Beispiel #8
0
 public Boolean CheckFieldsINICIAR()
 {
     if (
         !Etc.CheckFieldsTBOX(TxtCodigo) ||
         !Etc.CheckFieldsTBOX(TxtRaizSel) ||
         !Etc.CheckFieldsTBOX(TxtChequeo) ||
         !Etc.CheckFieldsTBOX(TxtServidor) ||
         !Etc.CheckFieldsPBOX(TxtCodigoMaestro)
         )
     {
         return(false);
     }
     return(true);
 }
Beispiel #9
0
        public ConfiguracionFTP(Inicio _inicio)
        {
            ini  = _inicio;
            gLog = new Log();
            time = new Timer();



            tools = new Etc();
            InitializeComponent();

            LoadInitialValuesINICIO();
            gLog.SaveLog("--- Modo FTP ---");
        }
Beispiel #10
0
        public void TestFormatCsvHeaders()
        {
            var testInput = new string[]
            {
                "S. No:", "Screen / Sub Tab", "Field Name", "Section", "Functionality", "Type", "Functionality", "Type", "WE Mapping", "Required ?", "Comments"
            };
            var testResult = Etc.FormatCsvHeaders(testInput);

            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(0, testResult.Length);
            foreach (var tr in testResult)
            {
                Console.WriteLine(tr);
            }
        }
Beispiel #11
0
        public static void CalcMeteoAvg(List <Row> meteoRows, string meteoColumnName,
                                        TableProcessing.Table calcsHydroTable, string hydroColumnName,
                                        ICellMapper cellMapper, params TableProcessing.Table[] resultTables)
        {
            var valuesColumnName = meteoColumnName + "_Values";


            calcsHydroTable.IterateRows(hydroRow =>
            {
                var intList = hydroRow["OI_METEO"].ToIntList();

                double number = 0;

                var realMeteoColumnName = meteoColumnName;

                if (meteoColumnName.StartsWith("&"))
                {
                    var hydroPtr        = meteoColumnName.Substring(1);
                    realMeteoColumnName = hydroRow[hydroPtr].StringValue;
                }

                Etc.NoThrow(() =>
                {
                    var doubleQuery = from meteoRow in meteoRows
                                      where intList.Contains(meteoRow["OI_Meteo"].IntValue) &&
                                      double.TryParse(
                        meteoRow[realMeteoColumnName].StringValue, out number)
                                      select number;

                    var enumerable = doubleQuery.ToList();

                    var strQuery = from dbl in enumerable
                                   select cellMapper.Map(new Cell(dbl)).StringValue;

                    var res = string.Join(";", strQuery.ToArray());

                    hydroRow.Set(valuesColumnName, res);

                    hydroRow.Set(hydroColumnName,
                                 enumerable.Average(), cellMapper);
                });
            }, valuesColumnName, hydroColumnName);

            foreach (var table in resultTables)
            {
                table.AddColumn(calcsHydroTable.Column(hydroColumnName));
            }
        }
Beispiel #12
0
 public Boolean CheckFieldsINICIAR()
 {
     if (
         !Etc.CheckFieldsTBOX(TxtCodigo) ||
         !Etc.CheckFieldsTBOX(TxtRaizSel) ||
         !Etc.CheckFieldsTBOX(TxtChequeo) ||
         !Etc.CheckFieldsTBOX(TxtIPFTP) ||
         !Etc.CheckFieldsTBOX(TxtPuerto) ||
         !Etc.CheckFieldsTBOX(TxtUsuario) ||
         !Etc.CheckFieldsPBOX(TxtContrasena)
         )
     {
         return(false);
     }
     return(true);
 }
        private static EtcUser GetPasswdFor(string containerUuid)
        {
            NodeConfig config = new Config.NodeConfig();

            string gecos = config.Get("GEAR_GECOS");

            if (string.IsNullOrEmpty(gecos))
            {
                gecos = "OO application container";
            }
            EtcUser etcUser = new Etc(config).GetPwanam(containerUuid);

            etcUser.Gecos = gecos;

            return(etcUser);
        }
        private void Calc_LR()
        {
            if (calcBranch.DSm)
            {
                tables.CalcsMeteo.AddColumn(
                    tables.OperInfoMeteo.Column("Lm"));

                tables.CalcsMeteo.IterateRows(row =>
                {
                    var dt       = GetDate(row["Lm"]);
                    var dayMonth = dateParser.ToDayMonth(dt, "_");

                    Etc.NoThrow(() =>
                    {
                        var columnName_L = DayAndMonthItemsRepr
                                           .DD_MM_to_LDD_MM(dayMonth);

                        row.Set("L_Column", columnName_L);
                    });
                }, "L_Column");

                var operRows = tables.OperInfoMeteo.GetRows();

                tables.CalcsMeteo.IterateRows(calcRow =>
                {
                    Etc.NoThrow(() =>
                    {
                        var colName = calcRow["L_Column"].StringValue;
                        var operRow = operRows[calcRow.Index];
                        calcRow.Set("LR", operRow[colName]);
                    });
                }, "LR");
            }
            else
            {
                var DD_MM = userInput[CalculationsForm.Arg_DayAndMonth];

                Etc.NoThrow(() =>
                {
                    var columnName_L = DayAndMonthItemsRepr.DD_MM_to_LDD_MM(DD_MM);

                    var column_oper_L = tables.OperInfoMeteo.Column(columnName_L);

                    tables.CalcsMeteo.Column("LR").SetDataFrom(column_oper_L);
                });
            }
        }
Beispiel #15
0
        /// <summary>
        /// Gets all token interface types, at all depths, which have only
        /// one concrete implementation
        /// </summary>
        /// <returns></returns>
        public MetadataTokenType[] GetAllInterfacesWithSingleImplementor(Action <ProgressMessage> reportProgress = null)
        {
            var sInfcs = new List <MetadataTokenType>();

            if (Items == null || !Items.Any())
            {
                return(null);
            }
            if (_singleImplementors != null)
            {
                return(_singleImplementors);
            }

            var allInfcs = GetAllInterfaceTypes();

            if (allInfcs == null || !allInfcs.Any())
            {
                return(null);
            }
            var totalLen = allInfcs.Length;

            for (var i = 0; i < totalLen; i++)
            {
                var ai = allInfcs[i];
                if (ai == null)
                {
                    continue;
                }
                reportProgress?.Invoke(new ProgressMessage
                {
                    Activity        = $"{ai?.Name}",
                    ProcName        = System.Diagnostics.Process.GetCurrentProcess().ProcessName,
                    ProgressCounter = Etc.CalcProgressCounter(i, totalLen),
                    Status          = "Getting all interfaces with only one implementation"
                });

                var cnt = 0;
                GetCountOfImplementors(ai, ref cnt);
                if (cnt == 1)
                {
                    sInfcs.Add(ai);
                }
            }

            _singleImplementors = sInfcs.ToArray();
            return(_singleImplementors);
        }
Beispiel #16
0
        public void Init()
        {
            if (CheckFieldsINICIAR())
            {
                this.Hide();
                ini.Minimize();
                SaveNewConfig();
                TemporalStorage = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\VoxLine\\" + ini.config.CodePc;
                Etc.CreateDir(TemporalStorage);
                if (initiated)
                {
                    StopTime();
                    initiated = false;
                }

                //GUstavo
                //Crear lock para que nadie mas pueda interactuar.

                /*if (Directory.Exists(ini.config.CarpetaRaiz + ini.config.CodePc))
                 * {
                 *      Etc.CreateLock(ini.config.CarpetaRaiz + ini.config.CodePc);
                 *      gLog.SaveLog("134 - create lock en la definitiva pivote");
                 * }else
                 * {
                 *      Directory.CreateDirectory(ini.config.CarpetaRaiz + ini.config.CodePc);
                 *      gLog.SaveLog("141 - crea carpeta  definitiva pivote");
                 *      Etc.CreateLock(ini.config.CarpetaRaiz + ini.config.CodePc);
                 *      gLog.SaveLog("141 - create lock en la definitiva pivote");
                 * }*/

                Sync();
                //Etc.DeleteLock(ini.config.CarpetaRaiz + ini.config.CodePc);
                //gLog.SaveLog("142 - borra el lock de la definitva pivote");

                if (!initiated)
                {
                    InitTime();
                    initiated = true;
                }
            }
            else
            {
                MessageBox.Show("Los campos obligatorios no se han llenado.", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
Beispiel #17
0
        public static void Show(HtmlNode docNode)
        {
            Color holder = Console.ForegroundColor;

            Console.ForegroundColor = Color.GreenYellow;

            Console.WriteLine(Etc.MakeUnderline("\nHead to Head\n\nAll Time Stats:"));

            HtmlNode allTimeCount = docNode.SelectSingleNode("//div[@class=\"head-to-head\"]");

            PrintAllTime(allTimeCount);

            HtmlNode hthListing = docNode.SelectSingleNode("//div[contains(@class, 'head-to-head-listing')]");

            PrintAdv(hthListing);

            Console.ForegroundColor = holder;
        }
Beispiel #18
0
 public void Init()
 {
     if (CheckFieldsINICIAR())
     {
         this.Hide();
         ini.Minimize();
         SaveNewConfig();
         TemporalStorage = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\VoxLine\\" + ini.config.CodePc;
         Etc.CreateDir(TemporalStorage);
         Sync();
         InitTime();
         initiated = true;
     }
     else
     {
         MessageBox.Show("Los campos obligatorios no se han llenado.", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
     }
 }
Beispiel #19
0
        public static DateTime?RandomMarriageDate(DateTime?dob, Gender myGender)
        {
            dob = dob ?? Etx.RandomAdultBirthDate();
            var dt             = DateTime.UtcNow;
            var avgAgeMarriage = myGender == Gender.Female
                ? AmericanEquations.FemaleAge2FirstMarriage.SolveForY(dob.Value.ToDouble())
                : AmericanEquations.MaleAge2FirstMarriage.SolveForY(dob.Value.ToDouble());
            var currentAge = Etc.CalcAge(dob.Value, dt);

            //all other MaritalStatus imply at least one marriage in past
            var yearsMarried = currentAge - Convert.ToInt32(Math.Round(avgAgeMarriage));

            var marriedOn = Etx.RandomDate(-1 * yearsMarried, dt);

            //zero-out the time
            marriedOn = new DateTime(marriedOn.Year, marriedOn.Month, marriedOn.Day);
            return(marriedOn);
        }
Beispiel #20
0
        // listens for incoming transmissions
        private void ServerTask()
        {
            try
            {
                // initialize tcp listener
                m_TCPListener = new TcpListener(m_ServerIP, m_ServerPort);
                m_TCPListener.Start();
                Console.WriteLine("Listening for incoming data...");

                while (m_bRunThread)
                {
                    // block until connection established
                    m_ClientSocket = m_TCPListener.AcceptSocket();

                    // if client connected start receiving thread
                    if (m_ClientSocket.Connected)
                    {
                        Console.WriteLine("Receiving data from: " + m_ClientSocket.RemoteEndPoint.ToString());

                        // get bytes
                        int numbytes = m_ClientSocket.Receive(m_LastReceivedData);
                        Console.WriteLine("Received " + numbytes.ToString() + " bytes from: " + m_ClientSocket.RemoteEndPoint.ToString());

                        // disconnect
                        m_ClientSocket.Disconnect(true);

                        // try to parse incoming data to network package struct
                        NetworkPackage nwPackage = new NetworkPackage();
                        nwPackage = (NetworkPackage)Etc.ByteArrayToObject(m_LastReceivedData, nwPackage.GetType());

                        // trigger event
                        OnNetworkReceivedData(nwPackage);
                    }
                }
            }
            catch (SocketException se)
            {
                OnNetworkError(se);
            }
            catch (SystemException e)
            {
                OnNetworkError(e);
            }
        }
Beispiel #21
0
        //everything is an async due to the live match functionality :/
        public void Get(string matchURL)
        {
            HtmlDocument doc     = Etc.GetDocFromURL(matchURL);
            HtmlNode     docNode = doc.DocumentNode;

            int    selection = 5;
            string title     = "You are viewing: " +
                               docNode.SelectSingleNode("//title").InnerText.Split('|')[0].Trim(),
                   watchLive = "";

            this.printout = "\n" + title + "\n" +
                            "\nPlease enter the category to view:\n" +
                            "1. Maps\n" +
                            "2. Lineups\n" +
                            "3. Past Matches\n" +
                            "4. Head to Head\n" +
                            "5. Comments\n";

            CheckLiveStatus(doc.DocumentNode);

            if (!this.over)
            {
                this.printout += "6. Streams\n";
                selection++;
                if (this.live)
                {
                    this.printout += "W. Watch Live\n";
                    watchLive      = ", W to watch";
                }
            }
            else
            {
                this.printout += "6. VODs\n" +
                                 "7. Highlights\n" +
                                 "8. Match Stats\n" +
                                 "9. Player of the Match\n";
                selection += 4;
            }
            //-4 for the first and last lines and overhead
            this.hint = "(1-" + selection + watchLive + ", Q to quit, B to return): ";
            Console.Write(this.printout + this.hint);
            GetEntry(docNode);
        }
Beispiel #22
0
        public static void Show(HtmlNode docNode)
        {
            HtmlNode mapGrid = docNode.SelectSingleNode("//div[contains(@class, 'g-grid')]");
            HtmlNode mapCol  = mapGrid.SelectNodes("./div")[0];

            HtmlNodeCollection info = mapCol.SelectNodes(".//*[contains(@class, 'padding')]");

            Console.WriteLine("\n" + info[0].InnerText + "\n");
            if (info.Count > 1)
            {
                HtmlNodeCollection vetoes = info[1].SelectNodes("./div");
                foreach (HtmlNode veto in vetoes)
                {
                    Console.WriteLine(veto.InnerText);
                }
                Console.Write("\n");
            }

            HtmlNodeCollection maps = mapCol.SelectNodes(".//div[@class=\"mapholder\"]");

            foreach (HtmlNode map in maps)
            {
                string   mapName = map.SelectSingleNode(".//div[@class=\"mapname\"]").InnerText;
                HtmlNode played  = map.SelectSingleNode("./div[@class=\"played\"]");

                //map wasn't played/ended before map could be played
                if (played == null)
                {
                    Console.Write(mapName + "(");
                    Console.Write("Map unplayed", Etc.LOST);
                    Console.Write(")\n");
                    break;
                }

                Console.WriteLine(Etc.MakeUnderline(mapName));
                HtmlNode results = map.SelectSingleNode(".//div[contains(@class, 'results')]");
                if (results != null)
                {
                    GetTeamScore(results);
                }
            }
        }
Beispiel #23
0
        // override setposition to handle enpassant
        public override void SetPosition(int Position)
        {
            // call the base
            base.SetPosition(Position);

            // check to see if this pawn can enpassant-ed
            if (Math.Abs(m_nPosition - m_nPrevPosition) == 16)
            {
                int Row    = -1;
                int Col    = -1;
                int Square = -1;

                Etc.GetRowColFromSquare(m_nPosition, out Row, out Col);

                // check left
                Col--;
                Etc.GetSquareFromRowCol(Row, Col, out Square);

                if (Square >= 0 && m_Type == PType.WhitePawn && GameData.g_CurrentGameState[Square] != null && GameData.g_CurrentGameState[Square].GetPieceType() == PType.BlackPawn)
                {
                    GameData.g_CurrentGameState[Square].AddEnPassantMove(m_nPosition - 8);
                }
                else if (Square >= 0 && m_Type == PType.BlackPawn && GameData.g_CurrentGameState[Square] != null && GameData.g_CurrentGameState[Square].GetPieceType() == PType.WhitePawn)
                {
                    GameData.g_CurrentGameState[Square].AddEnPassantMove(m_nPosition + 8);
                }

                // check right
                Etc.GetRowColFromSquare(m_nPosition, out Row, out Col);
                Col++;
                Etc.GetSquareFromRowCol(Row, Col, out Square);

                if (Square >= 0 && m_Type == PType.WhitePawn && GameData.g_CurrentGameState[Square] != null && GameData.g_CurrentGameState[Square].GetPieceType() == PType.BlackPawn)
                {
                    GameData.g_CurrentGameState[Square].AddEnPassantMove(m_nPosition - 8);
                }
                else if (Square >= 0 && m_Type == PType.BlackPawn && GameData.g_CurrentGameState[Square] != null && GameData.g_CurrentGameState[Square].GetPieceType() == PType.WhitePawn)
                {
                    GameData.g_CurrentGameState[Square].AddEnPassantMove(m_nPosition + 8);
                }
            }
        }
Beispiel #24
0
        public static void Show(HtmlNode docNode)
        {
            Console.WriteLine("\n");
            //makes a list filled with 7 empty string arrays to be populated w/ match data
            List <List <string> > PMData = Etc.GenerateEmptyListWithHeaders();

            HtmlNode           PMNode  = docNode.SelectSingleNode("//div[@class=\"past-matches\"]");
            HtmlNodeCollection teamPMs = PMNode.SelectNodes(".//div[contains(@class, 'standard-box')]");

            foreach (HtmlNode teamPM in teamPMs)
            {
                HtmlNode headline = teamPM.SelectSingleNode("./div[@class=\"box-headline\"]");
                string   teamName = headline.SelectSingleNode(".//a").InnerText;
                PMData[0].Add(teamName);

                HtmlNodeCollection matches = teamPM.SelectNodes(".//tr[@class=\"table\"]");

                for (int i = 0; i < matches.Count; i++)
                {
                    HtmlNodeCollection matchRows  = matches[i].SelectNodes(".//td");
                    string             format     = matchRows[0].SelectSingleNode(".//a").InnerText;
                    string             opponent   = matchRows[1].SelectSingleNode(".//a").InnerText;
                    string             score      = matchRows[2].InnerText;
                    List <string>      scoreClass = matchRows[2].GetClasses().ToList();
                    //eg. ["Best of 3", "Clown9", "2-0", "-16434134"]
                    List <string> toAdd = new List <string>(new string[] {
                        format,
                        opponent,
                        score,
                        (
                            (scoreClass.Contains("won")) ? Etc.WON.ToArgb().ToString() :
                            (scoreClass.Contains("lost")) ? Etc.LOST.ToArgb().ToString() :
                            Etc.DEFAULT_FG.ToArgb().ToString()
                        )
                    });
                    //+1 to make up for the header
                    PMData[i + 1].AddRange(toAdd);
                }
            }
            PrintPastMatches(PMData);
        }
        public static IEnumerable <ApplicationContainer> All(Hourglass hourglass = null, bool loadenv = true)
        {
            EtcUser[] users = new Etc(NodeConfig.Values).GetAllUsers();

            foreach (EtcUser user in users)
            {
                if (user.Gecos.StartsWith("openshift_service"))
                {
                    RubyHash env           = new RubyHash();
                    string   gearNamespace = null;

                    if (loadenv)
                    {
                        env = new RubyHash(Environ.Load(new string[] { Path.Combine(user.Dir, ".env") }));
                    }

                    if (env.ContainsKey("OPENSHIFT_GEAR_DNS"))
                    {
                        gearNamespace = env["OPENSHIFT_GEAR_DNS"];
                    }

                    ApplicationContainer app = null;

                    try
                    {
                        app = new ApplicationContainer(env["OPENSHIFT_APP_UUID"],
                                                       user.Name, user, env["OPENSHIFT_APP_NAME"], env["OPENSHIFT_GEAR_NAME"], gearNamespace, null, null, hourglass);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Failed to instantiate ApplicationContainer for uid {0}/uuid {1}: {2}",
                                     user.Uid, env["OPENSHIFT_APP_UUID"], ex.Message);
                        Logger.Error("Stacktrace: {0}", ex.StackTrace);

                        continue;
                    }

                    yield return(app);
                }
            }
        }
Beispiel #26
0
        private void HRm_Finder(string val_OI_Hydro, double val_QRm)
        {
            var dt = postGroups[val_OI_Hydro];

            var closestRowN  = 0;
            var closestColN  = 0;
            var closestValue = 0.0;
            var closestDiff  = double.PositiveInfinity;

            for (var colN = 0; colN < dt.Columns.Count; colN++)
            {
                if (!NumberColumns.Contains(dt.Columns[colN].ColumnName))
                {
                    continue;
                }

                for (var rowN = 0; rowN < dt.Rows.Count; rowN++)
                {
                    Etc.NoThrow(() =>
                    {
                        var value = new Cell(dt.Rows[rowN][colN]).DoubleValue;
                        var diff  = Math.Abs(value - val_QRm);

                        if (diff < closestDiff)
                        {
                            closestRowN  = rowN;
                            closestColN  = colN;
                            closestValue = value;
                            closestDiff  = diff;
                        }
                    });
                }
            }

            var colNumber = new Cell(dt.Rows[closestRowN]["H"]).IntValue;
            var rowNumber = new Cell(dt.Columns[closestColN].ColumnName).IntValue;

            calcMemory["HRm"]       = colNumber + rowNumber;
            calcMemory["QRm_Posts"] = closestValue;
        }
Beispiel #27
0
        // handles mouse mouse event
        private void Chessboard_MouseMove(object sender, MouseEventArgs e)
        {
            // get local mouse location
            m_LocalMousePosition = PointToClient(MousePosition);

            // clamp location
            m_LocalMousePosition.X = Etc.Clamp(m_LocalMousePosition.X, 1, this.Width);
            m_LocalMousePosition.Y = Etc.Clamp(m_LocalMousePosition.Y, 1, this.Height);

            // invert Y coordinate
            m_LocalMousePosition.Y = this.Height - m_LocalMousePosition.Y;

            // update mouse down offset
            if (m_bMouseDown)
            {
                m_PieceOffsetX = m_LocalMousePosition.X - m_MouseDownPosX;
                m_PieceOffsetY = this.Height - m_LocalMousePosition.Y - m_MouseDownPosY;
            }

            // make board repaint when the mouse moves
            this.Invalidate(new Rectangle(0, 0, this.Width, this.Height));
        }
Beispiel #28
0
        public void TestBlankOutLine2()
        {
            var testContent = new[]
            {
                "The following training has been completed:",
                "",
                "Training Title: Compliance General Data Protection Regulation (GDPR)",
                "Training Provider:Vinnie (the fists) Brooker ",
                "Description: This training is an introduction to the new European Union (EU) General Data Protection Regulation (GDPR)",
                "If you have any questions, please reach out to your supervisor or contact the Vinnie at 855-555-8888."
            };

            var testResult = Etc.BlankOutLines(testContent, 2, 15, 3, 8);

            Assert.AreEqual("Training Title:                                                     ", testResult[2]);
            Assert.AreEqual("         Provider:Vinnie (the fists) Brooker ", testResult[3]);

            //mismatch - has no effect
            testResult = Etc.BlankOutLines(testContent, 2, 15, 3);
            Assert.AreEqual("Training Title: Compliance General Data Protection Regulation (GDPR)", testResult[2]);
            Assert.AreEqual("Training Provider:Vinnie (the fists) Brooker ", testResult[3]);
        }
Beispiel #29
0
        //Get match time from matchbox node and returns in Day + 24 hour time
        private string GetMatchTime(HtmlNode match)
        {
            HtmlNode timeElem = match.SelectSingleNode(".//div[@data-time-format]");

            if (timeElem != null)
            {
                long           unixTime = long.Parse(timeElem.GetAttributeValue("data-unix", "-1"));
                DateTimeOffset matchDateTime = DateTimeOffset.FromUnixTimeMilliseconds(unixTime).ToLocalTime();
                int            hour = matchDateTime.TimeOfDay.Hours, min = matchDateTime.TimeOfDay.Minutes;
                string         time = " @ " + matchDateTime.DayOfWeek + " " + Etc.ConvertToStringTime(hour, min);
                return(time);
            }
            else
            {
                List <string> classes = match.GetClasses().ToList();
                if (classes.Contains("matchover"))
                {
                    return("match ended");
                }
            }
            return(" @ Unknown time");
        }
Beispiel #30
0
        public static int RandomNumberOfChildren(DateTime?dob, DateTime?atDateTime = null)
        {
            //average to be 2.5
            var vt = DateTime.UtcNow;

            if (atDateTime != null)
            {
                vt = atDateTime.Value;
            }
            dob = dob ?? Etx.RandomAdultBirthDate();
            var age   = Etc.CalcAge(dob.Value, vt);
            var randV = Etx.RandomInteger(1, 100);

            var meanAge = Math.Round(AmericanEquations.FemaleAge2ForthChild.SolveForY(vt.Year));

            if (randV >= 84 && age >= meanAge)
            {
                return(4);
            }

            meanAge = Math.Round(AmericanEquations.FemaleAge2ThirdChild.SolveForY(vt.Year));

            if (randV >= 66 && age >= meanAge)
            {
                return(3);
            }

            meanAge = Math.Round(AmericanEquations.FemaleAge2SecondChild.SolveForY(vt.Year));

            if (randV >= 33 && age >= meanAge)
            {
                return(2);
            }

            meanAge = Math.Round(AmericanEquations.FemaleAge2FirstChild.SolveForY(vt.Year));

            return(age >= meanAge ? 1 : 0);
        }