public Boolean UpdateModuleConfigInfo(Guid moduleID, String json, Boolean isActive, Int32 deviceType) { List <JZTestConfig> list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <JZTestConfig> >(json); Boolean flag = true; if (list != null) { IDbConnection DbConnection = GetConntion(); Yqun.Data.DataBase.Transaction Transaction = new Yqun.Data.DataBase.Transaction(DbConnection); try { Int32 active = isActive ? 1 : 0; String sql = String.Format(@"Delete dbo.sys_module_config WHERE ModuleID='{0}' ", moduleID); flag = flag && (ExcuteCommand(sql) == 1); sql = String.Format("UPDATE dbo.sys_module SET DeviceType={0} WHERE ID='{1}'", deviceType, moduleID); flag = flag && (ExcuteCommand(sql) == 1); foreach (var item in list) { String config = Newtonsoft.Json.JsonConvert.SerializeObject(item.Config); flag = flag && SaveModuleConfig(moduleID, item.SerialNumber, config, active); } if (flag) { Transaction.Commit(); } else { Transaction.Rollback(); } } catch (Exception ex) { Transaction.Rollback(); logger.Error("update module config error: " + ex.Message); } } return(flag); }
public Boolean SaveLineFormula(Guid moduleID, Dictionary <string, JZFormulaData> CrossSheetFormulaCache) { IDbConnection DbConnection = GetConntion(); Yqun.Data.DataBase.Transaction Transaction = new Yqun.Data.DataBase.Transaction(DbConnection); Boolean noError = true; String sql = "DELETE FROM dbo.sys_line_formulas WHERE ModuleID='" + moduleID + "' "; try { Int32 result = ExcuteCommand(sql); if (result == -1) { noError = false; } sql = @"INSERT INTO dbo.sys_line_formulas ( ID , ModuleID , SheetID , RowIndex , ColumnIndex , Formula , CreatedUser , CreatedTime , LastEditedUser , LasteditedTime , IsActive ) VALUES ( NEWID() , '{0}' , '{1}' , {2} , {3} , '{4}' , '{5}' , GETDATE() , '{6}' , GETDATE() , 1 )"; foreach (JZFormulaData item in CrossSheetFormulaCache.Values) { result = ExcuteCommand(String.Format(sql, item.ModelIndex, item.SheetIndex, item.RowIndex, item.ColumnIndex, item.Formula.Replace("'", "''"), Yqun.Common.ContextCache.ApplicationContext.Current.UserName, Yqun.Common.ContextCache.ApplicationContext.Current.UserName)); if (result == -1) { noError = false; } } if (noError) { Transaction.Commit(); } else { Transaction.Rollback(); } } catch (Exception ex) { Transaction.Rollback(); logger.Error("SaveLineFormula error: " + moduleID + ", error content is: " + ex.Message); } return(noError); }