Example #1
0
 private BSMonitoramento InternalExecuteProcedure(SituacaoMonitoramento SituacaoSolicitada, bool concatenarOcorrencias, string ocorrencia)
 {
     using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew))
     {
         using (var session = SessionHelper.SessionFactory.OpenSession())
         {
             var procedureInvoker = new ProcedureInvoker(session);
             var bsMonitoramento  = BSMonitoramento.Executar(procedureInvoker,
                                                             logger,
                                                             (long?)SituacaoSolicitada,
                                                             HandleRegistro,
                                                             Descricao,
                                                             UsuarioExecucao,
                                                             HostExecucao,
                                                             ProgressoAtual,
                                                             ProgressoMaximo,
                                                             HostAbortar,
                                                             UsuarioAbortar,
                                                             MensagemAtual,
                                                             ocorrencia,
                                                             HandleRotina,
                                                             TabelaRotina,
                                                             LocalChamada,
                                                             ArquivoLogs,
                                                             "-",
                                                             concatenarOcorrencias ? 1 : 0,
                                                             ChaveCorrelacao,
                                                             HandleProcessoPai,
                                                             BooleanHelper.getBuilderBooleanToString(ProgressoAutomatico),
                                                             BooleanHelper.getBuilderBooleanToString(GerouCriticas));
             scope.Complete();
             return(bsMonitoramento);
         }
     }
 }
Example #2
0
        private static object FormatValueAsExpectedString(object value)
        {
            var valueType = value.GetType();

            if (valueType == typeof(DateTime))
            {
                return(DateTimeHelper.Serialize((DateTime)value));
            }

            if (valueType == typeof(bool))
            {
                return(BooleanHelper.Serialize((bool)value));
            }

            if (valueType == typeof(double?))
            {
                return(DoubleHelper.Serialize((double?)value));
            }

            if (valueType == typeof(int?))
            {
                return(IntHelper.Serialize((int?)value));
            }

            return(value.ToString());
        }
        public static BooleanHelper GetBooleanHelper(IInterpreterBoolean interpreter)
        {
            BooleanHelper booleanHelper = new BooleanHelper();

            booleanHelper.SetInterpreter(interpreter);
            return(booleanHelper);
        }
        public void EqualBoolean_Element_CheckParametersPassedDown()
        {
            var lhs = Utilities.GetBoolLitExpression();
            var rhs = Utilities.GetBoolLitExpression();

            List <object> parameters     = Utilities.GetParameterList(4);
            List <object> expectedParams = parameters;
            var           expression     = new EqualExpression(lhs, rhs, 0, 0);

            expression.Type = TypeEnum.Element;
            IInterpreterBoolean parent      = Substitute.For <IInterpreterBoolean>();
            List <object>       lhsParams   = new List <object>();
            List <object>       rhsParams   = new List <object>();
            Element             testElement = new Element(17);

            parent.DispatchElement(lhs, Arg.Do <List <object> >(x => lhsParams = x)).Returns(testElement);
            parent.DispatchElement(rhs, Arg.Do <List <object> >(x => rhsParams = x)).Returns(testElement);

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            booleanHelper.EqualBoolean(expression, parameters);

            Assert.AreEqual(expectedParams, lhsParams);
            Assert.AreEqual(expectedParams, rhsParams);
        }
 private void LoadSettings()
 {
     _iniFile = new IniFile(_path);
     if (File.Exists(_path))
     {
         AutoRetry   = BooleanHelper.ConvertToBool(_iniFile.Read("Retry", "Automatic"));
         ShowToolbar = BooleanHelper.ConvertToBool(_iniFile.Read("ToolBar", "Visibility"));
     }
 }
        public void LiteralBoolean_BooleanLiteralExpression_ReturnedCorrectValue(bool value, bool expected)
        {
            BooleanLiteralExpression e             = new BooleanLiteralExpression(value, 0, 0);
            IInterpreterBoolean      parent        = Substitute.For <IInterpreterBoolean>();
            BooleanHelper            booleanHelper = Utilities.GetBooleanHelper(parent);

            bool result = booleanHelper.LiteralBoolean(e);

            Assert.AreEqual(expected, result);
        }
