public override void OnPageLoad(object sender, EventArgs e)
        {
            base.OnPageLoad(sender, e);
            facade       = new ReportFacade(this);
            commonFacade = new CommonDataFacade(this);
            queryVM      = new OutBoundNotReturnQueryVM();
            string getQueryParams = Request.Param;

            //Victor Added ,接收PO查询页面传过来的查询条件参数:
            if (!string.IsNullOrEmpty(getQueryParams))
            {
                string[] getParamList = getQueryParams.Split('|');
                queryVM.SendDays    = getQueryParams.Split('|')[0].Trim();
                queryVM.HasResponse = getQueryParams.Split('|')[1].Trim() == "1" ? true : false;
                if (getParamList.Length > 2)
                {
                    queryVM.VendorSysNo = getQueryParams.Split('|')[2].Trim();
                }
                this.QueryFilter.DataContext = queryVM;
                Button_Search_Click(null, null);
            }
            else
            {
                this.QueryFilter.DataContext = queryVM;
            }
        }
Exemple #2
0
 public override void OnPageLoad(object sender, EventArgs e)
 {
     queryVM      = new RMAInventoryQueryVM();
     facade       = new ReportFacade(this);
     commonFacade = new CommonDataFacade(this);
     LoadComboBoxData();
     this.QueryFilter.DataContext = queryVM;
     base.OnPageLoad(sender, e);
 }
