Exemple #1
0
 /// <summary>
 /// Adds a function import to the model.
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public ModelFunction AddFunctionImport(string name)
 {
     try
     {
         if (!EntityTypes.Any(et => et.Name == name) &&
             !FunctionImports.Any(mf => mf.Name == name))
         {
             ModelFunction mf = new ModelFunction(ParentFile, this, name);
             _modelFunctionImports.Add(name, mf);
             mf.NameChanged += new EventHandler <NameChangeArgs>(mf_NameChanged);
             mf.Removed     += new EventHandler(mf_Removed);
             return(mf);
         }
         else
         {
             throw new ArgumentException("A function with the name " + name + " already exist in the model.");
         }
     }
     catch (Exception ex)
     {
         try
         {
             if (!ex.Data.Contains("EDMXType"))
             {
                 ex.Data.Add("EDMXType", this.GetType().Name);
             }
             if (!ex.Data.Contains("EDMXObjectName"))
             {
                 ex.Data.Add("EDMXObjectName", this.ContainerName);
             }
         }
         catch { }
         throw;
     }
 }
Exemple #2
0
 /// <summary>
 /// Creates and adds a new complex type to the conceptual model.
 /// </summary>
 /// <param name="name">Type name for the new complex type.</param>
 /// <returns>A ModelComplexType corresponding to the new complex type.</returns>
 public ModelComplexType AddComplexType(string name)
 {
     try
     {
         if (!EntityTypes.Any(et => et.Name == name) &&
             !ComplexTypes.Any(ct => ct.Name == name))
         {
             ModelComplexType ct = new ModelComplexType(ParentFile, this, name);
             _modelComplexTypes.Add(name, ct);
             ct.NameChanged += new EventHandler <NameChangeArgs>(ct_NameChanged);
             ct.Removed     += new EventHandler(ct_Removed);
             return(ct);
         }
         else
         {
             throw new ArgumentException("A type with the name " + name + " already exist in the model.");
         }
     }
     catch (Exception ex)
     {
         try
         {
             if (!ex.Data.Contains("EDMXType"))
             {
                 ex.Data.Add("EDMXType", this.GetType().Name);
             }
             if (!ex.Data.Contains("EDMXObjectName"))
             {
                 ex.Data.Add("EDMXObjectName", this.ContainerName);
             }
         }
         catch { }
         throw;
     }
 }
Exemple #3
0
        /// <summary>
        /// Process Records
        /// </summary>
        protected override void ProcessRecord()
        {
            var queries = new QuerystringBuilder();

            if (StartIndex != null)
            {
                queries.Add("startIndex", StartIndex.Value);
            }

            if (PageCount != null)
            {
                queries.Add("pageCount", PageCount.Value);
            }

            if (Domains != null && Domains.Any())
            {
                queries.Add("domains", string.Join(",", Domains));
            }

            if (EntityTypes != null && EntityTypes.Any())
            {
                queries.Add("entityTypes", string.Join(",", EntityTypes));
            }

            if (Actions != null && Actions.Any())
            {
                queries.Add("actions", string.Join(",", Actions));
            }

            if (!string.IsNullOrWhiteSpace(Search))
            {
                queries.Add("search", Search.Trim());
            }

            if (UserNames != null && UserNames.Any())
            {
                queries.Add("userNames", string.Join(",", UserNames));
            }

            if (StartTime.HasValue)
            {
                queries.Add("startTimeUsecs", StartTime.ToString());
            }

            if (EndTime.HasValue)
            {
                queries.Add("endTimeUsecs", EndTime.ToString());
            }

            var preparedUrl = $"/public/auditLogs/cluster{queries.Build()}";

            WriteDebug(preparedUrl);
            var result = Session.ApiClient.Get <Model.ClusterAuditLogsSearchResult>(preparedUrl);

            WriteObject(result.ClusterAuditLogs, true);
        }
        Task Add(IEnumerable <object> entities, TDbContext context)
        {
            foreach (var entity in entities)
            {
                if (entity is IEnumerable enumerable)
                {
                    var entityType = entity.GetType();
                    if (EntityTypes.Any(x => x.ClrType != entityType))
                    {
                        foreach (var nested in enumerable)
                        {
                            context.Add(nested);
                        }

                        continue;
                    }
                }

                context.Add(entity);
            }
            return(context.SaveChangesAsync());
        }