Example #7
0
        public static IMarkdownFunctionSettings FromCalculateConfiguration(Dictionary <string, string> dictionary = null, ILambdaContext context = null)
        {
            var configuration = GetConfiguration(MarkdownSwitchType.Calculate, dictionary);

            if (!Int32.TryParse(configuration["ModelId"], out int modelId))
            {
                throw new ArgumentException("Model Id parameter could not be parsed", nameof(modelId));
            }

            if (!Int32.TryParse(configuration["ModelRunId"], out int modelRunId))
            {
                throw new ArgumentException("Model Run Id parameter could not be parsed", nameof(modelRunId));
            }

            if (!Int32.TryParse(configuration["ScenarioId"], out int scenarioId))
            {
                throw new ArgumentException("Scenario Id parameter could not be parsed", nameof(scenarioId));
            }

            if (!Int32.TryParse(configuration["OrganisationId"], out int organisationId))
            {
                throw new ArgumentException("Organisation Id parameter could not be parsed", nameof(organisationId));
            }

            if (!Int32.TryParse(configuration["UserId"], out int userId))
            {
                throw new ArgumentException("User Id parameter could not be parsed", nameof(userId));
            }

            if (!Int32.TryParse(configuration["PartitionId"], out int partitionId))
            {
                throw new ArgumentException("Partition Id parameter could not be parsed", nameof(partitionId));
            }

            if (!Int32.TryParse(configuration["PartitionCount"], out int partitionCount))
            {
                throw new ArgumentException("Partition Count parameter could not be parsed", nameof(partitionCount));
            }

            BooleanHelper.TryParseInexact(configuration["Upload"], out bool upload);

            var result = new MarkdownFunctionSettings(configuration, context)
            {
                ModelId        = modelId,
                ModelRunId     = modelRunId,
                OrganisationId = organisationId,
                UserId         = userId,
                ScenarioId     = scenarioId,
                PartitionId    = partitionId,
                PartitionCount = partitionCount,
                Upload         = upload
            };

            return(result);
        }
Example #8
0
        /// '-----------------------------------------------------------------------------------------
        /// <summary>
        /// Get specified config app setting's value as a boolean value
        /// </summary>
        /// <param name="appSetting"></param>
        /// <returns></returns>
        /// '-----------------------------------------------------------------------------------------
        public static bool GetAppSettingAsBool(string appSetting)
        {
            string setting = AppSettings[appSetting];

            if (setting == null || setting.Trim().Length == 0)
            {
                throw new ConfigurationErrorsException(String.Format(MISSING_APPSETTING_ERR_MSG, appSetting));
            }

            return(BooleanHelper.ConvertToBool(setting));
        }
Example #9
0
        void ColorSelect(object[] x)
        {
            bool isColor = BooleanHelper.GetBoolean(x[0]) ?? false;

            if (isColor)
            {
                IsDoubleIsEnable  = false;
                IsSingleIsChecked = true;
            }
            else
            {
                IsDoubleIsEnable = true;
            }
        }
        public void NotBoolean_CorrectValuesReturned(bool input, bool expected)
        {
            BooleanLiteralExpression child = Utilities.GetBoolLitExpression(input);

            var expr = new NotExpression(child, 0, 0);
            IInterpreterBoolean parent = Substitute.For <IInterpreterBoolean>();

            parent.DispatchBoolean(child, Arg.Any <List <object> >()).Returns(input);

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            bool res = booleanHelper.NotBoolean(expr, new List <object>());

            Assert.AreEqual(expected, res);
        }
        public void LessBoolean_Real_CorrectValuesReturned(double lhsValue, double rhsValue, bool expected)
        {
            var lhs = Utilities.GetRealLitExpression();
            var rhs = Utilities.GetRealLitExpression();

            var expression             = new LessExpression(lhs, rhs, 0, 0);
            IInterpreterBoolean parent = Substitute.For <IInterpreterBoolean>();

            parent.DispatchReal(lhs, Arg.Any <List <object> >()).Returns(lhsValue);
            parent.DispatchReal(rhs, Arg.Any <List <object> >()).Returns(rhsValue);

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            bool res = booleanHelper.LessBoolean(expression, new List <object>());

            Assert.AreEqual(expected, res);
        }
        public void AndBoolean__CorrectValuesReturned(bool lhsValue, bool rhsValue, bool expected)
        {
            BooleanLiteralExpression lhs = new BooleanLiteralExpression(lhsValue, 0, 0);
            BooleanLiteralExpression rhs = new BooleanLiteralExpression(rhsValue, 0, 0);

            AndExpression       andExpr = new AndExpression(lhs, rhs, 0, 0);
            IInterpreterBoolean parent  = Substitute.For <IInterpreterBoolean>();

            parent.DispatchBoolean(lhs, Arg.Any <List <object> >()).Returns(lhsValue);
            parent.DispatchBoolean(rhs, Arg.Any <List <object> >()).Returns(rhsValue);

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            bool res = booleanHelper.AndBoolean(andExpr, new List <object>());

            Assert.AreEqual(expected, res);
        }
        public void SubsetBoolean_GivenSetAndSet_CorrectValueReturned(int[] a, int[] b, bool expected)
        {
            Set              lhsValue   = GetSetWith1DElements(a);
            Set              rhsValue   = GetSetWith1DElements(b);
            SetExpression    lhs        = GetSetInit();
            SetExpression    rhs        = GetSetInit();
            SubsetExpression expression = new SubsetExpression(lhs, rhs, 0, 0);

            IInterpreterBoolean parent = Substitute.For <IInterpreterBoolean>();

            DispatchSetForParent(lhsValue, lhs, parent);
            DispatchSetForParent(rhsValue, rhs, parent);
            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            bool res = booleanHelper.SubsetBoolean(expression, new List <object>());

            Assert.AreEqual(expected, res);
        }
