public override void SetPropertyValue(System.Reflection.PropertyInfo property, string value, bool isParse) { if (property.Name == "Judgements") { Judgements = new JudgementCollection(); Judgements.SetValue(value); foreach (Judgement judgement in Judgements) { if (judgement.ID == 0) { MaxId++; judgement.ID = MaxId; break; } } } else base.SetPropertyValue(property, value, isParse); }
public static void ConvertJudgements() { string sql = @" IF EXISTS (SELECT * FROM sysobjects WHERE [type] = N'U' AND [name] = N'bbsMax_Judgements') BEGIN SELECT * FROM bbsMax_Judgements; END ELSE SELECT -9999 AS JudgementID; "; JudgementSettings setting = new JudgementSettings(); JudgementCollection judgements = new JudgementCollection(); using (SqlConnection connection = new SqlConnection(Settings.Current.IConnectionString)) { connection.Open(); SqlCommand command = new SqlCommand(sql, connection); command.CommandTimeout = 60; try { bool hasCreateErrorLog = false; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { int id = reader.GetInt32(reader.GetOrdinal("JudgementID")); if (id == -9999) return; Judgement judgement = new Judgement(); judgement.ID = id; judgement.Description = reader.GetString(reader.GetOrdinal("JudgementDescription")); //judgement.LogoUrlSrc = reader.GetString(reader.GetOrdinal("Url")); string imgUrl = reader.GetString(reader.GetOrdinal("JudgementLogoUrl")).Replace("\\", "/").Trim(); int i = imgUrl.LastIndexOf("/") + 1; string iconName = string.Empty; if (imgUrl.Length > i) { iconName = imgUrl.Substring(i, imgUrl.Length - i); string targetDir = MaxLabs.bbsMax.UrlUtil.JoinUrl(MaxLabs.bbsMax.Globals.ApplicationPath, "/max-assets/icon-judgement/"); string targetIconUrl = targetDir + iconName; imgUrl = MaxLabs.bbsMax.UrlUtil.JoinUrl(MaxLabs.bbsMax.Globals.ApplicationPath, imgUrl); if (File.Exists(imgUrl)) { if (File.Exists(targetIconUrl)) { } else { try { if (Directory.Exists(targetDir) == false) Directory.CreateDirectory(targetDir); File.Move(imgUrl, targetIconUrl); } catch { if (hasCreateErrorLog == false) { hasCreateErrorLog = true; ErrorMessages.Add("�ƶ��������ͼ��ʧ��,���ֶ��ѡ�/Images/Judgements/��Ŀ¼�µ�����ͼ�긴�Ƶ���/max-assets/icon-judgement/��Ŀ¼��"); } } } } judgement.LogoUrlSrc = "~/max-assets/icon-judgement/" + iconName; } else judgement.LogoUrlSrc = string.Empty; judgements.Add(judgement); if (setting.MaxId < judgement.ID) setting.MaxId = judgement.ID; } } setting.Judgements = judgements; sql = @" UPDATE bx_Settings SET [Value] = @SettingString WHERE TypeName = 'MaxLabs.bbsMax.Settings.JudgementSettings' AND [Key] = '*'; IF @@ROWCOUNT = 0 INSERT INTO bx_Settings ([Key], [Value], [TypeName]) VALUES ('*', @SettingString, 'MaxLabs.bbsMax.Settings.JudgementSettings'); DROP TABLE bbsMax_Judgements; "; command.CommandText = sql; SqlParameter param = new SqlParameter("@SettingString", SqlDbType.NText); param.Value = setting.ToString(); command.Parameters.Add(param); command.ExecuteNonQuery(); } catch (Exception ex) { CreateLog(ex); throw new Exception("�����������ͼ������ʧ��" + ex.Message + sql); } finally { connection.Close(); } } }
public bool SaveSettings() { int rowIndex = 0; MessageDisplay msgDisplay = CreateMessageDisplay("logourl", "description"); int[] oldJudgement = StringUtil.Split<int>(_Request.Get("judgementids", Method.Post)); Judgement temp; JudgementCollection judgements = new JudgementCollection(); foreach (int j in oldJudgement) { temp = new Judgement(); temp.ID = j; temp.Description = _Request.Get("description." + j, Method.Post); temp.LogoUrlSrc = _Request.Get("logourl." + j, Method.Post); temp.IsNew = _Request.Get<bool>("isnew." + j, Method.Post, false); ValidateJudgment(temp, msgDisplay, rowIndex); rowIndex++; judgements.Add(temp); } //客户端无脚本 if (_Request.Get("newjudgements", Method.Post) != null && _Request.Get("newjudgements", Method.Post).Contains("{0}")) { temp = JudgementSettings.CreateJudgemnet(); temp.LogoUrlSrc = _Request.Get("logourl.new.{0}", Method.Post); temp.Description = _Request.Get("description.new.{0}", Method.Post); if (string.IsNullOrEmpty(temp.Description) && string.IsNullOrEmpty(temp.LogoUrl)) judgements.Add(temp); } else { oldJudgement = StringUtil.Split<int>(_Request.Get("newjudgements", Method.Post)); foreach (int j in oldJudgement) { temp = JudgementSettings.CreateJudgemnet(); temp.LogoUrlSrc = _Request.Get("logourl.new." + j, Method.Post); temp.Description = _Request.Get("description.new." + j, Method.Post); ValidateJudgment(temp, msgDisplay, rowIndex); rowIndex++; judgements.Add(temp); } } if (!msgDisplay.HasAnyError()) { JudgementSettings.Judgements = judgements; foreach (Judgement j in judgements) { j.IsNew = false; } SettingManager.SaveSettings(JudgementSettings); } else { this.m_Judgements = judgements; msgDisplay.AddError(new DataNoSaveError()); } return true; }
public bool SaveSettings() { int rowIndex = 0; MessageDisplay msgDisplay = CreateMessageDisplay("logourl", "description"); int[] oldJudgement = StringUtil.Split <int>(_Request.Get("judgementids", Method.Post)); Judgement temp; JudgementCollection judgements = new JudgementCollection(); foreach (int j in oldJudgement) { temp = new Judgement(); temp.ID = j; temp.Description = _Request.Get("description." + j, Method.Post); temp.LogoUrlSrc = _Request.Get("logourl." + j, Method.Post); temp.IsNew = _Request.Get <bool>("isnew." + j, Method.Post, false); ValidateJudgment(temp, msgDisplay, rowIndex); rowIndex++; judgements.Add(temp); } //客户端无脚本 if (_Request.Get("newjudgements", Method.Post) != null && _Request.Get("newjudgements", Method.Post).Contains("{0}")) { temp = JudgementSettings.CreateJudgemnet(); temp.LogoUrlSrc = _Request.Get("logourl.new.{0}", Method.Post); temp.Description = _Request.Get("description.new.{0}", Method.Post); if (string.IsNullOrEmpty(temp.Description) && string.IsNullOrEmpty(temp.LogoUrl)) { judgements.Add(temp); } } else { oldJudgement = StringUtil.Split <int>(_Request.Get("newjudgements", Method.Post)); foreach (int j in oldJudgement) { temp = JudgementSettings.CreateJudgemnet(); temp.LogoUrlSrc = _Request.Get("logourl.new." + j, Method.Post); temp.Description = _Request.Get("description.new." + j, Method.Post); ValidateJudgment(temp, msgDisplay, rowIndex); rowIndex++; judgements.Add(temp); } } if (!msgDisplay.HasAnyError()) { JudgementSettings.Judgements = judgements; foreach (Judgement j in judgements) { j.IsNew = false; } SettingManager.SaveSettings(JudgementSettings); } else { this.m_Judgements = judgements; msgDisplay.AddError(new DataNoSaveError()); } return(true); }