/// <summary> /// 回复咨询信息 /// </summary> /// <returns></returns> private Hashtable RemvoeQues(HttpContext context) { Hashtable htRet = new Hashtable(); try { FastReadServer.admin.UserInfo user = (FastReadServer.admin.UserInfo)context.Session[FastReadServer.admin.CConst.CSession.C_UserInfoKey]; if (user == null || user.UserId == "") { htRet["msg"] = "用户信息超时,请重新登录!"; htRet["ok"] = false; return(htRet); } string sQuesId = CConvert.ToString(context.Request["qid"]); DBIndex dbm = new DBIndex(); int iRet = dbm.RemoveQuestion(sQuesId); if (iRet <= 0) { htRet["msg"] = "服务器异常,请联系管理员!"; htRet["ok"] = false; } else { htRet["ok"] = true; } } catch (Exception ex) { htRet["ok"] = false; htRet["msg"] = "处理失败!" + ex.Message; } return(htRet); }
public void InitPage() { DBIndex dbm = new DBIndex(); DataTable dt = dbm.GetAllCarousel("1").Tables[0]; rptData.DataSource = dt; rptData.DataBind(); }
/// <summary> /// Best Alignments /// </summary> /// <param name="swapPossibilities"> Value swap in DB </param> /// <param name="DB"> Data Base if sequence </param> /// <returns>Key Value Pair contains maxvalue (i.e. best alignment), DBIndex, SwapIndex, SeqPosIndex </returns> public KeyValuePair <int, List <List <int> > > ProvideBestSwapBulkAlignments(List <List <int[]> > swapPossibilities, List <FastaItem> DB) { int maxValue = int.MinValue; List <int> DBIndex = new List <int>(); List <int> SwapIndex = new List <int>(); List <int> SeqPosIndex = new List <int>(); int counter = 0; for (int i = 0; i < swapPossibilities.Count; i++) // { counter++; Console.WriteLine("Verifying swap " + counter + " of " + swapPossibilities.Count); List <int[]> swapOptions = swapPossibilities[i]; for (int j = 0; j < swapOptions.Count; j++) //SwappedOptions { for (int k = 0; k < swapOptions[j].Length; k++) { if (swapOptions[j][k] > maxValue) { maxValue = swapOptions[j][k]; DBIndex = new List <int>() { i }; SwapIndex = new List <int>() { j }; SeqPosIndex = new List <int>() { k }; } else if (swapOptions[j][k] == maxValue) { DBIndex.Add(i); SwapIndex.Add(j); SeqPosIndex.Add(k); } } } } Console.WriteLine(); return(new KeyValuePair <int, List <List <int> > >(maxValue, new List <List <int> >() { DBIndex, SwapIndex, SeqPosIndex })); }
/// <summary> /// 获取新闻列表信息 /// </summary> /// <returns></returns> private Hashtable GetQuesList(HttpContext context) { Hashtable htRet = new Hashtable(); Hashtable rowData = new Hashtable(); try { FastReadServer.admin.UserInfo user = (FastReadServer.admin.UserInfo)context.Session[FastReadServer.admin.CConst.CSession.C_UserInfoKey]; if (user == null || user.UserId == "") { htRet["msg"] = "用户信息超时,请重新登录!"; htRet["ok"] = false; return(htRet); } string sTestId = CConvert.ToString(context.Request["id"]); string sQType = CConvert.ToString(context.Request["qt"]); DBIndex dbm = new DBIndex(); DataSet ds = dbm.GetQuesList(sTestId, sQType); if (ds.Tables[0].Rows.Count == 0) { htRet["ok"] = true; htRet["cnt"] = 0; htRet["msg"] = "无数据!"; } else { ArrayList lst = new ArrayList(); foreach (DataRow dr in ds.Tables[0].Rows) { Hashtable htItem = new Hashtable(); foreach (DataColumn dc in ds.Tables[0].Columns) { htItem[dc.ColumnName] = CConvert.ToString(dr[dc.ColumnName]); } lst.Add(htItem); } htRet["ok"] = true; htRet["lst"] = lst; htRet["cnt"] = lst.Count; } } catch (Exception ex) { htRet["err"] = true; htRet["msg"] = "获取轮播信息失败!" + ex.Message; } return(htRet); }
private string CreateIndexSql(DBIndex item, string tableName) { StringBuilder strBuilder = new StringBuilder(); foreach (DBIndexField indexField in item.DbIndexFields) { strBuilder.AppendFormat("{0} {1},", indexField.Name, indexField.IndexOrderWay.ToString()); } strBuilder.Remove(strBuilder.Length - 1, 1); return(string.Format("create {0} index {1} on {2}({3})", item.IsUnique ? "unique" : string.Empty, item.Name, tableName, strBuilder.ToString())); }
/// <summary> /// 修改密码 /// </summary> /// <returns></returns> private Hashtable ChangePwd(HttpContext context) { Hashtable htRet = new Hashtable(); try { string sOldPwd = CConvert.ToString(context.Request["opwd"]).Trim(); string sNewPwd = CConvert.ToString(context.Request["npwd"]).Trim(); FastReadServer.admin.UserInfo user = (FastReadServer.admin.UserInfo)context.Session[FastReadServer.admin.CConst.CSession.C_UserInfoKey]; if (user == null || user.UserId == "") { htRet["msg"] = "用户信息超时,请重新登录!"; htRet["ok"] = false; return(htRet); } string sUid = user.UserId; DBIndex dbm = new DBIndex(); DataSet ds = new DBLogin().GetUserInfoById(sUid); if (ds.Tables[0].Rows.Count == 0) { htRet["msg"] = "用户不存在!"; htRet["ok"] = false; return(htRet); } if (System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sOldPwd, "MD5") != CConvert.ToString(ds.Tables[0].Rows[0]["pwd"])) { htRet["msg"] = "旧密码不正确!"; htRet["ok"] = false; return(htRet); } int iRet = dbm.ChangePwd(sUid, System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sNewPwd, "MD5")); if (iRet == 0) { htRet["msg"] = "服务器异常,请联系管理员!"; htRet["ok"] = false; return(htRet); } else { htRet["ok"] = true; } } catch (Exception ex) { htRet["ok"] = false; htRet["msg"] = "处理失败!" + ex.Message; } return(htRet); }
/// <summary> /// 获取新闻列表信息 /// </summary> /// <returns></returns> private Hashtable GetUpdateLog(HttpContext context) { Hashtable htRet = new Hashtable(); Hashtable rowData = new Hashtable(); try { FastReadServer.admin.UserInfo user = (FastReadServer.admin.UserInfo)context.Session[FastReadServer.admin.CConst.CSession.C_UserInfoKey]; if (user == null || user.UserId == "") { htRet["msg"] = "用户信息超时,请重新登录!"; htRet["ok"] = false; return(htRet); } string sVerCode = CConvert.ToString(context.Request["vercode"]); int iLimit = CConvert.ToInt32(context.Request["limit"]); int iPage = CConvert.ToInt32(context.Request["page"]); int allRows = 0; DBIndex dbm = new DBIndex(); DataSet ds = dbm.GetVercodeUpdateLog(sVerCode, iPage, iLimit, ref allRows); if (ds.Tables[0].Rows.Count == 0) { htRet["ok"] = true; htRet["cnt"] = 0; htRet["msg"] = "无数据!"; } else { ArrayList lst = new ArrayList(); foreach (DataRow dr in ds.Tables[0].Rows) { Hashtable htItem = new Hashtable(); htItem["code"] = CConvert.ToString(dr["code"]); htItem["last_time"] = CConvert.ToString(dr["last_time"]); lst.Add(htItem); } htRet["ok"] = true; htRet["lst"] = lst; htRet["cnt"] = allRows; htRet["curpage"] = iPage; } } catch (Exception ex) { htRet["err"] = true; htRet["msg"] = "获取轮播信息失败!" + ex.Message; } return(htRet); }
/// <summary> /// 获取在线咨询列表信息 /// </summary> /// <returns></returns> private Hashtable GetQaList(HttpContext context) { Hashtable htRet = new Hashtable(); Hashtable rowData = new Hashtable(); try { int iLimit = CConvert.ToInt32(context.Request["limit"]); int iPage = CConvert.ToInt32(context.Request["page"]); string sContent = CConvert.ToString(context.Request["sname"]); string sAll = CConvert.ToString(context.Request["all"]); int allRows = 0; DBIndex dbm = new DBIndex(); DataSet ds = dbm.GetQAList(sAll, sContent, iPage, iLimit, ref allRows); if (ds.Tables[0].Rows.Count == 0) { htRet["ok"] = true; htRet["cnt"] = 0; htRet["msg"] = "无数据!"; } else { ArrayList lst = new ArrayList(); foreach (DataRow dr in ds.Tables[0].Rows) { Hashtable htItem = new Hashtable(); htItem["nickname"] = CConvert.ToString(dr["nickname"]); htItem["problem"] = (CConvert.ToString(dr["problem"])); htItem["time"] = CConvert.ToString(dr["time"]); htItem["id"] = CConvert.ToString(dr["id"]); htItem["state"] = CConvert.ToString(dr["state"]); htItem["reply"] = (CConvert.ToString(dr["reply"])); htItem["replytime"] = CConvert.ToString(dr["replytime"]); lst.Add(htItem); } htRet["ok"] = true; htRet["lst"] = lst; htRet["cnt"] = allRows; htRet["curpage"] = iPage; } } catch (Exception ex) { htRet["err"] = true; htRet["msg"] = "获取轮播信息失败!" + ex.Message; } return(htRet); }
public List <CsStatutTransfert> ChargerStatusTransfert() { try { DBIndex db = new DBIndex(); return(db.RetourneListeDesStatusTransfert()); } catch (Exception ex) { ErrorManager.WriteInLogFile(this, ex.Message); return(null); } }
public bool InsertTransfertData(string NumeroLot, string Tournee) { try { DBIndex db = new DBIndex(); return(db.InsertTransfertData(NumeroLot, Tournee)); } catch (Exception ex) { ErrorManager.WriteInLogFile(this, ex.Message); return(false); } }
public List <CsEvenement> ChargerEvenementTSP(string NumeroLot, List <string> Tournee, bool IsEnquete) { try { DBIndex db = new DBIndex(); return(db.ChargerEvenementTsp(NumeroLot, Tournee, IsEnquete)); } catch (Exception ex) { ErrorManager.WriteInLogFile(this, ex.Message); return(null); } }
public List <CsLotri> ChargerLotri(string NumeroLot, List <string> lstLotDejaCharge, bool ReleveIndexChecked) { try { DBIndex db = new DBIndex(); return(db.ChargerLotTsp(NumeroLot, lstLotDejaCharge, ReleveIndexChecked)); } catch (Exception ex) { ErrorManager.WriteInLogFile(this, ex.Message); return(null); } }
/// <summary> /// 获取轮播图片信息 /// </summary> /// <returns></returns> private Hashtable CheckVerCode(HttpContext context) { Hashtable htRet = new Hashtable(); Hashtable rowData = new Hashtable(); try { DBIndex dbm = new DBIndex(); string sVerCode = CConvert.ToString(context.Request["vercode"]); string sMac = CConvert.ToString(context.Request["mac"]); DataSet ds = dbm.getVercodeInfoByCode(sVerCode); if (ds.Tables[0].Rows.Count == 0) { htRet["msg"] = "授权码不正确!"; htRet["ok"] = false; } else { DataRow dr = ds.Tables[0].Rows[0]; if (CConvert.ToString(dr["mac"]) == "") { if (dbm.UpdateMac(sVerCode, sMac) != 1) { htRet["msg"] = "授权码不正确!"; htRet["ok"] = false; return(htRet); } } else { if (CConvert.ToString(dr["mac"]) != sMac) { htRet["msg"] = "授权码不正确!"; htRet["ok"] = false; return(htRet); } } htRet["ok"] = true; } } catch (Exception ex) { htRet["ok"] = false; htRet["msg"] = "获取轮播信息失败!" + ex.Message; } return(htRet); }
/// <summary> /// 选择redis database /// </summary> /// <param name="dbIndex"></param> /// <returns></returns> public bool Select(int dbIndex = -1) { if (dbIndex > -1) { DBIndex = dbIndex; } if (!IsCluster) { if (_cnn.DoWithOne(RequestType.SELECT, DBIndex.ToString()).Data.IndexOf(RedisConst.ErrIndex, StringComparison.InvariantCultureIgnoreCase) == -1) { return(true); } } return(false); }
/// <summary> /// 修改授权信息 /// </summary> /// <returns></returns> private Hashtable DetailQues(HttpContext context) { Hashtable htRet = new Hashtable(); try { string sId = CConvert.ToString(context.Request["qid"]).Trim(); FastReadServer.admin.UserInfo user = (FastReadServer.admin.UserInfo)context.Session[FastReadServer.admin.CConst.CSession.C_UserInfoKey]; if (user == null || user.UserId == "") { htRet["msg"] = "用户信息超时,请重新登录!"; htRet["ok"] = false; return(htRet); } DBIndex dbm = new DBIndex(); DataSet ds = dbm.GetQuesById(sId); if (ds.Tables[0].Rows.Count == 0) { htRet["msg"] = "指定的问题不存在!"; htRet["ok"] = false; return(htRet); } else { htRet["ok"] = true; DataRow dr = ds.Tables[0].Rows[0]; Hashtable ht = new Hashtable(); foreach (DataColumn dc in ds.Tables[0].Columns) { ht[dc.ColumnName] = CConvert.ToString(dr[dc.ColumnName]); } htRet["data"] = ht; } } catch (Exception ex) { htRet["ok"] = false; htRet["msg"] = "处理失败!" + ex.Message; } return(htRet); }
/// <summary> /// 增加非聚集索引 /// </summary> /// <param name="newDBIndex"></param> /// <param name="tableName"></param> /// <returns></returns> private string GetAddNonclusteredIndexSql(DBIndex newDBIndex, string tableName) { StringBuilder strBuilder = new StringBuilder(); strBuilder.AppendLine("CREATE {0} NONCLUSTERED INDEX [{1}] ON [dbo].[{2}] "); strBuilder.AppendLine("({3})"); strBuilder.AppendLine("WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, " + "SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF," + " ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]"); StringBuilder indexFieldStr = new StringBuilder(); foreach (var item in newDBIndex.DbIndexFields) { indexFieldStr.AppendFormat("[{0}] {1},", item.Name, item.IndexOrderWay == IndexOrderWay.ASC ? "ASC" : "DESC"); } indexFieldStr.Remove(indexFieldStr.Length - 1, 1); return(string.Format(strBuilder.ToString(), newDBIndex.IsUnique ? "UNIQUE" : string.Empty, newDBIndex.Name, tableName, indexFieldStr.ToString())); }
/// <summary> /// 获取在线咨询列表信息 /// </summary> /// <returns></returns> private Hashtable GetArchiveList(HttpContext context) { Hashtable htRet = new Hashtable(); Hashtable rowData = new Hashtable(); try { DBIndex dbm = new DBIndex(); DataSet ds = dbm.GetAllAchievement(); if (ds.Tables[0].Rows.Count == 0) { htRet["ok"] = true; htRet["cnt"] = 0; htRet["msg"] = "无数据!"; } else { ArrayList lst = new ArrayList(); foreach (DataRow dr in ds.Tables[0].Rows) { Hashtable htItem = new Hashtable(); htItem["id"] = CConvert.ToString(dr["id"]); htItem["title"] = CConvert.ToString(dr["title"]); htItem["time"] = CConvert.ToString(dr["time"]); // htItem["content"] = System.Web.HttpUtility.HtmlDecode(CConvert.ToString(dr["content"])); htItem["bigimg"] = CConvert.ToString(dr["bigimg"]); htItem["img"] = CConvert.ToString(dr["img"]); lst.Add(htItem); } htRet["ok"] = true; htRet["lst"] = lst; } } catch (Exception ex) { htRet["err"] = true; htRet["msg"] = "获取轮播信息失败!" + ex.Message; } return(htRet); }
/// <summary> /// 回复咨询信息 /// </summary> /// <returns></returns> private Hashtable CreateQues(HttpContext context) { Hashtable htRet = new Hashtable(); try { FastReadServer.admin.UserInfo user = (FastReadServer.admin.UserInfo)context.Session[FastReadServer.admin.CConst.CSession.C_UserInfoKey]; if (user == null || user.UserId == "") { htRet["msg"] = "用户信息超时,请重新登录!"; htRet["ok"] = false; return(htRet); } string sTrainId = CConvert.ToString(context.Request["id"]); string sQuesType = CConvert.ToString(context.Request["qt"]); string sQuesTitle = CConvert.ToString(context.Request["title"]); string sQuesOpt1 = CConvert.ToString(context.Request["op1"]); string sQuesOpt2 = CConvert.ToString(context.Request["op2"]); string sQuesOpt3 = CConvert.ToString(context.Request["op3"]); string sQuesOpt4 = CConvert.ToString(context.Request["op4"]); string sQuesRight = CConvert.ToString(context.Request["right"]); DBIndex dbm = new DBIndex(); int iRet = dbm.CreateQuestion(sQuesType, sTrainId, sQuesTitle, sQuesOpt1, sQuesOpt2, sQuesOpt3, sQuesOpt4, sQuesRight); if (iRet <= 0) { htRet["msg"] = "服务器异常,请联系管理员!"; htRet["ok"] = false; } else { htRet["ok"] = true; } } catch (Exception ex) { htRet["ok"] = false; htRet["msg"] = "处理失败!" + ex.Message; } return(htRet); }
/// <summary> /// 获取新闻详情 /// </summary> /// <returns></returns> private Hashtable GetArchiveDetail(HttpContext context) { Hashtable htRet = new Hashtable(); Hashtable rowData = new Hashtable(); try { string sID = CConvert.ToString(context.Request["id"]); DBIndex dbm = new DBIndex(); DataSet ds = dbm.GetAchievementById(sID); if (ds.Tables[0].Rows.Count == 0) { htRet["ok"] = true; htRet["cnt"] = 0; htRet["msg"] = "无数据!"; } else { ArrayList lst = new ArrayList(); DataRow dr = ds.Tables[0].Rows[0]; Hashtable htItem = new Hashtable(); htItem["id"] = CConvert.ToString(dr["id"]); htItem["title"] = CConvert.ToString(dr["title"]); htItem["time"] = CConvert.ToString(dr["time"]); htItem["content"] = System.Web.HttpUtility.HtmlDecode(CConvert.ToString(dr["content"])); htItem["bigimg"] = CConvert.ToString(dr["bigimg"]); htItem["img"] = CConvert.ToString(dr["img"]); htRet["ok"] = true; htRet["data"] = htItem; } } catch (Exception ex) { htRet["err"] = true; htRet["msg"] = "获取新闻详情失败!" + ex.Message; } return(htRet); }
/// <summary> /// 回复咨询信息 /// </summary> /// <returns></returns> private Hashtable CreateVercode(HttpContext context) { Hashtable htRet = new Hashtable(); try { FastReadServer.admin.UserInfo user = (FastReadServer.admin.UserInfo)context.Session[FastReadServer.admin.CConst.CSession.C_UserInfoKey]; if (user == null || user.UserId == "") { htRet["msg"] = "用户信息超时,请重新登录!"; htRet["ok"] = false; return(htRet); } int iNum = CConvert.ToInt32(context.Request["num"]); if (iNum == 0) { htRet["msg"] = "请输入正确的数字!"; htRet["ok"] = false; return(htRet); } DBIndex dbm = new DBIndex(); int iRet = dbm.CreateVerCode(iNum); if (iRet <= 0) { htRet["msg"] = "服务器异常,请联系管理员!"; htRet["ok"] = false; } else { htRet["ok"] = true; } } catch (Exception ex) { htRet["ok"] = false; htRet["msg"] = "处理失败!" + ex.Message; } return(htRet); }
private Hashtable GetLotteryNum(HttpContext context) { Hashtable htRet = new Hashtable(); Hashtable rowData = new Hashtable(); try { string UserId = (context.Request["UserId"]).ToString(); DBIndex dbm = new DBIndex(); DataSet ds = dbm.GetLotteryNum(UserId); //获取抽奖次数 if (ds.Tables[0].Rows.Count == 0) { htRet["ok"] = true; htRet["cnt"] = 0; htRet["msg"] = "无数据"; } else { ArrayList lst = new ArrayList(); foreach (DataRow dr in ds.Tables[0].Rows) { Hashtable htItem = new Hashtable(); htItem["LotteryNum"] = (dr["lotteryNum"]).ToString(); lst.Add(htItem); } htRet["ok"] = true; htRet["lst"] = lst; } } catch (Exception e) { htRet["ok"] = false; htRet["msg"] = "获取轮番信息失败!" + e.Message; } return(htRet); }
/// <summary> /// 修改授权信息 /// </summary> /// <returns></returns> private Hashtable ChangeVerCodeInfo(HttpContext context) { Hashtable htRet = new Hashtable(); try { string sId = CConvert.ToString(context.Request["id"]).Trim(); string sBak = CConvert.ToString(context.Request["bak"]).Trim(); string sState = CConvert.ToString(context.Request["state"]).Trim(); FastReadServer.admin.UserInfo user = (FastReadServer.admin.UserInfo)context.Session[FastReadServer.admin.CConst.CSession.C_UserInfoKey]; if (user == null || user.UserId == "") { htRet["msg"] = "用户信息超时,请重新登录!"; htRet["ok"] = false; return(htRet); } DBIndex dbm = new DBIndex(); int iRet = dbm.ChangeVerCode(sId, sBak, sState); if (iRet == 0) { htRet["msg"] = "服务器异常,请联系管理员!"; htRet["ok"] = false; return(htRet); } else { htRet["ok"] = true; } } catch (Exception ex) { htRet["ok"] = false; htRet["msg"] = "处理失败!" + ex.Message; } return(htRet); }
private List <DBIndex> MergeSchemeIndexUnique(DBTable table, DbTable designerTable) { // get designer indexes List <DBIndex> indexes = designerTable.Indices.Where(i => i.ColumnNames != "id").Select(i => new DBIndex(_db) { Table = table, Columns = i.ColumnNames.Split(',').ToList(), isUnique = i.Unique }).ToList(); // get unique columns (not PK) IEnumerable <DbColumn> uniqueColumns = designerTable.Columns.Where(c => c.Unique && !c.PrimaryKey); // get target of FK (not PK) IEnumerable <DbColumn> targetOfForeignKey = designerTable.DbSchemeCommit.Relations.Where(r => r.TargetTableId == designerTable.Id).Select(r => r.TargetColumn).Where(c => !c.PrimaryKey); foreach (DbColumn column in uniqueColumns.Concat(targetOfForeignKey)) { // exists index - update DBIndex index = indexes.SingleOrDefault(i => i.Columns.Count == 1 && i.Columns.First() == column.Name); if (index != null) { index.isUnique = true; } // create new index else { indexes.Add(new DBIndex(_db) { Table = table, Columns = new List <string> { column.Name }, isUnique = true }); } } return(indexes); }
/// <summary> /// 获取新闻列表信息 /// </summary> /// <returns></returns> private Hashtable GetViewList(HttpContext context) { Hashtable htRet = new Hashtable(); Hashtable rowData = new Hashtable(); try { FastReadServer.admin.UserInfo user = (FastReadServer.admin.UserInfo)context.Session[FastReadServer.admin.CConst.CSession.C_UserInfoKey]; if (user == null || user.UserId == "") { htRet["msg"] = "用户信息超时,请重新登录!"; htRet["ok"] = false; return(htRet); } string sViewType = CConvert.ToString(context.Request["vt"]); string sKey = CConvert.ToString(context.Request["key"]); int iLimit = CConvert.ToInt32(context.Request["limit"]); int iPage = CConvert.ToInt32(context.Request["page"]); int allRows = 0; DBIndex dbm = new DBIndex(); DataSet ds = dbm.GetViewList(sViewType, sKey, iPage, iLimit, ref allRows); if (ds.Tables[0].Rows.Count == 0) { htRet["ok"] = true; htRet["cnt"] = 0; htRet["msg"] = "无数据!"; } else { ArrayList lst = new ArrayList(); foreach (DataRow dr in ds.Tables[0].Rows) { Hashtable htItem = new Hashtable(); htItem["title"] = CConvert.ToString(dr["title"]); htItem["create_time"] = CConvert.ToString(dr["create_time"]); htItem["viewtrain_id"] = CConvert.ToString(dr["viewtrain_id"]); htItem["photo"] = CConvert.ToString(dr["photo"]); htItem["content"] = CConvert.ToString(dr["content"]); htItem["route"] = CConvert.ToString(dr["route"]); htItem["desc"] = CConvert.ToString(dr["v_desc"]); htItem["vt_type"] = CConvert.ToString(dr["vt_type"]); switch (CConvert.ToString(dr["vt_type"])) { case "1": htItem["vt_name"] = "视点移动训练"; break; case "2": htItem["vt_name"] = "视幅扩展训练"; break; case "3": htItem["vt_name"] = "瞬间感知能力"; break; } lst.Add(htItem); } htRet["ok"] = true; htRet["lst"] = lst; htRet["cnt"] = allRows; htRet["curpage"] = iPage; } } catch (Exception ex) { htRet["err"] = true; htRet["msg"] = "获取轮播信息失败!" + ex.Message; } return(htRet); }
/// <summary> /// Создание индекса для таблицы /// </summary> /// <param name="table">Таблица, для которой создается индекс</param> /// <param name="index">Создаваемый индекс</param> public override void CreateIndex(DBTable table, DBIndex index) { StringBuilder indexColumns = new StringBuilder(); foreach (string indexColumn in index.Columns) { if (indexColumns.Length > 0) indexColumns.Append(", "); indexColumns.Append(FormatColumnSafe(indexColumn)); } string schemaName = ComposeSafeSchemaName(table.Name); string tableFullName = FormatTableSafe(table); string indexName = GetIndexName(index, table); string indexFullName = ComposeSafeConstraintName(indexName); indexFullName = (string.IsNullOrEmpty(schemaName) ? indexFullName : string.Concat(schemaName, ".", indexFullName)).ToLowerInvariant(); ExecuteSqlSchemaUpdate("Index", indexName, table.Name, String.Format(CultureInfo.InvariantCulture, CreateIndexTemplate, index.IsUnique ? "unique" : string.Empty, indexFullName, tableFullName, indexColumns, string.IsNullOrEmpty(indexTablespace) ? string.Empty : "tablespace " + indexTablespace)); }
private bool IsIndexExists(DBTable table, DBIndex index) { foreach (DBIndex i in table.Indexes) { if (IsColumnsEqual(i.Columns, index.Columns)) return true; } return false; }
private void GetIndexes(DBTable table) { string schema = ComposeSafeSchemaName(table.Name); string safeTableName = ComposeSafeTableName(table.Name); Query query; if (schema == string.Empty) query = new Query( "select ind.index_name, cols.column_name, cols.column_position, ind.uniqueness " + "from user_indexes ind inner join user_ind_columns cols " + "on ind.index_name = cols.index_name and cols.table_name = ind.table_name " + "where ind.table_name = :p0 order by ind.index_name, cols.column_position", new QueryParameterCollection(new OperandValue(safeTableName)), new string[] { ":p0" }); else query = new Query( "select ind.index_name, cols.column_name, cols.column_position, ind.uniqueness " + "from all_indexes ind inner join all_ind_columns cols on ind.index_name = cols.index_name " + "and cols.index_owner = ind.table_owner and cols.table_name = ind.table_name " + "where ind.table_owner = :p0 and ind.table_name = :p1 " + "order by ind.index_name, cols.column_position", new QueryParameterCollection(new OperandValue(schema), new OperandValue(safeTableName)), new string[] { ":p0", ":p1" }); SelectStatementResult data = SelectData(query); DBIndex index = null; foreach (SelectStatementResultRow row in data.Rows) { if (Convert.ToDecimal(row.Values[2]) == 1m) { StringCollection list = new StringCollection(); list.Add((string)row.Values[1]); index = new DBIndex((string)row.Values[0], list, string.Equals(row.Values[3], "UNIQUE")); table.Indexes.Add(index); } else index.Columns.Add((string)row.Values[1]); } }
/// <summary> /// Выполняет изменение структуры данных /// </summary> protected UpdateSchemaResult ProcessUpdateSchema(UpdateSchemaMode mode, bool skipIfFirstTableNotExists, params DBTableEx[] tables) { // Конвертация исходных таблиц в таблицы с информацией о констрейнтах ICollection collectedTables = CollectTablesToCreate(tables); Hashtable createdTables = new Hashtable(); Hashtable recreateSafe = new Hashtable(); // Проверка существования первой таблицы if (skipIfFirstTableNotExists && collectedTables.Count > 0) { IEnumerator te = tables.GetEnumerator(); IEnumerator ce = collectedTables.GetEnumerator(); te.MoveNext(); ce.MoveNext(); if (object.ReferenceEquals(te.Current, ce.Current)) return UpdateSchemaResult.FirstTableNotExists; } // Изменение структуры данных if (CanCreateSchema) BeginTransaction(); try { // Создание таблиц if (!CanCreateSchema && collectedTables.Count > 0) { IEnumerator ce = collectedTables.GetEnumerator(); ce.MoveNext(); throw new SchemaCorrectionNeededException("Table '" + ComposeSafeTableName(((DBTable)ce.Current).Name) + "' not found"); } else { foreach (DBTableEx table in collectedTables) { if (table.IsView || table.IsCustom) continue; CreateTable(table); CreateSequence(table); CreatePrimaryKey(table); createdTables[table] = table; recreateSafe[table] = table; } } // Модификация таблиц Hashtable realTables = new Hashtable(); foreach (DBTableEx table in tables) { // Пропуск представлений, уже созданных таблиц // и таблиц с настраиваемой модификацией данных if (table.IsView || createdTables[table] != null || table.IsCustom) continue; DBTableEx realTable = new DBTableEx(table.Name); bool collectIndexes = false; bool collectFKs = false; bool collectConstraints = false; if (CanCreateSchema) { collectIndexes = table.Indexes.Count > 0; collectFKs = table.ForeignKeys.Count > 0; collectConstraints = table.Constraints.Exists(c => c is DBCriteriaConstraint); if (NeedsIndexForForeignKey) collectIndexes = collectIndexes || collectFKs; } GetTableSchema(realTable, collectIndexes, collectFKs, collectConstraints); realTables[table] = realTable; // Новые колонки foreach (DBColumn column in table.Columns) { // Создание колонки DBColumn realColumn = FindColumnByName(realTable, column); if (realColumn == null) { if (!CanCreateSchema) throw new SchemaCorrectionNeededException(string.Format( "Column '{0}' not found in table '{1}'", ComposeSafeColumnName(column.Name), ComposeSafeTableName(table.Name))); CreateColumn(table, column); recreateSafe[table] = table; } // Изменение типа колонки if (realColumn != null && GetDBTableColumnType(table, column) != realColumn.DBTypeName) { if (!CanCreateSchema) throw new SchemaCorrectionNeededException(string.Format( "Type of column '{0}' in table '{1}' is changed to {2}", ComposeSafeColumnName(column.Name), ComposeSafeTableName(table.Name), GetSqlCreateColumnType(table, column))); ChangeColumn(table, realColumn, column); recreateSafe[table] = table; } // Изменение констрейнта обязательности bool notNull = table.ColumnIsNotNull(column); if (realColumn != null && notNull != realTable.ColumnIsNotNull(realColumn)) { ChangeColumnNullable(table, column, notNull); recreateSafe[table] = table; } } // Старые колонки if (CanCreateSchema && (updateOptions & UpdateSchemaOptions.UnsafeChanges) != 0) { List<DBColumn> realColumns = new List<DBColumn>(realTable.Columns); foreach (DBColumn column in table.Columns) { // Поиск по колонкам заданной таблицы table, чтобы учесть преобразование имен колонок DBColumn realColumn = FindColumnByName(realTable, column); if (realColumn != null) realColumns.Remove(realColumn); } foreach (DBColumn realColumn in realColumns) DeleteColumn(realTable, realColumn); } // Последовательность для первичного ключа if (CanCreateSchema && GetTableSequenceColumn(table) != null && !GetSequence(table)) { CreateSequence(table); recreateSafe[table] = table; } // Первичный ключ if (CanCreateSchema && table.PrimaryKey != null && realTable.PrimaryKey == null) { CreatePrimaryKey(table); recreateSafe[table] = table; } // Невалидные или отсутствующие представления и пакеты if (recreateSafe[table] == null && !GetValidSafeObjects(table)) recreateSafe[table] = table; } // Индексы, ссылки, констрейнты if (CanCreateSchema) { foreach (DBTableEx table in tables) { // Новая или измененная таблица DBTableEx realTable = (DBTableEx)realTables[table]; if (realTable == null && createdTables[table] != null) { realTable = new DBTableEx(table.Name); realTable.Columns.AddRange(table.Columns); } if (realTable == null) continue; // Индексы foreach (DBIndex index in table.Indexes) { if (!IsIndexExists(realTable, index)) { CreateIndex(table, index); realTable.AddIndex(index); } } // Индексы ссылок if (NeedsIndexForForeignKey) { foreach (DBForeignKey fk in table.ForeignKeys) { DBIndex index = new DBIndex(fk.Columns, false); if (!IsIndexExists(realTable, index) && (table.PrimaryKey == null || (table.PrimaryKey != null && !IsColumnsEqual(table.PrimaryKey.Columns, index.Columns)))) { CreateIndex(table, index); realTable.AddIndex(index); } } } // Ссылки foreach (DBForeignKey fk in table.ForeignKeys) { if (!IsForeignKeyExists(realTable, fk)) CreateForeignKey(table, fk); } // Констрейнты foreach (DBCriteriaConstraint cons in table.Constraints.Where(c => c is DBCriteriaConstraint)) { string expression = OracleCheckConstraintGenerator.GenerateExpression(this, cons.Criteria); if (expression != null && !realTable.Constraints.Exists( c => c is DBCheckConstraint && ((DBCheckConstraint)c).Condition == expression)) CreateConstraint(table, expression); if (expression == null) //&& !IsConstraintExists - сложные констрейнты реализованы в пакетах recreateSafe[table] = table; } if (table.Constraints.Exists(c => !(c is DBCriteriaConstraint || c is DBNotNullConstraint))) recreateSafe[table] = table; } } // Представления и пакеты if (CanCreateSchema) { bool allSafeObjects = (updateOptions & UpdateSchemaOptions.AllSafeObjects) == UpdateSchemaOptions.AllSafeObjects; foreach (DBTableEx table in tables) { if (table.IsView || table.IsCustom || (!allSafeObjects && recreateSafe[table] == null)) continue; CreateOrReplaceView(table); CreateOrReplacePackage(table); } } // Завершение транзакции if (CanCreateSchema) CommitTransaction(); } catch { if (CanCreateSchema) RollbackTransaction(); throw; } return UpdateSchemaResult.SchemaExists; }
/// <inheritdoc/> protected override string GetIndexName(DBIndex cons, DBTable table) { if (cons.Name != null) return cons.Name; StringBuilder sb = new StringBuilder(); sb.Append("idx_"); sb.Append(ComposeSafeTableName(table.Name)); foreach (string col in cons.Columns) sb.Append(col); return sb.ToString(); }
private void GenerateTables(DbSchemeCommit dbSchemeCommit) { _progressHandler.SetMessage("GenerateTables", type: MessageType.InProgress, progressSteps: dbSchemeCommit.Tables.Count); foreach (DbTable efTable in dbSchemeCommit.Tables) { //// Table //// DBTable entitronTable = _db.Table(efTable.Name); // new if (!_db.Exists(entitronTable.Name, ETabloid.ApplicationTables)) { // columns foreach (DbColumn column in efTable.Columns) { AddColumn(entitronTable, efTable, column); } // add indexes foreach (DBIndex index in MergeSchemeIndexUnique(entitronTable, efTable)) { entitronTable.Indexes.Add(index); } // create table & columns & costraints & indexes entitronTable.Create(); } // update existing else { /// columns UpdateColumns(entitronTable, efTable); /// Indexes List <DBIndex> designerIndexes = MergeSchemeIndexUnique(entitronTable, efTable); foreach (DBIndex designerIndex in designerIndexes) { // create DBIndex entitronIndex = entitronTable.Indexes.SingleOrDefault(ei => ei.Columns.Count == designerIndex.Columns.Count && ei.Columns.All(eic => designerIndex.Columns.Contains(eic))); if (entitronIndex == null) { entitronTable.Indexes.Add(designerIndex); } // modify - isUnique changed else if (entitronIndex.isUnique != designerIndex.isUnique) { entitronTable.Indexes.Remove(entitronIndex); entitronTable.Indexes.Add(designerIndex); } } // drop IEnumerable <DBIndex> deletedIndeces = entitronTable.Indexes.Where(ei => !designerIndexes.Any(di => di.Columns.Count == ei.Columns.Count && ei.Columns.All(eic => di.Columns.Contains(eic)))).ToList(); foreach (DBIndex index in deletedIndeces) { entitronTable.Indexes.Remove(index); } } _progressHandler.IncrementProgress(); } //end foreach efTable /// SAVE _db.SaveChanges(); _ent.SaveChanges(); _progressHandler.SetMessage("GenerateTables", type: MessageType.Success); }
/// <summary> /// 获取新闻详情 /// </summary> /// <returns></returns> private Hashtable GetDetail(HttpContext context) { Hashtable htRet = new Hashtable(); Hashtable rowData = new Hashtable(); try { string sID = CConvert.ToString(context.Request["id"]); DBIndex dbm = new DBIndex(); DataSet ds = dbm.GetNewsById(sID); if (ds.Tables[0].Rows.Count == 0) { htRet["ok"] = true; htRet["cnt"] = 0; htRet["msg"] = "无数据!"; } else { ArrayList lst = new ArrayList(); DataRow dr = ds.Tables[0].Rows[0]; Hashtable htItem = new Hashtable(); htItem["category"] = CConvert.ToString(dr["category"]); htItem["categoryname"] = CConvert.ToString(dr["categoryname"]); htItem["title"] = CConvert.ToString(dr["title"]); htItem["author"] = CConvert.ToString(dr["author"]); htItem["time"] = CConvert.ToString(dr["time"]); htItem["content"] = CConvert.ToString(dr["content"]); //前一条 DataSet ds1 = dbm.getNewsPrev(CConvert.ToString(dr["category"]), sID); Hashtable htPrev = new Hashtable(); htPrev["url"] = ""; htPrev["title"] = ""; if (ds1.Tables[0].Rows.Count > 0) { htPrev["title"] = CConvert.ToString(ds1.Tables[0].Rows[0]["title"]); htPrev["id"] = CConvert.ToString(ds1.Tables[0].Rows[0]["id"]); } //后一条 DataSet ds2 = dbm.getNewsNext(CConvert.ToString(dr["category"]), sID); Hashtable htnext = new Hashtable(); htnext["url"] = ""; htnext["title"] = ""; if (ds2.Tables[0].Rows.Count > 0) { htnext["title"] = CConvert.ToString(ds2.Tables[0].Rows[0]["title"]); htnext["id"] = CConvert.ToString(ds2.Tables[0].Rows[0]["id"]); } htRet["ok"] = true; htRet["data"] = htItem; htRet["prev"] = htPrev; htRet["next"] = htnext; } } catch (Exception ex) { htRet["err"] = true; htRet["msg"] = "获取新闻详情失败!" + ex.Message; } return(htRet); }
/// <summary> /// 通过留言信息 /// </summary> /// <returns></returns> private Hashtable GetUpdateInfo(HttpContext context) { Hashtable htRet = new Hashtable(); try { string sMode = CConvert.ToString(context.Request["mode"]).Trim(); if (sMode == "") { sMode = "1";//默认【部分更新】 } string sVerCode = CConvert.ToString(context.Request["vercode"]).Trim(); string sLastTime = CConvert.ToString(context.Request["lasttime"]).Trim(); DBIndex dbm = new DBIndex(); DataSet ds = dbm.getVercodeInfoByCode(sVerCode); if (ds.Tables[0].Rows.Count == 0) { htRet["ok"] = false; htRet["msg"] = "授权码错误"; return(htRet); } if (sMode == "2") { sLastTime = "2010-01-01 00:00:00"; } //临时文件夹 string sUpdTime = DateTime.Now.ToString("yyyyMMddHHmmss"); string sPath = AppConfig.ImagePath + sVerCode + "/"; if (Directory.Exists(sPath) == false) { Directory.CreateDirectory(sPath); } DirectoryInfo di = new DirectoryInfo(sPath); di.Delete(true); if (Directory.Exists(sPath + "anima/") == false) { Directory.CreateDirectory(sPath + "anima/"); } if (Directory.Exists(sPath + "train/") == false) { Directory.CreateDirectory(sPath + "train/"); } if (Directory.Exists(sPath + "test/") == false) { Directory.CreateDirectory(sPath + "test/"); } if (Directory.Exists(sPath + "view/") == false) { Directory.CreateDirectory(sPath + "view/"); } //返回的json数据 Hashtable htJson = new Hashtable(); //获取最近更新日期之后的 卡通图标 ArrayList lstAnima = new ArrayList(); DataSet dsAnima = dbm.getAnimaByTime(sLastTime); foreach (DataRow dr in dsAnima.Tables[0].Rows) { Hashtable ht = new Hashtable(); ht["id"] = CConvert.ToString(dr["img_id"]); ht["file_name"] = CConvert.ToString(dr["file_name"]); File.Copy(AppConfig.ImagePath + "anima/" + CConvert.ToString(dr["file_name"]), sPath + "anima/" + CConvert.ToString(dr["file_name"])); lstAnima.Add(ht); } htJson["anima"] = lstAnima; //课堂训练 ArrayList lstTrain = new ArrayList(); DataSet dsTrain = dbm.getTrainByTime("1", sLastTime); foreach (DataRow dr in dsTrain.Tables[0].Rows) { Hashtable ht = new Hashtable(); ht["id"] = CConvert.ToString(dr["train_id"]); ht["title"] = CConvert.ToString(dr["title"]); ht["photo"] = CConvert.ToString(dr["photo"]); ht["content"] = CConvert.ToString(dr["content"]); ht["words"] = CConvert.ToString(dr["words"]); ht["speed"] = CConvert.ToString(dr["speed"]); File.Copy(AppConfig.ImagePath + "train/" + CConvert.ToString(dr["photo"]), sPath + "train/" + CConvert.ToString(dr["photo"])); lstTrain.Add(ht); } htJson["train"] = lstTrain; //阅读测评 ArrayList lstTest = new ArrayList(); DataSet dsTest = dbm.getTrainByTime("2", sLastTime); foreach (DataRow dr in dsTest.Tables[0].Rows) { Hashtable ht = new Hashtable(); ht["id"] = CConvert.ToString(dr["train_id"]); ht["title"] = CConvert.ToString(dr["title"]); ht["photo"] = CConvert.ToString(dr["photo"]); ht["content"] = CConvert.ToString(dr["content"]); ht["words"] = CConvert.ToString(dr["words"]); ht["speed"] = CConvert.ToString(dr["speed"]); File.Copy(AppConfig.ImagePath + "test/" + CConvert.ToString(dr["photo"]), sPath + "test/" + CConvert.ToString(dr["photo"])); lstTest.Add(ht); } htJson["test"] = lstTest; //测评问题 ArrayList lstQues = new ArrayList(); DataSet dsQues = dbm.getQuesByTime("2", sLastTime); foreach (DataRow dr in dsQues.Tables[0].Rows) { Hashtable ht = new Hashtable(); ht["id"] = CConvert.ToString(dr["q_id"]); ht["q_type"] = CConvert.ToString(dr["q_type"]); ht["train_id"] = CConvert.ToString(dr["train_id"]); ht["title"] = CConvert.ToString(dr["title"]); ht["op1"] = CConvert.ToString(dr["op1"]); ht["op2"] = CConvert.ToString(dr["op2"]); ht["op3"] = CConvert.ToString(dr["op3"]); ht["op4"] = CConvert.ToString(dr["op4"]); ht["answer"] = CConvert.ToString(dr["answer"]); lstQues.Add(ht); } htJson["question"] = lstQues; //视幅拓展训练 ArrayList lstView = new ArrayList(); DataSet dsView = dbm.getViewByTime(sLastTime); foreach (DataRow dr in dsView.Tables[0].Rows) { Hashtable ht = new Hashtable(); ht["id"] = CConvert.ToString(dr["viewtrain_id"]); ht["type"] = CConvert.ToString(dr["vt_type"]); ht["title"] = CConvert.ToString(dr["title"]); ht["photo"] = CConvert.ToString(dr["photo"]); ht["content"] = CConvert.ToString(dr["content"]); ht["route"] = CConvert.ToString(dr["route"]); ht["v_desc"] = CConvert.ToString(dr["v_desc"]); File.Copy(AppConfig.ImagePath + "view/" + CConvert.ToString(dr["photo"]), sPath + "view/" + CConvert.ToString(dr["photo"])); lstView.Add(ht); } htJson["view"] = lstView; JavaScriptSerializer jss = new JavaScriptSerializer(); StreamWriter sw = new StreamWriter(sPath + "data.json"); sw.Write(jss.Serialize(htJson)); sw.Flush(); sw.Close(); ZipOutputStream s = new ZipOutputStream(File.Create(AppConfig.ImagePath + sVerCode + sUpdTime + ".zip")); s.SetLevel(6); Compress(sPath, sPath, s); s.Finish(); s.Close(); htRet["ok"] = true; htRet["lasttime"] = sUpdTime; htRet["file"] = AppConfig.SiteRoot + "upload/" + sVerCode + sUpdTime + ".zip"; dbm.InsertUpdateLog(sVerCode); } catch (Exception ex) { htRet["ok"] = false; htRet["msg"] = "处理失败!" + ex.Message; } return(htRet); }