Ejemplo n.º 1
0
 //This will parse the data to a Data Set
 public void parseFileToDataSet(String filePath, data textDatabase, data textDatabaseView, String day)
 {
     //This function is a test function to parse items into a dataset.
     String[] FileLines = System.IO.File.ReadAllLines(filePath); // This will store all the lines of the file into a string array
     foreach (String line in FileLines)
     {
         int tabCount = 0; // reset the tabCount
         String[] temp = new String[tabCount];
         // here we will resize the array depending on the tabCount
         temp = line.Split('\t');
         if (temp.Count() < 16 && temp.Count() != 1)
         {
             temp = (String[])resizeArray(temp); // in some lines in the text file, the last field is sometimes incomplete and without a tab character.
         }
         if (temp[0].Equals("Day") || temp[0].Equals("") || temp[0].StartsWith("The") || temp[0].StartsWith("***") )  // this won't add the first row which contains the headings.
             Console.WriteLine();  // just a stupid step
         else
         {
             textDatabase.addRow(temp, textDatabase);
             if(temp[0].Equals(day))  // and if it belongs to the day from the KML file, we'll use that.
             {
                 //Check if this is the day before the day we want
                 textDatabaseView.addRow(temp, textDatabaseView);  // This will add the parsed data as a row in the database. //But this will add only the days for this KML file
             }
         }
     }
 }