Example #14
0
        public void Printer(Object[] x)
        {
            int     num1          = JObjectHelper.GetStrNum(x[0].ToString());
            int     num2          = JObjectHelper.GetStrNum(x[1].ToString());
            int     begion        = num1 <= num2 ? num1 : num2;
            int     end           = num1 > num2 ? num1 : num2;
            int     copies        = JObjectHelper.GetStrNum(x[2].ToString());
            bool    isColor       = BooleanHelper.GetBoolean(x[3]) ?? false;
            bool    isSinglePrint = BooleanHelper.GetBoolean(x[4]) ?? false;
            JObject jo            = null;

            switch (OrderState)
            {
            case 0:      //去支付
                jo = GotoPay(begion.ToString(), end.ToString(), copies.ToString(), isColor, isSinglePrint);
                break;

            case 10:     //未打印订单,重新生成一单
                jo = ReCreateOrder(begion.ToString(), end.ToString(), copies.ToString(), isColor?"1":"0", isSinglePrint?"0":"1");
                break;

            case 200:     //打印完成,重新生成
                jo = ReCreateOrder(begion.ToString(), end.ToString(), copies.ToString(), isColor ? "1" : "0", isSinglePrint?"0":"1");
                break;

            default:
                MessageBox.Show("信息错误");
                return;
            }

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    Messenger.Default.Send <string>(OrderId, "ordercreatesuccess");
                });
                MessageBox.Show("订单生成成功");
            }
            else
            {
                MessageBox.Show(jo["message"].ToString());
            }
            //myDocument.ReCreateOrder(AccountInfo.Token, FileId, Path.GetFileName(LocalFilePath));
        }
        public void NotBoolean__CheckParametersPassedDown()
        {
            BooleanLiteralExpression child = Utilities.GetBoolLitExpression();

            List <object>       parameters     = Utilities.GetParameterList(4);
            List <object>       expectedParams = parameters;
            var                 expression     = new NotExpression(child, 0, 0);
            IInterpreterBoolean parent         = Substitute.For <IInterpreterBoolean>();
            List <object>       lhsParams      = new List <object>();
            List <object>       rhsParams      = new List <object>();

            parent.DispatchBoolean(child, Arg.Do <List <object> >(x => lhsParams = x));

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            booleanHelper.NotBoolean(expression, parameters);

            Assert.AreEqual(expectedParams, lhsParams);
        }
