Example #1
0
        protected override void OnStart(string[] args)
        {
            // 是否检查在线状态
            SystemInfo.CheckOnLine = false;
            SystemInfo.EnableCheckPasswordStrength = true;
            // 是否记录日志
            SystemInfo.EnableRecordLog = true;
            // 是否需要注册
            SystemInfo.NeedRegister = false;
            // 读取配置文件
            UserConfigHelper.GetConfig(SystemInfo.StartupPath + "\\" + UserConfigHelper.FileName);

            // 读取配置文件
            var configuration            = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location);
            var serviceModelSectionGroup = (ServiceModelSectionGroup)configuration.GetSectionGroup("system.serviceModel");
            // 开启每个服务
            var idxService = 0;

            serviceHosts = new ServiceHost[serviceModelSectionGroup.Services.Services.Count];
            foreach (ServiceElement serviceElement in serviceModelSectionGroup.Services.Services)
            {
                var assemblyString = serviceElement.Name.Substring(0, serviceElement.Name.LastIndexOf('.'));
                var serviceHost    = new ServiceHost(Assembly.Load(assemblyString).GetType(serviceElement.Name), serviceElement.Endpoints[0].Address);
                //var serviceHost = new ServiceHost(Assembly.Load(assemblyString).GetType(serviceElement.Name));
                serviceHost.Opened += delegate { Console.WriteLine("第{0}个服务:{1}", idxService + 1, serviceHost.BaseAddresses[0]); };
                serviceHost.Open();
                serviceHosts[idxService] = serviceHost;
                idxService++;
            }
            base.OnStart(args);
        }
Example #2
0
        /// <summary>
        /// 获取配置信息
        /// </summary>
        public static void GetConfig()
        {
            // 读取客户端配置文件
            BaseSystemInfo.ConfigurationFrom = ConfigurationCategory.UserConfig;
            UserConfigHelper.GetConfig();

            // 这里应该读取服务上的配置信息,不只是读取本地的配置信息

            /*
             * DotNetService dotNetService = new DotNetService();
             * string allowUserRegister = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "AllowUserRegister");
             * BaseSystemInfo.AllowUserRegister = allowUserRegister.Equals(false.ToString()) ? false : true;
             * // 密码强度检查
             * string checkPasswordStrength = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "CheckPasswordStrength");
             * BaseSystemInfo.CheckPasswordStrength = checkPasswordStrength.Equals(false.ToString()) ? false : true;
             * string useColumnPermission = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "UseColumnPermission");
             * BaseSystemInfo.UseColumnPermission = useColumnPermission.Equals(true.ToString()) ? true : false;
             * string useModulePermission = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "UseModulePermission");
             * BaseSystemInfo.UseModulePermission = useModulePermission.Equals(true.ToString()) ? true : false;
             * string usePermissionScope = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "UsePermissionScope");
             * BaseSystemInfo.UsePermissionScope = usePermissionScope.Equals(true.ToString()) ? true : false;
             * string useTablePermission = dotNetService.ParameterService.GetServiceConfig(BaseSystemInfo.UserInfo, "UseTablePermission");
             * BaseSystemInfo.UseTablePermission = useTablePermission.Equals(true.ToString()) ? true : false;
             * if (dotNetService.ParameterService is ICommunicationObject)
             * {
             *  ((ICommunicationObject)dotNetService.ParameterService).Close();
             * }
             */
        }
Example #3
0
        //调试修改添加
        private void GetAllDbLinks()
        {
            UserConfigHelper.GetConfig();
            //RDIFramework.Utilities.UserInfo user = new RDIFramework.Utilities.UserInfo();
            this.UserInfo.OpenId          = "7d46323d-0091-4bf5-8a13-67fef63a4cd4";
            this.UserInfo.Id              = "26F43BC9-AE6D-42D2-BAC9-F4237A949484";
            this.UserInfo.Code            = "Administrator";
            this.UserInfo.RealName        = "Administrator";
            this.UserInfo.IsAdministrator = true;
            DataTable dtDbLinks = RDIFrameworkService.Instance.DbLinkDefineService.GetDT(this.UserInfo);

            if (dtDbLinks != null && dtDbLinks.Rows.Count > 0)
            {
                foreach (DataRow dataRow in dtDbLinks.Rows)
                {
                    ConnectString connStr = new ConnectString
                    {
                        LinkName = dataRow[CiDbLinkDefineTable.FieldLinkName].ToString()
                    };
                    string dbType = dataRow[CiDbLinkDefineTable.FieldLinkType].ToString();
                    switch (dbType.ToUpper())
                    {
                    case "ACCESS":
                        connStr.DbType = CurrentDbType.Access;
                        break;

                    case "ORACLE":
                        connStr.DbType = CurrentDbType.Oracle;
                        break;

                    case "MYSQL":
                        connStr.DbType = CurrentDbType.MySql;
                        break;

                    case "SQLLITE":
                        connStr.DbType = CurrentDbType.SQLite;
                        break;

                    case "DB2":
                        connStr.DbType = CurrentDbType.DB2;
                        break;

                    default:
                        connStr.DbType = CurrentDbType.SqlServer;
                        break;
                    }
                    connStr.DbLink = dataRow[CiDbLinkDefineTable.FieldLinkData].ToString();
                    DbLinks.Add(connStr);
                }
            }
        }
 /// <summary>
 /// 读取配置信息
 /// </summary>
 public static void GetSetting()
 {
     // 读取注册表
     if (BaseSystemInfo.ConfigurationFrom == ConfigurationCategory.RegistryKey)
     {
         RegistryHelper.GetConfig();
     }
     // 读取配置文件
     if (BaseSystemInfo.ConfigurationFrom == ConfigurationCategory.Configuration)
     {
         ConfigurationHelper.GetConfig();
     }
     // 读取个性化配置文件
     if (BaseSystemInfo.ConfigurationFrom == ConfigurationCategory.UserConfig)
     {
         UserConfigHelper.GetConfig();
     }
 }
