示例#1
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services"></param>
        public void ConfigureServices(IServiceCollection services)
        {
            //string defaultSqlConnectionString = Configuration.GetConnectionString("SqlServerConnection");
            //string defaultMySqlConnectionString = Configuration.GetConnectionString("MySqlConnection");

            RepositoryInjection.ConfigureRepository(services);
            BusinessInjection.ConfigureBusiness(services);
            services.AddMvc();
            services.AddSwaggerGen(m =>
            {
                m.SwaggerDoc("v1", new Info
                {
                    Description = "Light System WebApi",
                    Contact     = new Contact {
                        Email = "*****@*****.**", Name = "王杰光", Url = "http://www.jiqunar.com"
                    },
                    Version = "v1",
                    Title   = "LightAPI"
                });
                var basePath = PlatformServices.Default.Application.ApplicationBasePath;//或者AppContext.BaseDirectory
                var xmlName  = this.GetType().GetTypeInfo().Module.Name.Replace(".dll", ".xml").Replace(".exe", ".xml");
                var xmlPath  = Path.Combine(basePath, xmlName);
                m.IncludeXmlComments(xmlPath);
            });
        }
示例#2
0
        private void UpdateReport()
        {
            var ri    = new RepositoryInjection();
            var _conn = ri.GetClass <IFactoryConnection>();
            var pioc  = new ParkingInOutController(_conn);

            if (CurrentControl != null)
            {
                var r = pioc.ListForReport(CurrentControl.Id);
                foreach (var item in r)
                {
                    item.Convenio         = ParkingAgreementId.SComponent.Text;
                    item.Desconto         = (decimal)DiscountValuePorcent.ValueControl == decimal.Zero ? (decimal)DiscountValueReal.ValueControl : (decimal)DiscountValuePorcent.ValueControl;
                    item.FormaPagamento   = FormOfPaymentId.SComponent.Text;
                    item.Troco            = (decimal)ChangeOfMoney.ValueControl;
                    item.ValorPago        = (decimal)AmountPaid.ValueControl;
                    item.ValorTotal       = (decimal)TotalValue.ValueControl;
                    item.ValorTotalaPagar = (decimal)TotalPayable.ValueControl;
                    item.DataFinal        = DateTime.Now;
                }

                reportViewer1.LocalReport.DataSources.Clear();
                reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSetTicket", r));
                reportViewer1.RefreshReport();
            }
        }
示例#3
0
        protected virtual string DisplayName(PropertyInfo propertyInfo)
        {
            if (propertyInfo == null)
            {
                return(string.Empty);
            }

            var conn      = new RepositoryInjection().GetClass <IFactoryConnection>();
            var translate = new TranslateApp(conn);

            var displayName = string.Empty;

            try
            {
                var t = GlobalUser.Translates.FirstOrDefault(c => c.PropertyName == Name);

                if (t == null)
                {
                    translate.InsertOrUpdate(new Translate()
                    {
                        PropertyName     = Name,
                        Portugues        = GetAttribute <DisplayNameAttribute>(propertyInfo).DisplayName,
                        CompanyControlId = GlobalUser.Company.Id,
                        UserControlId    = GlobalUser.User.Id
                    });
                    conn.Save();
                }
                else
                {
                    var newDisplayName = GetAttribute <DisplayNameAttribute>(propertyInfo).DisplayName;

                    if (newDisplayName != t.Portugues)
                    {
                        t.Portugues = newDisplayName;
                        translate.InsertOrUpdate(t);
                        conn.Save();
                    }

                    displayName = t.Portugues;
                }
            }
            catch (Exception)
            {
                // ignored
            }

            var display = !string.IsNullOrEmpty(Caption) ? Caption : !string.IsNullOrEmpty(displayName) ? displayName : GetAttribute <DisplayNameAttribute>(propertyInfo)?.DisplayName;

            return(display);
        }