Exemple #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            StartLoggly();

            services.AddWebSocketManager();

            IFileRepository     fileRepository;
            IGroupRepository    groupRepository;
            IKeysRepository     keysRepository;
            ITagRepository      tagRepository;
            IUserRepository     userRepository;
            ISanctionRepository sanctionRepository;
            IEventRepository    eventRepository;

            if (bool.Parse(Configuration.GetValue <string>("UseDB")))
            {
                var dbContext = Configuration.GetValue <string>("MysqlConnectionString");
                using (var context = new EduhubContext(dbContext))
                {
                    if (bool.Parse(Configuration.GetValue <string>("DeleteDB")))
                    {
                        context.Database.EnsureDeleted();
                    }
                    if (context.Database.EnsureCreated())
                    {
                        var dbName = dbContext.Split("database=")[1].Split(";")[0];
                        context.Database.ExecuteSqlCommand(
                            "ALTER DATABASE " + dbName + " CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;");
                        var modelNames = context.Model.GetEntityTypes();
                        foreach (var modelname in modelNames)
                        {
                            var mapping   = context.Model.FindEntityType(modelname.Name).Relational();
                            var tableName = mapping.TableName;
                            context.Database.ExecuteSqlCommand(
                                "alter table " + tableName.ToLower()
                                + " convert to character set utf8mb4 collate utf8mb4_bin;");
                        }
                    }

                    context.Database.Migrate();
                }

                fileRepository     = new InMysqlFileRepository(dbContext);
                groupRepository    = new InMysqlGroupRepository(dbContext);
                keysRepository     = new InMysqlKeyRepository(dbContext);
                tagRepository      = new InMysqlTagRepository(dbContext);
                userRepository     = new InMysqlUserRepository(dbContext);
                sanctionRepository = new InMysqlSanctionRepository(dbContext);
                eventRepository    = new InMemoryEventRepository();
            }
            else
            {
                fileRepository     = new InMemoryFileRepository();
                groupRepository    = new InMemoryGroupRepository();
                keysRepository     = new InMemoryKeysRepository();
                tagRepository      = new InMemoryTagRepository();
                sanctionRepository = new InMemorySanctionRepository();
                userRepository     = new InMemoryUserRepository();
                eventRepository    = new InMemoryEventRepository();
            }

            var emailSettings = new EmailSettings(Configuration.GetValue <string>("EmailLogin"),
                                                  Configuration.GetValue <string>("Email"),
                                                  Configuration.GetValue <string>("EmailPassword"),
                                                  Configuration.GetValue <string>("SmtpAddress"),
                                                  Configuration.GetValue <string>("ConfirmAddress"),
                                                  int.Parse(Configuration.GetValue <string>("SmtpPort")));


            var defaultAvatarFilename    = Configuration.GetValue <string>("DefaultAvatarFilename");
            var defaultAvatarContentType = Configuration.GetValue <string>("DefaultAvatarContentType");
            var userSettings             = new UserSettings(defaultAvatarFilename);

            if (!fileRepository.DoesFileExists(defaultAvatarFilename))
            {
                fileRepository.AddFile(new UserFile(defaultAvatarFilename, defaultAvatarContentType));
            }

            var tagFacade   = new TagFacade(tagRepository);
            var emailSender = new EmailSender(emailSettings);
            var notificationsDistributor = new NotificationsDistributor(groupRepository, userRepository, emailSender);

            var groupSettings = new GroupSettings(Configuration.GetValue <int>("MinGroupSize"),
                                                  Configuration.GetValue <int>("MaxGroupSize"),
                                                  Configuration.GetValue <double>("MinGroupValue"),
                                                  Configuration.GetValue <double>("MaxGroupValue"));

            var eventBusSettings = new EventBusSettings(Configuration.GetValue <string>("RabbitMqServerHostName"),
                                                        Configuration.GetValue <string>("RabbitMqServerVirtualHost"),
                                                        Configuration.GetValue <string>("RabbitMqAdminUserName"),
                                                        Configuration.GetValue <string>("RabbitMqAdminPassword"));
            var eventBus = new EventBus(eventBusSettings);

            eventBus.StartListening();

            var adminsEventConsumer     = new AdminsEventConsumer(notificationsDistributor, eventRepository);
            var courseEventConsumer     = new CourseEventConsumer(notificationsDistributor, eventRepository);
            var curriculumEventConsumer = new CurriculumEventConsumer(notificationsDistributor, eventRepository);
            var groupEventsConsumer     = new GroupEventsConsumer(notificationsDistributor, eventRepository);
            var invitationConsumer      = new InvitationConsumer(notificationsDistributor, eventRepository);
            var memberActionsConsumer   = new MemberActionsConsumer(notificationsDistributor, eventRepository);

            eventBus.RegisterConsumer(new TagPopularityConsumer(tagFacade));
            eventBus.RegisterConsumer <ReportMessageEvent>(adminsEventConsumer);
            eventBus.RegisterConsumer <SanctionsAppliedEvent>(adminsEventConsumer);
            eventBus.RegisterConsumer <SanctionCancelledEvent>(adminsEventConsumer);
            eventBus.RegisterConsumer <TeacherFoundEvent>(courseEventConsumer);
            eventBus.RegisterConsumer <CourseFinishedEvent>(courseEventConsumer);
            eventBus.RegisterConsumer <ReviewReceivedEvent>(courseEventConsumer);
            eventBus.RegisterConsumer <CurriculumAcceptedEvent>(curriculumEventConsumer);
            eventBus.RegisterConsumer <CurriculumDeclinedEvent>(curriculumEventConsumer);
            eventBus.RegisterConsumer <CurriculumSuggestedEvent>(curriculumEventConsumer);
            eventBus.RegisterConsumer <NewCreatorEvent>(groupEventsConsumer);
            eventBus.RegisterConsumer <GroupIsFormedEvent>(groupEventsConsumer);
            eventBus.RegisterConsumer <InvitationAcceptedEvent>(invitationConsumer);
            eventBus.RegisterConsumer <InvitationDeclinedEvent>(invitationConsumer);
            eventBus.RegisterConsumer <InvitationReceivedEvent>(invitationConsumer);
            eventBus.RegisterConsumer <NewMemberEvent>(memberActionsConsumer);
            eventBus.RegisterConsumer <MemberLeftEvent>(memberActionsConsumer);

            var publisher = eventBus.GetEventPublisher();

            var userFacade      = new UserFacade(userRepository, groupRepository, eventRepository, publisher);
            var groupEditFacade = new GroupEditFacade(groupRepository, groupSettings, publisher);
            var userEditFacade  = new UserEditFacade(userRepository, fileRepository, sanctionRepository);
            var groupFacade     = new GroupFacade(groupRepository, userRepository, sanctionRepository, groupSettings,
                                                  publisher);
            var fileFacade        = new FileFacade(fileRepository);
            var chatFacade        = new ChatFacade(groupRepository, userRepository);
            var sanctionsFacade   = new SanctionFacade(sanctionRepository, userRepository, publisher);
            var userAccountFacade = new AccountFacade(keysRepository, userRepository, emailSender, userSettings);
            var reportFacade      = new ReportFacade(userRepository, eventRepository, publisher);

            services.AddSingleton <IUserFacade>(userFacade);
            services.AddSingleton <IGroupFacade>(groupFacade);
            services.AddSingleton <IFileFacade>(fileFacade);
            services.AddSingleton <IChatFacade>(chatFacade);
            services.AddSingleton <IGroupEditFacade>(groupEditFacade);
            services.AddSingleton <IUserEditFacade>(userEditFacade);
            services.AddSingleton <ITagFacade>(tagFacade);
            services.AddSingleton <ISanctionFacade>(sanctionsFacade);
            services.AddSingleton <IAccountFacade>(userAccountFacade);
            services.AddSingleton <IReportFacade>(reportFacade);
            services.AddSingleton(Env);

            userAccountFacade.CheckAdminExistence(Configuration.GetValue <string>("AdminEmail"));

            services.AddSwaggerGen(current =>
            {
                current.SwaggerDoc("v1", new Info
                {
                    Title   = "EduHub API",
                    Version = "v1"
                });
                current.AddSecurityDefinition("Bearer", new ApiKeyScheme
                {
                    Description =
                        "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
                    Name = "Authorization",
                    In   = "header",
                    Type = "apiKey"
                });
                current.OperationFilter <ExamplesOperationFilter>();
                current.DescribeAllEnumsAsStrings();
                var a = string.Format(@"{0}\EduHub.xml", AppDomain.CurrentDomain.BaseDirectory);
                current.IncludeXmlComments(string.Format(@"{0}/EduHub.xml", AppDomain.CurrentDomain.BaseDirectory));
            });
            ConfigureSecurity(services);
            if (Configuration.GetValue <bool>("Authorization"))
            {
                services.AddMvc(o =>
                {
                    o.Filters.Add(new ExceptionFilter());
                    o.Filters.Add(new ActionFilter());
                });
            }
            else
            {
                services.AddMvc(o =>
                {
                    o.Filters.Add(new AllowAnonymousFilter());
                    o.Filters.Add(new ExceptionFilter());
                    o.Filters.Add(new ActionFilter());
                });
            }
            services.AddCors(options =>
            {
                options.AddPolicy("AllowAnyOrigin",
                                  builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
            });
        }