Example #5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            SystemInfo.EnableRecordLog = true;
            SystemInfo.StartupPath     = Application.StartupPath;
            UserConfigHelper.GetConfig();
            System.Console.ForegroundColor = ConsoleColor.Red;
            System.Console.WriteLine(@"服务器端正在启动...");
            System.Console.ForegroundColor = ConsoleColor.White;
            // 读取配置文件
            var configuration            = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location);
            var serviceModelSectionGroup = (ServiceModelSectionGroup)configuration.GetSectionGroup("system.serviceModel");
            // 开启每个服务
            var idxService = 1;

            if (serviceModelSectionGroup != null)
            {
                foreach (var serviceHost in from ServiceElement serviceElement in serviceModelSectionGroup.Services.Services
                         let assemblyString = serviceElement.Name.Substring(0, serviceElement.Name.LastIndexOf('.'))
                                              select new System.ServiceModel.ServiceHost(Assembly.Load(assemblyString).GetType(serviceElement.Name), serviceElement.Endpoints[0].Address))
                {
                    serviceHost.Opened += delegate
                    {
                        Console.WriteLine(@"第{0:00}个服务:{1}", idxService, serviceHost.BaseAddresses[0]);
                    };
                    serviceHost.Open();
                    idxService++;
                }


                /* V2.7版本时的方法
                 * foreach (ServiceElement serviceElement in serviceModelSectionGroup.Services.Services)
                 * {
                 *  var assemblyString = serviceElement.Name.Substring(0, serviceElement.Name.LastIndexOf('.'));
                 *  var serviceHost =
                 *      new System.ServiceModel.ServiceHost(Assembly.Load(assemblyString).GetType(serviceElement.Name),
                 *          serviceElement.Endpoints[0].Address);
                 *
                 *  serviceHost.Opened += delegate
                 *  {
                 *      Console.WriteLine(@"第{0:00}个服务:{1}", idxService, serviceHost.BaseAddresses[0]);
                 *  };
                 *  serviceHost.Open();
                 *  idxService++;
                 * }*/
            }
            System.Console.ForegroundColor = ConsoleColor.Green;
            System.Console.WriteLine(@"服务器端已正常启动...");
            System.Console.ForegroundColor = ConsoleColor.White;

            System.Console.WriteLine();
            System.Console.WriteLine();


            System.Console.WriteLine(@"服务器 当前时间:" + DateTime.Now.ToString(SystemInfo.DateTimeFormat));
            var dbProvider = DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConection);

            System.Console.WriteLine(@"数据库服务器 当前时间:" + dbProvider.GetDBDateTime());
            System.Console.WriteLine();

            // 写入调试信息
            #if (DEBUG)
            var rdiDBProviderService = new RDIFrameworkDBProviderService();
            System.Console.WriteLine(@"RDIFramework.NET ━ .NET快速信息化系统开发框架 数据库服务器数据库连接:");
            System.Console.WriteLine(rdiDBProviderService.ServiceDbConnection);
            System.Console.WriteLine(rdiDBProviderService.ExecuteScalar(SystemInfo.UserInfo, "SELECT GETDATE()").ToString());
            System.Console.WriteLine();

            var bizDBProviderService = new BusinessDBProviderService();
            System.Console.WriteLine(@"业务数据库服务器 数据库连接:");
            System.Console.WriteLine(bizDBProviderService.ServiceDbConnection);
            System.Console.WriteLine(bizDBProviderService.ExecuteScalar(SystemInfo.UserInfo, "SELECT GETDATE()").ToString());
            System.Console.ReadLine();
            #endif
            Application.Run(new FrmServiceHost());
        }