示例#4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            RepositoryInjection.ConfigureRepository(services);
            BusinesInjection.ConfigureBusiness(services);

            services.AddHttpContextAccessor();
            services.AddCors();
            services.AddMvc().AddJsonOptions(config =>
            {
                config.SerializerSettings.ContractResolver = new DefaultContractResolver();
            });
            services.AddMemoryCache();

            services.AddSession();
        }
示例#5
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services"></param>
        public void ConfigureServices(IServiceCollection services)
        {
            //string defaultSqlConnectionString = Configuration.GetConnectionString("SqlServerConnection");
            string defaultMySqlConnectionString = Configuration.GetConnectionString("MySqlConnection");

            RepositoryInjection.ConfigureRepository(services);
            BusinessInjection.ConfigureBusiness(services);
            services.AddMvc();
            services.AddSwaggerGen(m =>
            {
                m.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info {
                    Title = "LightApi", Version = "v1", Description = "Light接口文档"
                });
            });
        }
        public static void RegisterBindings(IServiceCollection services, IConfiguration configuration)
        {
            ConfigureBindingsDatabaseContext.RegisterBindings(services, configuration);

            #region ApplicationService
            ApplicationServiceInjection.RegisterBindings(services, configuration);
            #endregion



            #region Repository
            RepositoryInjection.RegisterBindings(services, configuration);
            #endregion



            #region UnitOfWork
            UnitOfWorkInjection.RegisterBindings(services, configuration);
            #endregion
        }
示例#7
0
        public FSearch(string formName, TypeSearch typeSearch, object sender)
        {
            var conn = new RepositoryInjection().GetClass <IFactoryConnection>();

            _reports  = new ReportApp(conn);
            _consults = new ConsultApp(conn);

            _form      = formName;
            TypeSearch = typeSearch;

            InitializeComponent();

            MenuSearch.Tag = this;

            // Define o style do grid de pesquisa
            GridFilter.SMenuComponent.Visible = false;
            GridFilter.STextBox.Visible       = false;
            GridFilter.SComponent.EditMode    = DataGridViewEditMode.EditOnKeystrokeOrF2;

            // Define as colunas padrões do grid de pesquisa
            GridFilter.SComponent.Columns.Add("Description", "Descrição");
            GridFilter.SComponent.Columns.Add("Filter", "Filtro");
            GridFilter.SComponent.Columns.Add("Value", "Valor");
            GridFilter.SComponent.Columns.Add("Value2", "");
            GridFilter.SComponent.EditingControlShowing += dataGridView1_EditingControlShowing;
            Tag = sender;

            InicitializeTreeView();

            TreeView.ExpandAll();

            TreeView.AfterSelect += TreeView_AfterSelect;

            TreeView.SelectedNode = TreeView.Nodes[0].FirstNode;

            TreeView.Focus();
        }
        public static void RegisterBindings(IServiceCollection services, IConfiguration configuration)
        {
            ConfigureBindingsDatabaseContext.RegisterBindings(services, configuration);
            services.AddScoped(s => s.GetService <IOptions <ImageConfig> >().Value);
            services.AddScoped(s => s.GetService <IOptions <EmailConfig> >().Value);
            services.AddScoped <ImageUpload>();
            services.AddScoped <EmailService>();

            #region ApplicationService
            ApplicationServiceInjection.RegisterBindings(services, configuration);
            #endregion



            #region Repository
            RepositoryInjection.RegisterBindings(services, configuration);
            #endregion



            #region UnitOfWork
            UnitOfWorkInjection.RegisterBindings(services, configuration);
            #endregion
        }
示例#9
0
        public FFilterCompany()
        {
            StateForm = StateForm.Editing;

            InitializeComponent();

            sMenuProcess1.Visibility = System.Windows.Visibility.Hidden;
            elementHost1.Visible     = false;

            gridFilterCompany.SMenuComponent.Visible   = false;
            gridFilterCompany.Label.Visible            = false;
            gridFilterCompany.SComponent.SelectionMode = DataGridViewSelectionMode.CellSelect;

            var ri = new RepositoryInjection();

            _conn = ri.GetClass <IFactoryConnection>();

            _filterCompanyApp = new FilterCompanyApp(_conn);
            _companyApp       = new CompanyApp(_conn);
            _dbTableApp       = new DbTableApp(_conn);

            InitializeStrutureColumns();
            UpdateDataSource();
        }
