/// <summary> /// 返回最新未使用的凭证号 /// </summary> /// <returns></returns> public static string GetNewNum() { GeneralConfigInfo ManageConfig = GeneralConfigs.GetConfig(); ManageConfig.CertificateCode = (Convert.ToInt32(Config.GeneralConfigs.GetConfig().CertificateCode.Trim()) + 1).ToString(); GeneralConfigs.Serialiaze(ManageConfig, Utils.GetMapPath(BaseConfigs.GetSysPath + "config/general.config")); BaseConfigs.ResetConfig(); return(ManageConfig.CertificateCode); }
/// <summary> /// 返回最新未使用单据号 /// </summary> /// <returns></returns> public static string GetNewOrderNum() { GeneralConfigInfo ManageConfig = GeneralConfigs.GetConfig(); ManageConfig.OrderID = (Convert.ToInt64(Config.GeneralConfigs.GetConfig().OrderID.Trim()) + 1).ToString(); GeneralConfigs.Serialiaze(ManageConfig, Utils.GetMapPath(BaseConfigs.GetSysPath + "config/general.config")); BaseConfigs.ResetConfig(); return(ManageConfig.OrderID); }
protected virtual void Page_Load(object sender, EventArgs e) { if (this.userid > 0) { if (CheckUserPopedoms("X")) { Act = HTTPRequest.GetString("Act"); if (!ispost) { ManageConfig = GeneralConfigs.GetConfig(); if (ManageConfig == null) { AddErrLine("获取配置信息发生错误.<br>"); } else { dList = M_Utils.GetM_ConfigInfoList(" 1=1 order by m_ConfigInfoID desc").Tables[0]; } } else { try { ManageConfig = GeneralConfigs.GetConfig(); ManageConfig.Taobao_Open = HTTPRequest.GetInt("Taobao_Open", 0); ManageConfig.Taobao_SandBox = HTTPRequest.GetInt("Taobao_SandBox", 1); GeneralConfigs.Serialiaze(ManageConfig, Utils.GetMapPath(BaseConfigs.GetSysPath + "config/general.config")); BaseConfigs.ResetConfig(); Caches.ReSet(); AddMsgLine("提交成功!"); SetBackLink("mconfig.aspx?r=" + Utils.GetRanDomCode()); SetMetaRefresh(1, "mconfig.aspx?r=" + Utils.GetRanDomCode()); } catch (Exception ex) { AddErrLine("提交时发生错误:<br>" + ex.Message.ToString()); } } } else { AddErrLine("权限不足!"); AddScript("window.parent.HidBox();"); } } else { AddErrLine("请先登录!"); SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer())); SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer())); } }
private bool SaveDBConfig(BaseConfigInfo bci) { try { string file = Server.MapPath("~/config/db.config"); BaseConfigs.SaveConfigTo(bci, file); BaseConfigs.ResetConfig(); SetupPage.CreateLockFile(); return(true); } catch { ErrProcess(bci); } return(false); }
public static void ResetApplication() { lock (lockHelper) { HttpContext context = HttpContext.Current; context.Application.Clear(); if (context.Session != null) { context.Session.Clear(); } BaseConfigs.ResetConfig(); SiteConfigs.ResetConfig(); GeneralConfigs.ResetConfig(); context.Application["We7.Application.OnlinePeople.Key"] = 0; if (BaseConfigs.ConfigFileExist()) { BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); string root = context.Server.MapPath("~/"); string dataPath = context.Server.MapPath("~/App_Data/XML"); ObjectAssistant assistant = new ObjectAssistant(); try { if (baseconfig != null && baseconfig.DBConnectionString != "") { baseconfig.DBConnectionString = baseconfig.DBConnectionString.Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory).Replace("\\\\", "\\"); assistant.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver); } assistant.LoadDataSource(dataPath); } catch (DataException ex) { Debug.WriteLine(ex.ToString()); string s = string.Format("注意检查:/app_data/xml目录下的配置文件:\r\n错误代码:{0}\r\n错误消息:{1}", ex.Errorcode, ex.Message); LogHelper.WriteLog(typeof(ApplicationHelper), s); throw ex; } HelperFactory factory = new HelperFactory(); factory.Assistant = assistant; factory.Root = root; factory.Initialize(); context.Application["We7.HelperFactory"] = factory; } } }
private void ResetDBInfo_Click(object sender, EventArgs e) { CreateDataLogPath(); if (GenerateConfigCheckbox.Checked) { string configPath = Server.MapPath("~/config/db.config"); BaseConfigs.SaveConfigTo(DBConfig, configPath); BaseConfigs.ResetConfig(); } //读取默认db.config文件内容 BaseConfigInfo bci = BaseConfigs.GetBaseConfig(); if (bci != null && bci.DBType != "" && bci.DBConnectionString != "") { Installer.ExcuteSQLGroup(bci); this.Response.Redirect("succeed.aspx"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('无法读取数据库配置文件db.config,请检查重试。');</script>"); } }
protected virtual void Page_Load(object sender, EventArgs e) { getAct = HTTPRequest.GetString("Act"); getAdminName = HTTPRequest.GetString("adminName"); getAdminPwd = HTTPRequest.GetString("adminPwd"); comName = HTTPRequest.GetString("comName"); comID = HTTPRequest.GetString("comID"); comAddress = HTTPRequest.GetString("comAddress"); comTel = HTTPRequest.GetString("comTel"); orderNum = HTTPRequest.GetString("orderNum"); cumNum = HTTPRequest.GetString("cumNum"); ordNum = HTTPRequest.GetString("ordNum"); pzLen = HTTPRequest.GetInt("pzLen", 0); MonNum = HTTPRequest.GetInt("MonNum", 0); CounNum = HTTPRequest.GetInt("CounNum", 0); oListWidth = HTTPRequest.GetString("oListWidth"); pzWidth = HTTPRequest.GetString("pzWidth"); pzRow = HTTPRequest.GetInt("pzRow", 0); sOListWidth = HTTPRequest.GetString("sOListWidth"); sOrderRow = HTTPRequest.GetInt("sOrderRow", 0); if (!ispost) { if (getAct.IndexOf("install_four") > -1) { //设置基本配置 ManageConfig = GeneralConfigs.GetConfig(); ManageConfig.CompanyName = comName; ManageConfig.RegistrationNo = comID; ManageConfig.Address = comAddress; ManageConfig.Phone = comTel; ManageConfig.OrderID = orderNum; ManageConfig.SupplierCode = cumNum; ManageConfig.MonthlyStatementCode = ordNum; ManageConfig.CertificateCodeLen = pzLen; ManageConfig.MoneyDecimal = MonNum; ManageConfig.QuantityDecimal = CounNum; ManageConfig.PrintPageWidth = oListWidth; ManageConfig.PrintCertificatePageWidth = pzWidth; ManageConfig.CertificateRow = pzRow; ManageConfig.PrintAddPageWidth = sOListWidth; ManageConfig.PrintAddRow = sOrderRow; GeneralConfigs.Serialiaze(ManageConfig, Yannyo.Common.Utils.GetMapPath(BaseConfigs.GetSysPath + "/config/general.config")); Logs.AddEventLog(this.userid, "修改系统配置."); BaseConfigs.ResetConfig(); Caches.ReSet(); try { Yannyo.Install.Utils.toSystemReg(ManageConfig); } catch { } if (getAdminName != "" && getAdminPwd != "") { if (!tbUserInfo.ExistsUserInfo(getAdminName)) { //创建新用户 UserInfo ui = new UserInfo(); ui.uName = getAdminName; ui.uPWD = Yannyo.Common.Utils.MD5(getAdminPwd); ui.uCode = Yannyo.Common.Utils.CutString(Yannyo.Common.Utils.GetRanDomCode(), 16); ui.uLastIP = HTTPRequest.GetIP(); ui.uAppendTime = DateTime.Now; ui.uUpAppendTime = DateTime.Now; ui.uEstate = 0; ui.StaffID = 0; ui.uType = 0; ui.uPermissions = "X"; if (tbUserInfo.AddUserInfo(ui) > 0) { Logs.AddEventLog(this.userid, "新增用户:" + ui.uName); } } else { this.AddErrLine("系统已经初始化,请不要刷新页面或重新初始化!"); } } } } }
[SoapHeader("header")] //用户身份验证的soap header public string InitDBConfig(string setupDbType, DatabaseInfo dbi) { //验证是否有权访问(当然,也可以通过查询数据库实现,具体视项目要求) if (!CheckAdmin(header.UserName, header.PassWord)) { throw new Exception("无权使用此服务"); } string source = "We7.CMS.Install-InstallWebService-SetSiteConfig"; try { BaseConfigInfo baseConfig = Installer.GenerateConnectionString(setupDbType, dbi); string file = Server.MapPath("~/config/db.config"); BaseConfigs.SaveConfigTo(baseConfig, file); BaseConfigs.ResetConfig(); if (dbi.CreateDB) { Exception ex = null; int ret = Installer.CreateDatabase(baseConfig, out ex); if (ret == -1) { string msg = "数据库已存在,请重新命名或去掉重新“创建新数据库”前面的勾,使用已有数据库。"; Exception ex1 = new Exception(msg); EventLogHelper.WriteToLog(source, ex1, EventLogEntryType.Error); return(msg); } else if (ret == 0) { string exceptionMsgs = ex.Message; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); return("创建数据库发生错误。错误原因:" + exceptionMsgs); } } //设置数据库脚本路径 //string basePath = Server.MapPath("/install/SQL"); //if (!Directory.Exists(basePath)) //{ // basePath = Server.MapPath("../install/SQL"); //} if (!Directory.Exists(Server.MapPath("/_data/"))) { Directory.CreateDirectory(Server.MapPath("/_data/")); } List <string> files = new List <string>(); files.Add("create.xml"); files.Add("install.xml"); files.Add("update.xml"); Installer.ExcuteSQLGroup(baseConfig, files); //创建内容模型表 Installer.CreateModelTables(); ApplicationHelper.ResetApplication(); return("0"); } catch (Exception ex) { EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); return("创建数据库发生错误。错误原因:" + ex.Message); } }
protected virtual void Page_Load(object sender, EventArgs e) { if (this.userid > 0) { if (CheckUserPopedoms("X")) { Act = HTTPRequest.GetString("Act"); if (!ispost) { if (Act == "recache") { BaseConfigs.ResetConfig(); GeneralConfigs.Serialiaze(GeneralConfigs.GetConfig(), Utils.GetMapPath(BaseConfigs.GetSysPath + "config/general.config")); Caches.ReSet(); AddMsgLine("已重建缓存."); AddScript("window.setTimeout('history.back(1);',2000);"); } else { ManageConfig = GeneralConfigs.GetConfig(); if (ManageConfig == null) { AddErrLine("获取配置信息发生错误.<br>"); } } } else { try { ManageConfig = GeneralConfigs.GetConfig(); ManageConfig.OrderID = HTTPRequest.GetString("OrderID"); ManageConfig.MoneyDecimal = HTTPRequest.GetInt("MoneyDecimal", 0); ManageConfig.QuantityDecimal = HTTPRequest.GetInt("QuantityDecimal", 0); ManageConfig.CompanyName = HTTPRequest.GetString("CompanyName"); ManageConfig.RegistrationNo = HTTPRequest.GetString("RegistrationNo"); ManageConfig.Address = HTTPRequest.GetString("Address"); ManageConfig.Phone = HTTPRequest.GetString("Phone"); ManageConfig.MonthlyStatementCode = HTTPRequest.GetString("MonthlyStatementCode"); ManageConfig.SupplierCode = HTTPRequest.GetString("SupplierCode"); ManageConfig.ReWorkedOrderNum = HTTPRequest.GetString("ReWorkedOrderNum"); //ManageConfig.CertificateCode = HTTPRequest.GetString("CertificateCode"); ManageConfig.PrinterName = HTTPRequest.GetString("PrinterName"); ManageConfig.PrintPageWidth = HTTPRequest.GetString("PrintPageWidth"); ManageConfig.PrintCertificatePageWidth = HTTPRequest.GetString("PrintCertificatePageWidth"); ManageConfig.CertificateRow = HTTPRequest.GetInt("CertificateRow", 0); ManageConfig.CertificateCodeLen = HTTPRequest.GetInt("CertificateCodeLen", 0); ManageConfig.PrintAddPageWidth = HTTPRequest.GetString("PrintAddPageWidth"); ManageConfig.PrintAddRow = HTTPRequest.GetInt("PrintAddRow", 0); ManageConfig.Taobao_Open = HTTPRequest.GetInt("Taobao_Open", 0); ManageConfig.Order_lock = HTTPRequest.GetInt("Order_lock", 0); ManageConfig.Certificate_lock = HTTPRequest.GetInt("Certificate_lock", 0); //ManageConfig.Taobao_AppKey = HTTPRequest.GetString("Taobao_AppKey"); //ManageConfig.Taobao_AppSecret = HTTPRequest.GetString("Taobao_AppSecret"); GeneralConfigs.Serialiaze(ManageConfig, Utils.GetMapPath(BaseConfigs.GetSysPath + "config/general.config")); Logs.AddEventLog(this.userid, "修改系统配置."); BaseConfigs.ResetConfig(); Caches.ReSet(); AddMsgLine("提交成功!"); SetBackLink("config.aspx?r=" + Utils.GetRanDomCode()); SetMetaRefresh(1, "config.aspx?r=" + Utils.GetRanDomCode()); } catch (Exception ex) { AddErrLine("提交时发生错误:<br>" + ex.Message.ToString()); } } } else { AddErrLine("权限不足!"); AddScript("window.parent.HidBox();"); } } else { AddErrLine("请先登录!"); SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer())); SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer())); } }
/// <summary> /// 重启网站 /// </summary> public static void ResetApplication() { lock (lockHelper) { HttpContext context = HttpContext.Current; context.Application.Clear(); if (context.Session != null) { context.Session.Clear(); } BaseConfigs.ResetConfig(); SiteConfigs.ResetConfig(); GeneralConfigs.ResetConfig(); PluginManager.LoadPlugins(); context.Application["We7.Application.OnlinePeople.Key"] = 0; //如果数据库配置文件存在,加载配置 if (BaseConfigs.ConfigFileExist()) { BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); //加载数据库映射表 string root = context.Server.MapPath("~/"); string dataPath = context.Server.MapPath("~/App_Data/XML"); ObjectAssistant assistat = new ObjectAssistant(); try { if (baseconfig != null && baseconfig.DBConnectionString != "") { baseconfig.DBConnectionString = baseconfig.DBConnectionString. Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory).Replace("\\\\", "\\"); assistat.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver); } assistat.LoadDataSource(dataPath); } catch (Thinkment.Data.DataException ex) { Debug.WriteLine(ex.ToString()); string source = "CD.Utils_CDHelper_ResetApplication"; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); string msg = string.Format("注意检查:/app_data/xml里的配置文件:\r\n错误代码:{0}\r\n错误消息:{1}" , ex.ErrorCode, ex.Message); We7.Framework.LogHelper.WriteLog(typeof(ApplicationHelper), msg); throw ex; } HelperFactory hf = new HelperFactory(); /* * 添加内容模型表结构(系统内置字段已在LoadDataSource里添加) * author:丁乐 */ ModelHelper.ReCreateModelIndex(); MoudelMonitoring.SetModelDataDic(assistat); hf.Assistant = assistat; hf.Root = root; hf.Initialize(); context.Application.Add("We7.HelperFactory", hf); AppCtx.Cache.AddObject(HelperFactory.CacheKey, hf); MoudelMonitoring ml = new MoudelMonitoring(); //监控内容模型 } } }