Exemple #1
0
        bool LoginDb()
        {
            try
            {
                if (m_TempUserID.Contains("用户已过期"))
                {
                    throw new InvalidUserIdException("用户已过期");
                }
                m_Acnt.Login(m_TempUserID, textBoxPassword.Text, 0);

                //Add By wwj 2011-06-07
                string masterID = m_Acnt.User.MasterID;//得到带教老师的ID
                if (!string.IsNullOrEmpty(masterID))
                {
                    m_MasterAcnt.InitMaster(masterID);//初始化带教老师用户信息
                }

                //m_Bizbus.UpdateObject<Users>("CurrentUser", user);
                m_Log.Info("用户:" + m_Acnt.User.Name + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "成功登录系统");
            }
            catch (Exception ex)
            {
                textBoxUserID.Focus();
                textBoxUserID.Text = ex.Message;
                textBoxUserID.SelectAll();
                progressBarControlWait.Position = 0;
                return(false);
            }

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// 通过给定的文件加载控件菜单
        /// </summary>
        /// <param name="appPath"></param>
        /// <param name="menufile"></param>
        public void RegisterPlugins(string appPath, params string[] menufile)
        {
            //装载插件文件夹下所有插件,注册成插件菜单
            this.pluginMenu = PlugInLoadHelper.LoadAllPlugIns(appPath, _startupInterface, menufile);
            //this.RegisterMenuPlugins();

            _log.Info("Menu Reader Over");
        }
Exemple #3
0
        /// <summary>
        /// 若用原始用户登录,直接验证信息
        /// </summary>
        /// <returns></returns>
        private bool LoginDb()
        {
            try
            {
                IUser user = m_Account.Login(this.lookUpEditorLock.CodeValue, textEditPassWord.Text, 0);
                m_Logger.Info("用户:" + user.Name + "于" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "成功登录系统");
            }
            catch (Exception ex)
            {
                //todo
                textEditPassWord.SelectAll();
                textEditPassWord.Focus();
                return(false);
            }

            return(true);
        }
        private bool CreatePlugInConfiguration()
        {
            if (!File.Exists(_configFileName))
            {
                _log.Warn("文件[" + _configFileName + "]不存在!");

                //不存在,需要自动创建XML文档,所有信息由自定制的特性得到,
                XmlTextWriter emptyXmlDoc = new XmlTextWriter(_configFileName, Encoding.Default);
                emptyXmlDoc.WriteStartDocument();
                emptyXmlDoc.WriteStartElement("config");
                emptyXmlDoc.WriteEndElement();
                emptyXmlDoc.Flush();
                emptyXmlDoc.Close();
            }

            //创建菜单的XML文档
            XmlDocument plugInDoc = new XmlDocument();

            try {
                plugInDoc.Load(_configFileName);
            }
            catch {
                _log.Error("载入菜单文档时出错!\n");
                throw;
            }

            if (_plugInLoader == null)
            {
                throw new ArgumentNullException("plugInLoader", "指定的加载域为空");
            }

            //遍历指定路径的满足条件的插件
            string[]      paths       = _assemblySetPath.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            List <string> plugInFiles = new List <string>();

            foreach (string path in paths)
            {
                string[] plgs = Directory.GetFiles(path, "*.dll");
                plugInFiles.AddRange(plgs);
            }
            foreach (string pluginfile in plugInFiles)
            {
                //创建读取插件模块的自制特性
                try {
                    //Assembly assembly = Assembly.LoadFrom(plugInFiles[i]);
                    Assembly assembly = _plugInLoader.RemoteLoadAssembly(pluginfile);

                    if (assembly == null)
                    {
                        continue;
                    }
                    AttributesReader attrReader = new AttributesReader(assembly);

                    PluginAttribute[] attrPlugInInfo = attrReader.GetPlugInMenuInfoAttribute();
                    for (int menuIndex = 0; menuIndex < attrPlugInInfo.Length; menuIndex++)
                    {
                        if (!(attrPlugInInfo[menuIndex] is ClientPluginAttribute))
                        {
                            continue;
                        }
                        ClientPluginAttribute attrMenuPluginInfo = attrPlugInInfo[menuIndex] as ClientPluginAttribute;

                        //检查所给定的启动类是否实现了_assemblyIntfType接口
                        Type startupInterfaceType = attrMenuPluginInfo.StartupClassType.GetInterface(_assemblyInterfaceType);
                        if (startupInterfaceType == null)
                        {
                            _log.Warn("所给定的启动类没有实现[" + _assemblyInterfaceType + "]接口!");
                            break;
                        }

                        XmlNode plugInNode = plugInDoc.DocumentElement.SelectSingleNode(
                            "//plugin[@library='" + Path.GetFileName(pluginfile) + "'"
                            + " and @class='" + attrMenuPluginInfo.StartupClassType.FullName + "']");
                        if (plugInNode != null)
                        {
                            break;
                        }

                        Hashtable ht = new Hashtable();
                        ht.Add("caption", attrMenuPluginInfo.MenuNameSubsystem);
                        XmlNode subSystemRootNode = FindAndCreateXmlNode(plugInDoc, plugInDoc.DocumentElement
                                                                         , "system[@caption='" + attrMenuPluginInfo.MenuNameSubsystem + "']"
                                                                         , "system", ht);

                        ht.Clear();
                        ht.Add("caption", attrMenuPluginInfo.MenuNameParent);
                        XmlNode subSystemPlugInsNode = FindAndCreateXmlNode(plugInDoc, subSystemRootNode
                                                                            , "plugins[@caption='" + attrMenuPluginInfo.MenuNameParent + "']"
                                                                            , "plugins", ht);

                        ht.Clear();
                        ht.Add("caption", attrMenuPluginInfo.MenuNameAssembly);
                        ht.Add("library", Path.GetFileName(pluginfile));
                        ht.Add("class", attrMenuPluginInfo.StartupClassType.FullName);
                        if (!String.IsNullOrEmpty(attrMenuPluginInfo.IconName))
                        {
                            ht.Add("iconname", attrMenuPluginInfo.IconName);
                        }

                        FindAndCreateXmlNode(plugInDoc, subSystemPlugInsNode
                                             , "plugin[@library='" + Path.GetFileName(pluginfile) + "'"
                                             + " and @class='" + attrMenuPluginInfo.StartupClassType.FullName + "']"
                                             , "plugin", ht);
                    }
                }
                catch (Exception e) {
                    _log.Error(e.ToString());
                    continue;
                }
            }

            plugInDoc.Save(_configFileName);

            _log.Info("Config文件更新完成");

            return(true);
        }