示例#10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="services"></param>
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddJsonOptions(option =>
            {
                option.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            });
            services.AddHttpsRedirection(option =>
            {
                option.RedirectStatusCode = StatusCodes.Status307TemporaryRedirect;
                option.HttpsPort          = 5001;
            });
            services.AddDbContext <PomeloContext>(options => options.UseMySql(Configuration.GetConnectionString("mysqlConnection")));
            RepositoryInjection.ConfigureRepository(services);
            BusinessInjection.ConfigureBusiness(services);
            services.AddSingleton(Configuration);
            PropertyMappingInjection.MappingInjection(services);

            services.AddSwaggerGen(m =>
            {
                m.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info {
                    Title = "PomeloButterApi", Version = "v1", Description = "Pomelo接口文档"
                });
            });

            services.AddAutoMapper();

            BaseValidator.ConfigureEntityValidator(services);
            services.AddTransient <ITypeHelperService, TypeHelperService>();
            services.AddSingleton <IActionContextAccessor, ActionContextAccessor>();
            services.AddScoped <IUrlHelper>(options =>
            {
                var actionContext = options.GetService <IActionContextAccessor>().ActionContext;
                return(new UrlHelper(actionContext));
            });
        }
示例#11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var jwtTokenModel = new JwtConfigModel();

            Configuration.GetSection("JwtToken").Bind(jwtTokenModel);

            services.AddDbContext <AppIdentityDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <AppIdentityUser, AppIdentityRole>()
            .AddEntityFrameworkStores <AppIdentityDbContext>()
            .AddDefaultTokenProviders();

            // ===== Add Jwt Authentication ========
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); // => remove default claims
            services
            .AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultScheme             = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(cfg =>
            {
                cfg.RequireHttpsMetadata      = false;
                cfg.SaveToken                 = true;
                cfg.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidIssuer      = jwtTokenModel.Issuer,
                    ValidAudience    = jwtTokenModel.Audience,
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtTokenModel.Key)),
                    ClockSkew        = TimeSpan.Zero // remove delay of token when expire
                };
            });


            services.Configure <JwtConfigModel>(config => Configuration.GetSection("JwtToken").Bind(config));

            // Comment the next line if your app is running on the .NET Core 2.0
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            RepositoryInjection.Inject(services);

            services.AddMemoryCache(); // Adds a default in-memory
                                       // implementation of
                                       // IDistributedCache

            services.AddSession(options =>
            {
                options.IdleTimeout     = TimeSpan.FromMinutes(20);
                options.Cookie.HttpOnly = true;
            });

            services.AddAntiforgery(options =>
            {
                options.HeaderName  = "X-XSRF-TOKEN";
                options.Cookie.Name = "MyAntiForgeryCookieName";
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });
        }
示例#12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddHealthChecks();

            services.AddDbContext <ArkDatabaseContext>(options =>
                                                       options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            //services.AddDbContext<ArkRadiusContext>(options =>
            //    options.UseMySQL(Configuration.GetConnectionString("RadiusDefaultConnection")));

            services.AddIdentity <ApplicationUser, ApplicationUserRole>(
                options => {
                options.User.RequireUniqueEmail            = true;
                options.SignIn.RequireConfirmedEmail       = true;
                options.SignIn.RequireConfirmedPhoneNumber = true;
            })
            .AddEntityFrameworkStores <ArkDatabaseContext>()
            .AddDefaultTokenProviders();

            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.WithOrigins("https://*****:*****@halilkoca.com", Url = new Uri("http://halilkoca.com")
                    }
                });

                // 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);
            });

            // get weblog section
            services.AddOptions();
            var section = Configuration.GetSection("Weblog");

            services.Configure <WeblogConfiguration>(section);

            // email
            services.Configure <EmailSettings>(Configuration.GetSection("EmailSettings"));
        }
