public static void UpdateStyleFile(string StyleFilePath, Style style) { if (!string.IsNullOrEmpty(StyleFilePath) && style != null) { StreamWriter streamWriter = new StreamWriter(StyleFilePath, false); streamWriter.Write(style.Details); streamWriter.Flush(); streamWriter.Close(); } }
public static int Add(Style style) { return StyleDataMapper.Add(style); }
public static void Update(Style style) { StyleDataMapper.Update(style); }
internal static void FillFromReader(Style style, SqlDataReader reader) { int colIndex = 0; int days = 0, seconds = 0; colIndex = reader.GetOrdinal(CN_STYLE_CREATION_DAY); if (!reader.IsDBNull(colIndex)) days = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_STYLE_CREATION_SEC); if (!reader.IsDBNull(colIndex)) seconds = reader.GetInt32(colIndex); style.CreationDate = CMSCoreHelper.GetDateTime(days, seconds); colIndex = reader.GetOrdinal(CN_STYLE_DETAILS); if (!reader.IsDBNull(colIndex)) style.Details = reader.GetString(colIndex); colIndex = reader.GetOrdinal(CN_STYLE_FILE_NAME); if (!reader.IsDBNull(colIndex)) style.FileName = reader.GetString(colIndex); colIndex = reader.GetOrdinal(CN_STYLE_ID); if (!reader.IsDBNull(colIndex)) style.ID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_STYLE_IS_DELETED); if (!reader.IsDBNull(colIndex)) style.IsDeleted = reader.GetBoolean(colIndex); colIndex = reader.GetOrdinal(CN_STYLE_LANGUAGE_ID); if (!reader.IsDBNull(colIndex)) style.LanguageID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_STYLE_NAME); if (!reader.IsDBNull(colIndex)) style.Name = reader.GetString(colIndex); colIndex = reader.GetOrdinal(CN_STYLE_PORTAL_ID); if (!reader.IsDBNull(colIndex)) style.PortalID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_STYLE_CREATED_BY); if (!reader.IsDBNull(colIndex)) style.CreatedBy = reader.GetInt32(colIndex); }
internal static Style GetStyle(List<Style> styles, SqlDataReader reader) { int colIndex = 0; colIndex = reader.GetOrdinal(CN_STYLE_ID); int value = reader.GetInt32(colIndex); Style style = styles.Where(c => c.ID == value).FirstOrDefault(); if (style == null) { style = new Style(); styles.Add(style); } return style; }
internal static Style GetStyleById(int StyleID) { Style style = null; using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString)) { SqlCommand sqlCommand = new SqlCommand(SN_STYLE_GET_BY_ID, sqlConnection); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter parameter = new SqlParameter(PN_STYLE_ID, System.Data.SqlDbType.Int); parameter.Direction = System.Data.ParameterDirection.Input; parameter.Value = StyleID; sqlCommand.Parameters.Add(parameter); sqlCommand.Connection.Open(); using (SqlDataReader reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { while (reader.Read()) { if (style == null) style = new Style(); FillFromReader(style, reader); } reader.Close(); sqlCommand.Connection.Close(); } } return style; }