/// <summary> /// コンストラクタ /// </summary> public MainWindowViewModel() { this.MessageList = new ObservableCollection <Message>(); BindingOperations.EnableCollectionSynchronization(this.MessageList, new Object()); this.uiDispatcher = Dispatcher.CurrentDispatcher; // 設定データの取得 this.config = Config.GetConfig(); #region Commandの登録 this.ConnectSpeakApplicationCommand = new RelayCommand(p => this.ConnectSpeakApplication()); this.DisconnectSpeakApplicationCommand = new RelayCommand(p => this.DisconnectSpeakApplication()); this.JoinRoomCommand = new RelayCommand(p => this.JoinRoom(this.LiveUrl)); this.LeaveRoomCommand = new RelayCommand(p => this.LeaveRoom()); this.LoginCommand = new RelayCommand(p => this.LoginCavetube()); this.LogoutCommand = new RelayCommand(p => this.LogoutCavetube()); this.SwitchAccountCommand = new RelayCommand(p => { this.LogoutCavetube(); this.LoginCavetube(); }); this.PostCommentCommand = new RelayCommand(p => { var apiKey = this.config.ApiKey ?? String.Empty; this.PostComment(this.PostName, this.PostMessage, apiKey); }); this.AboutBoxCommand = new RelayCommand(p => this.ShowVersion()); this.SettingWindowCommand = new RelayCommand(p => this.ShowOption()); this.StartBroadcastWindowCommand = new RelayCommand(p => this.ShowStartBroadcast()); #endregion this.PostName = this.config.UserId; }
/// <summary> /// 获取符合配置的MonitorServer /// </summary> /// <returns></returns> public MonitorServer GetMonitorServer(Model.Config config, ErrorPathInfo epi) { MonitorServer ms = null; string connstr = config.DB.ConnString; string sql = "select top 1 * from [monitorServer] where [deleteFlg]=0 and charindex([monitorDrive],@monitorDrive)>0"; SqlParameter sp = new SqlParameter("@monitorDrive", epi.source); DataSet ds = DBHelper.ExecuteDataset(connstr, CommandType.Text, sql, sp); DataTable dt = null; if (ds != null && ds.Tables.Count == 1) { dt = ds.Tables[0]; } if (dt != null && dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; ms = new MonitorServer() { //monitorServerName unique monitorServerName = Convert.ToString(dr["monitorServerName"]), monitorServerIP = Convert.ToString(dr["monitorServerIP"]), account = Convert.ToString(dr["account"]), password = Convert.ToString(dr["password"]), startFile = Convert.ToString(dr["startFile"]), monitorDrive = Convert.ToString(dr["monitorDrive"]), monitorMacPath = Convert.ToString(dr["monitorMacPath"]), monitorLocalPath = Convert.ToString(dr["monitorLocalPath"]), }; } return(ms); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var id = Request.QueryString["id"]; var bll = new BLL.BLLBase(); var tb = bll.Select(ctx, new Model.Config() { ID = Convert.ToInt32(id), State = 0 }); if (tb != null && tb.Rows.Count > 0) { config = tb.ToList <Model.Config>()[0]; } if (config == null) { config = new Model.Config(); } img_1.ImgUrls = config.Url; } }
/// <summary> /// 判断此路径是否发生变化 /// 数据库中路径信息 暂定:有效性为一个月 即 每个月全部清空一次 /// </summary> /// <param name="path"></param> /// <returns></returns> public static bool IsUpdate(Model.Config config, SftpFile sf, MonitorServer ms) { //判断是否更新 bool isUpdate = false; try { SSHPathInfo spi = new SSHPathInfo() { MonitorServerIP = ms.monitorServerIP, MacPath = sf.FullName, LastName = sf.FullName.Substring(sf.FullName.LastIndexOf('/') + 1), depth = GetDepth(sf.FullName), typeflag = sf.IsDirectory ? 0 : 1, updateTime = (Int32)(sf.Attributes.LastWriteTime.Subtract(new DateTime(1970, 1, 1))).TotalSeconds }; SSHPathInfoDAL spidal = new SSHPathInfoDAL(); isUpdate = spidal.IsUpdate(config, spi); } catch (System.Exception ex) { isUpdate = true; BudSSH.Common.Util.LogManager.WriteLog(Common.Util.LogFile.Error, MessageUtil.GetExceptionMsg(ex, "")); } return(isUpdate); }
public bool SetHostIpAddress(string hostIp, string port) { try { using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, dbFileName))) { List <Model.Config> configList = connection.Table <Model.Config>().ToList(); Model.Config config = new Model.Config(); config.hostIp = hostIp; config.port = port; if (configList.Count > 0) { connection.DeleteAll <Model.Config>(); } connection.Insert(config); } } catch (SQLiteException ex) { Log.Info("SQLiteEx", ex.Message); return(false); } return(true); }
public void SaveDynamicConfig() { var configToSave = new Model.Config(); configToSave.FromDynamicConfig(DynamicConfig); _configData.SaveConfiguration(configToSave); }
public Model.Config LoadConfig() { Model.Config config = new Model.Config(); config.LogPath = GetLogPaths(); config.Folder = GetFolder(); return(config); }
/// <summary> /// コンストラクタ /// </summary> public MainWindowViewModel() { this.MessageList = new ObservableCollection<Message>(); BindingOperations.EnableCollectionSynchronization(this.MessageList, new Object()); this.uiDispatcher = Dispatcher.CurrentDispatcher; // 設定データの取得 this.config = Config.GetConfig(); #region Commandの登録 this.ConnectSpeakApplicationCommand = new RelayCommand(p => this.ConnectSpeakApplication()); this.DisconnectSpeakApplicationCommand = new RelayCommand(p => this.DisconnectSpeakApplication()); this.JoinRoomCommand = new RelayCommand(p => this.JoinRoom(this.LiveUrl)); this.LeaveRoomCommand = new RelayCommand(p => this.LeaveRoom()); this.LoginCommand = new RelayCommand(p => this.LoginCavetube()); this.LogoutCommand = new RelayCommand(p => this.LogoutCavetube()); this.SwitchAccountCommand = new RelayCommand(p => { this.LogoutCavetube(); this.LoginCavetube(); }); this.PostCommentCommand = new RelayCommand(p => { var apiKey = this.config.ApiKey ?? String.Empty; this.PostComment(this.PostName, this.PostMessage, apiKey); }); this.AboutBoxCommand = new RelayCommand(p => this.ShowVersion()); this.SettingWindowCommand = new RelayCommand(p => this.ShowOption()); this.StartBroadcastWindowCommand = new RelayCommand(p => this.ShowStartBroadcast()); #endregion this.PostName = this.config.UserId; }
/// <summary> /// 保存配置 /// </summary> /// <param name="config"></param> public bool SaveConfig(Model.Config config) { bool isOk = true; try { if (config != null) { #region save config if (config.Path != null) { SavePath(config.Path); } if (config.DB != null) { SaveDB(config.DB); } #endregion } } catch (System.Exception ex) { logger.Error(MessageUtil.GetExceptionMsg(ex, "")); isOk = false; } return(isOk); }
private void AddNewConfig(Model.Config config) { var existingType = _context.Configs.FirstOrDefault(p => p.Name == config.Name); if (existingType == null) { _context.Configs.Add(config); } }
private IconManager() { _iconsNormalSize = new ConcurrentDictionary <Tuple <string, string>, string>(); _cachedImages = new ConcurrentDictionary <string, CachedImage>(StringComparer.InvariantCultureIgnoreCase); _config = Model.Sys.s_instance.Config; _config.BackgroundDirectoryChanged += LoadIconFiles; _config.IconDirectoryChanged += LoadIconFiles; LoadIconResouces(); LoadIconFiles(); }
private T Deserialize <T>(Model.Config config) { try { return(_objSerializer.Deserialize <T>(config?.Value)); } catch (Exception e) { throw e; } }
///<summary>settings.xmlを上書きし、新たなConfigインスタンスを生成する</summary> public Config OverWriteUserSettingFile(string projectRoot, string dateTime) { WoditorSettings.ProjectRoot = projectRoot; OutputSettings.DateTime = dateTime; Utils.File.WriteUserSetting(this); Config config = new Model.Config(this); return(config); }
protected void btnSave_Click(object sender, EventArgs e) { var type = (Enums.SystemType)Enum.Parse(typeof(Enums.SystemType), drpSystemType.SelectedValue); Model.Config _entity = new Model.Config(); var conf = ViewState["__scorelist"] as Configuration; conf.AllowedTime = txtTime.Text.ToInt32(); conf.TimeUpStepID = txtWfName.Text; conf.SystemType = type; _entity.Scoring = conf.SerializeToXML(); _entity.ID = ViewState["__confid"] != null ? ViewState["__confid"].ToInt32() : -1; _entity.AddUpdate(); }
private void BindData() { Model.Config _con = new Model.Config(); _con = _con.GetConfiguration(); if (_con != null) { ViewState["__confid"] = _con.ID; var config = ViewState["__scorelist"] as Configuration; config = config.Deserialize(_con.Scoring); txtTime.Text = config.AllowedTime.ToString(); txtWfName.Text = config.TimeUpStepID; drpSystemType.SelectedIndex = drpSystemType.Items.IndexOf(drpSystemType.Items.FindByValue(config.SystemType.ToString())); ViewState["__scorelist"] = config; grdConfig.DataBind(); } }
private static void Main(string[] args) { Console.WriteLine("Welcome to CustomSync"); string configFilePath = ""; do { Console.WriteLine("Please insert a valid config file path:"); configFilePath = Console.ReadLine(); } while (string.IsNullOrEmpty(configFilePath) || !File.Exists(configFilePath)); try { ConfigApplicationService configApplicationService = new ConfigApplicationService(); Trasversal.Result <Model.Config> configResponse = configApplicationService.ReadConfig(configFilePath); if (configResponse.ActionResult && configResponse.ResultObject != null) { Console.WriteLine("Config is Ok - Starting process... "); Model.Config config = configResponse.ResultObject; FileApplicationService fileService = new FileApplicationService(); Console.WriteLine("Coping Files, please be patient...."); Trasversal.Result resultado = fileService.CopyFilesReorganizing(config); if (resultado.ActionResult) { Console.WriteLine("SUCCESS - No errors found :)"); } else { Console.WriteLine("Warning - Errors found :("); Console.WriteLine("*********************************"); Console.WriteLine("************ ERRORS *************"); Console.WriteLine("*********************************"); foreach (string error in resultado.Errors) { Console.WriteLine(error); } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public async Task SetDynamicConfig() { var dbConfig = await _configData.GetConfiguration(); if (dbConfig != null) { dbConfig.ToDynamicConfig(DynamicConfig); } else { dbConfig = new Model.Config(); dbConfig.FromDynamicConfig(DynamicConfig.GetDefault()); dbConfig.ToDynamicConfig(DynamicConfig); await _configData.SaveConfiguration(dbConfig); } DynamicConfig.TrackChanges = true; }
/// <summary> /// 保存配置 /// </summary> /// <param name="config"></param> public bool SaveConfig(Model.Config config) { bool isOk = true; try { if (config != null) { SetLogPath(config.LogPath); SetFolder(config.Folder); } } catch (System.Exception ex) { logger.Error(ex.Message); isOk = false; } return(isOk); }
public IEnumerable GetSSHPathInfo(Model.Config config) { #region 获取SqlDataReader try { string sql = "select ID,MonitorServerIP,MacPath,typeflag from SSHPathInfo"; sr = DBHelper.ExecuteReader(config.DB.ConnString, CommandType.Text, sql); } catch (System.Exception ex) { Common.Util.LogManager.WriteLog(Common.Util.LogFile.Error, MessageUtil.GetExceptionMsg(ex, "")); if (sr != null) { sr.Close(); sr = null; } yield break; } #endregion //获取数据 while (sr != null && sr.Read()) { yield return(new SSHPathInfo() { ID = Convert.ToString(sr[0]), MonitorServerIP = Convert.ToString(sr[1]), MacPath = Convert.ToString(sr[2]), typeflag = Convert.ToInt32(sr[3]) }); } //退出 if (sr != null) { sr.Close(); sr = null; } yield break; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var id = Request.QueryString["id"]; var bll = new BLL.BLLBase(); var tb = bll.Select(ctx, new Model.Config() { ID = Convert.ToInt32(id), State = 0 }); if (tb != null && tb.Rows.Count > 0) { config = tb.ToList<Model.Config>()[0]; } if (config == null) { config = new Model.Config(); } img_1.ImgUrls = config.Url; } }
/// <summary> /// 判断某个mac上的文件或目录是否更新 /// </summary> /// <param name="path"></param> /// <param name="ip"></param> /// <returns></returns> public bool IsUpdate(Model.Config config, SSHPathInfo spi) { string connstr = config.DB.ConnString; SqlParameter[] spin = new SqlParameter[] { new SqlParameter("@monitorServerIP", SqlDbType.VarChar) { Value = spi.MonitorServerIP }, new SqlParameter("@macPath", SqlDbType.NVarChar) { Value = spi.MacPath }, new SqlParameter("@lastName", SqlDbType.NVarChar) { Value = spi.LastName }, new SqlParameter("@depth", SqlDbType.Int) { Value = spi.depth }, new SqlParameter("@typeflag", SqlDbType.Bit) { Value = spi.typeflag }, new SqlParameter("@updateTime", SqlDbType.VarChar) { Value = spi.updateTime }, }; SqlParameter spout = new SqlParameter("@IsUpdate", SqlDbType.Bit) { Direction = ParameterDirection.Output }; return(Convert.ToBoolean(DBHelper.GetOutValue(connstr, "CheckSSHPath", spout, spin))); }
public static bool LoadConfig() { if (File.Exists(_fileName)) { var rawConfig = File.ReadAllText(_fileName); var config = JsonConvert.DeserializeObject <Model.Config>(rawConfig); if (config != null) { Instance = config; return(true); } } else { var newConfig = JsonConvert.SerializeObject(new Model.Config() { Telegram = new Model.Config.TelegramConfig() }, Formatting.Indented); File.WriteAllText(_fileName, newConfig); } return(false); }
/// <summary> /// 获取配置 /// </summary> /// <returns></returns> public Model.Config LoadConfig() { Model.Config config = new Model.Config(); config.Path = new Model.PathConfig() { InputLogPath = ExeConfigUtil.GetAPPSettingValue("LogPath") ?? "", OutputPath = ExeConfigUtil.GetAPPSettingValue("SSHPath") ?? "" }; string dbconnctionstring = ExeConfigUtil.GetConnectionString("BudBackup2Context"); //待完善:应使用正则表达式校验格式,防止用户收到配置错误 string[] paras = dbconnctionstring.Split(';'); config.DB = new Model.DBConfig() { ServerName = paras[0].Split('=')[1], LoginName = paras[1].Split('=')[1], Password = paras[2].Split('=')[1], DatabaseName = paras[3].Split('=')[1] }; //调度间隔 config.SynchronizingTimeInterval = ExeConfigUtil.GetAPPSettingValue("SynchronizingTimeInterval") ?? ""; //同步开始时间 config.SSHLocalSyncTime = ExeConfigUtil.GetAPPSettingValue("SSHLocalSyncTime") ?? ""; //read log time config.ReadLogTime = ExeConfigUtil.GetAPPSettingValue("readLogTime") ?? ""; //DB Sync Time config.DBSyncTime = ExeConfigUtil.GetAPPSettingValue("DBSyncTime") ?? ""; //SSH Boot Time config.SSHBootTime = ExeConfigUtil.GetAPPSettingValue("SSHBootTime") ?? ""; return(config); }
/// <summary> /// 保存各项系统设置 /// </summary> /// <param name="ConfigValue">项目名称和数据值的组合,格式ConfigKey@ConfigValue,...,如 网站名称@百度,PC端网址@http://www.baidu.com,...</param> public void ExSaveConfig(string ConfigValue) { try { string[] ArrTemp = ConfigValue.Split(','); string[] ArrTemp2; for (int i = 0; i < ArrTemp.Length; i++) { ArrTemp2 = ArrTemp[i].Split('@'); modelConfig = ExGetModel(ArrTemp2[0]); if (modelConfig != null) { //数据库中已有当前项目名称,则仅修改数据值 modelConfig.ConfigValue = ""; for (int j = 1; j < ArrTemp2.Length; j++) { modelConfig.ConfigValue += ArrTemp2[j] + "@"; } modelConfig.ConfigValue = modelConfig.ConfigValue.Substring(0, modelConfig.ConfigValue.Length - 1); dal.Update(modelConfig); } else { //数据库中无当前项目名称,则新建项目名称和对应的数据值 modelConfig = new Model.Config(); modelConfig.GUID = Guid.NewGuid().ToString(); modelConfig.ConfigKey = ArrTemp2[0]; modelConfig.ConfigValue = ArrTemp2[1]; dal.Add(modelConfig); } } } catch (Exception ex) { throw; } }
/// <summary> /// 获取所有MonitorServer /// </summary> /// <returns></returns> public List <MonitorServer> GetAllMonitorServer(Model.Config config) { List <MonitorServer> list = new List <MonitorServer>(); string sql = "select * from [monitorServer] where [deleteFlg]=0 "; DataSet ds = DBHelper.ExecuteDataset(config.DB.ConnString, CommandType.Text, sql); DataTable dt = null; if (ds != null && ds.Tables.Count == 1) { dt = ds.Tables[0]; } if (dt != null && dt.Rows.Count > 0) { //获取数据 foreach (DataRow dr in dt.Rows) { MonitorServer ms = new MonitorServer() { //monitorServerName unique monitorServerName = Convert.ToString(dr["monitorServerName"]), monitorServerIP = Convert.ToString(dr["monitorServerIP"]), account = Convert.ToString(dr["account"]), password = Convert.ToString(dr["password"]), startFile = Convert.ToString(dr["startFile"]), monitorDrive = Convert.ToString(dr["monitorDrive"]), monitorMacPath = Convert.ToString(dr["monitorMacPath"]), monitorLocalPath = Convert.ToString(dr["monitorLocalPath"]), }; list.Add(ms); } } return(list); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { int configId = 0; if (ViewState["ConfigId"] != null) { //修改 configId = Convert.ToInt32(ViewState["ConfigId"]); } oyxf.Model.Config config = new Model.Config(); config.ConfigId = configId; config.Copyright = txtCopyright.Text; config.AboutImgUrl = txtAboutImgUrl.Text; config.AboutIntro = txtAboutIntro.Text; config.AboutUrl = txtAboutUrl.Text; config.NewsUrl = txtNewsUrl.Text; config.ContactImgUrl = txtContactImgUrl.Text; config.ContactUrl = txtContactUrl.Text; config.CompanyName = txtCompanyName.Text; config.Address = txtAddress.Text; config.Postcode = Convert.ToInt32(txtPostcode.Text); config.Telephone = txtTelephone.Text; config.Website = txtWebsite.Text; config.Email = txtEmail.Text; config.ProductUrl = txtProductUrl.Text; if (bllConfig.Update(config)) { ScriptHelper.AlertRefresh("保存成功"); } else { ScriptHelper.Alert("保存失败"); } }
/// <summary> /// 删除数据库中相应记录 /// </summary> /// <param name="delIDList"></param> public void DeleteEntrys(Model.Config config, List <string> delIDList) { string sql = string.Empty; try { if (delIDList != null && delIDList.Count > 0) { //获取sql StringBuilder sqlSB = new StringBuilder("delete from [SSHPathInfo] where id in ("); foreach (string id in delIDList) { sqlSB.Append(id).Append(','); } sql = sqlSB.ToString().TrimEnd(',') + ")"; DBHelper.ExecuteNonQuery(config.DB.ConnString, CommandType.Text, sql); } } catch (System.Exception ex) { logger.Error(MessageUtil.GetExceptionMsg(ex, "") + " sql:" + sql); } }
protected void Page_Load(object sender, EventArgs e) { var act = Request.Form["act"]; var ctx = new DataContext(); if (act == "edit") { AjaxResult response = null; var id = Request.Form["id"]; var txtCode = Request.Form["txtCode"]; var txtText = Request.Form["txtText"]; var txtImage = Request.Form["txtImage"]; var url = Request.Form["txtUrl"]; if (txtCode == "Banner" && string.IsNullOrEmpty(txtImage)) { response = new AjaxResult() { Success = 0, Message = "图片不能为空!" }; this.Response.Write(response); return; } if (txtCode == "About" && string.IsNullOrEmpty(txtText)) { response = new AjaxResult() { Success = 0, Message = "文字说明不能为空。" }; this.Response.Write(response); return; } var admin = this.Session["LoginAdmin"] as Model.Admin; var dt = new Model.Config() { ID = Convert.ToInt32(id), Image = common.Common.UploadImagePath + txtImage.Replace(common.Common.UploadImagePath, ""), Text = txtText, Url = url, ModifyBy = admin == null ? 0 : admin.ID, ModifyDate = DateTime.Now }; ctx.BeginTransaction(); try { var bll = new BLL.BLLBase(); bll.Update(ctx, dt); ctx.CommitTransaction(); response = new AjaxResult() { Success = 1, Message = "操作成功", Data = id }; } catch (Exception exception) { ctx.RollBackTransaction(); response = new AjaxResult() { Success = 0, Message = "操作失败:" + exception.Message, Data = 0 }; } finally { ctx.CloseConnection(); } this.Response.Write(response); } else if (act == "stop") { AjaxResult response = null; var id = Request.Form["id"]; var state = Request.Form["state"]; var admin = this.Session["LoginAdmin"] as Model.Admin; var dt = new Model.Config() { ID = Convert.ToInt32(id), State = state == "0" ? 1 : 0, ModifyBy = admin == null ? 0 : admin.ID, ModifyDate = DateTime.Now }; ctx.BeginTransaction(); try { var bll = new BLL.BLLBase(); bll.Update(ctx, dt); ctx.CommitTransaction(); response = new AjaxResult() { Success = 1, Message = "操作成功", Data = id }; } catch (Exception exception) { ctx.RollBackTransaction(); response = new AjaxResult() { Success = 0, Message = "操作失败:" + exception.Message, Data = 0 }; } finally { ctx.CloseConnection(); } this.Response.Write(response); } }
public void Execute() { #region 循环 if (ExecuteStatus == 0) { if (dgv.Rows.Count > 0) { for (int i = 0; i < dgv.Rows.Count; i++) { model = new Config(); model.Id = 0; string date = dgv.Rows[i].Cells["本次执行时间"].Value.ToString().Trim(); int id = int.Parse(dgv.Rows[i].Cells["编号"].Value.ToString().Trim()); string statusrow = dgv.Rows[i].Cells["线程状态"].Value.ToString().Trim(); if (date != "" && !dtslist.Contains(id)) { DateTime dt = Convert.ToDateTime(date); if (DateTime.Now >= dt.AddSeconds(-10)) { #region 组织实体对象 model.Id = id; model.FileFormatName = dgv.Rows[i].Cells[12].Value.ToString().Trim(); model.DateSql = dgv.Rows[i].Cells["数据集Sql"].Value.ToString().Trim(); model.BecomeValidateDate = DateTime.Parse(dgv.Rows[i].Cells["首次执行日期"].Value.ToString().Trim()); model.BusinessName = dgv.Rows[i].Cells["业务名称"].Value.ToString().Trim(); model.ConfigType = Convert.ToInt32(dgv.Rows[i].Cells["配置方式"].Value.ToString().Trim() == "内置配置" ? "0" : "1"); model.Cycle = dgv.Rows[i].Cells["周期"].Value.ToString().Trim(); string type = dgv.Rows[i].Cells["文件格式"].Value.ToString().Trim(); int inttype = 2; switch (type) { case "Excel97_2003": inttype = 1; break; case "Excel2007": inttype = 2; break; case "文本文件": inttype = 3; break; case "csv": inttype = 4; break; } model.FileType = inttype; model.LoseEfficacyDate = DateTime.Parse(dgv.Rows[i].Cells["失效日期"].Value.ToString().Trim()); model.NextVoluntarilyTime = DateTime.Parse(date); model.PathName = dgv.Rows[i].Cells["文件路径"].Value.ToString().Trim(); model.IsHead = Convert.ToBoolean(dgv.Rows[i].Cells["是否显示头部"].Value.ToString().Trim()); model.ServerType = dgv.Rows[i].Cells["数据访问类型"].Value.ToString().Trim(); model.OrgCode = dgv.Rows[i].Cells["机构编码"].Value.ToString().Trim(); #endregion listModel.Add(model); dtslist.Add(model.Id); break; } } } if (model.Id > 0) { ExecuteStatus = 1; dal.ExecuteConfig(model, DateTime.Now); InvokeReFreshDgv rf = new InvokeReFreshDgv(RemoveDgv); this.BeginInvoke(rf, new object[] { model.Id.ToString().Trim() }); ExecuteStatus = 0; } } } #endregion }
public string AddUser(string UserName, string Password, string TCpassword, DateTime Birthday, string Name, string Tel, string Email, string Agent, string post, string Answer) { if (UserName.Trim() == "") { return("err8"); } else { if (UserName.Trim().Length < 6 || UserName.Trim().Length > 15) { return("err9"); } } if (ChkBadWord(UserName.Trim()))//检测是否有非法字符 { return("err8"); } Model.User info = new Model.User(); Model.Agent agent = null; Model.Agent subAgent = null; Model.Agent parAgent = null; Model.Agent zAgent = null; if (!string.IsNullOrEmpty(Email)) { if (DAL.UserService.IsExistEmail(Email)) { return("err:email"); //邮箱重复 } } AgentManager am = new AgentManager(); if (string.IsNullOrEmpty(Agent) || Agent == "undefined") { //网站直接会员 ConfigManager cm = new ConfigManager(); string styp = "人民币"; Model.Config config = cm.GetConfigByOtype(styp); Agent = config.Oval; } //代理会员 agent = am.GetAgentByUserName(Agent); //if (agent==null) //{ // return "err2"; //} //选择的币种是否与推荐人币种一致 //info.parentcode = agent.ParentCode; subAgent = am.GetAgentByUserName(agent.SubCompany); parAgent = am.GetAgentByUserName(agent.Partner); zAgent = am.GetAgentByUserName(agent.GeneralAgent); info.GeneralAgent = agent.GeneralAgent; info.GeneralAgentPercent = Convert.ToDecimal(zAgent.Percent); info.GeneralAgentCommission = zAgent.CommissionA; info.Agent = Agent; info.AgentPercent = Convert.ToDecimal(agent.Percent); info.AgentCommission = agent.CommissionA; info.CompanyPercent = 0; info.PartnerCommission = 0; info.SubCompany = agent.SubCompany; info.SubCompanyPercent = Convert.ToDecimal(subAgent.Percent); info.SubCompanyCommission = subAgent.CommissionA; info.Partner = agent.Partner; info.PartnerPercent = Convert.ToDecimal(parAgent.Percent); info.PartnerCommission = parAgent.CommissionA; info.Percent = 0; info.Commission = 0; info.Credit = 0; info.UpUserName = agent.UserName; info.UpUserID = agent.ID; info.UpRoleId = agent.RoleId; info.ItemMin = agent.ItemMin; info.ItemMax = agent.ItemMax; info.ItemsMax = agent.ItemsMax; info.Group = "A"; info.ResetCredit = "0"; info.RegistrationTime = DateTime.Now; info.LastLoginTime = DateTime.Now; info.UserLevel = "5"; info.Coefficient = 0; info.Proportion = 0; info.Balance = 0; info.RoleId = 6; info.UserName = UserName.Trim(); info.Password = Password; info.TCpassword = TCpassword; info.Birthday = Birthday; info.Name = Name.Trim(); info.Tel = Tel; info.Email = Email; info.Agent = Agent.Trim(); info.Status = 1; info.MoneyType = "0"; info.regip = Util.RequestHelper.GetIP(); info.Post = post.Trim(); info.Answer = Answer.Trim(); bool reval = UserManager.AddAgentUser2(info); if (reval) { //用户登录 UserManager um = new UserManager(); Model.User user = null; user = um.GetUserByUserName(info.UserName); if (user != null) { Session[ProjectConfig.LOGINUSER] = user; CookieHelper cook = new CookieHelper(); //cook.SetCookie(ProjectConfig.LANGUAGE_COOK, "tw", TimeSpan.FromDays(1)); Application[user.ID + "Session"] = this.Session.SessionID; user.LastLoginIP = RequestHelper.GetIP(); UserManager.UpdateUser(user); //会员登录日志 UserManager.AddLogClient(user.UserName); //发送游戏帐号开通信息到后台 Boolean isOk = Getpwds(Password, "1"); } } if (reval) { //当注册成功时,发送邮件。 try { string isok = SendEmail2(Email, UserName, Name); if (isok != "ok") { return("1000"); } //else return "ok"; return("ok"); } catch (Exception) { return("8008"); } } else { return("err"); } }