Ejemplo n.º 2
0
        public Config(String[] args)
        {
            if (args.Count() == 1 && args[0] == "/?")
            {
                Banners.About();
                throw new ConfigurationErrorsException(String.Empty);
            }
            else
            {
                if (args.LastOrDefault() == "/verbose")
                {
                    IsVerbose = true;
                    args = args.Take(args.Count() - 1).ToArray();
                }

                if (args.Count() != 3)
                {
                    throw new ConfigurationErrorsException("Expected three arguments as explained below.");
                }
                else
                {
                    ProjectFile = Path.GetFullPath(args[0]);
                    if (IsVerbose) Console.WriteLine("Resolved %ProjectFile as {0}.", ProjectFile.ToTrace());
                    if (!File.Exists(ProjectFile))
                    {
                        throw new ConfigurationErrorsException(String.Format(
                            "%ProjectFile (specified as \"{0}\") does not exist.", ProjectFile.ToTrace()));
                    }

                    ProjectDir = Path.GetDirectoryName(ProjectFile);
                    if (IsVerbose) Console.WriteLine("Resolved %ProjectDir as {0}.", ProjectDir.ToTrace());

                    TemplateFile = Path.GetFullPath(args[1]);
                    if (IsVerbose) Console.WriteLine("Resolved %TemplateFile as {0}.", TemplateFile.ToTrace());
                    if (!File.Exists(TemplateFile))
                    {
                        throw new ConfigurationErrorsException(String.Format(
                            "%TemplateFile (specified as \"{0}\") does not exist.", TemplateFile.ToTrace()));
                    }

                    DestinationFile = Path.GetFullPath(args[2]);
                    if (IsVerbose) Console.WriteLine("Resolved %DestinationFile as {0}.", DestinationFile.ToTrace());
                    if (!File.Exists(DestinationFile))
                    {
                        if (IsVerbose) Console.WriteLine("Destination file doesn't exist at {0}. Creating it...", DestinationFile.ToTrace());

                        var destinationDir = Path.GetDirectoryName(DestinationFile);
                        if (!Directory.Exists(destinationDir))
                        {
                            if (IsVerbose) Console.WriteLine("Destination file directory doesn't exist at {0}. Creating it...", destinationDir.ToTrace());
                            Directory.CreateDirectory(destinationDir);
                            if (IsVerbose) Console.WriteLine("Destination file directory successfully created at {0}.", destinationDir.ToTrace());
                        }

                        File.WriteAllText(DestinationFile, String.Empty);
                        if (IsVerbose) Console.WriteLine("Destination file successfully created at {0}.", DestinationFile.ToTrace());
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public sigConfigServer(String[] args)
        {
            // Initialise variables and check commandline arguments for values (for manual specific logging)
            InitializeComponent();
            this.AutoLog = false;
            sigConfigServerServiceLog = new System.Diagnostics.EventLog();
            string logSource = "sigConfigServerSource";
            string logName = "sigConfigServerLog";

            if (args.Count() > 0)
            {
                logSource = args[0];
            }
            if (args.Count() > 1)
            {
                logSource = args[1];
            }

            if (!System.Diagnostics.EventLog.SourceExists(logSource))
            {
                System.Diagnostics.EventLog.CreateEventSource(logSource, logName);
            }

            sigConfigServerServiceLog.Source = logSource;
            sigConfigServerServiceLog.Log = logName;

            // Logging
            sigConfigServerServiceLog.WriteEntry("Roswell Email Signature Sync service (server mode) created.");

            this.OnStart();
        }
Ejemplo n.º 4
0
 public static String equals(String s, String t)
 {
     var lcm = LCM(s.Count(), t.Count());
     //var r = Enumerable.SequenceEqual(
     //    Enumerable.Repeat(s, (lcm / s.Count())).SelectMany(l => l),
     //    Enumerable.Repeat(t, (lcm / t.Count())).SelectMany(l => l));
     return (Enumerable.Repeat(s, (lcm / s.Count())).SelectMany(l => l)
         .SequenceEqual(Enumerable.Repeat(t, (lcm / t.Count())).SelectMany(l => l))) ?
         "Equal" : "Not Equal";
 }
Ejemplo n.º 5
0
        private String[] GenerateChoices(
            String [] names)
        {
            String [] choices = new String[names.Count()];

             for (int i = 0; i < names.Count(); i++)
               { choices[i] = names[i]; }

             return choices;
        }
Ejemplo n.º 6
0
 /* Concatenate all the strings in an array into one single string. */
 public static String ConcatenateAll(String seperator, String[] texts)
 {
     if (texts.Count() == 0)
         return "";
     var sb = new StringBuilder(texts[0]);
     for (int i = 1; i < texts.Count(); i++ )
     {
         sb.Append(seperator + texts[i]);
     }
     return sb.ToString();
 }
Ejemplo n.º 7
0
 public Button(int x, int y, String text, String iD, Window parentWindow)
     : base(x, y, 1, text.Count() + 2, parentWindow, iD)
 {
     Text = text;
     BackgroundColour = parentWindow.BackgroundColour;
     Selectable = true;
 }
        public ActionResult Login(UsuarioModel usuario)
        {
            if (ModelState.IsValid)
            {
                var servico = ModuleBuilder.CriarServicoAutenticacao();

                var usuarioAutentiado = servico.AutenticacarUsuario(usuario.Email, usuario.Senha);

                if (usuarioAutentiado != null)
                {
                    String[] permicoes = new String[2];

                    foreach (var permissao in usuarioAutentiado.Permissoes)
                    {
                        permicoes[permicoes.Count(t => t != null)] = permissao.Texto;
                    }

                    var logado = new UsuarioLogado(usuarioAutentiado.Email, permicoes);
                    FormsAuthentication.SetAuthCookie(logado.Email, true);
                    Session["USUARIO_LOGADO"] = logado;
                    return RedirectToAction("Index", "Home");
                }
            }

            ModelState.AddModelError("INVALID_LOGIN", "Usuário ou senha inválidos.");
            return View("Index", usuario);
        }
Ejemplo n.º 9
0
        public Alert(String Message, Window parentWindow, ConsoleColor backgroundColour, String Title)
            : base(Title, 6, (Console.WindowWidth / 2) - 25, 50, 5 + (int)Math.Ceiling(((Double)Message.Count() / textLength)), parentWindow)
        {
            BackgroundColour = backgroundColour;

            Create(Message, parentWindow);
        }
Ejemplo n.º 10
0
        public SongButton(Rectangle rect, String folder)
        {
            String[] songfiles = Directory.GetFiles(folder, "*.wav", SearchOption.TopDirectoryOnly);
            String[] dmlfiles = Directory.GetFiles(folder, "*.dml", SearchOption.TopDirectoryOnly);

            if (dmlfiles.Count() > 0)
                dmlfile = dmlfiles[0];

            String[] pngs = Directory.GetFiles(folder, "*.png", SearchOption.TopDirectoryOnly);//gets images from folder
            String[] jpgs = Directory.GetFiles(folder, "*.jpg", SearchOption.TopDirectoryOnly);
            String[] images = new String[pngs.Length + jpgs.Length];
            pngs.CopyTo(images, 0);
            jpgs.CopyTo(images, pngs.Length);
            if (images.Count() > 0)
            {
                String image = images[0];
                texture = Texture2D.FromStream(Globals.graphics.GraphicsDevice, File.OpenRead(image));//reads images from stream(non content)
            }
            else
            {
                texture = new Texture2D(Globals.graphics.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                texture.SetData<Color>(new Color[] { Color.White });
            }
            this.song = songfiles[0];
            if (songfiles.Length>0) this.music = new Wave(songfiles[0]);
            this.title = songfiles[0];
            this.rect = rect;
            CollisionMask = new RectCollider(rect);
        }
Ejemplo n.º 11
0
        private void Create(String Message, Window parentWindow)
        {
            var count = 0;
            while ((count*45) < Message.Count())
            {
                var splitMessage = Message.PadRight(textLength * (count + 1), ' ').Substring((count * textLength), textLength);
                var messageLabel = new Label(splitMessage, PostionX + 2 + count, PostionY + 2, "messageLabel", this);
                Inputs.Add(messageLabel);

                count++;
            }

            /*
            var messageLabel = new Label(Message, PostionX + 2, PostionY + 2, "messageLabel", this);
            messageLabel.BackgroundColour = BackgroundColour;*/

            okBtn = new Button(PostionX + Height - 2, PostionY + 2, "OK", "OkBtn", this);
            okBtn.Action = delegate() { ExitWindow(); };

            Inputs.Add(okBtn);

            CurrentlySelected = okBtn;

            Draw();
            MainLoop();
        }
 public static bool isChinese(String str)
 {
     for (int i = 0; i < str.Count(); i++)
         if (!isChinese(str[i]))
             return false;
     return true;
 }
Ejemplo n.º 13
0
 public Label(int x, int y, String text, String id, Window parentWindow)
     : base(x, y, 1, text.Count(), parentWindow, id)
 {
     Text = text;
     BackgroundColour = parentWindow.BackgroundColor;
     IsSelectable = false;
 }
Ejemplo n.º 14
0
        private void Create(String Message, TuiWindow parentTuiWindow)
        {
            var count = 0;
            while ((count * 45) < Message.Count())
            {
                var splitMessage = Message.PadRight(textLength * (count + 1), ' ').Substring((count * textLength), textLength);
                var messageLabel = new TuiLabel(splitMessage, X + 2 + count, Y + 2, "messageLabel", this);
                AddControl(messageLabel);

                count++;
            }

            okBtn = new TuiButton(X + Height - 2, Y + 2, "OK", "OkBtn", this);
            okBtn.Action = delegate() { Result = true; Close(); };

            cancelBtn = new TuiButton(X + Height - 2, Y + 8, "Cancel", "cancelBtn", this);
            cancelBtn.Action = delegate() { Close(); };

            AddControl(okBtn);
            AddControl(cancelBtn);

            CurrentlySelected = okBtn;

            Draw();
        }
Ejemplo n.º 15
0
        public TuiConfirm(String Message, TuiWindow parentTuiWindow, ConsoleColor backgroundColor, String Title = "Message")
            : base(Title, 6, (Console.WindowWidth / 2) - 25, 50, 5 + (int)Math.Ceiling(((Double)Message.Count() / textLength)), parentTuiWindow)
        {
            BackgroundColor = backgroundColor;

            Create(Message, parentTuiWindow);
        }
Ejemplo n.º 16
0
        public Menu(String text, int x, int y, String id, Window parentWindow)
            : base(x, y, 1, text.Count() + 2, parentWindow, id)
        {
            Text = text;
            Origin = new Point { X = x, Y = y };

            IsSelectable = true;
        }
Ejemplo n.º 17
0
 private static string CheckForImplicitMultiplication(String expression)
 {
     for (var i = 1; i < expression.Count() - 1; i++)
         if ((expression[i] == ')' && Char.IsNumber(expression[i + 1])) ||
            (expression[i] == '(' && Char.IsNumber(expression[i - 1])))
             expression = expression.Insert(i + 1, "*");
     return expression;
 }
Ejemplo n.º 18
0
        public Menu(String text, int x, int y, String iD, Window parentWindow)
            : base(x, y, 1, text.Count() + 2, parentWindow, iD)
        {
            Text = text;
            Xpostion = x;
            Ypostion = y;

            Selectable = true;
        }
Ejemplo n.º 19
0
 public Data search(Data data, String[] item)
 {
     Search_db search = new Search_db();
     if (item.Count() == 0)
     {
         return search.selectAll(data);
     }
     return search.search(data, item);
 }
        public static void main(String [] args)
        {
            if (args.Count() != 1) {
            Console.Write("ERROR: Missing or Extra Arguments");
            } else {
            String classificationPath = args[0];
            StreamReader input = new StreamReader(classificationPath);
            List<int> classificationList = new List<int>();

            // -6 class --> 0 (gets mapped to 0) (everything is shifted over 6
            // places for algorithmic ease)
            int [] classCount = new int[18];
            var skip = input.ReadLine();

            while (!input.EndOfStream) {
                String cur = input.ReadLine();
                String [] parms = cur.Split(' ');
                classCount[Convert.ToInt32(parms[2]) + 6]++;
                classificationList.Add(Convert.ToInt32(parms[2]));
            }

            StreamWriter output = new StreamWriter("../../../Resuls/" + "classificationAnalysis.txt");
            int ellipseTot = 0;
            int spiralTot = 0;
            int irregTot = 0;
            double tot = 0.0;

            Console.Write("Class totals: ");
            output.WriteLine("Class totals: ");

            for (int i = 0; i < classCount.Count(); i++) {
                Console.Write(i - 6 + "total :" + classCount[i]);
                output.WriteLine(i - 6 + "total :" + classCount[i]);
                if (i <= 5) {
                    ellipseTot += classCount[i];
                } else if (i <= 14) {
                    spiralTot += classCount[i];
                } else {
                    irregTot += classCount[i];
                }
                tot += classCount[i];
            }

            output.Write("Total: " + tot + "\n");
            output.Write("Ellipse Total: " + ellipseTot + "\n");
            output.Write("Ellipse Percent: " + ellipseTot / tot * 100 + "\n");
            output.Write("Sprial Total: " + spiralTot + "\n");
            output.Write("Sprial Percent: " + spiralTot / tot * 100 + "\n");
            output.Write("Irregular Total " + irregTot + "\n");
            output.Write("Irregular Percent " + irregTot / tot * 100 + "\n");

            output.Flush();
            output.Close();
            output.Dispose();
            }
        }
 public CommandParameterDTO()
 {
     String[] arr = new String[] { "Switch on", "Switch after", "Switch at" };
     String[] types = new String[] { "date", "time", "datetime", "number", "string" };
     //add custom initialization logic here.
     required = rnd.Next() % 2 == 0 ? "required" : "";
     placeholder = arr[rnd.Next(arr.Count())];
     type = types[rnd.Next(types.Count())];
     validate = "*";
 }
Ejemplo n.º 22
0
        protected double difference(int index, String string1, String string2)
        {
            switch (m_Data.attribute(index).type()) {
                case weka.core.Attribute.STRING:
                    double diff = stringDistance(string1, string2);
                    if (m_DontNormalize == true) {
                        return diff;
                    } else {
                        if (string1.Count() > string2.Count()) {
                            return diff / ((double)string1.Count());
                        } else {
                            return diff / ((double)string2.Count());
                        }
                    }

                default:
                    return 0;
            }
        }
        public string[] Speichern(String[] Var1)
        {
            int e = Var1.Count() -1;
            for (int i = 1; i <= e; i++)
            {
                TextDatei c_textdatei = new TextDatei();
                c_textdatei.WriteLine(@"config.conf", i, Var1[i], true);
            }

            return (null);
        }
Ejemplo n.º 24
0
        //public static void Main(string[] args)
        //{
        //    Console.WriteLine("Enter a Comma separated string:");
        //    var input = Console.ReadLine();
        //    var listOfWords = input.Split(',');
        //    Console.WriteLine(string.Format("The Maximum length of anagram-free subset is:{0}", GetMaximumSubset(listOfWords)));
        //    Console.ReadLine();
        //}
        #endregion

        public static int GetMaximumSubset(String[] listOfWords)
        {
            var anagramFreeSubset = new List<string>();
            anagramFreeSubset.Add(listOfWords[0]);
            for (int index = 1; index < listOfWords.Count(); index++)
            {
                if (!CheckWhetherCurrentInputWordIsAnagrmaticWithOtherWords(anagramFreeSubset, listOfWords[index]))
                    anagramFreeSubset.Add(listOfWords[index]);
            }
            return anagramFreeSubset.Count;
        }
Ejemplo n.º 25
0
        static void Main(string[] args)
        {
            var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
            var stringChars = new char[255];
            var random = new Random();

            for (int i = 0; i < stringChars.Length; i++)
            {
                stringChars[i] = chars[random.Next(chars.Length)];
            }

            var finalString = new String(stringChars);
            var countA = finalString.Count(x => x == 'a');
            var countB = finalString.Count(x => x == 'b');
            var countZ = finalString.Count(x => x == 'z');
            Console.WriteLine(finalString);
            Console.WriteLine();
            Console.WriteLine("'a' се среща " + countA + " пъти във подадения стринг");
            Console.WriteLine("'b' се среща " + countB + " пъти във подадения стринг");
            Console.WriteLine("'z' се среща " + countZ + " пъти във подадения стринг");
        }
Ejemplo n.º 26
0
 public static Boolean is_valid_email(String email)
 {
     if (!email.Contains("@") || email.Count(ch => ch== '@') > 1)
     {
         return false;
     }
     String after = email.Substring(email.IndexOf("@"));
     if (!after.Contains("."))
     {
         return false;
     }
     return true;
 }
Ejemplo n.º 27
0
 public Data search(Data data, String[] item)
 {
     Data db = new Data();
     string items = "";
     db.open();
     string query = queryType(data);
     for (int i = 0; i < item.Count(); i++)
     {
         int count = item.Count();
         if (i == count - 1)
         {
             items = items + item[i];
         }
         else
         {
             items = items + item[i] + ",";
         }
     }
     query = query.Replace("<SEARCH>", items);
     Data result = db.select(query, data);
     db.close();
     return result;
 }
Ejemplo n.º 28
0
 public static void Main(String[] args)
 {            
     if (args.Count() == 0) {
         Log.Info("Starting service");
         ServiceBase[] ServicesToRun;
         ServicesToRun = new ServiceBase[] { new Service() };
         ServiceBase.Run(ServicesToRun);  
     }
     else {
         Log.Info("Starting");
         Router wsr = new Router();
         wsr.Start();
     } 
 }
Ejemplo n.º 29
0
 public Data selectUser(Data data, String[] item)
 {
     string items = "";
     Data db = new Data();
     for (int i = 0; i < item.Count(); i++)
     {
         int count = item.Count();
         if (i == count - 1)
         {
             items = items + item[i];
         }
         else
         {
             items = items + item[i] + ",";
         }
     }
     string query = "SELECT * FROM user WHERE id IN(<SEARCH>)";
     query = query.Replace("<SEARCH>", items);
     db.open();
     Data result = db.select(query, data);
     db.close();
     return result;
 }
Ejemplo n.º 30
0
 /*
  * TODO
  * Mind blanks on check
  */
 public bool hasWord(String s)
 {
     if (s.Length == 0)
     {
         return true;
     }
     for (int i = 0; i < s.Length; i++)
     {
         if(s.Count(x => x == s[i]) > hand.Count(x => x.letter == s[i])){
             Log.log("hand","false word",4);
             return false;
         }
     }
         Log.log("hand","ok word",4);
         return true;
 }
Ejemplo n.º 31
0
 public static float processingSingleCondtion(String conditionArray, List <Attribute> empData)
 {
     string[] substrings = Regex.Split(conditionArray.Trim(), @"[^a-zA-Z0-9<>=.]+");
     substrings = substrings.Take(substrings.Count() - 1).ToArray();
     for (int i = 0; i < substrings.Count() - 1; i = i + 3)
     {
         if (descriptCondition(substrings[i + 1], empData))
         {
             substrings[i + 2] = substrings[i + 2].Replace('.', ',');
             return(float.Parse(substrings[i + 2]));
         }
         var conditionCount = conditionArray.Count();
         if (i + 6 > substrings.Count())
         {
             substrings[i + 3] = substrings[i + 3].Replace('.', ',');
             return(float.Parse(substrings[i + 3]));
         }
     }
     return(0);
 }
 /// <summary> Returns the number of occurences of a single character within a string. </summary>
 public static int Occurrences(this System.String input, char value)
 {
     return(input.Count(c => c == value));
 }