示例#1
0
 public void Set_parameters()
 {
     using (var connection = new MySqlConnection(Literals.ConnectionString())) {
         connection.Open();
         DbHelper.SetLogParameters(connection);
     }
 }
示例#2
0
        static BooleanEngineBuilder()
        {
            var OperatorNode = Deferred <OperatorNode>();

            var AndOperator = Terms.Text("AND")
                              .Or(
                Terms.Text("&&")
                );

            var NotOperator = Terms.Text("NOT")
                              .Or(
                Terms.Text("!")
                );

            var OrTextOperators = Terms.Text("OR")
                                  .Or(
                Terms.Text("||")
                );

            // Operators that need to be NOT next when the default OR ' ' operator is found.
            var NotOrOperators = OneOf(AndOperator, NotOperator, OrTextOperators);

            // Default operator.
            var OrOperator = Literals.WhiteSpace()
                             .Then <string>(static x => " ") // Normalize whitespace.
示例#3
0
        private static int RunFirstMenu()
        {
            int select = 0;

            while (select == 0)
            {
                PrintFrontScreen();
                Console.WriteLine(Literals.getLiterals("1. Increase balance"));
                Console.WriteLine(Literals.getLiterals("2. Decrease balance"));
                Console.WriteLine(Literals.getLiterals("3. Options"));
                Console.WriteLine(Literals.getLiterals("4. Exit"));
                try
                {
                    select = Int32.Parse(Console.ReadKey(true).KeyChar.ToString());
                    if (select < 1 || select > 4)
                    {
                        throw new Exception();
                    }
                }
                catch (Exception)
                {
                    select = 0;
                }
                Console.Clear();
            }
            return(select);
        }
        private static void ChangeLanguage()
        {
            Console.WriteLine(Literals.getLiterals("Input the language code or 123 to exit"));
            string pattern = "^[a-z]{2}$";

            try
            {
                string str = Console.ReadLine();
                if (str.Equals("123"))
                {
                    Console.Clear(); return;
                }
                if (Regex.IsMatch(str, pattern, RegexOptions.IgnoreCase))
                {
                    Literals.TranslateMenu(str);
                }
                else
                {
                    Console.WriteLine(Literals.getLiterals("Invalid language code pattern"));
                    Console.ReadKey(true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(Literals.getLiterals("Invalid language code or lost internet connection"));
                Console.ReadKey(true);
            }
            Console.Clear();
        }
        private static int RunFirstMenu()
        {
            int select = 0;

            while (select == 0)
            {
                Console.WriteLine(Literals.getLiterals("1. Change currency"));
                Console.WriteLine(Literals.getLiterals("2. Change language"));
                Console.WriteLine(Literals.getLiterals("3. Export to file"));
                Console.WriteLine(Literals.getLiterals("4. Add category"));
                Console.WriteLine(Literals.getLiterals("5. Remove category"));
                Console.WriteLine(Literals.getLiterals("6. Add account"));
                Console.WriteLine(Literals.getLiterals("7. Remove account"));
                Console.WriteLine(Literals.getLiterals("8. Transactions per month"));
                Console.WriteLine(Literals.getLiterals("9. Back"));
                try
                {
                    select = Int32.Parse(Console.ReadKey(true).KeyChar.ToString());
                    if (select < 1 || select > 9)
                    {
                        throw new Exception();
                    }
                }
                catch (Exception)
                {
                    select = 0;
                }
                Console.Clear();
            }
            return(select);
        }
示例#6
0
        public async Task <IActionResult> PutLiterals([FromRoute] Guid id, [FromBody] Literals literals)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != literals.LiteralID)
            {
                return(BadRequest());
            }

            _context.Entry(literals).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LiteralsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#7
0
        private static void OutputResults(List <Instruction> finalBank, List <int> finalInstruction)
        {
            List <string> convertedInstruction = finalInstruction.Select(i => Literals.IntToBinaryString(i, 9)).ToList();
            List <string> bankString           = finalBank.Select(b => b.ToString()).ToList();

            File.WriteAllLines(@"C:\Users\maxlu\Desktop\141L\instruction.txt", convertedInstruction);
            File.WriteAllLines(@"C:\Users\maxlu\Desktop\141L\bank.txt", bankString);
        }
        public Branch(string instruction, int jumpLocation)
        {
            string cond, condBinary;

            cond       = instruction.Split(" ", 2)[0].Trim().ToUpper();
            condBinary = Literals.Branches[cond];
            _operation = condBinary + TypeOp + Literals.IntToBinaryString(jumpLocation, 24);
        }
示例#9
0
 private FirstMenu()
 {
     literals    = Literals.getInstance();
     accounts    = Accounts.GetInstance();
     payments    = Payments.GetInstance();
     categories  = Categories.GetInstance();
     optionsMenu = OptionsMenu.GetInstance(accounts, categories);
 }
        private MemberDeclarationSyntax CreateConstant(T entity)
        {
            var entityId = MetadataResolver.GetEntityId(entity);
            var name     = entityId.Substring(0, 1).ToUpper() + entityId.Substring(1, entityId.Length - 1);
            var value    = Literals.String(entityId);

            return(Fields.PublicConstField(name, typeof(string), value));
        }
示例#11
0
 public int GetSumOfWeights()
 {
     if (sumOfWeights < 0)
     {
         sumOfWeights = Literals.Aggregate(0, (acc, l) => acc + l.Weight);
     }
     return(sumOfWeights);
 }
示例#12
0
        public override (Parser <TermNode> Parser, TTermOption TermOption) Build()
        {
            var op = _operatorParser.Build();

            var parser = Terms.Text(Name, caseInsensitive: true)
                         .AndSkip(Literals.Char(':'))
                         .And(op.Parser)
                         .Then <TermNode>(static x => new NamedTermNode(x.Item1, x.Item2));
示例#13
0
        public void WhenShouldFailParserWhenFalse()
        {
            var evenIntegers = Literals.Integer().When(x => x % 2 == 0);

            Assert.True(evenIntegers.TryParse("1234", out var result1));
            Assert.Equal(1234, result1);

            Assert.False(evenIntegers.TryParse("1235", out var result2));
            Assert.Equal(default, result2);
示例#14
0
        public void AddLiteral(string literal, DfaNode node)
        {
            if (Literals == null)
            {
                Literals = new Dictionary <string, DfaNode>(StringComparer.OrdinalIgnoreCase);
            }

            Literals.Add(literal, node);
        }
示例#15
0
 public static void PrintFrontScreen()
 {
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.Write(Literals.getLiterals("Currency") + " - " + CurrencyModule.Currency.ToUpper() + "   " + Literals.getLiterals("Total balance") + " - " + Accounts.OverAllBalance.ToString("#.##") + "   ");
     Console.ForegroundColor = ConsoleColor.Magenta;
     Console.WriteLine(Literals.getLiterals("Total expences") + " - " + Categories.TotalExpense.ToString("#.##"));
     Console.ForegroundColor = ConsoleColor.Green;
     categories.Show();
 }
示例#16
0
文件: Clause.cs 项目: renestein/SAT
        public void DeleteLiteral(Literal literal)
        {
            int index;

            while ((index = getLiteralIndex(literal)) >= 0)
            {
                Literals.RemoveAt(index);
            }
        }
示例#17
0
        public static bool IsLiteralType(this Type type)
        {
            if (type.IsNullable())
            {
                type = Nullable.GetUnderlyingType(type);
            }

            return(Literals.Contains(type));
        }
 protected override ICommandAcceptor OnInitialize(ICommandAcceptor previousAcceptor)
 {
     if (ArgumentCount > 1)
     {
         return(base.OnInitialize(previousAcceptor));
     }
     Literals.Add(previousAcceptor);
     CompletedLiterals = 1;
     return(Factory.CreateLiteral(Calculate()));
 }
示例#19
0
        public LoadStore(string instruction)
        {
            string[] insPieces = instruction.Split(" ", 2);
            string   l = "0";
            string   rd, rn, imm = "000000000000";

            if (insPieces[0].ToUpper() == "LDB")
            {
                string[] split = insPieces[1].Split(",");
                l  = "1";
                rd = Literals.Registers[split[0].Trim()];
                string rnRaw = split[1].Trim(new char[] { ' ', '[', ']' });
                if (Int32.TryParse(rnRaw[0].ToString(), out int dead))
                {
                    rn  = Literals.Registers["r15"];
                    imm = Literals.IntToBinaryString(Int32.Parse(rnRaw), 12);
                }
                else
                {
                    if (rnRaw.Contains("+"))
                    {
                        rn  = Literals.Registers[rnRaw.Split("+")[0]];
                        imm = Literals.IntToBinaryString(Int32.Parse(rnRaw.Split("+")[1]), 12);
                    }
                    else
                    {
                        rn = Literals.Registers[rnRaw];
                    }
                }
            }
            else
            {
                string[] split = insPieces[1].Split(",");
                rn = Literals.Registers[split[1].Trim()];
                string rdRaw = split[0].Trim(new char[] { ' ', '[', ']' });
                if (Int32.TryParse(rdRaw[0].ToString(), out int dead))
                {
                    rd  = Literals.Registers["r15"];
                    imm = Literals.IntToBinaryString(Int32.Parse(rdRaw), 12);
                }
                else
                {
                    if (rdRaw.Contains("+"))
                    {
                        rd  = Literals.Registers[rdRaw.Split("+")[0]];
                        imm = Literals.IntToBinaryString(Int32.Parse(rdRaw.Split("+")[1]), 12);
                    }
                    else
                    {
                        rd = Literals.Registers[rdRaw];
                    }
                }
            }
            _operation = Prefix + l + rn + rd + imm;
        }
示例#20
0
        public async Task <IActionResult> PostLiterals([FromBody] Literals literals)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.literals.Add(literals);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLiterals", new { id = literals.LiteralID }, literals));
        }
示例#21
0
        public DataProcessing(string instruction)
        {
            string[]      insPieces = instruction.Split(" ", 2);
            string        opcode = Literals.OpCodes[insPieces[0].ToUpper()];
            string        s = "1";
            string        I = "0";
            OperationType type = Literals.GetOperation(insPieces[0].ToUpper());
            string        rd = "r15", rn = "r15", rs = "r15", imm = "00000000";

            //Compare is weird because it doesn't have an rd, add it anyways because it isn't used.
            if (opcode.Equals("1000"))
            {
                insPieces[1] = "r15," + insPieces[1];
            }
            string[] registers = insPieces[1].Split(',');
            if (type.HasFlag(OperationType.Rd))
            {
                rd = registers[0];
            }
            if (type.HasFlag(OperationType.Rn))
            {
                if (Int32.TryParse(registers[1].ToString(), out int immInt))
                {
                    rn  = "r15";
                    imm = Literals.IntToBinaryString(immInt);
                    I   = "1";
                }
                else
                {
                    rn = registers[1];
                }
            }
            if (type.HasFlag(OperationType.Rs) || type.HasFlag(OperationType.Imm))
            {
                if (!type.HasFlag(OperationType.Rs) && registers.Length == 2)
                {
                    //Do nothing, we already did it in the last step
                }
                else if (Int32.TryParse(registers[2].ToString(), out int immInt))
                {
                    rs  = "r15";
                    imm = Literals.IntToBinaryString(immInt);
                    I   = "1";
                }
                else
                {
                    rs = registers[2];
                }
            }
            _operation = Prefix + I + opcode + s + Literals.Registers[rn] + Literals.Registers[rd] + Literals.Registers[rs] + imm;
        }
        protected void Save_Click(object sender, EventArgs e)
        {
            ProcessChanges();
            using (var connection = new MySqlConnection(Literals.GetConnectionString())) {
                connection.Open();
                var transaction = connection.BeginTransaction(IsolationLevel.RepeatableRead);
                try {
                    var dataAdapter = new MySqlDataAdapter("", connection);
                    dataAdapter.InsertCommand             = new MySqlCommand(@"
insert into ordersendrules.handler_properties(name, value, OrderSendRuleId)
values (?name, ?value, ?ruleId);", connection);
                    dataAdapter.InsertCommand.Transaction = transaction;
                    dataAdapter.InsertCommand.Parameters.Add("?Name", MySqlDbType.VarString, 0, "Name");
                    dataAdapter.InsertCommand.Parameters.Add("?Value", MySqlDbType.VarString, 0, "Value");
                    dataAdapter.InsertCommand.Parameters.AddWithValue("?RuleId", RuleId);

                    dataAdapter.DeleteCommand             = new MySqlCommand(@"
delete from ordersendrules.handler_properties
where id = ?id;", connection);
                    dataAdapter.DeleteCommand.Transaction = transaction;
                    dataAdapter.DeleteCommand.Parameters.Add("?Id", MySqlDbType.Int32, 0, "Id");

                    dataAdapter.UpdateCommand             = new MySqlCommand(@"
update ordersendrules.handler_properties
set name = ?name,
	value = ?value
where id = ?id;", connection);
                    dataAdapter.UpdateCommand.Transaction = transaction;
                    dataAdapter.UpdateCommand.Parameters.Add("?Id", MySqlDbType.Int32, 0, "Id");
                    dataAdapter.UpdateCommand.Parameters.Add("?Name", MySqlDbType.VarString, 0, "Name");
                    dataAdapter.UpdateCommand.Parameters.Add("?Value", MySqlDbType.VarString, 0, "Value");

                    dataAdapter.Update(Data.Tables["Properties"]);

                    transaction.Commit();
                }
                catch (Exception) {
                    if (transaction != null)
                    {
                        transaction.Rollback();
                    }

                    throw;
                }
            }

            GetData();
            ConnectDataSource();
            DataBind();
        }
		private SiteMapNode SiteMapResolve(object sender, SiteMapResolveEventArgs e)
		{
			var currentNode = e.Provider.CurrentNode.Clone(true);
			if (currentNode.Url.EndsWith("/managep.aspx"))
				currentNode.ParentNode.Url += e.Context.Request["cc"];
			else if (currentNode.Url.EndsWith("/SenderProperties.aspx")) {
				uint firmCode;
				using (var connection = new MySqlConnection(Literals.GetConnectionString())) {
					connection.Open();
					var command = new MySqlCommand(@"
select firmcode 
from ordersendrules.order_send_rules osr
where osr.id = ?ruleId
", connection);
					command.Parameters.AddWithValue("?RuleId", e.Context.Request["RuleId"]);
					firmCode = Convert.ToUInt32(command.ExecuteScalar());
				}
				currentNode.ParentNode.Url += "?cc=" + firmCode;
				currentNode.ParentNode.ParentNode.Url += firmCode;
			}
			else if (currentNode.Url.EndsWith("/EditRegionalInfo.aspx")) {
				uint firmCode;
				using (var connection = new MySqlConnection(Literals.GetConnectionString())) {
					connection.Open();
					var command = new MySqlCommand(@"
SELECT FirmCode
FROM usersettings.regionaldata rd
WHERE RowID = ?Id", connection);
					command.Parameters.AddWithValue("?Id", Convert.ToUInt32(e.Context.Request["id"]));
					firmCode = Convert.ToUInt32(command.ExecuteScalar());
				}
				currentNode.ParentNode.Url += "?cc=" + firmCode;
				currentNode.ParentNode.ParentNode.Url += firmCode;
			}
			else if (currentNode.Url.EndsWith("/managecosts.aspx")) {
				uint firmCode;
				using (var connection = new MySqlConnection(Literals.GetConnectionString())) {
					connection.Open();
					var command = new MySqlCommand(@"
SELECT FirmCode
FROM usersettings.PricesData pd
WHERE PriceCode = ?Id", connection);
					command.Parameters.AddWithValue("?Id", Convert.ToUInt32(e.Context.Request["pc"]));
					firmCode = Convert.ToUInt32(command.ExecuteScalar());
				}
				currentNode.ParentNode.Url += "?cc=" + firmCode;
				currentNode.ParentNode.ParentNode.Url += firmCode;
			}
			return currentNode;
		}
示例#24
0
        private void ChangeBalance(int a)
        {
            int    amount = 0;
            bool   exists = false;
            string input  = "";

            while (amount <= 0 || exists == false)
            {
                Accounts.Show();
                Console.WriteLine(Literals.getLiterals("Input the name of account or it's identity describer , or 123 to exit"));
                input = Console.ReadLine();
                if (input.CompareTo("123") == 0)
                {
                    Console.Clear();
                    break;
                }
                exists = Accounts.AccountExists(input);
                if (exists)
                {
                    Console.WriteLine(Literals.getLiterals("Input amount"));
                    try
                    {
                        amount = Int32.Parse(Console.ReadLine().ToString());
                        if (amount <= 0)
                        {
                            throw new Exception();
                        }
                        if (a == 1)
                        {
                            Accounts.IncreaseAccountAmount(input, amount);
                        }
                        else if (a == -1)
                        {
                            AccountNameId = input;
                            Amount        = amount;
                        }
                    }
                    catch (Exception)
                    {
                        amount = 0;
                    }
                }
                else
                {
                    Console.WriteLine(Literals.getLiterals("Account does not exist"));
                    Console.ReadKey(true);
                }
                Console.Clear();
            }
        }
示例#25
0
        private void AddAccount()
        {
            string pattern = "^[A-Za-z0-9]{3,20}$";

            while (true)
            {
                Accounts.Show();
                Console.WriteLine(Literals.getLiterals("Input the name of account or it's identity describer , or 123 to exit"));
                string idName = Console.ReadLine();
                if (idName.Equals("123"))
                {
                    Console.Clear(); break;
                }
                int amount = 0;
                if (Regex.IsMatch(idName, pattern, RegexOptions.IgnoreCase))
                {
                    if (!Accounts.AccountExists(idName))
                    {
                        try
                        {
                            Console.WriteLine(Literals.getLiterals("Input amount"));
                            amount = Int32.Parse(Console.ReadLine().ToString());
                            if (amount <= 0)
                            {
                                throw new Exception();
                            }
                            Accounts.AddAccount(idName, amount);
                            Console.Clear();
                            break;
                        }
                        catch (Exception)
                        {
                            amount = 0;
                        }
                    }
                    else
                    {
                        Console.WriteLine(Literals.getLiterals("Account exists"));
                        Console.ReadKey(true);
                    }
                }
                else
                {
                    Console.WriteLine(Literals.getLiterals("Invalid account pattern"));
                    Console.ReadKey(true);
                }
                Console.Clear();
            }
        }
示例#26
0
        public DocumentRange GetDollarSignRange()
        {
            var literal = Literals.FirstOrDefault();

            if (literal == null)
            {
                return(DocumentRange.InvalidRange);
            }

            var startOffset = literal.GetDocumentStartOffset();

            var text = literal.GetText();

            return(text[0] == '$'
        ? startOffset.ExtendRight(+1)
        : startOffset.Shift(+1).ExtendRight(+1));
        }
示例#27
0
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        using (var connection = new MySqlConnection(Literals.GetConnectionString())) {
            connection.Open();

            var commandText = @"
UPDATE usersettings.regionaldata
SET ContactInfo = ?ContactInformation, 
	OperativeInfo = ?Information
WHERE RowId = ?Id;";
            var command     = new MySqlCommand(commandText, connection);
            command.Parameters.AddWithValue("?Id", _regionalSettingsCode);
            command.Parameters.AddWithValue("?ContactInformation", ContactInfoText.Text);
            command.Parameters.AddWithValue("?Information", OperativeInfoText.Text);
            command.ExecuteNonQuery();
            Response.Redirect(String.Format("managep.aspx?cc={0}", _clientCode));
        }
    }
示例#28
0
        private void RemoveAccount()
        {
            string pattern = "^[A-Za-z0-9]{3,20}$";

            while (true)
            {
                Accounts.Show();
                Console.WriteLine(Literals.getLiterals("Input the name of account or it's identity describer , or 123 to exit"));
                string idName = Console.ReadLine();
                int    amount = 0;
                if (idName.Equals("123"))
                {
                    Console.Clear(); break;
                }

                if (Regex.IsMatch(idName, pattern, RegexOptions.IgnoreCase))
                {
                    if (Accounts.AccountExists(idName))
                    {
                        try
                        {
                            Accounts.RemoveAccount(idName);
                            Console.Clear();
                            break;
                        }
                        catch (Exception)
                        {
                            amount = 0;
                        }
                    }
                    else
                    {
                        Console.WriteLine(Literals.getLiterals("Account does not exist"));
                        Console.ReadKey(true);
                    }
                }
                else
                {
                    Console.WriteLine(Literals.getLiterals("Invalid account pattern"));
                    Console.ReadKey(true);
                }
                Console.Clear();
            }
        }
示例#29
0
 private void TransactionsPerMonth()
 {
     while (true)
     {
         try
         {
             Console.WriteLine(Literals.getLiterals("Input month"));
             int month = Int32.Parse(Console.ReadLine());
             Console.WriteLine(Literals.getLiterals("Input year"));
             int year = Int32.Parse(Console.ReadLine());
             LinkedList <Payment> linkedList = Payments.TransactionsPerMonth(month, year);
             if (linkedList == null)
             {
                 Console.WriteLine(Literals.getLiterals("Nothing to show for this month : ") + month + "." + year);
                 Console.ReadKey(true);
                 Console.Clear();
                 break;
             }
             else
             {
                 Console.WriteLine("---------------------------------------------------------------");
                 foreach (Payment pay in linkedList)
                 {
                     Console.Write(Literals.getLiterals("Account :") + " " + pay.AccountNameId + " | ");
                     Console.Write(Literals.getLiterals("Category :") + " " + pay.CategoryNameId + " | ");
                     Console.Write(Literals.getLiterals("Expence amount :") + " " + pay.Amount.ToString("#.##") + " | ");
                     Console.Write(Literals.getLiterals("Currency :") + " " + CurrencyModule.Currency.ToUpper() + " | ");
                     Console.WriteLine(Literals.getLiterals("Date :") + " " + pay.DateTime.ToString("yyyy.MM.dd.HH.mm.ss"));
                 }
                 Console.WriteLine("---------------------------------------------------------------");
                 Console.ReadKey(true);
                 Console.Clear();
                 break;
             }
         }
         catch (Exception)
         {
             Console.WriteLine(Literals.getLiterals("Only numeric input !"));
             Console.ReadKey(true);
         }
         Console.Clear();
     }
 }
示例#30
0
        private string DebuggerToString()
        {
            var builder = new StringBuilder();

            builder.Append(Label);
            builder.Append(" d:");
            builder.Append(PathDepth);
            builder.Append(" m:");
            builder.Append(Matches.Count);
            builder.Append(" c: ");
            builder.Append(string.Join(", ", Literals.Select(kvp => $"{kvp.Key}->({FormatNode(kvp.Value)})")));
            return(builder.ToString());

            // DfaNodes can be self-referential, don't traverse cycles.
            string FormatNode(DfaNode other)
            {
                return(ReferenceEquals(this, other) ? "this" : other.DebuggerToString());
            }
        }