コード例 #1
0
ファイル: FormLock.cs プロジェクト: xuanximoming/key
        /// <summary>
        /// Init
        /// </summary>
        private void Init()
        {
            try
            {
                //// 隐藏任务栏
                //IntPtr trayHwnd = FindWindow("Shell_TrayWnd", null);
                //ShowWindow(trayHwnd, 0);


                //// 禁用windows热键
                //intLLKey = SetWindowsHookEx(13, DisableHotkeys, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]).ToInt32(), 0);


                this.FormBorderStyle = FormBorderStyle.FixedDialog;//no title
                m_SqlHelper          = DataAccessFactory.DefaultDataAccess;

                m_Logger      = new DrectSoftLog("系统锁屏模块跟踪");
                m_CurrentUser = FormMain.Instance.User;
                m_Account     = new Account();

                InitControls();

                // 禁用任务管理器
                //RegistryKey regkey = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\System");
                //regkey.SetValue("DisableTaskMgr", 1, RegistryValueKind.DWord);
                //regkey.Close();
            }
            catch (Exception ex)
            {
                m_Logger.Error(ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// 替换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Save_Click(object sender, EventArgs e)
        {
            DataTable dt = (DataTable)gridControl1.DataSource;

            if (null == dt || dt.Rows.Count == 0)
            {
                MyMessageBox.Show("模板列表为空,请先将左侧需要删除日志的模板移动到右侧列表。", "提示", MyMessageBoxButtons.Ok, DrectSoft.Common.Ctrs.DLG.MessageBoxIcon.WarningIcon);
                return;
            }

            SetWaitDialogCaption("正在批量清除模板日志内容...");

            Emrtemplet m_Emrtemplet;
            //循环替换页眉页脚
            int losecnt    = 0;
            int successcnt = 0;

            foreach (DataRow dr in ((DataTable)gridControl1.DataSource).Rows)
            {
                try
                {
                    m_Emrtemplet = m_SQLManger.GetTemplet(dr["ID"].ToString());

                    //if (chk_Title.Checked)
                    //    m_Emrtemplet.XML_DOC_NEW = ReplaceTitle(m_Emrtemplet.XML_DOC_NEW);
                    //if (chk_Foot.Checked)
                    m_Emrtemplet.XML_DOC_NEW = ReplaceSaveLog(m_Emrtemplet.XML_DOC_NEW);

                    m_SQLManger.BatchSaveTemplet(m_Emrtemplet, "2");
                }
                catch (Exception ex)
                {
                    losecnt++;
                    m_Logger.Error("模板批量删除日志信息错误日志:" + "\t" + "模板TempletID:" + dr["ID"] + "\t" + ex.Message);

                    continue;
                }
                successcnt++;
            }

            HideWaitDialog();

            string mess = "";

            if (successcnt > 0)
            {
                mess = "替换成功,成功替换了【" + successcnt.ToString() + "】条记录。";
                if (losecnt > 0)
                {
                    mess += "\n其中有【" + losecnt + "】条记录未替换成功,\n未成功记录请查看服务器上\\Logs下日志信息。";
                }
                m_app.CustomMessageBox.MessageShow(mess);
            }
            else
            {
                m_app.CustomMessageBox.MessageShow("替换失败,有【" + losecnt + "】条记录未替换成功。\n未成功记录请查看服务器上\\Logs下日志信息。");
            }
        }
コード例 #3
0
 private void InitializeUI()
 {
     //TODO
     // 调出背景图
     try
     {
         // 加载登录按钮图标
         buttonLogIn.BackgroundImageLayout = ImageLayout.Stretch;
         //add by xjt,2010-05-26,读取锁屏后,重新选择的用户ID
         if (Program.m_StrUserId != string.Empty && Program.m_StrUserId != null)
         {
             this.textBoxUserID.Text = Program.m_StrUserId;
         }
         Program.m_StrUserId = string.Empty;
         //add end,xjt
     }
     catch (System.IO.IOException ex)
     {
         m_Log.Error("加载窗口背景图失败:" + ex.Message + "");
     }
 }
コード例 #4
0
ファイル: FormLock.cs プロジェクト: xuanximoming/key
 private void FormLock_Load(object sender, EventArgs e)
 {
     try
     {
         Init();
     }
     catch (Exception ex)
     {
         m_Logger.Error(ex);
     }
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        /// <summary>
        /// 替换事件
        /// edit by Yanqiao.Cai 2012-11-06
        /// add try ... catch
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                string errorStr = CheckItem();
                if (!string.IsNullOrEmpty(errorStr))
                {
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(errorStr);
                    return;
                }
                if (DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("您确定要批量替换" + (chk_Title.Checked ? "页眉" : "") + (chk_Foot.Checked ? "页脚" : "") + "吗?该操作不可恢复。", "批量替换页眉页脚", DrectSoft.Common.Ctrs.DLG.MyMessageBoxButtons.OkCancel) == DialogResult.Cancel)
                {
                    return;
                }

                SetWaitDialogCaption("正在批量替换" + (chk_Title.Checked ? "页眉" : "") + (chk_Foot.Checked ? "页脚" : "") + "...");

                GetHeaderFootEntity();

                Emrtemplet m_Emrtemplet;
                //循环替换页眉页脚
                int losecnt    = 0;
                int successcnt = 0;
                foreach (DataRow dr in ((DataTable)gridControl1.DataSource).Rows)
                {
                    try
                    {
                        m_Emrtemplet = m_SQLManger.GetTemplet(dr["ID"].ToString());

                        if (chk_Title.Checked)
                        {
                            m_Emrtemplet.XML_DOC_NEW = ReplaceTitle(m_Emrtemplet.XML_DOC_NEW);
                        }
                        if (chk_Foot.Checked)
                        {
                            m_Emrtemplet.XML_DOC_NEW = ReplaceFoot(m_Emrtemplet.XML_DOC_NEW);
                        }

                        m_SQLManger.BatchSaveTemplet(m_Emrtemplet, "2");
                    }
                    catch (Exception ex)
                    {
                        losecnt++;
                        //Log log = new Log();
                        //log.Write("模板批量替换页眉页脚错误日志:" + "\t" + "模板TempletID:" + dr["ID"] + ex.Message);
                        //(new Log()).Write("模板批量替换页眉页脚错误日志:" + "\t" + "模板TempletID:" + dr["ID"] + ex.Message);
                        m_Logger.Error("模板批量替换页眉页脚错误日志:" + "\t" + "模板TempletID:" + dr["ID"] + "\t" + ex.Message);
                        //m_Logger.Info("模板批量替换页眉页脚错误日志:" + "\t" + "模板TempletID:" + dr["ID"] + "\t" + ex.Message);
                        continue;
                    }
                    successcnt++;
                }

                HideWaitDialog();

                string mess = "";
                if (successcnt > 0)
                {
                    mess = "替换成功,成功替换了【" + successcnt.ToString() + "】记录。";
                    if (losecnt > 0)
                    {
                        mess += "\n其中有【" + losecnt + "】条记录未替换成功,\n未成功记录请查看服务器上\\Logs下日志信息。";
                    }
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(mess);
                }
                else
                {
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("替换失败,有【" + losecnt + "】条记录未替换成功,\n未成功记录请查看服务器上\\Logs下日志信息。");
                }
            }
            catch (Exception ex)
            {
                HideWaitDialog();
                DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(1, ex);
            }
        }