Exemple #1
0
 private void CheckClientVer()
 {
     //检查DUMMY表,仅用于强行使用户不能使用旧版本的客户端程序
     /*System.Data.DataTable tbldummy = CustomClassCache.GetDataTableWithKey("select * from sys_dummy_1");*/
     System.Data.DataTable tbldummy = CustomClassCache.GetDataTableWithKeyProxy("sys_dummy_1");
     tbldummy.Dispose();
 }
Exemple #2
0
        private void CheckACL()
        {
            //if (MainForm.conn.Database.ToString().ToLower() == "s3design" || MainForm.conn.Database.ToString().ToLower() == "s3design_debug")
            //{
            //    return; //不检查调试库中的内容
            //}

            CheckClientVer();

            //检查是否用户访问列表中的用户,否则拒绝进入
            string strHost = Helper.GetHostName().ToLower();
            string _sql    = string.Format("SELECT * FROM sys_useracl WHERE userid = '{0}'", strHost);
            /*System.Data.DataTable tbl = CustomClassCache.GetDataTableWithKey(_sql);*/
            string filter = string.Format("userid = '{0}'", strHost);

            System.Data.DataTable tbl = CustomClassCache.GetDataTableWithKeyProxy("sys_useracl", filter, null);

            //System.Data.DataRow row = null;
            bool bFind = false;

            System.Net.IPAddress[] ips = Helper.GetIPAddresses();
            foreach (System.Data.DataRow r in tbl.Rows)
            {
                foreach (System.Net.IPAddress ip in ips)
                {
                    if (r["ip"].ToString().Trim() == ip.ToString())
                    {
                        bFind = true;

                        // 更新信息
                        _hostname  = Helper.GetHostName();
                        _ip        = Helper.GetIPAddress();
                        _userindex = r["_index"].ToString().Trim();
                        //todo: 以后要从本地ini取
                        _username = string.Empty;
                        _psw      = string.Empty;

                        break;
                    }
                }
            }
            if (!bFind)
            {
                throw new Exception("无权访问!");
            }
        }