Exemple #5
0
        private int OnExecute(CommandLineApplication app)
        {
            TextWriter output = System.Console.Out;
            bool       outputDirectorySpecified = !String.IsNullOrEmpty(OutputDirectory);

            try {
                if (CreateCompilableProjectFlag)
                {
                    DecompileAsProject(InputAssemblyName, OutputDirectory, ReferencePaths);
                }
                else if (EntityTypes.Any())
                {
                    var values = EntityTypes.SelectMany(v => v.Split(',', ';')).ToArray();
                    HashSet <TypeKind> kinds = TypesParser.ParseSelection(values);
                    if (outputDirectorySpecified)
                    {
                        string outputName = Path.GetFileNameWithoutExtension(InputAssemblyName);
                        output = File.CreateText(Path.Combine(OutputDirectory, outputName) + ".list.txt");
                    }

                    ListContent(InputAssemblyName, output, kinds, ReferencePaths);
                }
                else if (ShowILCodeFlag)
                {
                    if (outputDirectorySpecified)
                    {
                        string outputName = Path.GetFileNameWithoutExtension(InputAssemblyName);
                        output = File.CreateText(Path.Combine(OutputDirectory, outputName) + ".il");
                    }

                    ShowIL(InputAssemblyName, output, ReferencePaths);
                }
                else if (CreateDebugInfoFlag)
                {
                    string pdbFileName = null;
                    if (outputDirectorySpecified)
                    {
                        string outputName = Path.GetFileNameWithoutExtension(InputAssemblyName);
                        pdbFileName = Path.Combine(OutputDirectory, outputName) + ".pdb";
                    }
                    else
                    {
                        pdbFileName = Path.ChangeExtension(InputAssemblyName, ".pdb");
                    }

                    return(GeneratePdbForAssembly(InputAssemblyName, pdbFileName, ReferencePaths, app));
                }
                else if (ShowVersion)
                {
                    string vInfo = "ilspycmd: " + typeof(ILSpyCmdProgram).Assembly.GetName().Version.ToString() +
                                   Environment.NewLine
                                   + "ICSharpCode.Decompiler: " +
                                   typeof(FullTypeName).Assembly.GetName().Version.ToString();
                    output.WriteLine(vInfo);
                }
                else
                {
                    if (outputDirectorySpecified)
                    {
                        string outputName = Path.GetFileNameWithoutExtension(InputAssemblyName);
                        output = File.CreateText(Path.Combine(OutputDirectory,
                                                              (String.IsNullOrEmpty(TypeName) ? outputName : TypeName) + ".decompiled.cs"));
                    }

                    Decompile(InputAssemblyName, output, ReferencePaths, TypeName);
                }
            } catch (Exception ex) {
                app.Error.WriteLine(ex.ToString());
                return(ProgramExitCodes.EX_SOFTWARE);
            } finally {
                output.Close();
            }

            return(0);
        }
        private static WSSources <WSTableSource> LoadMetaSources()
        {
            LoadStatusStatic.AddNote($"IOSB.LoadMetaSources()");
            WSSources <WSTableSource>        ORG_SOURCES = new WSSources <WSTableSource>();
            Dictionary <Type, WSDataContext> dbList      = new Dictionary <Type, WSDataContext>();

            try
            {
                if (EntityTypes != null && EntityTypes.Any())
                {
                    IEnumerable <string> namespaces_         = EntityTypes.Select(t => t.Namespace).Distinct();
                    Dictionary <string, List <Type> > nsList = namespaces_.ToDictionary(key => key, val => new List <Type>());

                    foreach (Type type in EntityTypes)
                    {
                        nsList[type.Namespace].Add(type);
                    }
                    foreach (KeyValuePair <string, List <Type> > ns in nsList)
                    {
                        if (ns.Value.Any())
                        {
                            foreach (Type type in ns.Value)
                            {
                                try
                                {
                                    Type          DCType = GetDCTypeByEntityType(type);
                                    WSDataContext db     = null;
                                    if (dbList.Any(x => x.Key == DCType))
                                    {
                                        db = dbList.FirstOrDefault(x => x.Key == DCType).Value;
                                    }
                                    else
                                    {
                                        db = GetServerContext(DCType, null, $"{typeof(WSServerMeta).Name}.LoadMetaSources() => [{type.FullName}:{DCType.Name}");
                                        dbList.Add(DCType, db);
                                    }

                                    if (db != null)
                                    {
                                        string        DBName = db.GetType().CustomAttribute <DatabaseAttribute>(true).Name;
                                        WSTableSource tSrc   = new WSTableSource(
                                            type,
                                            SecurityMap.FirstOrDefault(m => m.Key.Equals(DBName)).Value.Zone,
                                            type.Name,
                                            ServerFunctions,
                                            WSConstants.ACCESS_LEVEL.READ
                                            );

                                        #region READ PROPERTIES
                                        List <MetaDataMember> eProps = db.ReadProperties(type, ref LoadStatusStatic);
                                        if (eProps != null && eProps.Any())
                                        {
                                            List <WSTableParam> _params = new List <WSTableParam>();
                                            foreach (MetaDataMember prop in eProps)
                                            {
                                                try
                                                {
                                                    WSTableParam tParam = new WSTableParam(type, next_code, prop.Name, new WSColumnRef(prop.Name), prop.Type, ServerFunctions);

                                                    object[] CustomAttributes = prop.Member.GetCustomAttributes(true);

                                                    IEnumerable <AssociationAttribute> assAttributes = CustomAttributes.OfType <AssociationAttribute>();
                                                    if (assAttributes != null && assAttributes.Any())
                                                    {
                                                        tParam.IsAssociation = true;
                                                    }

                                                    IEnumerable <ColumnAttribute> cAttributes = CustomAttributes.OfType <ColumnAttribute>();
                                                    if (cAttributes != null && cAttributes.Any())
                                                    {
                                                        tParam.IsColumn = true;
                                                        if (cAttributes.FirstOrDefault().IsPrimaryKey)
                                                        {
                                                            tParam.WRITE_ACCESS_MODE = new WSAccessMode(WSConstants.ACCESS_LEVEL.LOCK, false);
                                                            if (!tSrc.Params.Any(p => p.Match(WSConstants.PARAMS.RECORD_ID.NAME)))
                                                            {
                                                                tParam.DISPLAY_NAME = WSConstants.PARAMS.RECORD_ID.NAME;
                                                                if (!tParam.ALIACES.Any(a => a.Equals(WSConstants.PARAMS.RECORD_ID.NAME)))
                                                                {
                                                                    tParam.ALIACES.Add(WSConstants.PARAMS.RECORD_ID.NAME);
                                                                }
                                                            }
                                                        }
                                                    }
                                                    _params.Add(tParam);
                                                }
                                                catch (Exception) { }
                                            }
                                            tSrc.AddParams(_params);
                                            tSrc.ClearDublicatedAliaces();
                                        }
                                        #endregion

                                        if (!ORG_SOURCES.Any(x => x.Match(tSrc)))
                                        {
                                            ORG_SOURCES.Add(tSrc);
                                        }
                                    }
                                }
                                catch (Exception) { }
                            }
                        }
                    }
                }
            }
            catch (Exception) { }
            finally {
                foreach (Type t in dbList.Keys)
                {
                    try {
                        if (dbList[t] != null)
                        {
                            dbList[t].Dispose();
                        }
                    } catch (Exception e) { }
                }
            }
            return(ORG_SOURCES);
        }