示例#13
0
        public FLogin(SplashScreen splash)
        {
            _splashScreen = splash;
            var ri   = new RepositoryInjection();
            var conn = ri.GetClass <IFactoryConnection>();

            _userApp               = new UserApp(conn);
            _companyApp            = new CompanyApp(conn);
            _translateApp          = new TranslateApp(conn);
            _tableApp              = new TableApp(conn);
            _dbTableApp            = new DbTableApp(conn);
            _automaticNumberingApp = new AutomaticNumberingApp(conn);

            _userController = new UserController(conn);

            GlobalUser.Forms               = _tableApp.Search().ToList();
            GlobalUser.Translates          = _translateApp.Search().ToList();
            GlobalUser.Tables              = _dbTableApp.Search().ToList();
            GlobalUser.AutomaticNumberings = _automaticNumberingApp.Search().ToList();

            InitializeComponent();

            Unidade.ObjetoApp     = new InvokeMethod(typeof(CompanyController), TypeExecute.SearchAll, "ListCompany", typeof(Company));
            Unidade.DisplayMember = "PersonName";
            Unidade.ValueMember   = "Id";
            Unidade.Enabled       = false;
            Unidade.Refresh();
            Unidade.SComponent.DropDown += SComponentOnDropDown;
            Unidade.Caption              = "Unidade";

            EntrarButton.SComponent.BackColor = Color.DarkSlateGray;
            EntrarButton.SComponent.ForeColor = Color.White;
            EntrarButton.SComponent.Text      = @"Entrar";
            EntrarButton.SComponent.Click    += EntrarButton_Click;
            EntrarButton.Enabled = false;

            SenhaTextBox.SComponent.PasswordChar = '*';
            SenhaTextBox.Caption = "Senha";
            SenhaTextBox.SComponent.TextChanged += SenhaComponentOnTextChanged;

            UsuarioTextBox.SComponent.TextChanged += UsuarioComponentOnTextChanged;
            UsuarioTextBox.Caption = "Login";

            var cont = false;

            if (_companyApp.Search().Any())
            {
                if (!_userApp.Search().Any())
                {
                    MessageBox.Show(@"Necessário cadastrar um usuário",
                                    @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK);
                    var fuser = new FUser
                    {
                        StateForm       = StateForm.Inserting,
                        ClosedAfterSave = true
                    };
                    fuser.RefreshControls();
                    ((User)fuser.CurrentControl).IsAdministrator = true;
                    _splashScreen.Close();
                    fuser.ShowDialog();
                }
                return;
            }
            ;
            MessageBox.Show(@"Este é o seu primeiro acesso ao sistema, por favor, cadastre sua empresa.",
                            @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK);

            do
            {
                var fcompany = new FCompany()
                {
                    StateForm       = StateForm.Inserting,
                    ClosedAfterSave = true
                };
                fcompany.RefreshControls();
                _splashScreen.Close();
                fcompany.ShowDialog();
                if (!_companyApp.Search().Any())
                {
                    cont = MessageBox.Show(@"Necessário cadastrar uma empresa, deseja continuar ?",
                                           @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                           DialogResult.Yes;
                }
            } while (cont);

            if (!_companyApp.Search().Any())
            {
                Close();
            }
            else
            {
                if (_userApp.Search().Any())
                {
                    return;
                }
                MessageBox.Show(@"Necessário cadastrar um usuário",
                                @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK);
                var fuser = new FUser
                {
                    ClosedAfterSave = true,
                    StateForm       = StateForm.Inserting,
                };
                ((User)fuser.CurrentControl).IsAdministrator = true;
                _splashScreen.Close();
                fuser.ShowDialog();
            }
        }