Exemple #3
0
        /*
         * private void InitUserAclDesc()
         * {
         *
         *  conn.Open();
         *  SqlCommand sqlCmd = new SqlCommand("delete from sys_useracl_desc", conn);
         *  sqlCmd.ExecuteNonQuery();
         *  sqlCmd.Dispose();
         *  conn.Close();
         *
         *  DataTable tblAcl = Helper.GetDataTable("select userid,_index from sys_useracl", conn);
         *  DataTable tblModl = Helper.GetDataTable("select id,modelname_en from sys_modl_def", conn);
         *  DataTable tblAclDesc = Helper.GetDataTable("select * from sys_useracl_desc", conn);
         *  SqlDataAdapter adp = new SqlDataAdapter("select * from sys_useracl_desc", conn);
         *
         *  foreach (DataRow rowAcl in tblAcl.Rows)
         *  {
         *      foreach (DataRow rowModl in tblModl.Rows)
         *      {
         *          DataRow rowDesc = tblAclDesc.NewRow();
         *          rowDesc.BeginEdit();
         *          rowDesc["userindex"] = rowAcl["_index"];
         *          rowDesc["moduleid"] = rowModl["id"];
         *          rowDesc["groupname"] = "";
         *          rowDesc["modulename_en"] = rowModl["modelname_en"];
         *          rowDesc["canread"] = 1;
         *          rowDesc["canwrite"] = 1;
         *          rowDesc["canimport"] = 1;
         *          rowDesc["canconfigmeta"] = 1;
         *          rowDesc.EndEdit();
         *          tblAclDesc.Rows.Add(rowDesc);
         *      }
         *  }
         *
         *  SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adp);
         *  adp.InsertCommand = cmdBuilder.GetInsertCommand();
         *  int val = adp.Update(tblAclDesc);
         *  tblAclDesc.AcceptChanges();
         * }
         * private void InitUserAclDesc2()
         * {
         *
         *  DataTable tblAcl = Helper.GetDataTable("select userid,_index from sys_useracl", conn);
         *  SqlDataAdapter adp = new SqlDataAdapter("select * from sys_useracl_desc", conn);
         *  DataTable tblAclDesc = Helper.GetDataTable("select * from sys_useracl_desc", conn);
         *  foreach (DataRow rowDesc in tblAclDesc.Rows)
         *  {
         *      rowDesc.BeginEdit();
         *      int userid = Convert.ToInt32(rowDesc["userindex"]);
         *      string username = tblAcl.Rows.Find(userid)["userid"].ToString().Trim();
         *      string s = username.Substring(0, 1).ToLower();
         *      if (string.Compare(s, "j") <= 0)
         *          rowDesc["groupname"] = "A - J";
         *      else if (string.Compare(s, "s") <= 0)
         *          rowDesc["groupname"] = "K - S";
         *      else if (string.Compare(s, "x") <= 0)
         *          rowDesc["groupname"] = "T - X";
         *      else
         *          rowDesc["groupname"] = "Y - Z";
         *      rowDesc.EndEdit();
         *
         *  }
         *  SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adp);
         *  adp.UpdateCommand = cmdBuilder.GetUpdateCommand();
         *  int val = adp.Update(tblAclDesc);
         *  tblAclDesc.AcceptChanges();
         * }
         *
         * private void GenQuestText()
         * {
         *  string Output = "剑侠情缘网络版叁 任务脚本\r\n\r\n\r\n";
         *
         *  StringBuilder sb = new StringBuilder();
         *  DataTable tblQuest = Helper.GetDataTable("select questname, objective, description, dunningdialogue, unfinisheddialogue, finisheddialogue from tbl_quests order by class, questid", conn);
         *  foreach (DataRow row in tblQuest.Rows)
         *  {
         *      if (row["QuestName"].ToString().Length != 0)
         *      {
         *          sb.Append("任务名称:");
         *          sb.Append(row["QuestName"].ToString());
         *          sb.Append("\r\n任务目标:");
         *          sb.Append(row["Objective"].ToString());
         *          sb.Append("\r\n任务描述:");
         *          sb.Append(row["Description"].ToString());
         *          sb.Append("\r\n未完成对话1:");
         *          sb.Append(row["DunningDialogue"].ToString());
         *          sb.Append("\r\n未完成对话2:");
         *          sb.Append(row["UnfinishedDialogue"].ToString());
         *          sb.Append("\r\n完成对话:");
         *          sb.Append(row["FinishedDialogue"].ToString());
         *          sb.Append("\r\n\r\n");
         *      }
         *  }
         *
         *  Output += sb.ToString();
         *  Output = Output.Replace("<G>", string.Empty);
         *  Output = Output.Replace("\\n", string.Empty);
         *  Output = Output.Replace("<C>", string.Empty);
         *  Output = Output.Replace("<H28>", string.Empty);
         *  Output = Output.Replace("<N>", string.Empty);
         *  FileFolderHelper.StringToFile(Output, "c:/q.txt");
         * }
         * private void GenNpcText()
         * {
         *  string Output = "剑侠情缘网络版叁 任务脚本\r\n\r\n\r\n";
         *
         *  StringBuilder sb = new StringBuilder();
         *  DataTable tblNpc = Helper.GetDataTable("select name, idledialog1, idledialog2, idledialog3, idledialogafterquest from npctemplate order by mapname, id", conn);
         *  foreach (DataRow row in tblNpc.Rows)
         *  {
         *      if (row["IdleDialog1"].ToString().Length != 0)
         *      {
         *          sb.Append("NPC名称:");
         *          sb.Append(row["Name"].ToString());
         *          sb.Append("\r\n待机对话1:");
         *          sb.Append(row["IdleDialog1"].ToString());
         *          sb.Append("\r\n待机对话2:");
         *          sb.Append(row["IdleDialog2"].ToString());
         *          sb.Append("\r\n待机对话3:");
         *          sb.Append(row["IdleDialog3"].ToString());
         *          sb.Append("\r\n任务后待机对话:");
         *          sb.Append(row["IdleDialogAfterQuest"].ToString());
         *          sb.Append("\r\n\r\n");
         *      }
         *  }
         *
         *  Output += sb.ToString();
         *  Output = Output.Replace("<G>", string.Empty);
         *  Output = Output.Replace("\\n", string.Empty);
         *  Output = Output.Replace("<C>", string.Empty);
         *  Output = Output.Replace("<H28>", string.Empty);
         *  Output = Output.Replace("<N>", string.Empty);
         *  FileFolderHelper.StringToFile(Output, "c:/n.txt");
         * }
         * private void OldIpToNewIp()
         * {
         *  string sql = "select * from sys_useracl";
         *  SqlDataAdapter adp = new SqlDataAdapter(sql, conn);
         *  DataTable tbl = Helper.GetDataTable(sql, conn);
         *  foreach (DataRow row in tbl.Rows)
         *  {
         *      string hostname = row["userid"].ToString().Trim();
         *      System.Net.IPHostEntry ipEntry = null;
         *      try
         *      {
         *          ipEntry = System.Net.Dns.GetHostByName(hostname);
         *      }
         *      catch (Exception ex)
         *      {
         *          if ((ex as System.Net.Sockets.SocketException) != null)
         *              ipEntry = null;
         *      }
         *      if (ipEntry == null)
         *          continue;
         *
         *      //获取IP地址列表
         *      foreach (System.Net.IPAddress ip in ipEntry.AddressList)
         *      {
         *          string strIp = ip.ToString();
         *          if (strIp.StartsWith("10.20."))
         *          {
         *              row["ip"] = strIp;
         *          }
         *      }
         *
         *  }
         *
         *  SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adp);
         *  adp.UpdateCommand = cmdBuilder.GetUpdateCommand();
         *  int val = adp.Update(tbl);
         *  tbl.AcceptChanges();
         * }
         */
        private void MainForm_Load(object sender, EventArgs e)
        {
            //InitUserAclDesc();
            //InitUserAclDesc2();
            //GenQuestText();
            //GenNpcText();
            //OldIpToNewIp();

            //Helper.LockWndUpdate(this);
            try
            {
                //System.Diagnostics.Process.Start("regsvr32.exe   /s", "atlax.dll");

                //InitConn();

                tabStrip1.MdiForm = this;
                m_debugform       = new ScriptDebugForm();
                m_codeform        = new ScriptCodeForm(this);

                // 从sys_modl_def读取功能模块信息 只列出来该用户可读的
                string sql;
                if (Program.m_bUseNewAcl)
                {
                    sql = string.Format("SELECT * FROM sys_modl_def WHERE (id IN (SELECT moduleid FROM sys_useracl_desc WHERE userindex = {0} AND canread = 1))", Program.m_rightmgr._userindex);
                }
                else
                {
                    sql = "SELECT * FROM sys_modl_def";
                }

                string[]  names = new string[] { "sys_modl_def", "sys_useracl_desc" };
                DataTable tbl   = Helper.GetDataTableWithSqlProxy(names, sql, conn);
                cmdModels = new ButtonItem[tbl.Rows.Count];
                int i = 0;
                // 绑定新的点击事件处理方法
                customizeItem1.Click += new EventHandler(bConfigModel_Click);

                foreach (DataRow row in tbl.Rows)
                {
                    cmdModels[i] = new ButtonItem();
                    this.moduletoolbar.Items.AddRange(new BaseItem[] { cmdModels[i] });
                    cmdModels[i].Name       = "cmd" + row["modelname_en"] + "editor";
                    cmdModels[i].GlobalName = cmdModels[i].Name;
                    //cmdModels[i].ImageIndex = Convert.ToInt32(row["iconid"]);
                    if (Convert.ToInt32(row["iconid"]) < imageList2.Images.Count)
                    {
                        if (Convert.ToInt32(row["iconid"]) == -1) // 自定义图标
                        {
                            cmdModels[i].Image = GetImageFromDataBase(row);
                        }
                        else
                        {
                            cmdModels[i].Image = imageList2.Images[Convert.ToInt32(row["iconid"])];
                        }
                    }
                    cmdModels[i].PopupAnimation = DevComponents.DotNetBar.ePopupAnimation.SystemDefault;
                    if (!(row["displaystyle"] is DBNull)) // 自定义显示样式不为空
                    {
                        cmdModels[i].Text    = row["displaytext"].ToString();
                        cmdModels[i].Tooltip = row["modelname_en"].ToString();

                        switch (row["displaystyle"].ToString())
                        {
                        case "0":     // 默认样式
                        {
                            cmdModels[i].ButtonStyle = eButtonStyle.Default;
                            break;
                        }

                        case "1":     // 单一文本
                        {
                            cmdModels[i].ButtonStyle = eButtonStyle.TextOnlyAlways;
                            break;
                        }

                        case "2":     // 图文混合
                        {
                            cmdModels[i].ButtonStyle = eButtonStyle.ImageAndText;
                            break;
                        }
                        }
                    }
                    else
                    {
                        cmdModels[i].Text    = row["modelname_en"].ToString();
                        cmdModels[i].Tooltip = cmdModels[i].Text;
                    }

                    cmdModels[i].Click += new System.EventHandler(this.cmdNewModelEditor_Click);
                    imageTable[row["id"].ToString()] = cmdModels[i]; // 记录模块id对应的Button
                    cmdModels[i].Tag = row["id"].ToString();         // 记录该模块的id
                }
                moduletoolbar.RecalcLayout();
                FileInfo _fi = new FileInfo("_layout.xml");
                FileInfo fi  = new FileInfo("layout.xml");
                if (_fi.Exists)
                {
                    dotNetBarManager1.LoadLayout("_layout.xml"); // 读取布局设置
                }
                else if (fi.Exists)
                {
                    dotNetBarManager1.LoadLayout("layout.xml"); // 读取布局设置
                }

                // 从配置文件中读取模块显示的自定义内容
                ReloadButtonItems(LoadModelConfigInfo());

                //初始化状态条内容
                LDBName.Text   = conn.DataSource + " : " + conn.Database;
                LHostName.Text = Helper.GetHostName() + " : " + Helper.GetIPAddress();

                //谁要是再截屏,hehe
                try
                {
                    string strHost = Helper.GetHostName().ToLower();
                    string _sql    = string.Format("select * from sys_useracl where userid = '{0}'", strHost);

                    /*DataTable tbl_acl = CustomClassCache.GetDataTableWithKey(_sql);*/

                    string    filter  = string.Format("userid = '{0}'", strHost);
                    DataTable tbl_acl = CustomClassCache.GetDataTableWithKeyProxy("sys_useracl", filter, null);

                    DataRow row_acl = tbl_acl.Rows[0];
                    this.Text = string.Format("剑3游戏设计工具(1.0.2.{0})", row_acl["_index"].ToString().Trim());

                    if (Program.forPublic)
                    {
                        this.Text = string.Format("策划工具(1.0.2.{0})", row_acl["_index"].ToString().Trim());
                    }
                }
                catch (Exception)
                {
                    Helper.AddLog("出错啦~~~");
                }
            }
            catch (Exception ex)
            {
                Helper.AddLog(ex.Message);
                this.Close();
                throw;
            }
            finally
            {
                //Helper.LockWndUpdate(null);
            }
        }