public FrmSiteEdit(DBOperateType type, CoSite site, string parentID) { InitializeComponent(); Type = type; Site = site; ParentID = parentID; }
public FrmParameterEdit(DBOperateType type, SysParameter parameter, string parameterType) { InitializeComponent(); Type = type; Parameter = parameter; ParameterType = parameterType; }
public FrmDepartmentEdit(DBOperateType type, CoDepartment dept, int parentID) { InitializeComponent(); Type = type; Department = dept; ParentID = parentID; }
public FrmFunctionEdit(DBOperateType type, SysFunction function, string parentCode) { InitializeComponent(); Type = type; Function = function; ParentCode = parentCode; }
public DataOperateResult(DBOperateType operationType, Exception ex) { OperateType = operationType; HasError = true; ErrorType = DBErrorType.UnKnowError; ExceptionMessage = ex.ToString(); // ex.AddLog("Error", 0); }
public bool SubmitData(DBOperateType opType, string entityName, string pkName, string pkValue, Dictionary <string, object> dicParams) { FE_SubmitDataParam param = new FE_SubmitDataParam(); param.OperateType = opType; param.EntityName = entityName; param.PrimaryKey = pkName; param.PKValue = pkValue; param.SubmitValues = dicParams; return(SubmitData(param)); }
/// <summary> /// 采集并计算北京数据 /// </summary> /// <param name="periodNum">期号</param> /// <param name="retTime">开奖时间</param> /// <param name="dbOperateType">DB操作类型</param> /// <returns></returns> public bool CollectAndCalculateBeijing(long periodNum, DateTime retTime, DBOperateType dbOperateType) { bool result = true; string errorMessage = "{0},方法:CollectAndCalculate,期号:" + periodNum.ToString(); try { #region 采集数据 CollectResultEntity collectResult = CollectBeijingData.Instance().Collect(periodNum, retTime); if (collectResult == null || collectResult.Group == null || collectResult.Group.Length != 20) { WriteLog.Write(string.Format(errorMessage, "采集数据失败")); return false; } collectResult.PeriodNum = periodNum; collectResult.RetTime = retTime; #endregion #region 计算数据 //28数据 List<SourceDataEntity> sourceDataList28 = Calculate28Data(collectResult); if (sourceDataList28 == null || sourceDataList28.Count == 0) { WriteLog.Write(string.Format(errorMessage, "计算数据失败")); return false; } #endregion #region DB持久化 //28数据 switch (dbOperateType) { case DBOperateType.Insert: result = Insert28Data(Source.Beijing, sourceDataList28); break; case DBOperateType.Update: result = Update28Data(Source.Beijing, sourceDataList28); break; } #endregion } catch (Exception ex) { WriteLog.Write(string.Format(errorMessage, "异常,异常信息:" + ex.ToString())); } return result; }
internal static string GetConnectionString(DBOperateType dBOperateType) { string connString = null; switch (dBOperateType) { case DBOperateType.Write: connString = ConfigurationManager.SqlConnectionStringWrite; break; case DBOperateType.Read: connString = DispatcherConn(); break; default: throw new Exception("类型错误"); } return connString; }
public void AddTableDb(string table_name, DBWorkPool db, DBOperateType operate_type) { switch (operate_type) { case DBOperateType.Write: WriteTableList.Add(table_name, db); break; case DBOperateType.Read: ReadTableList.Add(table_name, db); break; default: Console.WriteLine("add table db failed: got invalid opetate type {0}", operate_type); break; } }
public void AddTableDB(string tableName, DBManagerPool db, DBOperateType operateType) { switch (operateType) { case DBOperateType.Write: WriteTableList.Add(tableName, db); break; case DBOperateType.Read: ReadTableList.Add(tableName, db); break; default: LOG.Error("add table db falied:got invalid opetate type {0}", operateType); break; } }
internal static string GetConnectionString(DBOperateType dBOperateType) { if (!ConfigurationManager.GetEnableWriteRead) { return(ConfigurationManager.SqlConnectionStringCustom); } switch (dBOperateType) { case DBOperateType.Write: return(ConfigurationManager.SqlConnectionStringWrite); case DBOperateType.Read: return(DispatcherConn()); default: throw new Exception("Wrong DBOperateType"); } }
public DBWorkPool GetDbByTable(string table_name, DBOperateType type) { DBWorkPool db = null; switch (type) { case DBOperateType.Write: WriteTableList.TryGetValue(table_name, out db); break; case DBOperateType.Read: ReadTableList.TryGetValue(table_name, out db); break; default: break; } return(db); }
public FrmEmployeeEdit(DBOperateType type, CoEmployee employee) { InitializeComponent(); Type = type; Employee = employee; }
public void Call(AbstractDBOperater query, int index, string table_name = DBProxyDefault.DefaultTableName, DBOperateType type = DBProxyDefault.DefaultOperateType, DBCallback callback = null) { DBWorkPool dbPool = GetDbByTable(table_name, type); if (dbPool == null) { Log.Error("db call {0} failed: can not find table {1} type {2} db", query.GetCmd(), table_name, type.ToString()); return; } dbPool.Call(query, index, callback); }
public FrmDestinationEdit(DBOperateType type, CoDestination destination) { InitializeComponent(); Type = type; Destination = destination; }
public FrmUserEdit(DBOperateType type, SysUser user) { InitializeComponent(); Type = type; User = user; }
public void Call(AbstractDBQuery query, string tableName = DBProxyDefault.DefaultTableName, DBOperateType type = DBProxyDefault.DefaultOperateType, DBCallback callback = null) { DBManagerPool dbPool = GetDbByTable(tableName, type); if (dbPool == null) { LOG.Warn("db call {0} failed:can not find table{1} type {2} db", query.GetCmd(), tableName, type.ToString()); return; } dbPool.Call(query, callback); }
public DataOperateResult(DBOperateType operationType) { OperateType = operationType; }
/// <summary> /// 根据参数保存修改实体数据 /// </summary> /// <param name="param"></param> /// <returns></returns> public bool SubmitData(FE_SubmitDataParam param) { if (param == null) { return(false); } if (string.IsNullOrWhiteSpace(param.EntityName)) { return(false); } if (param.OperateType != DBOperateType.Add && (string.IsNullOrWhiteSpace(param.PrimaryKey) || string.IsNullOrWhiteSpace(param.PKValue))) { return(false); } if (param.OperateType != DBOperateType.Delete && param.OperateType != DBOperateType.View && (param.SubmitValues == null || param.SubmitValues.Count == 0)) { return(false); } DBOperateType opType = param.OperateType; string entityName = param.EntityName; string pkName = param.PrimaryKey; string pkValue = param.PKValue; Dictionary <string, string> dicParams = new Dictionary <string, string>(); foreach (KeyValuePair <string, object> keyValuePair in param.SubmitValues) { if (!string.IsNullOrWhiteSpace(keyValuePair.Key)) { string value = string.Empty; if (keyValuePair.Value != null) { value = keyValuePair.Value.ToString(); } if (keyValuePair.Key.IndexOf("time", StringComparison.OrdinalIgnoreCase) > 0 || keyValuePair.Key.IndexOf("date", StringComparison.OrdinalIgnoreCase) > 0) { if (value.Contains("午") || value.Contains("星期") || value.Contains("周") || !value.Take(4).All(char.IsNumber)) { value = DateTimeHelper.ToDateTime(value).ToFormatDateTimeStr(); } } dicParams.Add(keyValuePair.Key, value); } } DataTable dtStruct = GetTableStruct(entityName); bool falseDel = dtStruct.Columns.Contains("is_del"); bool autoInputTime = dtStruct.Columns.Contains("input_time") && opType == DBOperateType.Add; if (autoInputTime && !dicParams.ContainsKey("input_time")) { dicParams.Add("input_time", TmoShare.DateTimeNow); } bool autoUpdateTime = dtStruct.Columns.Contains("update_time") && opType != DBOperateType.Delete; if (autoUpdateTime && !dicParams.ContainsKey("update_time")) { dicParams.Add("update_time", DateTimeHelper.DateTimeNowStr); } StringBuilder sbsql = new StringBuilder(); if (opType == DBOperateType.Add) { if (falseDel) { if (dicParams.ContainsKey("is_del")) { dicParams["is_del"] = "0"; } else { dicParams.Add("is_del", "0"); } } sbsql.AppendFormat("insert into {0}(", entityName); int i = 0; foreach (string col in dicParams.Keys) { sbsql.Append(col); if (i < dicParams.Count - 1) { sbsql.Append(","); } i++; } sbsql.Append(") values("); i = 0; foreach (string val in dicParams.Values) { sbsql.AppendFormat("'{0}'", val); if (i < dicParams.Count - 1) { sbsql.Append(","); } i++; } sbsql.Append(");"); } else if (opType == DBOperateType.Update) { sbsql.AppendFormat("update {0} set ", entityName); int i = 0; foreach (var item in dicParams) { sbsql.AppendFormat("{0}='{1}'", item.Key, item.Value); if (i < dicParams.Count - 1) { sbsql.Append(","); } i++; } sbsql.AppendFormat(" where {0}='{1}';", pkName, pkValue); } else if (opType == DBOperateType.Delete) { return(DeleteData(entityName, pkName, pkValue)); } int count = MySQLHelper.ExecuteSqlTran(sbsql.ToString()); if (count > 0) { if (entityName.ToLower() == "tmo_monitor_devicebind") { MemoryCacheHelper.ClearCache("tmo_monitor_devicebind"); } } return(count > 0); }
/// <summary> /// 根据传过来参数添加或修改数据 /// </summary> /// <param name="submitdataEntityParams"></param> /// <returns></returns> public bool SubmitData(string submitdataEntityParams) { List <string> list = StringPlus.GetStrArray(submitdataEntityParams, "_;_"); DBOperateType opType = (DBOperateType)Convert.ToInt32(list[0]); string entityName = list[1]; string pkName = list[2]; string pkValue = list[3]; string dicStr = list[4]; if (string.IsNullOrWhiteSpace(dicStr) && opType != DBOperateType.Delete) { return(false); } Dictionary <string, string> dicParams = new Dictionary <string, string>(); List <string> tmp = StringPlus.GetStrArray(dicStr, "-|-"); for (int i = 0; i < tmp.Count - 1; i++) { List <string> t = StringPlus.GetStrArray(tmp[i], "_|_"); dicParams.Add(t[0], t[1]); } DataTable dtStruct = GetTableStruct(entityName); bool falseDel = dtStruct.Columns.Contains("is_del"); bool autoInputTime = dtStruct.Columns.Contains("input_time") && opType == DBOperateType.Add; if (autoInputTime && !dicParams.ContainsKey("input_time")) { dicParams.Add("input_time", TmoShare.DateTimeNow); } StringBuilder sbsql = new StringBuilder(); if (opType == DBOperateType.Add) { if (falseDel) { if (dicParams.ContainsKey("is_del")) { dicParams["is_del"] = "0"; } else { dicParams.Add("is_del", "0"); } } sbsql.AppendFormat("insert into {0}(", entityName); int i = 0; foreach (string col in dicParams.Keys) { sbsql.Append(col); if (i < dicParams.Count - 1) { sbsql.Append(","); } i++; } sbsql.Append(") values("); i = 0; foreach (string val in dicParams.Values) { sbsql.AppendFormat("'{0}'", val); if (i < dicParams.Count - 1) { sbsql.Append(","); } i++; } sbsql.Append(");"); } else if (opType == DBOperateType.Update) { sbsql.AppendFormat("update {0} set ", entityName); int i = 0; foreach (var item in dicParams) { sbsql.AppendFormat("{0}='{1}'", item.Key, item.Value); if (i < dicParams.Count - 1) { sbsql.Append(","); } i++; } sbsql.AppendFormat(" where {0}='{1}';", pkName, pkValue); } else if (opType == DBOperateType.Delete) { return(DeleteData(entityName, pkName, pkValue)); } int count = MySQLHelper.ExecuteSqlTran(sbsql.ToString()); if (count > 0) { if (entityName.ToLower() == "tmo_monitor_devicebind") { MemoryCacheHelper.ClearCache("tmo_monitor_devicebind"); } } return(count > 0); }
public FrmCustomersEdit(DBOperateType type, CoCustomers customers) { InitializeComponent(); Type = type; Customers = customers; }