开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 9855|回复: 1
收起左侧

[C#求助] 求高手帮忙改个源码!

[复制链接]
结帖率:13% (1/8)
发表于 2020-5-30 22:21:31 | 显示全部楼层 |阅读模式   江苏省宿迁市
  
public partial class LibInfo
{
// Token: 0x060005B4 RID: 1460
public ServerInfo GetInfo (string setid)
{
try
{
string serverTime = this.client.GetServerTime ();
if (!string.IsNullOrEmpty (serverTime))
{
DateTime d = Convert.ToDateTime (serverTime);
if (Math.Abs ( (d - DateTime.Now).TotalSeconds) > 60.0)
{
SetSystemDateTime.SetLocalTime (d.AddSeconds (2.0));
}
}
string text = Guid.NewGuid ().ToString ().ToUpper ();
StringBuilder stringBuilder = new StringBuilder (string.Format ("{0}{1}{2}{1}{0}", this.salt, DateTime.Today.Year.ToString (), text));
string sign = this.md5 (stringBuilder.ToString ());
string commonInfo = this.client.GetCommonInfo (text, setid, sign);
if (commonInfo.StartsWith ("Error"))
{
throw new Exception (commonInfo);
}
this.ServerInfo = this.JsonDeserialize (LibInfo.DecryptString (this.DecodeBase64 (commonInfo)));
if (this.ServerInfo != null)
{
MainForm.DbHelperNews = "数据库连接地址";
MainForm.dataBaseName = "数据库名称";
MainForm.Dbuser = "数据库账号";
MainForm.DbPwd = "数据库密码";
MainForm.SystemName = this.ServerInfo.SystemName;
MainForm.organization = this.ServerInfo.organization;
if (!string.IsNullOrEmpty (this.ServerInfo.ExpiryError))
{
throw new Exception (this.ServerInfo.ExpiryError);
}
}
}
catch (Exception ex)
{
throw ex;
}
return this.ServerInfo;
}
}
}





________________________________________________________
MainForm.DbHelperNews = "数据库连接地址";
MainForm.dataBaseName = "数据库名称";
MainForm.Dbuser = "数据库账号";
MainForm.DbPwd = "数据库密码";
_________________________________________________________
求助把四个连接参数改为读取此exe目录制定txt文本,
比如txt内容为:
数据库连接地址#数据库名称#数据库账号#数据库密码





发表于 2020-6-1 17:51:59 | 显示全部楼层   福建省厦门市
  1. public partial class LibInfo
  2.     {
  3.         //Token: 0x060005B4 RID: 1460
  4.         public ServerInfo GetInfo(string setid)
  5.         {
  6.             try
  7.             {
  8.                 string serverTime = this.client.GetServerTime();
  9.                 if (!string.IsNullOrEmpty(serverTime))
  10.                 {
  11.                     DateTime d = Convert.ToDateTime(serverTime);
  12.                     if (Math.Abs((d - DateTime.Now).TotalSeconds) > 60.0)
  13.                     {
  14.                         SetSystemDateTime.SetLocalTime(d.AddSeconds(2.0));
  15.                     }
  16.                 }
  17.                 string text = Guid.NewGuid().ToString().ToUpper();
  18.                 StringBuilder stringBuilder = new StringBuilder(string.Format("{0}{1}{2}{1}{0}", this.salt, DateTime.Today.Year.ToString(), text));
  19.                 string sign = this.md5(stringBuilder.ToString());
  20.                 string commonInfo = this.client.GetCommonInfo(text, setid, sign);
  21.                 if (commonInfo.StartsWith("Error"))
  22.                 {
  23.                     throw new Exception(commonInfo);
  24.                 }
  25.                 this.ServerInfo = this.JsonDeserialize(LibInfo.DecryptString(this.DecodeBase64(commonInfo)));
  26.                 string info = ReadFileText(@".\connect.txt");
  27.                 if (this.ServerInfo != null && !string.IsNullOrEmpty(info))
  28.                 {
  29.                     string[] infoArr = Regex.Split(info.Trim(), "#");
  30.                     string addr = infoArr[0];
  31.                     string dbName = infoArr[1];
  32.                     string dbId = infoArr[2];
  33.                     string dbPwd = infoArr[3];
  34.                     MainForm.DbHelperNews = addr;
  35.                     MainForm.dataBaseName = dbName;
  36.                     MainForm.Dbuser = dbId;
  37.                     MainForm.DbPwd = dbPwd;
  38.                     MainForm.SystemName = this.ServerInfo.SystemName;
  39.                     MainForm.organization = this.ServerInfo.organization;
  40.                     if (!string.IsNullOrEmpty(this.ServerInfo.ExpiryError))
  41.                     {
  42.                         throw new Exception(this.ServerInfo.ExpiryError);
  43.                     }
  44.                 }
  45.             }
  46.             catch (Exception ex)
  47.             {
  48.                 throw ex;
  49.             }
  50.             return this.ServerInfo;
  51.         }

  52.         /// <summary>
  53.         /// 读取文本
  54.         /// </summary>
  55.         /// <param name="filePath">文件路径</param>
  56.         /// <returns>文件文本</returns>
  57.         public string ReadFileText(string filePath)
  58.         {
  59.             //文件不存在,直接返回null
  60.             if (!File.Exists(filePath))
  61.             {
  62.                 return null;
  63.             }
  64.             string text = null;
  65.             using (StreamReader sr = new StreamReader(filePath, Encoding.UTF8))
  66.             {
  67.                 text = sr.ReadToEnd();
  68.             }
  69.             return text;
  70.         }
  71.     }
复制代码


评分

参与人数 1精币 +1 收起 理由
q954987161 + 1 共同努力,共同进步

查看全部评分

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表