Example #6
0
 /// <summary>
 /// 获取配置信息
 /// </summary>
 public static void GetConfig()
 {
     // 读取客户端配置文件
     SystemInfo.ConfigurationFrom = ConfigurationCategory.UserConfig;
     UserConfigHelper.GetConfig();
 }
Example #7
0
        private void SaveConfigInfo()
        {
            //**********************************************************
            //一、客户端配置
            //**********************************************************
            SystemInfo.EncryptClientPassword = EncryptClientPassword.Checked;
            SystemInfo.AutoLogOn             = AutoLogOn.Checked;
            SystemInfo.RememberPassword      = RememberPassword.Checked;
            SystemInfo.LoadAllUser           = LoadAllUser.Checked;
            SystemInfo.EncryptDbConnection   = EncryptDbConnection.Checked;
            SystemInfo.ServiceUserName       = ServiceUserName.Text.Trim();
            SystemInfo.ServicePassword       = ServicePassword.Text.Trim();

            switch (RDIFrameworkDbType.Text.Trim())
            {
            case "SqlServer":
                SystemInfo.RDIFrameworkDbType = CurrentDbType.SqlServer;
                break;

            case "Oracle":
                SystemInfo.RDIFrameworkDbType = CurrentDbType.Oracle;
                break;

            case "MySql":
                SystemInfo.RDIFrameworkDbType = CurrentDbType.MySql;
                break;

            case "DB2":
                SystemInfo.RDIFrameworkDbType = CurrentDbType.DB2;
                break;

            case "Access":
                SystemInfo.RDIFrameworkDbType = CurrentDbType.Access;
                break;

            case "SQLite":
                SystemInfo.RDIFrameworkDbType = CurrentDbType.SQLite;
                break;

            default:
                SystemInfo.RDIFrameworkDbType = CurrentDbType.SqlServer;
                break;
            }
            SystemInfo.CurrentLanguage = CurrentLanguage.SelectedItem == null ? "zh-CN" : CurrentLanguage.SelectedItem.ToString();

            SystemInfo.RDIFrameworkDbConectionString = RDIFrameworkDbConection.Text.Trim();

            if (SystemInfo.EncryptDbConnection)
            {
                SystemInfo.RDIFrameworkDbConectionString = SecretHelper.AESEncrypt(SystemInfo.RDIFrameworkDbConectionString);
                SystemInfo.BusinessDbConnectionString    = SecretHelper.AESEncrypt(SystemInfo.BusinessDbConnectionString);
                SystemInfo.WorkFlowDbConnectionString    = SecretHelper.AESEncrypt(SystemInfo.WorkFlowDbConnectionString);
            }
            //**********************************************************
            //二、服务端配置
            //**********************************************************

            SystemInfo.AllowUserToRegister             = AllowUserToRegister.Checked;
            SystemInfo.EnableRecordLog                 = EnableRecordLog.Checked;
            SystemInfo.EnableCheckIPAddress            = EnableCheckIPAddress.Checked;
            SystemInfo.EnableUserAuthorization         = EnableUserAuthorization.Checked;
            SystemInfo.EnableModulePermission          = EnableModulePermission.Checked;
            SystemInfo.EnablePermissionItem            = EnablePermissionItem.Checked;
            SystemInfo.EnableTableFieldPermission      = EnableTableFieldPermission.Checked;
            SystemInfo.EnableTableConstraintPermission = EnableTableConstraintPermission.Checked;
            SystemInfo.EnableEncryptServerPassword     = EnableEncryptServerPassword.Checked;
            SystemInfo.EnableCheckPasswordStrength     = EnableCheckPasswordStrength.Checked;
            SystemInfo.NumericCharacters               = NumericCharacters.Checked;
            SystemInfo.CheckOnLine = CheckOnLine.Checked;
            SystemInfo.EnableOrganizePermission = EnableOrganizePermission.Checked;
            if (OnLineLimit.Text.Trim().Length > 0)
            {
                SystemInfo.OnLineLimit = OnLineLimit.Value;
            }

            if (OnLineTime0ut.Text.Trim().Length > 0)
            {
                SystemInfo.OnLineTime0ut = OnLineTime0ut.Value;
            }

            if (AccountMinimumLength.Text.Trim().Length > 0)
            {
                SystemInfo.AccountMinimumLength = AccountMinimumLength.Value;
            }

            if (PasswordChangeCycle.Text.Trim().Length > 0)
            {
                SystemInfo.PasswordChangeCycle = PasswordChangeCycle.Value;
            }

            if (PasswordErrorLockLimit.Text.Trim().Length > 0)
            {
                SystemInfo.PasswordErrorLockLimit = PasswordErrorLockLimit.Value;
            }

            if (PasswordErrorLockCycle.Text.Trim().Length > 0)
            {
                SystemInfo.PasswordErrorLockCycle = PasswordErrorLockCycle.Value;
            }

            SystemInfo.DefaultPassword = DefaultPassword.Text.Trim();

            if (PasswordMiniLength.Text.Trim().Length > 0)
            {
                SystemInfo.PasswordMiniLength = PasswordMiniLength.Value;
            }

            //**********************************************************
            //三、系统参数配置
            //**********************************************************
            SystemInfo.MainForm            = BusinessLogic.ConvertToString(MainForm.SelectedItem);
            SystemInfo.LogOnForm           = LogOnForm.Text.Trim();
            SystemInfo.LogOnAssembly       = LogOnAssembly.Text.Trim();
            SystemInfo.CustomerCompanyName = CustomerCompanyName.Text.Trim();
            //SystemInfo.ConfigurationFrom     = ConfigurationFrom.Text.Trim();
            SystemInfo.SoftName     = SoftName.Text.Trim();
            SystemInfo.SoftFullName = SoftFullName.Text.Trim();
            SystemInfo.Version      = Version.Text.Trim();
            SystemInfo.Service      = Service.Text.Trim();
            //SystemInfo.RegisterKey           = RegisterKey.Text;

            /**********************************************************
            * 四、错误报告反馈配置
            **********************************************************/
            SystemInfo.ErrorReportFrom         = ErrorReportFrom.Text.Trim();
            SystemInfo.ErrorReportMailServer   = ErrorReportMailServer.Text.Trim();
            SystemInfo.ErrorReportMailUserName = ErrorReportMailUserName.Text.Trim();
            SystemInfo.ErrorReportMailPassword = ErrorReportMailPassword.Text.Trim();


            UserConfigHelper.SaveConfig();
            //再次得到配置文件。这儿主要是对加密的数据在软件运行过程中是解密的。
            UserConfigHelper.GetConfig();
        }
