Ejemplo n.º 1
0
        public static Result <AccessLog> Get(this AccessLog from, SelectKeys keyType = SelectKeys.External)
        {
            var result = Result <AccessLog> .Success();

            var keys = (from as ExternalEntity).GetKeys(keyType);

            if (keys.Failed)
            {
                return(result.Merge(keys));
            }

            try
            {
                keys.Entity.MapKeys(from);

                using (var db = new RSMDB.RSMDataModelDataContext())
                {
                    var row = from.Select(db);

                    if (row == null)
                    {
                        return(result.Fail("AccessLog not found"));
                    }

                    result.Entity = row.ToModel();
                    keys.Entity.MapKeys(result.Entity);
                }
            }
            catch (Exception e)
            {
                return(result.Set(ResultType.TechnicalError, e, "Get AccessLog failed. {0}", e.ToString()));
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get External entity keys.
        /// </summary>
        /// <param name="from"></param>
        /// <param name="keyType"><typeparamref name="SelectKeys"/></param>
        /// <param name="replace">If true, criteria entity will be replaced with values retrieved.</param>
        /// <returns></returns>
        public static Result <ExternalEntity> GetKeys(this ExternalEntity from, SelectKeys keyType = SelectKeys.External, bool replace = false)
        {
            var result = Result <ExternalEntity> .Success();

            try
            {
                using (var db = new RSMDB.RSMDataModelDataContext())
                {
                    var row = keyType == SelectKeys.External
                                                ? from.SelectExternal(db)
                                                : from.Select(db);

                    if (row == null)
                    {
                        return(result.Fail("ExternalEntity not found", "NotFound"));
                    }

                    Debug.Assert(row.ExternalSystem != null, "ExternalSystem instance was not fetched!");

                    result.Entity = row.ToModel <ExternalEntity>(replace ? from : null);
                }
            }
            catch (Exception e)
            {
                return(result.Set(ResultType.TechnicalError, e, "Get ExternalEntity failed. {0}", e.ToString()));
            }

            return(result);
        }
Ejemplo n.º 3
0
        internal override GremlinToSqlContext GetContext()
        {
            GremlinToSqlContext inputContext = GetInputContext();

            if (SelectKeys.Count == 1)
            {
                switch (Pop)
                {
                case GremlinKeyword.Pop.Default:
                    inputContext.PivotVariable.Select(inputContext, SelectKeys.First());
                    break;

                default:
                    inputContext.PivotVariable.Select(inputContext, Pop, SelectKeys.First());
                    break;
                }
            }
            else
            {
                switch (Pop)
                {
                case GremlinKeyword.Pop.Default:
                    inputContext.PivotVariable.Select(inputContext, SelectKeys);
                    break;

                default:
                    inputContext.PivotVariable.Select(inputContext, Pop, SelectKeys);
                    break;
                }
            }

            return(inputContext);
        }
Ejemplo n.º 4
0
        public List <TResponseType> Draw()
        {
            Console.CursorVisible = false;
            StartPosition         = Console.CursorTop;

            while (true)
            {
                Position.Write(Question);

                if (CurrentIndex < 0)
                {
                    ChangeIndex(0);
                }

                for (var index = 0; index < Options.Count; index++)
                {
                    var consoleRadioCheck = Options[index];
                    Position.WriteCleaningLine(consoleRadioCheck.ToString(), index + 1);
                }

                var key = Console.ReadKey(true);

                if (DownKeys.Contains(key.Key))
                {
                    DownIndex();
                }

                if (UpKeys.Contains(key.Key))
                {
                    UpIndex();
                }

                if (SelectKeys.Contains(key.Key))
                {
                    ToggleCurrent();
                }

                if (key.Key == ConsoleKey.Enter)
                {
                    var consoleRadioChecks = Options.Where(i => i.IsChecked).ToList();

                    if (Parameters.Required && consoleRadioChecks.Count <= 0)
                    {
                        continue;
                    }
                    Console.CursorVisible = true;
                    Clear();
                    Console.WriteLine(Question + " > " + consoleRadioChecks
                                      .Select(i => i.Message)
                                      .Aggregate((x, y) => $"{x}, {y}"));
                    return(consoleRadioChecks.Select(i => i.Value).ToList());
                }
            }
        }
Ejemplo n.º 5
0
        internal override bool Populate(string property, string label = null)
        {
            bool populateSuccessfully = false;

            if (label == null || this.Labels.Contains(label))
            {
                if (SelectKeys.Count() == 1)
                {
                    populateSuccessfully = true;
                }
                foreach (string selectKey in this.SelectKeys)
                {
                    if (GremlinVariableType.NULL <= this.InputVariable.GetVariableType() && this.InputVariable.GetVariableType() <= GremlinVariableType.Map)
                    {
                        this.InputVariable.Populate(property, selectKey);
                    }
                    this.PathVariable.PopulateStepProperty(property, selectKey);
                    foreach (var sideEffectVariable in this.SideEffectVariables)
                    {
                        sideEffectVariable.Populate(property, selectKey);
                    }
                    foreach (var context in this.ByContexts)
                    {
                        context.Populate(property, selectKey);
                    }
                }
            }
            else
            {
                if (SelectKeys.Count() == 1)
                {
                    populateSuccessfully = base.Populate(property, label);
                }
                if (GremlinVariableType.NULL <= this.InputVariable.GetVariableType() && this.InputVariable.GetVariableType() <= GremlinVariableType.Map)
                {
                    this.InputVariable.Populate(property, label);
                }
                this.PathVariable.PopulateStepProperty(property, label);
                foreach (var sideEffectVariable in this.SideEffectVariables)
                {
                    sideEffectVariable.Populate(property, label);
                }
                foreach (var context in this.ByContexts)
                {
                    context.Populate(property, label);
                }
            }
            if (populateSuccessfully && property != null)
            {
                this.ProjectedProperties.Add(property);
            }
            return(populateSuccessfully);
        }
Ejemplo n.º 6
0
        internal override GremlinToSqlContext GetContext()
        {
            GremlinToSqlContext inputContext = GetInputContext();

            if (inputContext.PivotVariable == null)
            {
                throw new QueryCompilationException("The PivotVariable can't be null.");
            }

            if (SelectKeys.Count == 1)
            {
                switch (Pop)
                {
                case GremlinKeyword.Pop.Default:
                    inputContext.PivotVariable.Select(inputContext, SelectKeys.First());
                    break;

                default:
                    inputContext.PivotVariable.Select(inputContext, Pop, SelectKeys.First());
                    break;
                }
            }
            else
            {
                switch (Pop)
                {
                case GremlinKeyword.Pop.Default:
                    inputContext.PivotVariable.Select(inputContext, SelectKeys);
                    break;

                default:
                    inputContext.PivotVariable.Select(inputContext, Pop, SelectKeys);
                    break;
                }
            }

            return(inputContext);
        }
Ejemplo n.º 7
0
        internal override void Populate(string property)
        {
            InputVariable.Populate(property);
            PathVariable.Populate(property);
            foreach (var sideEffectVariable in SideEffectVariables)
            {
                sideEffectVariable.Populate(property);
            }
            foreach (var context in ByContexts)
            {
                context.Populate(property);
            }

            if (SelectKeys.Count() > 1 && property != GremlinKeyword.TableDefaultColumnName)
            {
                //block the select multi label to populate column
                return;
            }
            else
            {
                base.Populate(property);
            }
        }
Ejemplo n.º 8
0
 public static bool KeysExist(this ExternalEntity from, SelectKeys keyType = SelectKeys.External)
 {
     return(from.GetKeys(keyType).Succeeded);
 }