Example #16
0
        /// <summary>
        /// This method is used to parse Setting objects.
        /// </summary>
        public Setting ParseSetting(ref Setting setting, XmlNode xmlNode)
        {
            // if the setting object exists and the xmlNode exists
            if ((setting != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "Setting.DisableHoverControl":

                    // Set the value for setting.DisableHoverControl
                    setting.DisableHoverControl = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Setting.PromptForDelete":

                    // Set the value for setting.PromptForDelete
                    setting.PromptForDelete = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this Setting
                        setting = ParseSetting(ref setting, childNode);
                    }
                }
            }

            // return value
            return(setting);
        }
        public void EqualBoolean_Function_CorrectValuesReturned(int lhsValue, int rhsValue, bool expected)
        {
            var lhs = Utilities.GetFuncCallExpresssion();
            var rhs = Utilities.GetFuncCallExpresssion();

            EqualExpression expression = new EqualExpression(lhs, rhs, 0, 0);

            expression.Type = TypeEnum.Function;
            IInterpreterBoolean parent = Substitute.For <IInterpreterBoolean>();

            parent.DispatchFunction(lhs, Arg.Any <List <object> >()).Returns(new Function(lhsValue));
            parent.DispatchFunction(rhs, Arg.Any <List <object> >()).Returns(new Function(rhsValue));

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            bool res = booleanHelper.EqualBoolean(expression, new List <object>());

            Assert.AreEqual(expected, res);
        }
        public void NotEqualBoolean_Bool_CorrectValuesReturned(bool lhsValue, bool rhsValue, bool expected)
        {
            var lhs = Utilities.GetRealLitExpression();
            var rhs = Utilities.GetRealLitExpression();

            var expression = new NotEqualExpression(lhs, rhs, 0, 0);

            expression.Type = TypeEnum.Boolean;
            IInterpreterBoolean parent = Substitute.For <IInterpreterBoolean>();

            parent.DispatchBoolean(lhs, Arg.Any <List <object> >()).Returns(lhsValue);
            parent.DispatchBoolean(rhs, Arg.Any <List <object> >()).Returns(rhsValue);

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            bool res = booleanHelper.NotEqualBoolean(expression, new List <object>());

            Assert.AreEqual(expected, res);
        }
        public void EqualBoolean_Set_CorrectValuesReturned(int leftDataRow, int rightDataRow, bool expected)
        {
            Set lhsValue = GetSet(leftDataRow);
            Set rhsValue = GetSet(rightDataRow);

            var lhs = Utilities.GetRealLitExpression();
            var rhs = Utilities.GetRealLitExpression();

            EqualExpression expression = new EqualExpression(lhs, rhs, 0, 0);

            expression.Type = TypeEnum.Set;
            IInterpreterBoolean parent = Substitute.For <IInterpreterBoolean>();

            parent.DispatchSet(lhs, Arg.Any <List <object> >()).Returns(lhsValue);
            parent.DispatchSet(rhs, Arg.Any <List <object> >()).Returns(rhsValue);

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            bool res = booleanHelper.EqualBoolean(expression, new List <object>());

            Assert.AreEqual(expected, res);
        }
        public void EqualBoolean_Element_CorrectValuesReturned(int[] a, int[] b, bool expected)
        {
            Element lhsValue = new Element(a.ToList());
            Element rhsValue = new Element(b.ToList());

            var lhs = Utilities.GetRealLitExpression();
            var rhs = Utilities.GetRealLitExpression();

            EqualExpression expression = new EqualExpression(lhs, rhs, 0, 0);

            expression.Type = TypeEnum.Element;
            IInterpreterBoolean parent = Substitute.For <IInterpreterBoolean>();

            parent.DispatchElement(lhs, Arg.Any <List <object> >()).Returns(lhsValue);
            parent.DispatchElement(rhs, Arg.Any <List <object> >()).Returns(rhsValue);

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            bool res = booleanHelper.EqualBoolean(expression, new List <object>());

            Assert.AreEqual(expected, res);
        }
        public void LessBoolean_Real_CheckParametersPassedDown()
        {
            var lhs = Utilities.GetRealLitExpression();
            var rhs = Utilities.GetRealLitExpression();

            List <object>       parameters     = Utilities.GetParameterList(4);
            List <object>       expectedParams = parameters;
            var                 expression     = new LessExpression(lhs, rhs, 0, 0);
            IInterpreterBoolean parent         = Substitute.For <IInterpreterBoolean>();
            List <object>       lhsParams      = new List <object>();
            List <object>       rhsParams      = new List <object>();

            parent.DispatchReal(lhs, Arg.Do <List <object> >(x => lhsParams = x));
            parent.DispatchReal(rhs, Arg.Do <List <object> >(x => rhsParams = x));

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            booleanHelper.LessBoolean(expression, parameters);

            Assert.AreEqual(expectedParams, lhsParams);
            Assert.AreEqual(expectedParams, rhsParams);
        }
        public void NotEqualBoolean_Function_CheckParametersPassedDown()
        {
            var lhs = Utilities.GetFuncCallExpresssion();
            var rhs = Utilities.GetFuncCallExpresssion();

            List <object> parameters     = Utilities.GetParameterList(4);
            List <object> expectedParams = parameters;
            var           expression     = new NotEqualExpression(lhs, rhs, 0, 0);

            expression.Type = TypeEnum.Function;
            IInterpreterBoolean parent    = Substitute.For <IInterpreterBoolean>();
            List <object>       lhsParams = new List <object>();
            List <object>       rhsParams = new List <object>();

            parent.DispatchFunction(lhs, Arg.Do <List <object> >(x => lhsParams = x)).Returns(new Function(0));
            parent.DispatchFunction(rhs, Arg.Do <List <object> >(x => rhsParams = x)).Returns(new Function(0));

            BooleanHelper booleanHelper = Utilities.GetBooleanHelper(parent);

            booleanHelper.NotEqualBoolean(expression, parameters);

            Assert.AreEqual(expectedParams, lhsParams);
            Assert.AreEqual(expectedParams, rhsParams);
        }
Example #23
0
        /// <summary>
        /// This method is used to parse Database objects.
        /// </summary>
        public Database ParseDatabase(ref Database database, XmlNode xmlNode)
        {
            // if the database object exists and the xmlNode exists
            if ((database != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "Database.ClassFileName":

                    // Set the value for database.ClassFileName
                    database.ClassFileName = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.ClassName":

                    // Set the value for database.ClassName
                    database.ClassName = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.ConnectionString":

                    // Set the value for database.ConnectionString
                    database.ConnectionString = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Name":

                    // Set the value for database.Name
                    database.Name = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Password":

                    // Set the value for database.Password
                    database.Password = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Path":

                    // Set the value for database.Path
                    database.Path = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Serializable":

                    // Set the value for database.Serializable
                    database.Serializable = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.XmlFileName":

                    // Set the value for database.XmlFileName
                    database.XmlFileName = xmlNode.FormattedNodeValue;

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this Database
                        database = ParseDatabase(ref database, childNode);
                    }
                }
            }

            // return value
            return(database);
        }
