init lserp cs 5.0

This commit is contained in:
cyf
2026-07-10 15:25:05 +08:00
commit 90f3fda86a
3799 changed files with 976868 additions and 0 deletions
@@ -0,0 +1,30 @@
using System;
namespace Zhaizj.Framework.Config {
/// <summary>
/// 配置项
/// </summary>
public interface ISetting {
int Id { get; set; }
String DataType { get; set; }
String Name { get; set; }
String Description { get; set; }
// 格式json
String Options { get; set; }
String SettingValue { get; set; }
String ValueString { get; }
int ValueInt { get; }
Boolean ValueBool { get; }
DateTime ValueTime { get; }
}
}
@@ -0,0 +1,18 @@
using System;
namespace Zhaizj.Framework.Config {
/// <summary>
/// 配置值的接口
/// </summary>
public interface ISettingValue {
int Id { get; set; }
String DataType { get; set; }
String SettingValue { get; set; }
void Update( String propertyName );
}
}
@@ -0,0 +1,116 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Zhaizj.Framework.Common.Resource;
using Zhaizj.Framework.Serialization;
using Zhaizj.Framework.Web;
using Zhaizj.Framework.Web.Context;
using Zhaizj.Framework.Web.Mvc;
namespace Zhaizj.Framework.Config {
/// <summary>
/// ÅäÖÃ±íµ¥¹¤¾ß
/// </summary>
public class SettingFormTool {
public static void BindTemplate( Template template, IList list, String categoryName, String actionUrl ) {
template.Set( "settingCategory.Name", categoryName );
template.Set( "ActionUrl", actionUrl );
IBlock block = template.GetBlock( "list" );
foreach (ISetting setting in list) {
block.Set( "setting.Id", setting.Id );
block.Set( "setting.Title", setting.Name );
SetInput( block, setting );
SetNote( block, setting );
block.Next();
}
}
private static void SetInput( IBlock block, ISetting setting ) {
String lbl = "setting.inputControl";
String inputName = GetInputName( setting.Id );
String settingValue = setting.SettingValue;
int width = 500;
if (setting.DataType == SettingType.Int.ToString()) {
block.Set( lbl, Html.TextInput( inputName, settingValue, "width:40px;" ) );
}
else if (setting.DataType == SettingType.Bool.ToString()) {
block.Set( lbl, Html.CheckBox( inputName, "", "1", Convert.ToBoolean( setting.SettingValue ) ) );
}
else if (setting.DataType == SettingType.Droplist.ToString()) {
block.Set( lbl, Html.DropList( getDropOptions(setting.Options), inputName, "Name", "Value", setting.ValueInt ) );
}
else if (setting.DataType == SettingType.ShortText.ToString()) {
block.Set( lbl, Html.TextInput( inputName, settingValue, "width:" + width + "px;" ) );
}
else if (setting.DataType == SettingType.BigText.ToString()) {
block.Set( lbl, Html.TextArea( inputName, settingValue, "width:" + width + "px;height:300px;" ) );
}
else {
block.Set( lbl, Html.TextArea( inputName, settingValue, "width:" + width + "px;height:50px;" ) );
}
}
private static PropertyCollection getDropOptions( String Options ) {
PropertyCollection result = new PropertyCollection();
if (strUtil.IsNullOrEmpty( Options )) return result;
Dictionary<String, object> dic = JsonParser.Parse( Options ) as Dictionary<String, object>;
foreach (KeyValuePair<String, object> pair in dic) {
result.Add( new PropertyItem( pair.Key, cvt.ToInt( pair.Value ) ) );
}
return result;
}
private static void SetNote( IBlock block, ISetting setting ) {
if (strUtil.HasText( setting.Description )) {
if ((setting.DataType == SettingType.Int.ToString()) || (setting.DataType == SettingType.Bool.ToString())) {
block.Set( "setting.Note", "<span class=\"note\">(" + setting.Description + ")</span>" );
}
else {
block.Set( "setting.Note", "<div class=\"note\">(" + setting.Description + ")</div>" );
}
}
else {
block.Set( "setting.Note", "" );
}
}
//------------------------------------------------------------------------------------
public static void UpdateSettings( IList list, MvcContext ctx ) {
for (int i = 0; i < list.Count; i++) {
ISettingValue s = list[i] as ISettingValue;
String target = ctx.Post( GetInputName( s.Id ) );
if (strUtil.HasText( target )) {
if (s.DataType == SettingType.Bool.ToString()) {
updateSetting( s, cvt.ToBool( target ).ToString() );
}
else if (!(s.DataType == SettingType.Int.ToString()) || cvt.IsInt( target )) {
updateSetting( s, target );
}
}
}
}
private static void updateSetting( ISettingValue s, String val ) {
if ((val != null) && (s.SettingValue.ToLower() != val.ToLower())) {
s.SettingValue = val;
s.Update( "SettingValue" );
}
}
private static String GetInputName( int settingId ) {
return ("SettingValue" + settingId);
}
}
}
@@ -0,0 +1,20 @@
using System;
namespace Zhaizj.Framework.Config {
/// <summary>
/// 配置项的数据类型
/// </summary>
public enum SettingType {
Int,
Bool,
ShortText,
LongText,
BigText,
Droplist
}
}