username@email.com
2021-07-23 00446e5e764fd57ea0f28b30921f4a5daa60c890
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
using AutoMapper;
using CommonToolsCore;
using IServices;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Services;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using UEditor.Core;
using zhengcaioa.IService;
using zhengcaioa.Model;
using zhengcaioa.Models;
using zhengcaioa.Service;
using zhengcaioa.Timer;
 
namespace zhengcaioa
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }
 
        public IConfiguration Configuration { get; }
 
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
           // Ìí¼Ócors ·þÎñ ÅäÖÿçÓò´¦Àí
            services.AddCors(options =>
            {
                options.AddPolicy("any", builder =>
                {
                    builder.WithMethods("GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS")
                       .AllowAnyHeader()
                    //.AllowCredentials()//Ö¸¶¨´¦Àícookie
                .AllowAnyOrigin(); //ÔÊÐíÈκÎÀ´Ô´µÄÖ÷»ú·ÃÎÊ
                });
            });
            //services.AddCors(option => option.AddPolicy("cors", policy => policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().AllowAnyOrigin()));
 
            services.AddSession(options =>
            {
                options.IdleTimeout = TimeSpan.FromMinutes(60);
            });
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
            services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
 
            var connectionString = Configuration.GetConnectionString("DefaultConnection");
            services.AddDbContext<zhengcaioaContext>(options =>
            options.UseSqlServer(connectionString));
 
            var connectionString1 = Configuration.GetConnectionString("zcwebConnection");
            services.AddDbContext<zcwebContext>(options =>
            options.UseSqlServer(connectionString1));
 
            services.AddControllersWithViews();
 
            services.AddScoped(typeof(ISimService), typeof(SimService));
            services.AddScoped(typeof(IHrSalaryService), typeof(HrSalaryService));
 
            services.AddScoped(typeof(IUserService), typeof(UserService));
            services.AddScoped(typeof(ILiaotianService), typeof(LiaotianService));
            services.AddScoped(typeof(IProjectService), typeof(ProjectService));
            services.AddScoped(typeof(ISysCodeService), typeof(SysCodeService));
            services.AddScoped(typeof(IPltRoleService), typeof(PltRoleService));
            services.AddScoped(typeof(IPltPageService), typeof(PltPageService));
            services.AddScoped(typeof(IHrPositionService), typeof(HrPositionService));
            services.AddScoped(typeof(IHrDeptService), typeof(HrDeptService));
            services.AddScoped(typeof(ICooperatecustomCustomerService), typeof(CooperatecustomCustomerService));
            services.AddScoped(typeof(IIntentionCustomerService), typeof(IntentionCustomerService));
            services.AddScoped(typeof(IIntentionVisitService), typeof(IntentionVisitService));
            services.AddScoped(typeof(ICooperVisitService), typeof(CooperVisitService));
            services.AddScoped(typeof(IIntentionOrderService), typeof(IntentionOrderService));
            services.AddScoped(typeof(ICooperOrderService), typeof(CooperOrderService));
            services.AddScoped(typeof(ISystemsettingService), typeof(SystemsettingService));
            services.AddScoped(typeof(IGroupTopicService), typeof(GroupTopicService));
            services.AddScoped(typeof(IGroupGrouptypeService), typeof(GroupGrouptypeService));
            services.AddScoped(typeof(IGroupGroupService), typeof(GroupGroupService));
            services.AddScoped(typeof(IGroupTuiguangService), typeof(GroupTuiguangService));
            services.AddScoped(typeof(IExpertService), typeof(ExpertService)); 
            services.AddScoped(typeof(IAdmSigninService), typeof(AdmSigninService));
            services.AddScoped(typeof(IDailyManagementService), typeof(DailyManagementService)); 
            services.AddScoped(typeof(IFiSubjectService), typeof(FiSubjectService));
            services.AddScoped(typeof(IFiAccountService), typeof(FiAccountService));
            services.AddScoped(typeof(IFiOrderrecievemoneyService), typeof(FiOrderrecievemoneyService));
            services.AddScoped(typeof(IFiPiecerateService), typeof(FiPiecerateService));
            services.AddScoped(typeof(IAdmDocBaseService), typeof(AdmDocBaseService));
            services.AddScoped(typeof(IAdmDocDocService), typeof(AdmDocDocService));
            services.AddScoped(typeof(IAdmEvaluateService), typeof(AdmEvaluateService));
            services.AddScoped(typeof(IAreaService), typeof(AreaService));
            services.AddScoped(typeof(IPltRoleDeptService), typeof(PltRoleDeptService));
            services.AddScoped(typeof(IAdmGoodsClassifyService), typeof(AdmGoodsClassifyService));
            services.AddScoped(typeof(IAdmGoodsManageService), typeof(AdmGoodsManageService));
            services.AddScoped(typeof(IAdmPieceCheckService), typeof(AdmPieceCheckService));
            services.AddScoped(typeof(IAdmBreakPrecedentService), typeof(AdmBreakPrecedentService));
            services.AddScoped(typeof(ISysAttachmentService), typeof(SysAttachmentService));
            services.AddScoped(typeof(IPltJiatingchengyuanService), typeof(PltJiatingchengyuanService));
            services.AddScoped(typeof(IFiAccountRecordService), typeof(FiAccountRecordService));
 
            services.AddScoped(typeof(IFiServiceService), typeof(FiServiceService));
            services.AddScoped(typeof(IFiMemberService), typeof(FiMemberService));
            services.AddScoped(typeof(IFiBookService), typeof(FiBookService));
 
            services.AddScoped(typeof(IAdmAttendanceRuleService), typeof(AdmAttendanceRuleService));
 
            services.AddScoped(typeof(IAdmAttendanceDtlService), typeof(AdmAttendanceDtlService));
            services.AddScoped(typeof(IAdmAttendanceService), typeof(AdmAttendanceService));
 
            services.AddScoped(typeof(IHrJibengongziService), typeof(HrJibengongziService));
 
            services.AddScoped(typeof(IHrJixiaotichengService), typeof(HrJixiaotichengService));
 
            services.AddScoped(typeof(IHrSalaryService), typeof(HrSalaryService));
 
            services.AddScoped(typeof(ICusFangwenjiluService), typeof(CusFangwenjiluService));
 
            services.AddScoped(typeof(ILZhuanjiahuidumService), typeof(LZhuanjiahuidumService));
 
            services.AddScoped(typeof(IWfApplytypeService), typeof(WfApplytypeService));
            services.AddScoped(typeof(IWfRunProcessService), typeof(WfRunProcessService));
            services.AddScoped(typeof(IWfNeeddeelService), typeof(WfNeeddeelService));
            services.AddScoped(typeof(IWfHistoryService), typeof(WfHistorieservice));
            services.AddScoped(typeof(IOrderBanciDtlService), typeof(OrderBanciDtlService));
            services.AddScoped(typeof(IOrderBanciService), typeof(OrderBanciService));
            services.AddScoped(typeof(IOrderBanciOrderService), typeof(OrderBanciOrderService));
 
            services.AddScoped(typeof(IAskService), typeof(AskService)); 
 
            //zcweb
            services.AddScoped(typeof(IDtChannelArticleNewsService), typeof(DtChannelArticleNewsService)); 
 
            //¶¨Ê±Ö´ÐÐ
            services.AddHostedService<TimedBackgroundService>();
 
 
            //¶¨Ê±Ö´ÐÐ
            services.AddHostedService<TimerGetShopUsersService>();
 
 
            services.AddAutoMapper(typeof(AutoMapperConfigs));
            services.AddUEditorService("ueditor.json", true, "wwwroot");
            services.AddMvc(options =>{
                options.Filters.Add<HttpGlobalExceptionFilter>();//È«¾Ö×¢²á
                options.Filters.Add<AntiSqlAttribute>();//È«¾Ö×¢²á
                
            });
            services.Configure<IISServerOptions>(options =>
            {
                options.MaxRequestBodySize = 52428800;
            });
            //services.AddMvc().AddJsonOptions(opt =>
            //{
            //    opt.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();//json×Ö·û´®´óСдԭÑùÊä³ö
            //});
            //È«¾ÖÅäÖÃJsonÐòÁл¯´¦Àí
            services.AddMvc().AddNewtonsoftJson(options =>
            {
                //ºöÂÔÑ­»·ÒýÓÃ
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                //²»Ê¹ÓÃÍÕ·åÑùʽµÄkey
                options.SerializerSettings.ContractResolver = new DefaultContractResolver();
                //ÉèÖÃʱ¼ä¸ñʽ
                options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
            });
            services.AddHttpClient();
            
        }
 
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseSession();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();
 
            app.UseRouting();
 
            app.UseAuthorization();
            app.UseCors("any");
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}").RequireCors("any");
            });
 
            //     app.UseStaticFiles(new StaticFileOptions
            //     {
            //         FileProvider = new PhysicalFileProvider(
            //Path.Combine(Directory.GetCurrentDirectory(), "UploadingFiles")),
            //         RequestPath = "/UploadingFiles",
            //         OnPrepareResponse = ctx =>
            //         {
            //             ctx.Context.Response.Headers.Append("Cache-Control", "public,max-age=36000");
            //         }
            //     });
 
            //app.UseMiddleware<CorsMiddleware>();
        }
    }
}