Example #1
0
        public void Test1()
        {
            Option <CancellationToken> ctok = CancellationToken.None;
            var dto = new MyDto(1, "Angga");

            new EntityCreateService <MyEntity, MyDto, MyCreateInterceptor>().CreateEntityAsync(dto, ctok);
            new EntityDeleteService <MyEntity, MyDto, MyDeleteInterceptor>().DeleteEntityAsync(dto, ctok);
            new EntityReadLookupService <MyEntity, MyReadLookupInterceptor>().GetLookupsAsync(false, ctok);
            new EntityReadOneService <MyEntity, MyDto, MyReadOneInterceptor>().GetByPredicateAsync(dto, ctok);
            new EntityReadPagedService <MyEntity, MyDto, MyReadPagedInterceptor>().GetPagedAsync(
                1,
                1,
                null,
                "bla",
                ctok);

            Create <MyEntity, MyDto, MyCreateInterceptor> .Handle(dto, ctok);

            Delete <MyEntity, MyDto, MyDeleteInterceptor> .Handle(dto, ctok);

            ReadLookup <MyEntity, MyDto, MyReadLookupInterceptor> .Handle(false, ctok);

            ReadOne <MyEntity, MyDto, MyReadOneInterceptor> .Handle(dto, ctok);

            ReadPaged <MyEntity, MyDto, MyReadPagedInterceptor> .Handle(1, 1, null, "Bla", ctok);

            Update <MyEntity, MyDto, MyUpdateInterceptor> .Handle(dto, ctok);

            Read <MyEntity, MyDto, MyReadInterceptor> .Handle(false, ctok);

            Read <MyEntity, MyDto, MyReadInterceptor> .Handle(dto, ctok);

            Read <MyEntity, MyDto, MyReadInterceptor> .Handle(1, 1, null, "bla", ctok);

            Crud <MyEntity, MyDto, MyCrudInterceptor> .HandleCreate(dto, ctok);

            Crud <MyEntity, MyDto, MyCrudInterceptor> .HandleDelete(dto, ctok);

            Crud <MyEntity, MyDto, MyCrudInterceptor> .HandleReadLookup(false, ctok);

            Crud <MyEntity, MyDto, MyCrudInterceptor> .HandleReadOne(dto, ctok);

            Crud <MyEntity, MyDto, MyCrudInterceptor> .HandleReadPaged(1, 1, null, "Bla", ctok);

            Crud <MyEntity, MyDto, MyCrudInterceptor> .HandleUpdate(dto, ctok);

            var mapperService = new AutoMapperService();

            mapperService.Initialize <IMapperProfile>(new MyMapperProfile());
            DslInjecterGetter.SetBaseMapperService(mapperService);
            DslInjecterGetter.SetBaseUnitOfWork(new EfCoreUnitOfWork(new MyEfCoreDbContext()));
        }
Example #2
0
        public void SNMPtrans()
        {
            try
            {
                List <string> list_OutData = new List <string>();
                string        ReadOne;
                string        OID = "";
                string        VT  = "";

                using (StreamReader sr = File.OpenText(TextBox_SNMPsource.Text))
                {
                    while ((ReadOne = sr.ReadLine()) != null)
                    {
                        if (ReadOne.IndexOf("oid") > -1)
                        {
                            int FirstDot = ReadOne.IndexOf(".");
                            OID = ReadOne.Substring(FirstDot, ReadOne.Length - 6);

                            if ((ReadOne = sr.ReadLine()).IndexOf("valueType") > -1)
                            {
                                if (ReadOne.IndexOf("String") > -1)
                                {
                                    VT = "STRING";
                                }
                                else if (ReadOne.IndexOf("TimeTicks") > -1)
                                {
                                    VT = "Timeticks";
                                }
                                else if (ReadOne.IndexOf("Integer") > -1)
                                {
                                    VT = "INTEGER";
                                }
                                else if (ReadOne.IndexOf("Gauge") > -1)
                                {
                                    VT = "Gauge32";
                                }
                                else
                                {
                                    VT = ReadOne.Substring((ReadOne.IndexOf("=") + 2), ReadOne.Length - 12);
                                }
                            }

                            list_OutData.Add($"{OID} = {VT}: {FakeValue(VT)}");
                            i_counToStr++;
                        }
                    }
                    sr.Dispose();
                }
                string TargetFolder = TextBox_SNMPtarget.Text.Substring(0, TextBox_SNMPtarget.Text.LastIndexOf(@"\"));
                if (!Directory.Exists(TargetFolder))
                {
                    ;
                }
                Directory.CreateDirectory(TargetFolder);

                StreamWriter sw = new StreamWriter(TextBox_SNMPtarget.Text);
                foreach (string everyOne in list_OutData)
                {
                    sw.WriteLine(everyOne, true);
                }
                sw.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }