Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var server   = Configuration["DBServer"] ?? "database";
            var port     = Configuration["DBPort"] ?? "1433";
            var user     = Configuration["DBUser"] ?? "SA";
            var password = Configuration["DBPassword"] ?? "Teste@123";

            ServiceConfigs.Configure(services);
            DatabaseConfig.Configure(Configuration, services, server, port, user, password);

            services.AddResponseCompression(options =>
            {
                options.EnableForHttps = true;
            });

            services.AddCors();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddJsonOptions(options => { options.SerializerSettings.NullValueHandling = NullValueHandling.Include; });

            services.AddSwaggerGen(opt =>
            {
                opt.SwaggerDoc("v1", new Info {
                    Title = "backend", Version = "v1"
                });
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// 长轮询通知任务
        /// </summary>
        /// <param name="apolloConfig"></param>
        /// <param name="serviceConfigs"></param>
        public LongPollingTask(ApolloConfig apolloConfig, ServiceConfigs serviceConfigs)
        {
            _apolloConfig = apolloConfig;

            _serviceConfigs = serviceConfigs;

            _httpHelper = new HttpHelper(_apolloConfig.Timeout, _apolloConfig.ReadTimeout);

            _getConfigTask = new ApolloServiceConfigTask(apolloConfig);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 生成配置文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnGenerateConfig_Click(object sender, EventArgs e)
        {
            List <ServiceMap> lstServiceMap = Singleton <ConfigPlatformBLL> .Instance.SearchServiceMap();

            ServiceConfigs configs = new ServiceConfigs();

            configs.ServiceMaps = lstServiceMap;
            string xmlContent = configs.ToXmlSerialization();

            string xmlPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase +
                             "Config\\ServiceConfig.xml";

            File.WriteAllText(xmlPath, xmlContent);

            MessageBox.Show("生成配置文件成功。");
        }
        public ServiceConfigs GetServiceConfigRecord(string recid, string UserID, string UserSNo)
        {
            ServiceConfigs config = new ServiceConfigs();

            try
            {
                DataSet        ds         = new DataSet();
                SqlParameter[] Parameters = { new SqlParameter("@UserID", Convert.ToInt32(UserSNo)) };
                string[]       tableNames = null;
                SqlHelper.FillDataset(ReadConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, "GetListSystemSettings", ds, tableNames, Parameters);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    config.RosterFTPHostName           = Convert.ToString(ds.Tables[0].Rows[0]["RosterFTPHostName"]);
                    config.RosterFTPUserId             = Convert.ToString(ds.Tables[0].Rows[0]["RosterFTPUserId"]);
                    config.RosterFTPPassword           = Convert.ToString(ds.Tables[0].Rows[0]["RosterFTPPassword"]);
                    config.RosterFtpFolderPath         = Convert.ToString(ds.Tables[0].Rows[0]["RosterFtpFolderPath"]);
                    config.RosterTimeInterval          = Convert.ToString(ds.Tables[0].Rows[0]["RosterTimeInterval"]);
                    config.AttendanceFTPHostName       = Convert.ToString(ds.Tables[0].Rows[0]["AttendanceFTPHostName"]);
                    config.AttendanceFTPUserId         = Convert.ToString(ds.Tables[0].Rows[0]["AttendanceFTPUserId"]);
                    config.AttendanceFTPPassword       = Convert.ToString(ds.Tables[0].Rows[0]["AttendanceFTPPassword"]);
                    config.AttendanceFtpFolderPath     = Convert.ToString(ds.Tables[0].Rows[0]["AttendanceFtpFolderPath"]);
                    config.AttendanceTimeInterval      = Convert.ToString(ds.Tables[0].Rows[0]["AttendanceTimeInterval"]);
                    config.StaffFTPHostName            = Convert.ToString(ds.Tables[0].Rows[0]["StaffFTPHostName"]);
                    config.StaffFTPUserId              = Convert.ToString(ds.Tables[0].Rows[0]["StaffFTPUserId"]);
                    config.StaffFTPPassword            = Convert.ToString(ds.Tables[0].Rows[0]["StaffFTPPassword"]);
                    config.StaffFtpFolderPath          = Convert.ToString(ds.Tables[0].Rows[0]["StaffFtpFolderPath"]);
                    config.SITAFTPHostName             = Convert.ToString(ds.Tables[0].Rows[0]["SITAFTPHostName"]);
                    config.SITAFTPUserId               = Convert.ToString(ds.Tables[0].Rows[0]["SITAFTPUserId"]);
                    config.SITAFTPPassword             = Convert.ToString(ds.Tables[0].Rows[0]["SITAFTPPassword"]);
                    config.SITAMAILBOXServerName       = Convert.ToString(ds.Tables[0].Rows[0]["SITAMAILBOXServerName"]);
                    config.EmailAttachmentWServicePath = Convert.ToString(ds.Tables[0].Rows[0]["EmailAttachmentWServicePath"]);
                    config.SITAFtpFolderPath           = Convert.ToString(ds.Tables[0].Rows[0]["SITAFtpFolderPath"]);
                    config.SITAMAILBOXServerName       = Convert.ToString(ds.Tables[0].Rows[0]["SITAMAILBOXServerName"]);
                    config.SITAMAILBOXUserId           = Convert.ToString(ds.Tables[0].Rows[0]["SITAMAILBOXUserId"]);
                    config.SITAMAILBOXPassword         = Convert.ToString(ds.Tables[0].Rows[0]["SITAMAILBOXPassword"]);
                    config.EmailFTPHostName            = Convert.ToString(ds.Tables[0].Rows[0]["EmailFTPHostName"]);
                    config.EmailFTPUserId              = Convert.ToString(ds.Tables[0].Rows[0]["EmailFTPUserId"]);
                    config.EmailFTPPassword            = Convert.ToString(ds.Tables[0].Rows[0]["EmailFTPPassword"]);
                    config.EmailFtpFolderPath          = Convert.ToString(ds.Tables[0].Rows[0]["EmailFtpFolderPath"]);
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveAttendanceWService")))
                    {
                        config.IsActiveAttendanceWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveAttendanceWService"]);
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveShiftWService")))
                    {
                        config.IsActiveShiftWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveShiftWService"]);
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveRosterWService")))
                    {
                        config.IsActiveRosterWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveRosterWService"]);
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveEmailWService")))
                    {
                        config.IsActiveEmailWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveEmailWService"]);
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveEDIOutboundWService")))
                    {
                        config.IsActiveEDIOutboundWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveEDIOutboundWService"]);
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveEdiInboundWService")))
                    {
                        config.IsActiveEdiInboundWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveEdiInboundWService"]);
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveEDIProcessWService")))
                    {
                        config.IsActiveEDIProcessWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveEDIProcessWService"]);
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveNilManifestWService")))
                    {
                        config.IsActiveNilManifestWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveNilManifestWService"]);
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveSMSWService")))
                    {
                        config.IsActiveSMSWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveSMSWService"]);
                    }
                    config.AttendanceTimeInterval  = Convert.ToString(ds.Tables[0].Rows[0]["AttendanceTimeInterval"]);
                    config.ShiftTimeInterval       = Convert.ToString(ds.Tables[0].Rows[0]["ShiftTimeInterval"]);
                    config.RosterTimeInterval      = Convert.ToString(ds.Tables[0].Rows[0]["RosterTimeInterval"]);
                    config.EmailTimeInterval       = Convert.ToString(ds.Tables[0].Rows[0]["EmailTimeInterval"]);
                    config.EDIOutboundTimeInterval = Convert.ToString(ds.Tables[0].Rows[0]["EDIOutboundTimeInterval"]);
                    config.EDIOutboundTimeInterval = Convert.ToString(ds.Tables[0].Rows[0]["EDIOutboundTimeInterval"]);
                    config.EDIInboundTimeInterval  = Convert.ToString(ds.Tables[0].Rows[0]["EDIInboundTimeInterval"]);
                    config.NilManifestTimeInterval = Convert.ToString(ds.Tables[0].Rows[0]["NilManifestTimeInterval"]);
                    config.EDIProcessTimeInterval  = Convert.ToString(ds.Tables[0].Rows[0]["EDIProcessTimeInterval"]);
                    config.SMSTimeInterval         = Convert.ToString(ds.Tables[0].Rows[0]["SMSTimeInterval"]);
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveLyingListWService")))
                    {
                        config.IsActiveLyingListWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveLyingListWService"]);
                    }
                    config.LyingListTimeInterval = Convert.ToString(ds.Tables[0].Rows[0]["LyingListTimeInterval"]);
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveLyingListService")))
                    {
                        config.IsActiveLyingListService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveLyingListService"]);
                    }
                    config.LyingListTimepmInterval = Convert.ToString(ds.Tables[0].Rows[0]["LyingListTimepmInterval"]);
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveAutoSCMCreation")))
                    {
                        config.IsActiveAutoSCMCreation = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveAutoSCMCreation"]);
                    }
                    config.AutoSCMCreation = Convert.ToString(ds.Tables[0].Rows[0]["AutoSCMCreation"]);
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveCustomsAPIWService")))
                    {
                        config.IsActiveCustomsAPIWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveCustomsAPIWService"]);
                    }
                    config.CustomsAPITimeInterval   = Convert.ToString(ds.Tables[0].Rows[0]["CustomsAPITimeInterval"]);
                    config.INBOUNDMAILBOXServerName = Convert.ToString(ds.Tables[0].Rows[0]["INBOUNDMAILBOXServerName"]);
                    config.INBOUNDMAILBOXUserId     = Convert.ToString(ds.Tables[0].Rows[0]["INBOUNDMAILBOXUserId"]);
                    config.INBOUNDMAILBOXPassword   = Convert.ToString(ds.Tables[0].Rows[0]["INBOUNDMAILBOXPassword"]);
                    config.BNICreateVATimeInterval  = Convert.ToString(ds.Tables[0].Rows[0]["BNICreateVATimeInterval"]);
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActiveBNICreateVAAPIWService")))
                    {
                        config.IsActiveBNICreateVAAPIWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActiveBNICreateVAAPIWService"]);
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString("IsActivePushAWBDataToCRAWService")))
                    {
                        config.IsActivePushAWBDataToCRAWService = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActivePushAWBDataToCRAWService"]);
                    }
                    config.PushAWBDataToCRATimeInterval = Convert.ToString(ds.Tables[0].Rows[0]["PushAWBDataToCRATimeInterval"]);
                }
            }
            catch (Exception ex)// (Exception ex)
            {
            }
            return(config);
        }
Exemplo n.º 5
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     ServiceConfigs.ReegisterAllServices(services, Configuration);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 加载所有服务端配置信息
        /// </summary>
        public void ReloadAllServiceMapConfig()
        {
            // 记录执行时间类
            using (StopWatcherAuto auto = new StopWatcherAuto())
            {
                ServiceUtility.ExportLog(m_Logger, LogExport, "开始加载所有服务端配置信息。");

                // 全部清空
                m_ServiceMapDic.Clear();

                if (string.IsNullOrEmpty(ServiceMapConfigFilePath))
                {
                    return;
                }

                string filePath = ServiceMapConfigFilePath + ServiceMapFileName;
                m_Logger.Debug("服务配置文件路径:" + filePath);
                if (!File.Exists(filePath))
                {
                    return;
                }

                string xmlContent = File.ReadAllText(filePath);
                m_Logger.Debug("服务配置文件内容:" + xmlContent);
                if (string.IsNullOrEmpty(xmlContent))
                {
                    return;
                }

                try
                {
                    ServiceConfigs configs = ServiceConfigs.XmlDeSerialization(xmlContent);

                    if (configs == null ||
                        configs.ServiceMaps == null ||
                        configs.ServiceMaps.Count == 0)
                    {
                        m_Logger.Debug("文件中没有服务配置信息。");
                        return;
                    }

                    foreach (var map in configs.ServiceMaps)
                    {
                        AddServiceMap(map);
                    }

                    ServiceUtility.ExportLog(m_Logger, LogExport, "加载所有服务端配置信息完成。");
                    ServiceUtility.ExportLog(m_Logger, LogExport
                                             , string.Concat("共计加载配置文件:ServiceConfig Count:", configs.ServiceMaps.Count));

                    // 加载完毕
                    IsLoadOver = true;
                }
                catch (Exception ex)
                {
                    m_Logger.Fatal(string.Concat("加载所有服务端配置信息异常 异常信息: ", ex.Message));
                    m_Logger.Fatal(string.Concat("加载所有服务端配置信息异常 异常信息: ", ex.StackTrace));
                    throw ex;
                }
            }
        }