示例#1
0
        public CcCardService()
        {
            var serviceRoot   = new ServiceRootConfig();
            var connectionStr = serviceRoot.A2BillingConfig().A2BillingConnectionString;

            options = new DbContextOptionsBuilder <Mya2billingContext>()
                      .UseMySql(connectionStr);
        }
示例#2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     #region Authorize config
     NesopsAuthorizationConfig.Entry(services, Configuration);
     #endregion
     services.AddDbContext <ProductdevContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ProductDev")));
     #region Nesops Service
     ServiceRootConfig.Entry(services, Configuration);
     #endregion
     services.AddSwaggerGen(c =>
     {
         c.SwaggerDoc("nesops", new OpenApiInfo
         {
             Version     = "v1",
             Title       = "Nesops Swagger Production",
             Description = "Nesops Swagger for Production Services",
             Contact     = new OpenApiContact
             {
                 Name  = "LuanDNH",
                 Email = "*****@*****.**",
                 Url   = new Uri("https://www.facebook.com/luandnh98")
             },
             TermsOfService = new Uri("http://nesops.xyz"),
             License        = new OpenApiLicense
             {
                 Name = "Use under LICX",
                 Url  = new Uri("http://nesops.xyz")
             }
         });
         c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
         {
             In          = ParameterLocation.Header,
             Description = "Please insert JWT with Bearer into field",
             Name        = "Authorization",
             Type        = SecuritySchemeType.ApiKey,
             Scheme      = "Bearer"
         });
         c.AddSecurityRequirement(new OpenApiSecurityRequirement
         {
             {
                 new OpenApiSecurityScheme
                 {
                     Reference = new OpenApiReference
                     {
                         Type = ReferenceType.SecurityScheme,
                         Id   = "Bearer"
                     },
                     Scheme = "oauth2",
                     Name   = "Bearer",
                     In     = ParameterLocation.Header
                 },
                 new List <string>()
             }
         });
         // Set the comments path for the Swagger JSON and UI.
         var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
         var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
         c.IncludeXmlComments(xmlPath);
     });
     services.AddMvc(options => {
         options.Filters.Add(typeof(ValidatorActionFilter));
     }).AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <Startup>());
     services.AddControllers();
 }
示例#3
0
        public A2BillingSIPService()
        {
            var serviceRoot = new ServiceRootConfig();

            fileDir = serviceRoot.A2BillingSipAdditionConfig().Dir;
        }
示例#4
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Welcome to A2Billing Console. Press any key to continue!");
                var c       = Console.ReadKey().Key;
                var service = new CcSipBuddiesService();
                var sipAdditionalservice = new SipAdditionService();
                var sipA2Billingservice  = new A2BillingSIPService();
                do
                {
                    Console.WriteLine("----------------------------------------------------------------------");
                    Console.WriteLine("-- 1. List Sip Accounts in table                                    --");
                    Console.WriteLine("-- 2. Check md5secret of SIP Account                                --");
                    Console.WriteLine("-- 3. Generate md5secret from string                                --");
                    Console.WriteLine("-- 4. Generate and md5secret for SIP Account                        --");
                    Console.WriteLine("-- 5. Generate and md5secret for all SIP Accounts                   --");
                    Console.WriteLine("-- 6. Generate and md5secret in sip_additional.conf                 --");
                    Console.WriteLine("-- 7. Import transport TCP to SIP Account                           --");
                    Console.WriteLine("-- 8. Set timer to auto update md5secret account                    --");
                    Console.WriteLine("-- 9. Exit                                                          --");
                    Console.WriteLine("----------------------------------------------------------------------");
                    Console.Write("Please choose your option: ");
                    var input = Console.ReadLine();
                    Console.WriteLine("");
                    try
                    {
                        int choice = Int32.Parse(input);
                        if (choice < 1 || choice > 8)
                        {
                            Console.WriteLine("Please select the correct option!");
                        }
                        switch (choice)
                        {
                        case 1:
                            Console.WriteLine("-- List Sip Accounts in table                                       --");
                            var listAccount = service.ListCcSipBuddies();
                            foreach (var account in listAccount)
                            {
                                Console.WriteLine(service.ToString(account));
                            }
                            Console.WriteLine("----------------------------------------------------------------------");
                            break;

                        case 2:
                            Console.WriteLine("-- Check md5secret of SIP Account                                   --");
                            Console.Write("Account Code : ");
                            var accountCheckInput = Console.ReadLine();
                            var checkResult       = service.CheckMD5Secret(accountCheckInput.Trim());
                            Console.WriteLine(checkResult);
                            Console.WriteLine("----------------------------------------------------------------------");
                            break;

                        case 3:
                            Console.WriteLine("--    Generate md5secret from string                                --");
                            Console.Write("String : ");
                            var stringGenerateInput  = Console.ReadLine();
                            var generateStringResult = service.GenerateMD5FromString(stringGenerateInput.Trim());
                            Console.WriteLine("=> " + generateStringResult);
                            Console.WriteLine("----------------------------------------------------------------------");
                            break;

                        case 4:
                            Console.WriteLine("-- Generate and md5secret for SIP Account                           --");
                            Console.Write("Account Code : ");
                            var accountGenerateInput = Console.ReadLine();
                            var generateResult       = service.GenerateMD5SecretForAccount(accountGenerateInput.Trim());
                            Console.WriteLine(service.ToString(generateResult));
                            Console.WriteLine("----------------------------------------------------------------------");
                            break;

                        case 5:
                            Console.WriteLine("-- Generate and md5secret for all SIP Accounts                      --");
                            var allUserResult = service.GenerateMD5SecretForAllAccounts();
                            foreach (var account in allUserResult)
                            {
                                Console.WriteLine(service.ToString(account));
                            }
                            Console.WriteLine("----------------------------------------------------------------------");
                            break;

                        case 6:
                            Console.WriteLine("-- Generate and md5secret in sip_additional.conf                    --");
                            var fileLine = sipAdditionalservice.ReadAndExec();
                            Console.WriteLine(fileLine);
                            Console.WriteLine("----------------------------------------------------------------------");
                            break;

                        case 7:
                            Console.WriteLine("-- Import transport TCP to SIP Account                              --");
                            var a2billingExec = sipA2Billingservice.ReadAndExec();
                            Console.WriteLine(a2billingExec);
                            Console.WriteLine("----------------------------------------------------------------------");
                            break;

                        case 8:
                            Console.WriteLine("-- Set timer to auto update md5secret account                       --");
                            var serviceRootConfig = new ServiceRootConfig();
                            var timeInterval      = serviceRootConfig.TimerConfig().TimeLoop;
                            Console.WriteLine("Timer interval = " + timeInterval);
                            Timer timer = new Timer();
                            timer.Elapsed += new ElapsedEventHandler(OnTimerEvent);
                            timer.Interval = timeInterval;
                            timer.Enabled  = true;
                            if (Console.Read() == 'q')
                            {
                                timer.Dispose();
                            }
                            ;
                            Console.WriteLine("----------------------------------------------------------------------");
                            break;
                        }
                    }catch (Exception ex)
                    {
                        Console.WriteLine("Please select the correct option!");
                    }
                    Console.WriteLine("Press any key to continue. Press ESC to exit.");
                    c = Console.ReadKey().Key;
                    Console.Clear();
                } while (c != ConsoleKey.Escape);
                Console.WriteLine("_");
                Console.WriteLine("Thank you!");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#5
0
        public SipAdditionService()
        {
            var serviceRoot = new ServiceRootConfig();

            fileDir = serviceRoot.SipAdditionConfig().Dir;
        }