Пример #1
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: nkxtract.exe path/to/file.nkx path/to/output/dir");
                return;
            }
            string inputFile = args[0];
            string outputDir = args[1];

            var key = KeyLoader.LoadKey("Release");

            if (key == null)
            {
                Console.WriteLine("Couldn't load decryption key: No key found in registry");
                return;
            }

            try
            {
                using (var s = File.OpenRead(inputFile))
                {
                    var nks = new Nks(s, key);
                    nks.Extract(outputDir);
                }
            }
            catch (InvalidDataException e)
            {
                Console.WriteLine("Could not extract files: " + e.Message);
            }
        }
Пример #2
0
        //ACC000_00_0V
        public static async Task <NksResponse> Access_000_00_0V()
        {
            SimpleQueryBuilder builder = Nks.NewConnection(Server).PrepareRequest().Access().Element()
                                         .CreateSimpleQuery()
                                         .AddTargets().Interventions().Done().Done()
                                         .AddConcept(BasicEntries.InterventionsStructure).Done();

            return(await builder.Execute());
        }
Пример #3
0
        //ACC000_00_03
        public static async Task <NksResponse> Access_000_00_04()
        {
            SimpleQueryBuilder builder = Nks.NewConnection(Server).PrepareRequest().Access().Element()
                                         .CreateSimpleQuery()
                                         .AddTargets().Shapes().Done().Done()
                                         //.AddConcept(BasicEntries.Phaenomenoms).Done()
                                         .SetOrder().Tree();

            return(await builder.Execute());
        }
Пример #4
0
        public static async Task <NksResponse> ACC_000_04()
        {
            SimpleQueryBuilder builder = Nks.NewConnection(Server).PrepareRequest().Search().Proposal()
                                         .CreateSimpleQuery()
                                         .AddTargets()
                                         .Causes().AddStructure("AkutPflege_").Done()
                                         .Done()
                                         .SetSearchText("Oberfl")
                                         .SetDepth(6);

            return(await builder.Execute());
        }
Пример #5
0
        //ACC000_00_01
        public static async Task <NksResponse> Access_000_00_01()
        {
            SimpleQueryBuilder builder = Nks.NewConnection(Server).PrepareRequest().Access().Element()
                                         .CreateSimpleQuery()
                                         .AddTargets().Interventions().Done().Done()
                                         .AddConcept(BasicEntries.InterventionsStructure).Done()
                                         .SetOrder().List();

            Console.Out.WriteLine(builder.GetPath());
            new NksJson().Display(builder.GetQuery());
            return(await builder.Execute());
        }
Пример #6
0
        public static async Task <NksResponse> ACC_000_01()
        {
            SimpleQueryBuilder builder = Nks.NewConnection(Server).PrepareRequest().Search().AdHocIntervention()
                                         .CreateSimpleQuery()
                                         .AddTargets()
                                         .Interventions().AddStructure("AkutPflege_").Done()
                                         .InterventionsBundle().AddStructure("AkutPflege_").Done()
                                         .Done()
                                         .AddConcept("TA2.0").Done()
                                         .SetDepth(20);

            return(await builder.Execute());
        }
Пример #7
0
        public static async Task <NksResponse> ACC_000_03()
        {
            SimpleQueryBuilder builder = Nks.NewConnection(Server).PrepareRequest().Search().Proposal()
                                         .CreateSimpleQuery()
                                         .AddTargets()
                                         .Interventions().AddStructure("AkutPflege_").Done()
                                         .InterventionsBundle().AddStructure("AkutPflege_").Done()
                                         .Done()
                                         .SetDepth(7)
                                         .SetSearchText("Verba");

            Console.Out.WriteLine(builder.GetPath());
            new NksJson().Display(builder.GetQuery());
            return(await builder.Execute());
        }
Пример #8
0
        public static async Task <NksResponse> ACC_000_07()
        {
            SimpleQueryBuilder builder = Nks.NewConnection(Server).PrepareRequest().Access().Element()
                                         .CreateSimpleQuery()
                                         .AddTargets()
                                         .BodyLocations().AddStructure("AkutPflege_").Done()
                                         .BodyLocationsStructure().AddStructure("AkutPflege_").Done()
                                         .Done()
                                         .AddConcept("BF75").Done()
                                         .SetOrder().List()
                                         .SetDepth(1);

            new NksJson().Display(builder.GetQuery());
            return(await builder.Execute());
        }
Пример #9
0
        public static async Task <NksResponse> ACC_000_06()
        {
            SimpleQueryBuilder builder = Nks.NewConnection(Server).PrepareRequest().Search().Catalog()
                                         .CreateSimpleQuery()
                                         .AddTargets()
                                         .Interventions().AddStructure("AkutPflege_").Done()
                                         .InterventionsBundle().AddStructure("AkutPflege_").Done()
                                         .Done()
                                         .AddAttributes()
                                         .Aged()
                                         .Female()
                                         .Done()
                                         .AddConcept("TA11.0").Done()
                                         .SetSearchText("Oberfl")
                                         .SetDepth(20);

            new NksJson().Display(builder.GetQuery());
            return(await builder.Execute());
        }
Пример #10
0
        public static async Task <NksResponse> ACC_000_02()
        {
            SimpleQueryBuilder builder = Nks.NewConnection(Server).PrepareRequest().Search().AdHocIntervention()
                                         .CreateSimpleQuery()
                                         .AddTargets()
                                         .Interventions().AddStructure("AkutPflege_").Done()
                                         .InterventionsBundle().AddStructure("AkutPflege_").Done()
                                         .Done()
                                         .AddConcept("PC1115").Done()
                                         .AddConcept("TA2.0").Done()
                                         .AddConcept("UA0").Done()
                                         .AddConcept("BA293").Done()
                                         .AddConcept("PA50").Done()
                                         .SetDepth(10);

            Console.Out.WriteLine(builder.GetPath());
            new NksJson().Display(builder.GetQuery());
            return(await builder.Execute());
        }
        public async static void Workflow_001()
        {
            Nks nks = Nks.NewConnection(Server);

            SimpleQueryBuilder phenomenonsRequest = nks.PrepareRequest().Search().Catalog()
                                                    .CreateSimpleQuery()
                                                    .AddTargets().Phenomenons().Done().Done()
                                                    .SetSearchText("Zustand")
                                                    .DefineTemplate().PhenomenonsTemplate().Done();

            NksResponse shapes = await phenomenonsRequest.Execute();

            new NksJson().Display(phenomenonsRequest.GetQuery());
            NksEntry shape = shapes.Elements[0];

            new NksJson().Display(shape);

            SimpleQueryBuilder linkRequest = nks.PrepareRequest().Search().Link()
                                             .CreateSimpleQuery()
                                             .AddConcept(shape)
                                             .AddConcept("IA123").AddStructure("Blub").SetDomain("welt").Done()
                                             .AddTargets().Causes().Done().Done();

            NksResponse causes = await linkRequest.Execute();

            NksEntry cause = causes.Elements[1];

            SimpleQueryBuilder interventionRequest = nks.PrepareRequest().Search().Link()
                                                     .CreateSimpleQuery()
                                                     .AddConcept(cause).AddConcept(shape)
                                                     .AddTargets().Interventions().Done().Done();

            NksResponse interventions = await interventionRequest.Execute();

            //new NksJson().Display(interventions);

            SimpleQueryBuilder correlationRequest = nks.PrepareRequest().Search().Correlation()
                                                    .CreateSimpleQuery()
                                                    .AddConcept(cause)
                                                    .AddTargets().Causes().Done().Done();
            //causes
        }
Пример #12
0
        public static void Unpack(string file, string outputDirectoryPath, bool doList, bool doVerbose)
        {
            using (BinaryFile bf = new BinaryFile(file, BinaryFile.ByteOrder.LittleEndian, false))
            {
                UInt32 fileSize = bf.ReadUInt32();
                Log.Debug("fileSize: " + fileSize);

                bf.Seek(350, SeekOrigin.Begin);
                int    snpidCount = bf.ReadInt32();
                string snpid      = bf.ReadString(snpidCount * 2, Encoding.Unicode);

                // snpid cannot have more than 4 characters (?!)
                if (snpidCount > 4)
                {
                    snpidCount = 0;
                    snpid      = "";
                    bf.Seek(355, SeekOrigin.Begin);
                }
                else
                {
                    bf.ReadBytes(25);
                }
                Log.Debug("snpid: " + snpid);

                int    versionCount = bf.ReadInt32();
                string version      = bf.ReadString(versionCount * 2, Encoding.Unicode);
                Log.Debug("version: " + version);

                bf.ReadBytes(122);
                int    presetNameCount = bf.ReadInt32();
                string presetName      = bf.ReadString(presetNameCount * 2, Encoding.Unicode);
                int    presetNameRest  = bf.ReadInt32();
                Log.Debug("presetName: " + presetName);

                int    companyNameCount = bf.ReadInt32();
                string companyName      = bf.ReadString(companyNameCount * 2, Encoding.Unicode);
                int    companyNameRest  = bf.ReadInt32();
                Log.Debug("companyName: " + companyName);

                bf.ReadBytes(40);

                int    libraryNameCount = bf.ReadInt32();
                string libraryName      = bf.ReadString(libraryNameCount * 2, Encoding.Unicode);
                int    libraryNameRest  = bf.ReadInt32();
                Log.Debug("libraryName: " + libraryName);

                int typeCount = bf.ReadInt32();
                if (typeCount != 0)
                {
                    string type     = bf.ReadString(typeCount * 2, Encoding.Unicode);
                    int    typeRest = bf.ReadInt32();
                    Log.Debug("type: " + type);
                }

                int number = bf.ReadInt32();

                for (int i = 0; i < number * 2; i++)
                {
                    int    sCount = bf.ReadInt32();
                    string s      = bf.ReadString(sCount * 2, Encoding.Unicode);
                    Log.Debug(s);
                }

                bf.ReadBytes(249);

                UInt32 chunkSize = bf.ReadUInt32();
                Log.Debug("chunkSize: " + chunkSize);

                string outputFileName = Path.GetFileNameWithoutExtension(file);
                string outputFilePath = Path.Combine(outputDirectoryPath, "NKI_CONTENT", outputFileName + ".bin");
                IOUtils.CreateDirectoryIfNotExist(Path.Combine(outputDirectoryPath, "NKI_CONTENT"));

                var nks = new Nks();
                nks.BinaryFile = bf;
                nks.SetKeys    = new Dictionary <String, NksSetKey>();

                NksEncryptedFileHeader header = new NksEncryptedFileHeader();

                header.SetId    = snpid.ToUpper();
                header.KeyIndex = 0x100;
                header.Size     = chunkSize;

                BinaryFile outBinaryFile = new BinaryFile(outputFilePath, BinaryFile.ByteOrder.LittleEndian, true);

                if (snpid == "")
                {
                    if (!doList)
                    {
                        NKS.ExtractFileEntryToBf(nks, header, outBinaryFile);
                    }
                }
                else
                {
                    if (!doList)
                    {
                        NKS.ExtractEncryptedFileEntryToBf(nks, header, outBinaryFile);
                    }
                }

                outBinaryFile.Close();
            }
        }