Example #24
0
        /// <summary>
        /// This method is used to parse CodeComment objects.
        /// </summary>
        public CodeComment ParseCodeComment(ref CodeComment codeComment, XmlNode xmlNode)
        {
            // if the codeComment object exists and the xmlNode exists
            if ((codeComment != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "CommentDictionary.CommentItem.Comment":

                    // Set the value for codeComment.Comment
                    codeComment.Comment = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "CommentDictionary.CommentItem.HasReplacements":

                    // Set the value for codeComment.Comment
                    codeComment.HasReplacements = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "CommentDictionary.CommentItem.ID":

                    // Set the value for codeComment.Name
                    codeComment.ID = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "CommentDictionary.CommentItem.Name":

                    // Set the value for codeComment.Name
                    codeComment.Name = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "CommentDictionary.CommentItem.Pattern":

                    // Set the value for codeComment.Pattern
                    codeComment.Pattern = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "CommentDictionary.CommentItem.TargetPattern":

                    // Set the value for codeComment.TargetPattern
                    codeComment.TargetPattern = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "CommentDictionary.CommentItem.TargetPattern2":

                    // Set the value for codeComment.TargetPattern2
                    codeComment.TargetPattern2 = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "CommentDictionary.CommentItem.Type":

                    // Set the value for codeComment.CommentType
                    // codeComment.CommentType = // this field must be parsed manually.

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this CodeComment
                        codeComment = ParseCodeComment(ref codeComment, childNode);
                    }
                }
            }

            // return value
            return(codeComment);
        }
