private static List <Elf32_Sym> InitializeSymtab(BinaryReader elf, List <SectionHeader> sections, int symtabId) { SectionHeader symtab = sections[symtabId]; SectionHeader strtab = sections[symtab.sh_link]; List <Elf32_Sym> symbols = new List <Elf32_Sym>(); var elements = symtab.sh_size / symtab.sh_entsize; elf.BaseStream.Position = symtab.sh_offset; for (int i = 0; i < elements; i++) { var symbol = new Elf32_Sym(elf); symbols.Add(symbol); } elf.BaseStream.Position = strtab.sh_offset; MemoryStream ms = new MemoryStream(elf.ReadBytes(strtab.sh_size)); foreach (var symbol in symbols) { ms.Position = symbol.st_name; symbol.Name = CStr.Get(ms); //if (symbol.st_shndx > 0 && symbol.st_shndx < sections.Count) //{ // var section = sections[symbol.st_shndx]; // if (section.NS == null) // continue; // symbol.st_value += section.NS.Addr; // symbol.st_shndx = Elf32_Sym.ABS; //} } return(symbols); }
private static string ParseG_NOOP(BinaryReader br, Microcode microcode, bool simpleParse) { string result = string.Empty; if (microcode.EncodingLow == 0 || simpleParse) { return(result); } if (microcode.EncodingLow >> 24 != 0x80 && microcode.EncodingLow >> 24 != 0x00) { return(result); } var jumpBack = br.BaseStream.Position; br.BaseStream.Position = microcode.EncodingLow & 0xFFFFFF; Encoding enc = Encoding.GetEncoding("EUC-JP"); result = CStr.Get(br.BaseStream, enc, 0x100); br.BaseStream.Position = jumpBack; return(result); }
/// <summary> /// 重绘方法 /// </summary> /// <param name="paint">绘图对象</param> public void OnPaint(CPaint paint) { RECT rect = Bounds; int width = rect.right - rect.left; int height = rect.bottom - rect.top; if ((rect.left >= 0 || rect.top >= 0 || rect.right >= 0 || rect.bottom >= 0) && width > 0 && height > 0) { //绘制背景 paint.FillRect(BackColor, rect); String text = CStr.GetValueByDigit(Value, m_gannSquare.Digit); String suffix = m_gannSquare.Suffix; if (suffix != null && suffix.Length > 0) { text += suffix; } SIZE textSize = paint.TextSize(text, m_gannSquare.CellFont); //画文字 POINT tPoint = new POINT(rect.left + (width - textSize.cx) / 2, rect.top + (height - textSize.cy) / 2); RECT tRect = new RECT(tPoint.x, tPoint.y, tPoint.x + textSize.cx, tPoint.y + textSize.cy); paint.DrawText(text, ForeColor, m_gannSquare.CellFont, tRect); //绘制边线 paint.DrawLine(COLOR.ARGB(167, 170, 178), 0, 0, rect.left, rect.top, rect.right, rect.top); paint.DrawLine(COLOR.ARGB(167, 170, 178), 0, 0, rect.right, rect.top, rect.right, rect.bottom); } }
private static List <SectionHeader> GetSections(BinaryReader elf, FileHeader header) { List <SectionHeader> sections = new List <SectionHeader>(); elf.BaseStream.Position = header.e_shoff; for (int i = 0; i < header.e_shnum; i++) { var section = new SectionHeader(elf); sections.Add(section); } //set section names var shstr = sections[header.e_shstrndx]; elf.BaseStream.Position = shstr.sh_offset; MemoryStream ms = new MemoryStream(elf.ReadBytes(shstr.sh_size)); foreach (var section in sections) { ms.Position = section.sh_name; section.Name = CStr.Get(ms); } return(sections); }
/// <summary> /// 设置属性 /// </summary> /// <param name="name">名称</param> /// <param name="value">值</param> public override void SetProperty(string name, string value) { if (name == "showmaxbox") { ShowMaxBox = CStr.ConvertStrToBool(value); } else if (name == "showminbox") { ShowMinBox = CStr.ConvertStrToBool(value); } else if (name == "windowstate") { String str = value.ToLower(); if (str == "max") { WindowState = WindowStateA.Max; } else if (str == "min") { WindowState = WindowStateA.Min; } else if (str == "normal") { WindowState = WindowStateA.Normal; } } else { base.SetProperty(name, value); } }
/// <summary> /// 绘制有下划线的数字 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="value">值</param> /// <param name="digit">保留小数位数</param> /// <param name="font">字体</param> /// <param name="fontColor">文字颜色</param> /// <param name="zeroAsEmpty">0是否为空</param> /// <param name="x">横坐标</param> /// <param name="y">纵坐标</param> /// <returns>绘制的横坐标</returns> public static int DrawUnderLineNum(CPaint paint, double value, int digit, FONT font, long fontColor, bool zeroAsEmpty, int x, int y) { if (zeroAsEmpty && value == 0) { String text = "-"; SIZE size = paint.TextSize(text, font); CDraw.DrawText(paint, text, fontColor, font, x, y); return(size.cx); } else { String[] nbs = CStr.GetValueByDigit(value, digit).Split(new String[] { "." }, StringSplitOptions.RemoveEmptyEntries); if (nbs.Length == 1) { SIZE size = paint.TextSize(nbs[0], font); CDraw.DrawText(paint, nbs[0], fontColor, font, x, y); return(size.cx); } else { SIZE decimalSize = paint.TextSize(nbs[0], font); SIZE size = paint.TextSize(nbs[1], font); CDraw.DrawText(paint, nbs[0], fontColor, font, x, y); CDraw.DrawText(paint, nbs[1], fontColor, font, x + decimalSize.cx + 1, y); paint.DrawLine(fontColor, 1, 0, x + decimalSize.cx + 1, y + decimalSize.cy, x + decimalSize.cx + size.cx, y + decimalSize.cy); return(decimalSize.cx + size.cx); } } }
/// <summary> /// 获取属性 /// </summary> /// <param name="name">名称</param> /// <param name="value">值</param> /// <param name="type">类型</param> public override void GetProperty(string name, ref string value, ref string type) { if (name == "showmaxbox") { type = "bool"; value = CStr.ConvertBoolToStr(ShowMaxBox); } else if (name == "showminbox") { type = "bool"; value = CStr.ConvertBoolToStr(ShowMinBox); } else if (name == "windowstate") { type = "enum:WindowStateA"; WindowStateA windowState = WindowState; if (windowState == WindowStateA.Max) { value = "Max"; } else if (windowState == WindowStateA.Min) { value = "Min"; } else if (windowState == WindowStateA.Normal) { value = "Normal"; } } else { base.GetProperty(name, ref value, ref type); } }
/// <summary> /// 从字符串转换为对象 /// </summary> /// <param name="str">字符串</param> public void FromString(String str) { String[] strs = str.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); m_name = strs[0]; m_lines = CStr.ConvertStrToInt(strs[1]); m_rates = CStr.ConvertStrToDouble(strs[2]); }
/// <summary> /// 绑定图形 /// </summary> private void BindChart() { m_chartLevels.Clear(); CTable dataSource = m_chartLevels.DataSource; List <LevelInfo> levels = DataCenter.LevelService.m_levels; int levelsSize = levels.Count; for (int i = 0; i < levelsSize; i++) { if (levels[i].m_date.Length == 8) { int year = CStr.ConvertStrToInt(levels[i].m_date.Substring(0, 4)); int month = CStr.ConvertStrToInt(levels[i].m_date.Substring(4, 2)); int day = CStr.ConvertStrToInt(levels[i].m_date.Substring(6, 2)); DateTime dt = new DateTime(year, month, day); double pk = CStr.ConvertDateToNum(dt); dataSource.Set(pk, 0, CStr.ConvertStrToDouble(levels[i].m_level)); dataSource.Set2(i, 1, 10); dataSource.Set2(i, 2, 0); dataSource.Set2(i, 3, CStr.ConvertStrToDouble(levels[i].m_level2)); dataSource.Set2(i, 4, CStr.ConvertStrToDouble(levels[i].m_level3)); } } m_chartLevels.Update(); m_chartLevels.Invalidate(); }
/// <summary> /// 添加用户会话 /// </summary> /// <param name="message">消息</param> /// <returns>状态</returns> public int AddSessions(CMessage message) { List <UserSession> sessions = new List <UserSession>(); GetSessions(sessions, message.m_body, message.m_bodyLength); int sessionsSize = sessions.Count; List <UserSession> addSessions = new List <UserSession>(); for (int i = 0; i < sessionsSize; i++) { UserSession receive = sessions[i]; List <UserSession> oldSessions = new List <UserSession>(); GetSessions(oldSessions, receive.m_userID, receive.m_key); if (oldSessions.Count > 0) { UpdateSession(receive); oldSessions.Clear(); } else { String key = CStr.ConvertIntToStr(receive.m_userID) + ":" + receive.m_key; m_sessions[key] = receive; } addSessions.Add(receive); } int ret = Send(message, addSessions); sessions.Clear(); addSessions.Clear(); return(ret); }
/// <summary> /// 绘制背景 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void OnPaintBackground(CPaint paint, RECT clipRect) { int width = Width - 1, height = Height - 1; RECT drawRect = new RECT(0, 0, width, height); paint.FillRect(COLOR.ARGB(0, 0, 0), drawRect); int outSize = 40; int oX = width / 2, oY = height / 2, r = (width - outSize * 2) / 2; long innerBorderColor = COLOR.ARGB(100, 100, 100); int[] angles = new int[] { 240, 180, 120, 60, 0, -60 }; int[] rs = new int[] { r, r * 2 / 3, r / 3 }; for (int i = 0; i < 3; i++) { POINT[] drawPoints = new POINT[6]; for (int j = 0; j < 6; j++) { drawPoints[j] = GetCyclePoint(oX, oY, rs[i], angles[j]); } paint.DrawPolygon(innerBorderColor, 1, 0, drawPoints); } FONT pFont = new FONT("微软雅黑", 16, false, false, false); POINT[] points = GetTitlePoints(); int pointsSize = points.Length; String[] strs = new String[] { "业务", "情商", "学识", "智商", "管理", "技术" }; int[] values = new int[6]; if (m_dimension != null) { values = new int[] { m_dimension.m_business, m_dimension.m_EQ, m_dimension.m_knowledge, m_dimension.m_IQ, m_dimension.m_lead, m_dimension.m_technology }; } POINT [] scopePoints = GetScopePoints(); for (int i = 0; i < pointsSize; i++) { int bSize = 5; POINT bPoint = points[i]; RECT bRect = new RECT(bPoint.x - bSize, bPoint.y - bSize, bPoint.x + bSize, bPoint.y + bSize); SIZE pSize = paint.TextSize(strs[i], pFont); if (i == 0 || i == 5) { bPoint.y -= 20; } CDraw.DrawText(paint, strs[i], m_sysColors[i], pFont, bPoint.x - pSize.cx / 2, bPoint.y - pSize.cy / 2); int iSize = 5; POINT cp = GetCyclePoint(oX, oY, r, angles[i]); paint.DrawLine(innerBorderColor, 1, 0, oX, oY, cp.x, cp.y); paint.FillEllipse(m_sysColors[i], new RECT(cp.x - iSize, cp.y - iSize, cp.x + iSize, cp.y + iSize)); String text = String.Format("({0})", CStr.ConvertIntToStr(values[i])); SIZE sSize = paint.TextSize(text, pFont); CDraw.DrawText(paint, text, m_sysColors[i], pFont, bPoint.x - sSize.cx / 2, bPoint.y + sSize.cy / 2); } if (m_dimension != null) { paint.FillGradientPolygon(COLOR.ARGB(200, 50, 105, 217), COLOR.ARGB(200, 50, 105, 217), scopePoints, 90); paint.DrawPolygon(COLOR.ARGB(100, 255, 255, 255), 1, 0, scopePoints); } }
/// <summary> /// Windows下获取控件数值 /// </summary> /// <param name="var">变量</param> /// <returns>数值</returns> private double WIN_GETVALUE(CVariable var) { double value = 0; String text = WinHostEx.GetText(); value = CStr.ConvertStrToDouble(text); return(value); }
public void CStrWithInvalidArgumentReturnsPoundValue() { var func = new CStr(); var args = FunctionsHelper.CreateArgs(); var result = func.Execute(args, this.ParsingContext); Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type); }
public void CStrShouldConvertNumberToString() { var func = new CStr(); var result = func.Execute(FunctionsHelper.CreateArgs(1), _parsingContext); Assert.AreEqual(DataType.String, result.DataType); Assert.AreEqual("1", result.Result); }
/// <summary> /// 获取当前的指标 /// </summary> /// <param name="indicator">指标</param> public void GetIndicator(ref Indicator indicator) { //获取控件 TextBoxA txtName = GetTextBox("txtName"); CheckBoxA cbUsePassword = GetCheckBox("cbUsePassword"); TextBoxA txtPassword = GetTextBox("txtPassword"); TextBoxA txtDescription = GetTextBox("txtDescription"); ComboBoxA cbCategory = GetComboBox("cbCategory"); ComboBoxA cbPaintType = GetComboBox("cbPaintType"); ComboBoxA cbDigit = GetComboBox("cbDigit"); TextBoxA txtVersion = GetTextBox("txtVersion"); TextBoxA txtCoordinate = GetTextBox("txtCoordinate"); TextBoxA txtSpecialCoordinate = GetTextBox("txtSpecialCoordinate"); TextBoxA txtText = GetTextBox("txtText"); String parameters = ""; for (int i = 1; i <= 16; i++) { TextBoxA txtPN = GetTextBox("txtPN" + i.ToString()); if (txtPN.Text != null && txtPN.Text.Length > 0) { TextBoxA txtP = GetTextBox("txtP" + i.ToString()); TextBoxA txtPMin = GetTextBox("txtPMin" + i.ToString()); TextBoxA txtPMax = GetTextBox("txtPMax" + i.ToString()); parameters += txtPN.Text + "," + txtPMin.Text + "," + txtPMax.Text + "," + txtP.Text + ";"; } } if (indicator.m_indicatorID == null || indicator.m_indicatorID.Length == 0) { indicator.m_indicatorID = m_indicator.m_indicatorID; } indicator.m_name = txtName.Text; indicator.m_usePassword = cbUsePassword.Checked ? 1 : 0; if (indicator.m_usePassword == 1) { indicator.m_password = txtPassword.Text; } else { indicator.m_password = ""; } indicator.m_description = txtDescription.Text; indicator.m_category = cbCategory.SelectedText; indicator.m_paintType = cbPaintType.SelectedIndex; indicator.m_digit = cbDigit.SelectedIndex; int version = CStr.ConvertStrToInt(txtVersion.Text); indicator.m_version = version; indicator.m_coordinate = txtCoordinate.Text; indicator.m_specialCoordinate = txtSpecialCoordinate.Text; indicator.m_text = txtText.Text; indicator.m_parameters = parameters; indicator.m_userID = DataCenter.UserID; indicator.m_type = 1; }
public static extern bool SetForegroundWindow(IntPtr hWnd);//设置此窗体为活动窗体 /// <summary> /// 加载XML /// </summary> /// <param name="xmlPath">XML路径</param> public override void Load(String xmlPath) { LoadFile(xmlPath, null); DataCenter.MainUI = this; m_mainDiv = Native.GetControls()[0] as DivA; m_mainDiv.BackColor = COLOR.CONTROL; ControlPaintEvent paintLayoutEvent = new ControlPaintEvent(PaintLayoutDiv); m_mainDiv.RegisterEvent(paintLayoutEvent, EVENTID.PAINT); m_mainDiv.RegisterEvent(new ControlInvokeEvent(Invoke), EVENTID.INVOKE); DataCenter.ServerChatService.RegisterListener(DataCenter.ChatRequestID, new ListenerMessageCallBack(ChatMessageCallBack)); m_gridHosts = GetGrid("gridHosts"); m_gridHosts.GridLineColor = COLOR.CONTROLBORDER; GridRowStyle rowStyle = new GridRowStyle(); rowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; rowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; rowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4; rowStyle.Font = new FONT("微软雅黑", 12, false, false, false); m_gridHosts.RowStyle = rowStyle; GridRowStyle alternateRowStyle = new GridRowStyle(); alternateRowStyle.BackColor = CDraw.PCOLORS_ALTERNATEROWCOLOR; alternateRowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; alternateRowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; alternateRowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4; alternateRowStyle.Font = new FONT("微软雅黑", 12, false, false, false); m_gridHosts.AlternateRowStyle = alternateRowStyle; m_gridGroups = GetGrid("gridGroups"); m_gridGroups.RowStyle = rowStyle; m_gridGroups.AlternateRowStyle = alternateRowStyle; m_gridGroups.RegisterEvent(new GridCellMouseEvent(GridCellClick), EVENTID.GRIDCELLCLICK); RegisterEvents(m_mainDiv); //全节点服务器 if (DataCenter.IsFull) { DataCenter.UserID = DataCenter.HostInfo.m_localHost + ":" + CStr.ConvertIntToStr(DataCenter.HostInfo.m_localPort); DataCenter.UserName = DataCenter.UserID; Thread thread = new Thread(new ThreadStart(StartConnect)); thread.Start(); } else { UserCookie cookie = new UserCookie(); if (DataCenter.UserCookieService.GetCookie("USERINFO2", ref cookie) > 0) { String[] strs = cookie.m_value.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); GetTextBox("txtPhone").Text = strs[0]; GetTextBox("txtUserName").Text = strs[1]; GetTextBox("txtPort").Text = strs[2]; } } m_chatGroups = ChatGroup.ReadGroups(); BindGroups(); }
/// <summary> /// 开启服务 /// </summary> /// <param name="appPath">程序路径</param> public static void StartService() { //读取配置 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(DataCenter.GetAppPath() + "\\hostinfo.xml"); XmlNode root = xmlDoc.DocumentElement; foreach (XmlNode node in root.ChildNodes) { String name = node.Name.ToLower(); String value = node.InnerText; if (name == "clearcache") { m_hostInfo.m_clearCache = value == "1"; } else if (name == "defaulthost") { if (value.Length > 0) { String[] strs = value.Split(new String[] { ":" }, StringSplitOptions.RemoveEmptyEntries); m_hostInfo.m_defaultHost = strs[0]; m_hostInfo.m_defaultPort = CStr.ConvertStrToInt(strs[1]); } } else if (name == "isfull") { m_hostInfo.m_isFull = value == "1"; } else if (name == "localhost") { if (value.Length > 0) { String[] strs = value.Split(new String[] { ":" }, StringSplitOptions.RemoveEmptyEntries); m_hostInfo.m_localHost = strs[0]; m_hostInfo.m_localPort = CStr.ConvertStrToInt(strs[1]); } } } if (m_hostInfo.m_clearCache) { CFileA.RemoveFile(DataCenter.GetAppPath() + "\\usercookies.db"); } m_userCookieService = new UserCookieService(); Random rd = new Random(); m_isFull = m_hostInfo.m_isFull; String[] servers = new String[] { }; OwLibSV.BaseService.AddService(m_serverChatService); if (m_isFull) { OwLibSV.BaseService.StartServer(0, m_serverChatService.Port); } }
/// <summary> /// 保存配置 /// </summary> private void SaveData() { List <ConnectInfo> connectInfos = new List <ConnectInfo>(); m_connectServer.GetConnects(connectInfos); int connectInfosSize = connectInfos.Count; for (int i = 0; i < connectInfosSize; i++) { ConnectInfo connectInfo = connectInfos[i]; String type = connectInfo.m_type; if (type == "主服务器") { connectInfo.m_ip = m_cbMainServerIP.Text; connectInfo.m_port = CStr.ConvertStrToInt(m_txtMainServerPort.Text); } m_connectServer.UpdateConnect(connectInfo); } connectInfos.Clear(); //保存代理信息 ComboBoxA cbProxyType = GetComboBox("cbProxyType"); TextBoxA txtProxyIP = GetTextBox("txtProxyIP"); SpinA spinProxyPort = GetSpin("spinProxyPort"); TextBoxA txtProxyUserName = GetTextBox("txtProxyUserName"); TextBoxA txtProxyUserPwd = GetTextBox("txtProxyUserPwd"); TextBoxA txtProxyDomain = GetTextBox("txtProxyDomain"); ProxyInfo proxyInfo = new ProxyInfo(); proxyInfo.m_domain = txtProxyDomain.Text; proxyInfo.m_ip = txtProxyIP.Text; proxyInfo.m_port = (int)spinProxyPort.Value; proxyInfo.m_name = txtProxyUserName.Text; proxyInfo.m_pwd = txtProxyUserPwd.Text; proxyInfo.m_type = cbProxyType.SelectedIndex; proxyInfo.m_use = true; List <ProxyInfo> proxyInfos = new List <ProxyInfo>(); m_proxyService.GetProxyInfos(proxyInfos); int proxyInfosSize = proxyInfos.Count; for (int i = 0; i < proxyInfosSize; i++) { ProxyInfo pInfo = proxyInfos[i]; if (cbProxyType.SelectedIndex == pInfo.m_type) { m_proxyService.UpdateConnect(proxyInfo); } else { pInfo.m_use = false; m_proxyService.UpdateConnect(pInfo); } } }
/// <summary> /// 下拉列表选中索引改变事件 /// </summary> /// <param name="comboBox">下拉列表</param> private void OnComboBoxSelectedIndexChanged(ComboBoxA comboBox) { String name = comboBox.Name; if (name == "cbMainServerIP") { String port = comboBox.SelectedValue; m_txtMainServerPort.Value = CStr.ConvertStrToInt(port); } else if (name == "cbProxyType") { LoadProxyInfo(); } }
/// <summary> /// 表格选中行改变方法 /// </summary> public void OnGridSelectedRowsChanged() { List <GridRow> selectedRows = m_gridServers.SelectedRows; int selectedRowsSize = selectedRows.Count; if (selectedRowsSize > 0) { GridRow row = selectedRows[0]; m_txtIP.Text = row.GetCell(1).Text; m_spinPort.Value = CStr.ConvertStrToInt(row.GetCell(2).Text); m_cbType.Text = row.GetCell(3).Text; m_window.Invalidate(); } }
/// <summary> /// 绑定图形 /// </summary> private void BindChart() { m_chartLevels.Clear(); CTable dataSource = m_chartLevels.DataSource; List <DialogInfo> dialogs = DataCenter.DialogService.m_dialogs; Dictionary <String, int> dialogsMap = new Dictionary <String, int>(); int dialogsSize = dialogs.Count; for (int i = 0; i < dialogsSize; i++) { if (dialogs[i].m_date.Length == 8) { if (dialogsMap.ContainsKey(dialogs[i].m_date)) { dialogsMap[dialogs[i].m_date] = dialogsMap[dialogs[i].m_date] + 1; } else { dialogsMap[dialogs[i].m_date] = 1; } } } List <DialogData> datas = new List <DialogData>(); foreach (String key in dialogsMap.Keys) { DialogData data = new DialogData(); data.m_name = key; data.m_times = dialogsMap[key]; datas.Add(data); } datas.Sort(new DialogDataCompare2()); int datasSize = datas.Count; for (int i = 0; i < datasSize; i++) { DialogData data = datas[i]; int year = CStr.ConvertStrToInt(data.m_name.Substring(0, 4)); int month = CStr.ConvertStrToInt(data.m_name.Substring(4, 2)); int day = CStr.ConvertStrToInt(data.m_name.Substring(6, 2)); DateTime dt = new DateTime(year, month, day); double pk = CStr.ConvertDateToNum(dt); dataSource.Set(pk, 0, data.m_times); dataSource.Set2(i, 1, 0); } m_chartLevels.Update(); m_chartLevels.Invalidate(); }
/// <summary> /// 从字符串转换为对象 /// </summary> /// <param name="str">字符串</param> public void FromString(String str) { String[] strs = str.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); m_files = CStr.ConvertStrToInt(strs[0]); m_lines = CStr.ConvertStrToInt(strs[1]); m_scores = CStr.ConvertStrToInt(strs[2]); m_avgLevel = CStr.ConvertStrToInt(strs[3]); int strsSize = strs.Length; for (int i = 4; i < strsSize; i++) { FileJidian fileJidian = new FileJidian(); fileJidian.FromString(strs[i]); m_fileJidians.Add(fileJidian); } }
/// <summary> /// 启动监听 /// </summary> public void Start() { m_useScript = CFileA.IsFileExist(m_fileName); if (m_useScript) { m_native = NativeHandler.CreateNative(); CFileA.Read(m_fileName, ref m_script); m_indicator = CFunctionEx.CreateIndicator(m_script, m_native); Console.WriteLine(m_script); } try { //string host = "127.0.0.1"; //IPAddress ip = IPAddress.Parse(host); if (m_indicator != null) { m_indicator.CallFunction("ONHTTPSERVERSTARTING('" + m_fileName + "');"); } IPEndPoint ipe = new IPEndPoint(IPAddress.Any, m_port); m_listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); m_listener.Bind(ipe); m_listener.Listen(0); } catch (Exception ex) { if (m_indicator != null) { m_indicator.CallFunction("ONHTTPSERVERSTARTFAIL('" + ex.Message + "\r\n" + ex.StackTrace + "');"); } return; } int minThreadNum = 0, portThreadNum = 0, maxThreadNum = 0; ThreadPool.GetMaxThreads(out maxThreadNum, out portThreadNum); ThreadPool.GetMinThreads(out minThreadNum, out portThreadNum); if (m_indicator != null) { m_indicator.CallFunction("ONHTTPSERVERSTART(" + CStr.ConvertIntToStr(maxThreadNum) + "," + CStr.ConvertIntToStr(minThreadNum) + ");"); } while (DataCenter.IsAppAlive) { Socket socket = m_listener.Accept(); ThreadPool.QueueUserWorkItem(new WaitCallback(ReadData), socket); } m_listener.Close(); }
/// <summary> /// 从字符串转换为对象 /// </summary> /// <param name="str">字符串</param> public void FromString(String str) { String[] strs = str.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries); m_path = strs[0]; m_pID = strs[1]; m_codeType = strs[2]; m_lines = CStr.ConvertStrToInt(strs[3]); m_level = CStr.ConvertStrToInt(strs[4]); m_scores = CStr.ConvertStrToInt(strs[5]); int strsSize = strs.Length; for (int i = 6; i < strsSize; i++) { MemberJidian memberJidian = new MemberJidian(); memberJidian.FromString(strs[i]); m_memberJidians.Add(memberJidian); } }
/// <summary> /// 获取新的ID /// </summary> /// <returns>新ID</returns> public String GetNewID() { List<int> ids = new List<int>(); int bsStocksSize = m_bsStocks.Count; for (int i = 0; i < bsStocksSize; i++) { ids.Add(CStr.ConvertStrToInt(m_bsStocks[i].m_ID)); } ids.Sort(); int idsSize = ids.Count; if (idsSize > 0) { return CStr.ConvertIntToStr(ids[idsSize - 1] + 1); } else { return "1"; } }
public ThreadStack(N64Ptr addr) { Ram = new N64PtrRange(addr, addr + 0x20); Ptr ptr = SPtr.New(addr); NextPtr = ptr.ReadInt32(0x00); PrevPtr = ptr.ReadInt32(0x04); N64Ptr StartPtr = ptr.ReadInt32(0x08); N64Ptr EndPtr = ptr.ReadInt32(0x0C); Unknown = ptr.ReadInt32(0x14); //NamePtr = ptr.ReadInt32(0x18); Unknown2 = ptr.ReadInt32(0x1C); byte[] nameBuff = ptr.Deref(0x18).ReadBytes(0, 0x20); Name = CStr.Get(nameBuff, Encoding.GetEncoding("EUC-JP"), 0x20); StackAddr = new NamedBuffer(new N64PtrRange(StartPtr, EndPtr), $"{Name,-13} STACK"); }
/// <summary> /// 删除用户会话 /// </summary> /// <param name="message">消息</param> /// <returns>状态</returns> public int DeleteSessions(CMessage message) { List <UserSession> sessions = new List <UserSession>(); GetSessions(sessions, message.m_body, message.m_bodyLength); int sessionsSize = sessions.Count; List <UserSession> deleteSessions = new List <UserSession>(); for (int i = 0; i < sessionsSize; i++) { UserSession receive = sessions[i]; String key = CStr.ConvertIntToStr(receive.m_userID) + ":" + receive.m_key; m_sessions.Remove(key); } int ret = Send(message, deleteSessions); sessions.Clear(); deleteSessions.Clear(); return(ret); }
/// <summary> /// 获取新的ID /// </summary> /// <returns>新ID</returns> public String GetNewID() { List <int> ids = new List <int>(); int levelsSize = m_levels.Count; for (int i = 0; i < levelsSize; i++) { ids.Add(CStr.ConvertStrToInt(m_levels[i].m_ID)); } ids.Sort(); int idsSize = ids.Count; if (idsSize > 0) { return(CStr.ConvertIntToStr(ids[idsSize - 1] + 1)); } else { return("1"); } }
/// <summary> /// 登陆 /// </summary> private void Login() { String phone = GetTextBox("txtPhone").Text.Trim(); String userName = GetTextBox("txtUserName").Text.Trim(); String myPort = GetTextBox("txtPort").Text.Trim(); if (phone.Length == 0) { MessageBox.Show("请输入手机号码!", "提示"); return; } if (userName.Length == 0) { MessageBox.Show("请输入姓名!", "提示"); return; } m_isLogining = true; DataCenter.UserID = phone; DataCenter.UserName = userName; UserCookie cookie = new UserCookie(); cookie.m_key = "USERINFO2"; cookie.m_value = phone + "," + userName + "," + myPort; DataCenter.UserCookieService.AddCookie(cookie); DataCenter.ServerChatService.Port = CStr.ConvertStrToInt(GetTextBox("txtPort").Text); OwLibSV.BaseService.StartServer(0, DataCenter.ServerChatService.Port); Thread thread = new Thread(new ThreadStart(StartConnect)); thread.Start(); while (m_isLogining) { Thread.Sleep(100); } GetLabel("lblState").Visible = true; GetLabel("lblState").Text = "用户" + userName + "已登陆"; GetDiv("divLogin").Visible = false; GetDiv("divChat").Top = 30; Native.Update(); Native.Invalidate(); }
/// <summary> /// 获取用户会话信息 /// </summary> /// <param name="session">用户会话信息</param> /// <param name="userID">用户ID</param> /// <param name="key">键</param> public int GetSessions(List <UserSession> sessions, int userID, String key) { if (key != null && key.Length > 0) { String findKey = CStr.ConvertIntToStr(userID) + ":" + key; if (m_sessions.ContainsKey(findKey)) { sessions.Add(m_sessions[findKey]); } } else { foreach (UserSession session in m_sessions.Values) { if (session.m_userID == userID) { sessions.Add(session); } } } return(1); }