Exemple #4
0
 public override void OnPageLoad(object sender, EventArgs e)
 {
     facade = new ReportFacade(this);
     base.OnPageLoad(sender, e);
 }
Exemple #5
0
        public void RefreshQty()
        {
            BaseModelFacade  baseModelFacade  = new BaseModelFacade(this.DataProvider);
            ShiftModelFacade shiftModelFacade = new ShiftModelFacade(this.DataProvider);
            ReportFacade     reportFacade     = new ReportFacade(this.DataProvider);
            MOFacade         moFacade         = new MOFacade(this.DataProvider);

            //DateTime
            DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
            DateTime   now        = FormatHelper.ToDateTime(dbDateTime.DBDate, dbDateTime.DBTime);

            //ResCode
            string resCode = ApplicationService.Current().ResourceCode;

            //Shift day and shift
            string   shiftCode = string.Empty;
            int      shiftDay  = 0;
            Resource res       = (Resource)baseModelFacade.GetResource(resCode);

            if (res != null)
            {
                TimePeriod currTimePeriod = (TimePeriod)shiftModelFacade.GetTimePeriod(res.ShiftTypeCode, dbDateTime.DBTime);
                if (currTimePeriod != null)
                {
                    shiftDay  = shiftModelFacade.GetShiftDay(currTimePeriod, now);
                    shiftCode = currTimePeriod.ShiftCode;
                }
            }

            //刷新数量数据
            object[] reportSOQtyList = reportFacade.QueryMOCodeFromReportSOQty(shiftDay, shiftCode, resCode);

            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("MOCode");
            dataTable.Columns.Add("PlanQty");
            dataTable.Columns.Add("ResOutputCurrent");
            dataTable.Columns.Add("ResOutputTotal");

            decimal sumPlanQty          = 0;
            int     sumResOutputCurrent = 0;
            int     sumResOutputTotal   = 0;

            if (reportSOQtyList != null)
            {
                foreach (ReportSOQty reportSOQty in reportSOQtyList)
                {
                    MO mo = (MO)moFacade.GetMO(reportSOQty.MOCode);
                    if (mo != null)
                    {
                        object[] outputCurrent = reportFacade.QueryOPCountSumFromReportSOQty(shiftDay, shiftCode, resCode, reportSOQty.MOCode);
                        object[] outputTotal   = reportFacade.QueryOPCountSumFromReportSOQty(0, string.Empty, resCode, reportSOQty.MOCode);

                        if (outputCurrent != null && outputTotal != null)
                        {
                            DataRow row = dataTable.NewRow();
                            row["MOCode"]           = reportSOQty.MOCode;
                            row["PlanQty"]          = mo.MOPlanQty.ToString("0");
                            row["ResOutputCurrent"] = ((ReportSOQty)outputCurrent[0]).OPCount.ToString();
                            row["ResOutputTotal"]   = ((ReportSOQty)outputTotal[0]).OPCount.ToString();
                            dataTable.Rows.Add(row);

                            sumPlanQty          += mo.MOPlanQty;
                            sumResOutputCurrent += ((ReportSOQty)outputCurrent[0]).OPCount;
                            sumResOutputTotal   += ((ReportSOQty)outputTotal[0]).OPCount;
                        }
                    }
                }
            }

            DataRow rowSum = dataTable.NewRow();

            rowSum["MOCode"]           = UserControl.MutiLanguages.ParserString("Summary");
            rowSum["PlanQty"]          = sumPlanQty.ToString("0");
            rowSum["ResOutputCurrent"] = sumResOutputCurrent.ToString();
            rowSum["ResOutputTotal"]   = sumResOutputTotal.ToString();
            dataTable.Rows.Add(rowSum);

            this.ultraGridQty.DataSource = dataTable;
            this.ultraGridQty.DataBind();
        }