Example #8
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns>是否成功</returns>
        private bool LogOn()
        {
            if (!BaseSystemInfo.UserIsLogOn && this.cmbLogOnTo.Enabled)
            {
                UserConfigHelper.LogOnTo = ((ListItem)this.cmbLogOnTo.SelectedItem).Id;
                // 读取配置文件
                UserConfigHelper.GetConfig();
            }

            string        statusCode    = string.Empty;
            string        statusMessage = string.Empty;
            DotNetService dotNetService = new DotNetService();
            BaseUserInfo  userInfo      = dotNetService.LogOnService.UserLogOn(UserInfo, this.txtUserName.Text, this.txtPassword.Text, true, out statusCode, out statusMessage);

            if (dotNetService.LogOnService is ICommunicationObject)
            {
                ((ICommunicationObject)dotNetService.LogOnService).Close();
            }
            if (statusCode == StatusCode.OK.ToString())
            {
                // 检查身份
                if ((userInfo != null) && (userInfo.Id.Length > 0))
                {
                    BaseSystemInfo.UserInfo = userInfo;
                    if (BaseSystemInfo.RememberPassword)
                    {
                        this.SaveLogOnInfo();
                    }

                    // 这里是登录功能部分
                    if (this.Parent == null)
                    {
                        this.Hide();
                        if (!BaseSystemInfo.UserIsLogOn)
                        {
                            Form mainForm = CacheManager.Instance.GetForm(BaseSystemInfo.MainAssembly, BaseSystemInfo.MainForm);
                            ((IBaseMainForm)mainForm).InitService();
                            ((IBaseMainForm)mainForm).InitForm();
                            mainForm.Show();
                        }
                    }
                    // 这里表示已经登录系统了
                    BaseSystemInfo.UserIsLogOn = true;
                    // 登录次数归零,允许重新登录
                    this.LogOnCount = 0;

                    // 打开这个窗体的主窗口
                    if (this.Owner != null)
                    {
                        ((IBaseMainForm)this.Owner).InitService();
                        ((IBaseMainForm)this.Owner).InitForm();
                        ((IBaseMainForm)this.Owner).CheckMenu();
                        return(true);
                    }
                    if (this.Parent != null)
                    {
                        // 重新获取登录状态信息
                        ((IBaseMainForm)this.Parent.Parent).InitService();
                        ((IBaseMainForm)this.Parent.Parent).InitForm();
                        ((IBaseMainForm)this.Parent.Parent).CheckMenu();
                        this.Close();
                    }
                }
            }
            else
            {
                MessageBox.Show(statusMessage, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtPassword.Focus();
                this.txtPassword.SelectAll();
                return(false);
            }
            return(true);
        }
Example #9
0
 private void btnOuter_Click(object sender, EventArgs e)
 {
     this.SelectNetwork = "Outer";
     UserConfigHelper.GetConfig();
     this.Close();
 }