Example #25
0
        //////////////////////////////////////////////

        private static Boolean GotoNextLine(
            DynContext DynLanContext,
            DynLanState currentState,
            Object currentValue)
        {
            try
            {
                DynLanCodeLines lines       = currentState.GetCurrentLines();
                DynLanCodeLine  currentLine = currentState.GetCurrentLine();

                // jesli return to konczymy
                if (currentLine.OperatorType == EOperatorType.RETURN)
                {
                    return(ExitCurrentContext(
                               DynLanContext,
                               currentValue,
                               null));
                }
                // throw błędu
                else if (currentLine.OperatorType == EOperatorType.THROW)
                {
                    if (currentValue is Exception)
                    {
                        throw (Exception)currentValue;
                    }
                    else
                    {
                        String message = UniConvert.ToString(currentValue ?? "");
                        throw String.IsNullOrEmpty(message) ? new Exception() : new Exception(message);
                    }

                    /*return ExitCurrentContext(
                     *  DynLanContext,
                     *  new Exception(message));*/
                }
                // jesli return to konczymy
                else if (currentLine.OperatorType == EOperatorType.BREAK)
                {
                    return(ExitCurrentLoop(
                               DynLanContext,
                               currentValue,
                               null));
                }

                if (currentLine.OperatorType == EOperatorType.WHILE ||
                    currentLine.OperatorType == EOperatorType.IF ||
                    currentLine.OperatorType == EOperatorType.ELIF)
                {
                    Boolean conditionResult = BooleanHelper.IfTrue(currentValue);
                    if (conditionResult)
                    {
                        DynLanCodeLine nextLine = DynLanCodeLinesExtender.
                                                  NextOnSameOrHigher(lines, currentLine);

                        if (nextLine != null)
                        {
                            currentState.CurrentLineID = nextLine.ID;
                        }
                        else
                        {
                            throw new NotImplementedException();
                        }
                    }
                    else
                    {
                        DynLanCodeLine nextLine = DynLanCodeLinesExtender.
                                                  NextOnSameOrLower(lines, currentLine);

                        if (nextLine == null)
                        {
                            return(ExitCurrentContext(
                                       DynLanContext,
                                       null));
                        }
                        else
                        {
                            if (nextLine.Depth < currentLine.Depth)
                            {
                                while (
                                    nextLine != null &
                                    (nextLine.OperatorType == EOperatorType.ELSE ||
                                     nextLine.OperatorType == EOperatorType.ELIF /*||
                                                                                  * nextLine.OperatorType == EOperatorType.FINALLY*/))
                                {
                                    nextLine = DynLanCodeLinesExtender.ExitParentIf(lines, nextLine);

                                    if (nextLine == null)
                                    {
                                        break;
                                    }
                                }

                                if (nextLine == null)
                                {
                                    return(ExitCurrentContext(
                                               DynLanContext,
                                               null));
                                }

                                if (nextLine.Depth < currentLine.Depth)
                                {
                                    //DynLanCodeLine prevIf = lines.
                                    //    PrevLineWithLessDepth(currentLine, l => l.OperatorType == EOperatorType.IF || l.OperatorType == EOperatorType.ELIF);

                                    while (true)
                                    {
                                        DynLanCodeLine prevConditionLine = DynLanCodeLinesExtender.PrevLineWithLessDepth(
                                            lines,
                                            currentLine,
                                            l => l.OperatorType == EOperatorType.IF || l.OperatorType == EOperatorType.ELIF || l.OperatorType == EOperatorType.ELSE || l.OperatorType == EOperatorType.WHILE);

                                        if (prevConditionLine != null &&
                                            prevConditionLine.Depth >= nextLine.Depth &&
                                            prevConditionLine.OperatorType == EOperatorType.WHILE)
                                        {
                                            currentState.CurrentLineID = prevConditionLine.ID;
                                            break;
                                        }
                                        else if (prevConditionLine != null)
                                        {
                                            currentLine = prevConditionLine;
                                        }
                                        else
                                        {
                                            currentState.CurrentLineID = nextLine.ID;
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    currentState.CurrentLineID = nextLine.ID;
                                }
                            }
                            else
                            {
                                currentState.CurrentLineID = nextLine.ID;
                            }
                        }
                    }
                }
                else if (
                    currentLine.OperatorType == EOperatorType.TRY ||
                    currentLine.OperatorType == EOperatorType.ELSE)
                {
                    DynLanCodeLine nextLine = DynLanCodeLinesExtender.
                                              NextOnSameOrHigher(lines, currentLine);

                    if (nextLine != null)
                    {
                        currentState.CurrentLineID = nextLine.ID;
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
                else if (
                    (currentLine.OperatorType == EOperatorType.FINALLY))
                {
                    throw new NotImplementedException("FINALLY");
                }
                else if (
                    (currentLine.OperatorType == EOperatorType.CATCH))
                {
                    if (DynLanContext.Error != null)
                    {
                        DynLanContext.Error = null;
                        DynLanCodeLine nextLine = DynLanCodeLinesExtender.
                                                  NextOnSameOrHigher(lines, currentLine);

                        if (nextLine != null)
                        {
                            currentState.CurrentLineID = nextLine.ID;
                        }
                        else
                        {
                            throw new NotImplementedException();
                        }
                    }
                    else
                    {
                        DynLanCodeLine nextLine = DynLanCodeLinesExtender.NextOnSameOrLower(
                            lines, currentLine);

                        if (nextLine != null)
                        {
                            currentState.CurrentLineID = nextLine.ID;
                        }
                        else
                        {
                            return(ExitCurrentContext(
                                       DynLanContext,
                                       null));
                        }
                    }
                }
                else if (currentLine.OperatorType == EOperatorType.NONE || currentLine.OperatorType == EOperatorType.PASS)
                {
                    DynLanCodeLine nextLine = DynLanCodeLinesExtender.NextLine(lines, currentLine);
                    if (nextLine != null)
                    {
                        while (
                            nextLine != null &
                            (nextLine.OperatorType == EOperatorType.ELSE ||
                             nextLine.OperatorType == EOperatorType.ELIF /*||
                                                                          * nextLine.OperatorType == EOperatorType.FINALLY*/))
                        {
                            nextLine = DynLanCodeLinesExtender.ExitParentIf(lines, nextLine);

                            if (nextLine == null)
                            {
                                return(ExitCurrentContext(
                                           DynLanContext,
                                           null));
                            }
                        }

                        if (nextLine == null)
                        {
                            return(ExitCurrentContext(
                                       DynLanContext,
                                       null));
                        }

                        if (nextLine.Depth < currentLine.Depth)
                        {
                            //DynLanCodeLine prevIf = lines.
                            //    PrevLineWithLessDepth(currentLine, l => l.OperatorType == EOperatorType.IF || l.OperatorType == EOperatorType.ELIF);

                            while (true)
                            {
                                DynLanCodeLine prevConditionLine = DynLanCodeLinesExtender.
                                                                   PrevLineWithLessDepth(
                                    lines,
                                    currentLine,
                                    l => l.OperatorType == EOperatorType.IF || l.OperatorType == EOperatorType.ELIF || l.OperatorType == EOperatorType.ELSE || l.OperatorType == EOperatorType.WHILE);

                                if (prevConditionLine != null &&
                                    prevConditionLine.Depth >= nextLine.Depth &&
                                    prevConditionLine.OperatorType == EOperatorType.WHILE)
                                {
                                    currentState.CurrentLineID = prevConditionLine.ID;
                                    break;
                                }
                                else if (prevConditionLine != null)
                                {
                                    currentLine = prevConditionLine;
                                }
                                else
                                {
                                    currentState.CurrentLineID = nextLine.ID;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            currentState.CurrentLineID = nextLine.ID;
                        }
                    }
                    // jeśli ostatnia linia i jesteśmy w while'u
                    else
                    {
                        //DynLanCodeLine prevIf = lines.
                        //    PrevLineWithLessDepth(currentLine, l => l.OperatorType == EOperatorType.IF || l.OperatorType == EOperatorType.ELIF);

                        while (true)
                        {
                            DynLanCodeLine prevConditionLine = DynLanCodeLinesExtender.
                                                               PrevLineWithLessDepth(
                                lines,
                                currentLine,
                                l => l.OperatorType == EOperatorType.IF || l.OperatorType == EOperatorType.ELIF || l.OperatorType == EOperatorType.ELSE || l.OperatorType == EOperatorType.WHILE);

                            if (prevConditionLine != null &&
                                prevConditionLine.OperatorType == EOperatorType.WHILE)
                            {
                                currentState.CurrentLineID = prevConditionLine.ID;
                                break;
                            }
                            else if (prevConditionLine != null)
                            {
                                currentLine = prevConditionLine;
                            }
                            else
                            {
                                return(ExitCurrentContext(
                                           DynLanContext,
                                           null));
                            }
                        }
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// This method is used to parse DataTable objects.
        /// </summary>
        public DataTable ParseDataTable(ref DataTable dataTable, XmlNode xmlNode)
        {
            // if the dataTable object exists and the xmlNode exists
            if ((dataTable != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "Database.Tables.DataTable.IsView":

                    // Set the value for dataTable.IsView
                    dataTable.IsView = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Name":

                    // Set the value for dataTable.Name
                    dataTable.Name = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.ObjectNameSpaceName":

                    // Set the value for dataTable.ObjectNameSpaceName
                    dataTable.ObjectNameSpaceName = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.SchemaName":

                    // Set the value for dataTable.SchemaName
                    dataTable.SchemaName = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Scope":

                    // Set the value for dataTable.Scope
                    dataTable.Scope = EnumHelper.GetEnumValue <DataManager.Scope>(xmlNode.FormattedNodeValue, DataManager.Scope.Public);

                    // required
                    break;

                case "Database.Tables.DataTable.Serializable":

                    // Set the value for dataTable.Serializable
                    dataTable.Serializable = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this DataTable
                        dataTable = ParseDataTable(ref dataTable, childNode);
                    }
                }
            }

            // return value
            return(dataTable);
        }
Example #27
0
        /// <summary>
        /// This method is used to parse StoredProcedure objects.
        /// </summary>
        public StoredProcedure ParseStoredProcedure(ref StoredProcedure storedProcedure, XmlNode xmlNode)
        {
            // if the storedProcedure object exists and the xmlNode exists
            if ((storedProcedure != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "Database.StoredProcedures.StoredProcedure.DoesNotHaveParameters":

                    // Set the value for storedProcedure.DoesNotHaveParameters
                    storedProcedure.DoesNotHaveParameters = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.StoredProcedures.StoredProcedure.Parameters":

                    // Set the value for storedProcedure.Parameters
                    // storedProcedure.Parameters = // this field must be parsed manually.

                    // required
                    break;

                case "Database.StoredProcedures.StoredProcedure.ProcedureName":

                    // Set the value for storedProcedure.ProcedureName
                    storedProcedure.ProcedureName = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.StoredProcedures.StoredProcedure.ReturnSetSchema":

                    // Set the value for storedProcedure.ReturnSetSchema
                    // storedProcedure.ReturnSetSchema = // this field must be parsed manually.

                    // required
                    break;

                case "Database.StoredProcedures.StoredProcedure.StoredProcedureType":

                    // Set the value for storedProcedure.StoredProcedureType
                    storedProcedure.StoredProcedureType = EnumHelper.GetEnumValue <DataJuggler.Net5.Enumerations.StoredProcedureTypes>(xmlNode.FormattedNodeValue, DataJuggler.Net5.Enumerations.StoredProcedureTypes.NotSet);

                    // required
                    break;

                case "Database.StoredProcedures.StoredProcedure.Text":

                    // Set the value for storedProcedure.Text
                    storedProcedure.Text = xmlNode.FormattedNodeValue;

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this StoredProcedure
                        storedProcedure = ParseStoredProcedure(ref storedProcedure, childNode);
                    }
                }
            }

            // return value
            return(storedProcedure);
        }
Example #28
0
        /// <summary>
        /// This method is used to parse DataIndex objects.
        /// </summary>
        public DataIndex ParseDataIndex(ref DataIndex dataIndex, XmlNode xmlNode)
        {
            // if the dataIndex object exists and the xmlNode exists
            if ((dataIndex != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "Database.Tables.DataTable.Indexes.DataIndex.AllowPageLocks":

                    // Set the value for dataIndex.AllowPageLocks
                    dataIndex.AllowPageLocks = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.AllowRowLocks":

                    // Set the value for dataIndex.AllowRowLocks
                    dataIndex.AllowRowLocks = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.Clustered":

                    // Set the value for dataIndex.Clustered
                    dataIndex.Clustered = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.DataSpaceID":

                    // Set the value for dataIndex.DataSpaceID
                    dataIndex.DataSpaceID = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.FillFactor":

                    // Set the value for dataIndex.FillFactor
                    dataIndex.FillFactor = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.FilterDefinition":

                    // Set the value for dataIndex.FilterDefinition
                    dataIndex.FilterDefinition = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.HasFilter":

                    // Set the value for dataIndex.HasFilter
                    dataIndex.HasFilter = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IgnoreDuplicateKey":

                    // Set the value for dataIndex.IgnoreDuplicateKey
                    dataIndex.IgnoreDuplicateKey = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IndexID":

                    // Set the value for dataIndex.IndexID
                    dataIndex.IndexID = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IndexType":

                    // Set the value for dataIndex.IndexType
                    dataIndex.IndexType = EnumHelper.GetEnumValue <DataJuggler.Net.Enumerations.IndexTypeEnum>(xmlNode.FormattedNodeValue, DataJuggler.Net.Enumerations.IndexTypeEnum.Unknown);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsDisabled":

                    // Set the value for dataIndex.IsDisabled
                    dataIndex.IsDisabled = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsHypothetical":

                    // Set the value for dataIndex.IsHypothetical
                    dataIndex.IsHypothetical = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsPadded":

                    // Set the value for dataIndex.IsPadded
                    dataIndex.IsPadded = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsPrimary":

                    // Set the value for dataIndex.IsPrimary
                    dataIndex.IsPrimary = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsUnique":

                    // Set the value for dataIndex.IsUnique
                    dataIndex.IsUnique = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.IsUniqueConstraint":

                    // Set the value for dataIndex.IsUniqueConstraint
                    dataIndex.IsUniqueConstraint = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.Name":

                    // Set the value for dataIndex.Name
                    dataIndex.Name = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.ObjectID":

                    // Set the value for dataIndex.ObjectID
                    dataIndex.ObjectID = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Indexes.DataIndex.TypeDescription":

                    // Set the value for dataIndex.TypeDescription
                    dataIndex.TypeDescription = xmlNode.FormattedNodeValue;

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this DataIndex
                        dataIndex = ParseDataIndex(ref dataIndex, childNode);
                    }
                }
            }

            // return value
            return(dataIndex);
        }
Example #29
0
        /// <summary>
        /// This method is used to parse DataField objects.
        /// </summary>
        public DataField ParseDataField(ref DataField dataField, XmlNode xmlNode)
        {
            // if the dataField object exists and the xmlNode exists
            if ((dataField != null) && (xmlNode != null))
            {
                // get the full name of this node
                string fullName = xmlNode.GetFullName();

                // Check the name of this node to see if it is mapped to a property
                switch (fullName)
                {
                case "Database.Tables.DataTable.Fields.DataField.DataType":

                    // Set the value for dataField.DataType
                    dataField.DataType = EnumHelper.GetEnumValue <DataJuggler.Net.DataManager.DataTypeEnum>(xmlNode.FormattedNodeValue, DataJuggler.Net.DataManager.DataTypeEnum.NotSupported);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.DBDataType":

                    // Set the value for dataField.DBDataType
                    dataField.DBDataType = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.DBFieldName":

                    // Set the value for dataField.DBFieldName
                    dataField.DBFieldName = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.DecimalPlaces":

                    // Set the value for dataField.DecimalPlaces
                    dataField.DecimalPlaces = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.DefaultValue":

                    // Set the value for dataField.DefaultValue
                    dataField.DefaultValue = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.EnumDataTypeName":

                    // Set the value for dataField.EnumDataTypeName
                    dataField.EnumDataTypeName = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.FieldName":

                    // Set the value for dataField.FieldName
                    dataField.FieldName = xmlNode.FormattedNodeValue;

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.HasDefault":

                    // Set the value for dataField.HasDefault
                    dataField.HasDefault = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.IsAutoIncrement":

                    // Set the value for dataField.IsAutoIncrement
                    dataField.IsAutoIncrement = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.IsEnumeration":

                    // Set the value for dataField.IsEnumeration
                    dataField.IsEnumeration = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.IsNullable":

                    // Set the value for dataField.IsNullable
                    dataField.IsNullable = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.IsReadOnly":

                    // Set the value for dataField.IsReadOnly
                    dataField.IsReadOnly = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.Precision":

                    // Set the value for dataField.Precision
                    dataField.Precision = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.PrimaryKey":

                    // Set the value for dataField.PrimaryKey
                    dataField.PrimaryKey = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.Required":

                    // Set the value for dataField.Required
                    dataField.Required = BooleanHelper.ParseBoolean(xmlNode.FormattedNodeValue, false, false);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.Scale":

                    // Set the value for dataField.Scale
                    dataField.Scale = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;

                case "Database.Tables.DataTable.Fields.DataField.Size":

                    // Set the value for dataField.Size
                    dataField.Size = NumericHelper.ParseInteger(xmlNode.FormattedNodeValue, 0, -1);

                    // required
                    break;
                }

                // if there are ChildNodes
                if (xmlNode.HasChildNodes)
                {
                    // iterate the child nodes
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        // append to this DataField
                        dataField = ParseDataField(ref dataField, childNode);
                    }
                }
            }

            // return value
            return(dataField);
        }
 public void SaveSettings()
 {
     _iniFile.Write("Retry", "Automatic", BooleanHelper.ConvertToString(AutoRetry));
     _iniFile.Write("ToolBar", "Visibility", BooleanHelper.ConvertToString(ShowToolbar));
 }