/// <summary> /// Przeprowadza wszystkie czynności związane z umieszczeniem daynch w bazie danych. /// </summary> /// <param name="filename">Nazwa pliku z danymi.</param> public void transfer(String filename) { this.inputFile = filename; var functions = new BoolFunction[] { dropTables, createTables, import, export }; foreach (BoolFunction function in functions) { if (!function()) { rollback(); return; } if (transaction != null) { transaction.Commit(); Console.WriteLine("Beginning new transaction"); transaction = connection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); } } if (transaction != null) { transaction.Commit(); transaction = null; } }
/// <summary> /// Przeprowadza wszystkie czynności związane z umieszczeniem daynch w bazie danych. /// </summary> /// <param name="filename">Nazwa pliku z danymi.</param> public void transfer(String filename) { var functions = new BoolFunction[] { createSchema, delegate { return(rewriteData(filename)); }, importData, createConstraints1, createIndexes1, copyTables, removeTables, createConstraints2, createIndexes2 }; foreach (BoolFunction function in functions) { if (!function()) { rollback(); return; } if (transaction != null) { transaction.Commit(); Console.WriteLine("Beginning new transaction"); transaction = connection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); } } if (transaction != null) { transaction.Commit(); transaction = null; } if (toQuery) { while (true) { Thread th = new Thread((ThreadStart) delegate { System.Windows.Forms.Clipboard.SetText(allQueries); }); th.SetApartmentState(ApartmentState.STA); th.Start(); Console.Write("Queries copied to clipboard (y) "); String line = Console.ReadLine(); if (line.ToLower().Equals("y")) { break; } } } }
public BooleanFunctionDllImport(int inputNumberOfDigits, int outputNumberOfDigits, string dllObjectPath, string methodName = "BoolFunction") : base(inputNumberOfDigits, outputNumberOfDigits) { _pDll = NativeMethods.LoadLibrary(dllObjectPath);//@"C:\Users\User\Documents\Visual Studio 2012\Projects\lab5CS\Debug\dllexport.dll"); // error handling here if (_pDll == IntPtr.Zero) { throw new Exception("DllImport Error! Cann't Load Library!"); } IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(_pDll, methodName); // error handling here if (pAddressOfFunctionToCall == IntPtr.Zero) { throw new Exception("DllImport Error! Cann't get method address!"); } _improtedFunction = (BoolFunction)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(BoolFunction)); }
public static IBoolable Build(List <Token> tokens) { /// INITIAL CHECKING // check is is empty if (tokens.Count == 0) { throw new SyntaxErrorException("ERROR! Variable declaration is empty."); } // check if contains not allowed tokens Token wwtok = TokenGroups.WrongTokenInExpression(tokens); if (!wwtok.GetTokenType().Equals(TokenType.Null)) { return(null); } // check brackets if (!Brackets.CheckCorrectness(tokens)) { return(null); } // remove first and last bracket if it is there while (tokens[0].GetTokenType().Equals(TokenType.BracketOn) && tokens[tokens.Count - 1].GetTokenType().Equals(TokenType.BracketOff) && !Brackets.ContainsIndependentBracketsPairs(tokens, BracketsType.Normal)) { List <Token> tokensCopy = tokens.Select(t => t.Clone()).ToList(); tokensCopy.RemoveAt(tokens.Count - 1); tokensCopy.RemoveAt(0); tokens = tokensCopy; } // check is is empty again after removing brackets if (tokens.Count == 0) { throw new SyntaxErrorException("ERROR! Variable declaration is empty."); } /// BOOL BUILDING // try to build simple one-element Boolable if (tokens.Count == 1) { if (tokens[0].GetTokenType().Equals(TokenType.Variable)) { string str = tokens[0].GetContent(); if (InterVariables.GetInstance().Contains(str, InterVarType.Bool)) { return(new BoolVariableRefer(str)); } else { return(null); } } if (tokens[0].GetTokenType().Equals(TokenType.BoolConstant)) { if (tokens[0].GetContent().Equals("true")) { return(new BoolConstant(true)); } else { return(new BoolConstant(false)); } } } // try to build IN function if (TokenGroups.ContainsTokenOutsideBrackets(tokens, TokenType.In)) { IBoolable iboo = BuildIn(tokens); if (!iboo.IsNull()) { return(iboo); } } // try to build LIKE function if (TokenGroups.ContainsTokenOutsideBrackets(tokens, TokenType.Like)) { IBoolable iboo = BuildLike(tokens); if (!iboo.IsNull()) { return(iboo); } } // try to build BETWEEN function if (TokenGroups.ContainsTokenOutsideBrackets(tokens, TokenType.And) && TokenGroups.ContainsTokenOutsideBrackets(tokens, TokenType.Between)) { IBoolable iboo = BuildBetween(tokens); if (!iboo.IsNull()) { return(iboo); } } // try to build time comparison IS AFTER/IS BEFORE if (ContainsOneTimeComparingToken(tokens)) { IBoolable iboo = BuildTimeComparison(tokens); if (!iboo.IsNull()) { return(iboo); } } // try to build comparison = != > < >= <= if (ContainsOneComparingToken(tokens)) { IBoolable iboo = BuildComparison(tokens); if (!iboo.IsNull()) { return(iboo); } } // try to build bool ternary if (TernaryBuilder.IsPossibleTernary(tokens)) { IBoolable iboo = TernaryBuilder.BuildBoolTernary(tokens); if (!iboo.IsNull()) { return(iboo); } } // try to build bool function if (Functions.IsPossibleFunction(tokens)) { IBoolable iboo = BoolFunction.Build(tokens); if (!iboo.IsNull()) { return(iboo); } } // try to build expression: many elements with operators or, and, xor, not if (ContainsLogicTokens(tokens)) { return(BuildExpression(tokens)); } else { return(null); } }