code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
using UnityEngine; using System.Collections.Generic; /// <summary> /// Since it would be incredibly tedious to create thousands of unique items by hand, a simple solution is needed. /// Separating items into 2 parts is that solution. Base item contains stats that the item would have if it was max /// level. All base items are created with their stats at max level. Game item, the second item class, has an /// effective item level which is used to calculate effective item stats. Game items can be generated with a random /// level (clamped within base item's min/max level range), and with random quality affecting the item's stats. /// </summary> [System.Serializable] public class InvGameItem { public enum Quality { Broken, Cursed, Damaged, Worn, Sturdy, // Normal quality Polished, Improved, Crafted, Superior, Enchanted, Epic, Legendary, _LastDoNotUse, // Flash export doesn't support Enum.GetNames :( } // ID of the base item used to create this game item [SerializeField] int mBaseItemID = 0; /// <summary> /// Item quality -- applies a penalty or bonus to all base stats. /// </summary> public Quality quality = Quality.Sturdy; /// <summary> /// Item's effective level. /// </summary> public int itemLevel = 1; // Cached for speed InvBaseItem mBaseItem; /// <summary> /// ID of the base item used to create this one. /// </summary> public int baseItemID { get { return mBaseItemID; } } /// <summary> /// Base item used by this game item. /// </summary> public InvBaseItem baseItem { get { if (mBaseItem == null) { mBaseItem = InvDatabase.FindByID(baseItemID); } return mBaseItem; } } /// <summary> /// Game item's name should prefix the quality /// </summary> public string name { get { if (baseItem == null) return null; return quality.ToString() + " " + baseItem.name; } } /// <summary> /// Put your formula for calculating the item stat modifier here. /// Simplest formula -- scale it with quality and item level. /// Since all stats on base items are specified at max item level, /// calculating the effective multiplier is as simple as itemLevel/maxLevel. /// </summary> public float statMultiplier { get { float mult = 0f; switch (quality) { case Quality.Cursed: mult = -1f; break; case Quality.Broken: mult = 0f; break; case Quality.Damaged: mult = 0.25f; break; case Quality.Worn: mult = 0.9f; break; case Quality.Sturdy: mult = 1f; break; case Quality.Polished: mult = 1.1f; break; case Quality.Improved: mult = 1.25f; break; case Quality.Crafted: mult = 1.5f; break; case Quality.Superior: mult = 1.75f; break; case Quality.Enchanted: mult = 2f; break; case Quality.Epic: mult = 2.5f; break; case Quality.Legendary: mult = 3f; break; } // Take item's level into account float linear = itemLevel / 50f; // Add a curve for more interesting results mult *= Mathf.Lerp(linear, linear * linear, 0.5f); return mult; } } /// <summary> /// Item's color based on quality. You will likely want to change this to your own colors. /// </summary> public Color color { get { Color c = Color.white; switch (quality) { case Quality.Cursed: c = Color.red; break; case Quality.Broken: c = new Color(0.4f, 0.2f, 0.2f); break; case Quality.Damaged: c = new Color(0.4f, 0.4f, 0.4f); break; case Quality.Worn: c = new Color(0.7f, 0.7f, 0.7f); break; case Quality.Sturdy: c = new Color(1.0f, 1.0f, 1.0f); break; case Quality.Polished: c = NGUIMath.HexToColor(0xe0ffbeff); break; case Quality.Improved: c = NGUIMath.HexToColor(0x93d749ff); break; case Quality.Crafted: c = NGUIMath.HexToColor(0x4eff00ff); break; case Quality.Superior: c = NGUIMath.HexToColor(0x00baffff); break; case Quality.Enchanted: c = NGUIMath.HexToColor(0x7376fdff); break; case Quality.Epic: c = NGUIMath.HexToColor(0x9600ffff); break; case Quality.Legendary: c = NGUIMath.HexToColor(0xff9000ff); break; } return c; } } /// <summary> /// Create a game item with the specified ID. /// </summary> public InvGameItem (int id) { mBaseItemID = id; } /// <summary> /// Create a game item with the specified ID and base item. /// </summary> public InvGameItem (int id, InvBaseItem bi) { mBaseItemID = id; mBaseItem = bi; } /// <summary> /// Calculate and return the list of effective stats based on item level and quality. /// </summary> public List<InvStat> CalculateStats () { List<InvStat> stats = new List<InvStat>(); if (baseItem != null) { float mult = statMultiplier; List<InvStat> baseStats = baseItem.stats; for (int i = 0, imax = baseStats.Count; i < imax; ++i) { InvStat bs = baseStats[i]; int amount = Mathf.RoundToInt(mult * bs.amount); if (amount == 0) continue; bool found = false; for (int b = 0, bmax = stats.Count; b < bmax; ++b) { InvStat s = stats[b]; if (s.id == bs.id && s.modifier == bs.modifier) { s.amount += amount; found = true; break; } } if (!found) { InvStat stat = new InvStat(); stat.id = bs.id; stat.amount = amount; stat.modifier = bs.modifier; stats.Add(stat); } } // This would be the place to determine if it's a weapon or armor and sort stats accordingly stats.Sort(InvStat.CompareArmor); } return stats; } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Examples/Scripts/InventorySystem/System/InvGameItem.cs
C#
asf20
5,672
using UnityEngine; using System.Collections.Generic; /// <summary> /// Inventory system -- Equipment class works with InvAttachmentPoints and allows to visually equip and remove items. /// </summary> [AddComponentMenu("NGUI/Examples/Equipment")] public class InvEquipment : MonoBehaviour { InvGameItem[] mItems; InvAttachmentPoint[] mAttachments; /// <summary> /// List of equipped items (with a finite number of equipment slots). /// </summary> public InvGameItem[] equippedItems { get { return mItems; } } /// <summary> /// Equip the specified item automatically replacing an existing one. /// </summary> public InvGameItem Replace (InvBaseItem.Slot slot, InvGameItem item) { InvBaseItem baseItem = (item != null) ? item.baseItem : null; if (slot != InvBaseItem.Slot.None) { // If the item is not of appropriate type, we shouldn't do anything if (baseItem != null && baseItem.slot != slot) return item; if (mItems == null) { // Automatically figure out how many item slots we need int count = (int)InvBaseItem.Slot._LastDoNotUse; mItems = new InvGameItem[count]; } // Equip this item InvGameItem prev = mItems[(int)slot - 1]; mItems[(int)slot - 1] = item; // Get the list of all attachment points if (mAttachments == null) mAttachments = GetComponentsInChildren<InvAttachmentPoint>(); // Equip the item visually for (int i = 0, imax = mAttachments.Length; i < imax; ++i) { InvAttachmentPoint ip = mAttachments[i]; if (ip.slot == slot) { GameObject go = ip.Attach(baseItem != null ? baseItem.attachment : null); if (baseItem != null && go != null) { Renderer ren = go.renderer; if (ren != null) ren.material.color = baseItem.color; } } } return prev; } else if (item != null) { Debug.LogWarning("Can't equip \"" + item.name + "\" because it doesn't specify an item slot"); } return item; } /// <summary> /// Equip the specified item and return the item that was replaced. /// </summary> public InvGameItem Equip (InvGameItem item) { if (item != null) { InvBaseItem baseItem = item.baseItem; if (baseItem != null) return Replace(baseItem.slot, item); else Debug.LogWarning("Can't resolve the item ID of " + item.baseItemID); } return item; } /// <summary> /// Unequip the specified item, returning it if the operation was successful. /// </summary> public InvGameItem Unequip (InvGameItem item) { if (item != null) { InvBaseItem baseItem = item.baseItem; if (baseItem != null) return Replace(baseItem.slot, null); } return item; } /// <summary> /// Unequip the item from the specified slot, returning the item that was unequipped. /// </summary> public InvGameItem Unequip (InvBaseItem.Slot slot) { return Replace(slot, null); } /// <summary> /// Whether the specified item is currently equipped. /// </summary> public bool HasEquipped (InvGameItem item) { if (mItems != null) { for (int i = 0, imax = mItems.Length; i < imax; ++i) { if (mItems[i] == item) return true; } } return false; } /// <summary> /// Whether the specified slot currently has an item equipped. /// </summary> public bool HasEquipped (InvBaseItem.Slot slot) { if (mItems != null) { for (int i = 0, imax = mItems.Length; i < imax; ++i) { InvBaseItem baseItem = mItems[i].baseItem; if (baseItem != null && baseItem.slot == slot) return true; } } return false; } /// <summary> /// Retrieves the item in the specified slot. /// </summary> public InvGameItem GetItem (InvBaseItem.Slot slot) { if (slot != InvBaseItem.Slot.None) { int index = (int)slot - 1; if (mItems != null && index < mItems.Length) { return mItems[index]; } } return null; } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Examples/Scripts/InventorySystem/System/InvEquipment.cs
C#
asf20
3,969
using UnityEngine; using System.Collections.Generic; /// <summary> /// Inventory System -- Base Item. Note that it would be incredibly tedious to create all items by hand, Warcraft style. /// It's a lot more straightforward to create all items to be of the same level as far as stats go, then specify an /// appropriate level range for the item where it will appear. Effective item stats can then be calculated by lowering /// the base stats by an appropriate amount. Add a quality modifier, and you have additional variety, Terraria 1.1 style. /// </summary> [System.Serializable] public class InvBaseItem { public enum Slot { None, // First element MUST be 'None' Weapon, // All the following elements are yours to customize -- edit, add or remove as you desire Shield, Body, Shoulders, Bracers, Boots, Trinket, _LastDoNotUse, // Flash export doesn't support Enum.GetNames :( } /// <summary> /// 16-bit item ID, generated by the system. /// Not to be confused with a 32-bit item ID, which actually contains the ID of the database as its prefix. /// </summary> public int id16; /// <summary> /// Name of this item. /// </summary> public string name; /// <summary> /// This item's custom description. /// </summary> public string description; /// <summary> /// Slot that this item belongs to. /// </summary> public Slot slot = Slot.None; /// <summary> /// Minimum and maximum allowed level for this item. When random loot gets generated, /// only items within appropriate level should be considered. /// </summary> public int minItemLevel = 1; public int maxItemLevel = 50; /// <summary> /// And and all base stats this item may have at a maximum level (50). /// Actual object's stats are calculated based on item's level and quality. /// </summary> public List<InvStat> stats = new List<InvStat>(); /// <summary> /// Game Object that will be created and attached to the specified slot on the body. /// This should typically be a prefab with a renderer component, such as a sword, /// a bracer, shield, etc. /// </summary> public GameObject attachment; /// <summary> /// Object's main material color. /// </summary> public Color color = Color.white; /// <summary> /// Atlas used for the item's icon. /// </summary> public UIAtlas iconAtlas; /// <summary> /// Name of the icon's sprite within the atlas. /// </summary> public string iconName = ""; }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Examples/Scripts/InventorySystem/System/InvBaseItem.cs
C#
asf20
2,535
using UnityEngine; using System.Collections.Generic; [ExecuteInEditMode] [AddComponentMenu("NGUI/Examples/Item Database")] public class InvDatabase : MonoBehaviour { // Cached list of all available item databases static InvDatabase[] mList; static bool mIsDirty = true; /// <summary> /// Retrieves the list of item databases, finding all instances if necessary. /// </summary> static public InvDatabase[] list { get { if (mIsDirty) { mIsDirty = false; mList = NGUITools.FindActive<InvDatabase>(); } return mList; } } /// <summary> /// Each database should have a unique 16-bit ID. When the items are saved, database IDs /// get combined with item IDs to create 32-bit IDs containing both values. /// </summary> public int databaseID = 0; /// <summary> /// List of items in this database. /// </summary> public List<InvBaseItem> items = new List<InvBaseItem>(); /// <summary> /// UI atlas used for icons. /// </summary> public UIAtlas iconAtlas; /// <summary> /// Add this database to the list. /// </summary> void OnEnable () { mIsDirty = true; } /// <summary> /// Remove this database from the list. /// </summary> void OnDisable () { mIsDirty = true; } /// <summary> /// Find an item by its 16-bit ID. /// </summary> InvBaseItem GetItem (int id16) { for (int i = 0, imax = items.Count; i < imax; ++i) { InvBaseItem item = items[i]; if (item.id16 == id16) return item; } return null; } /// <summary> /// Find a database given its ID. /// </summary> static InvDatabase GetDatabase (int dbID) { for (int i = 0, imax = list.Length; i < imax; ++i) { InvDatabase db = list[i]; if (db.databaseID == dbID) return db; } return null; } /// <summary> /// Find the specified item given its full 32-bit ID (not to be confused with individual 16-bit item IDs). /// </summary> static public InvBaseItem FindByID (int id32) { InvDatabase db = GetDatabase(id32 >> 16); return (db != null) ? db.GetItem(id32 & 0xFFFF) : null; } /// <summary> /// Find the item with the specified name. /// </summary> static public InvBaseItem FindByName (string exact) { for (int i = 0, imax = list.Length; i < imax; ++i) { InvDatabase db = list[i]; for (int b = 0, bmax = db.items.Count; b < bmax; ++b) { InvBaseItem item = db.items[b]; if (item.name == exact) { return item; } } } return null; } /// <summary> /// Get the full 32-bit ID of the specified item. /// Use this to get a list of items on the character that can get saved out to an external database or file. /// </summary> static public int FindItemID (InvBaseItem item) { for (int i = 0, imax = list.Length; i < imax; ++i) { InvDatabase db = list[i]; if (db.items.Contains(item)) { return (db.databaseID << 16) | item.id16; } } return -1; } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Examples/Scripts/InventorySystem/System/InvDatabase.cs
C#
asf20
3,021
Shader "NGUI/Examples/Orc Armor" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Diffuse (RGB), Color Mask (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} _MaskTex ("Specular (R), Reflection (G)", 2D) = "black" {} } // Good quality settings SubShader { Tags { "RenderType"="Opaque" } LOD 300 CGPROGRAM #pragma surface surf PPL sampler2D _MainTex; sampler2D _BumpMap; sampler2D _MaskTex; fixed4 _Color; float _Shininess; struct Input { float2 uv_MainTex; }; // Forward lighting half4 LightingPPL (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) { half3 nNormal = normalize(s.Normal); half shininess = s.Gloss * 250.0 + 4.0; #ifndef USING_DIRECTIONAL_LIGHT lightDir = normalize(lightDir); #endif // Phong shading model //half reflectiveFactor = max(0.0, dot(-viewDir, reflect(lightDir, nNormal))); // Blinn-Phong shading model half reflectiveFactor = max(0.0, dot(nNormal, normalize(lightDir + viewDir))); half diffuseFactor = max(0.0, dot(nNormal, lightDir)); half specularFactor = pow(reflectiveFactor, shininess) * s.Specular; half4 c; c.rgb = (s.Albedo * diffuseFactor + _SpecColor.rgb * specularFactor) * _LightColor0.rgb; c.rgb *= (atten * 2.0); c.a = s.Alpha; return c; } void surf (Input IN, inout SurfaceOutput o) { half4 tex = tex2D(_MainTex, IN.uv_MainTex); half4 maps = tex2D(_MaskTex, IN.uv_MainTex); o.Albedo = lerp(tex.rgb, tex.rgb * _Color.rgb, tex.a); o.Alpha = _Color.a; o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex)); o.Specular = maps.r; o.Gloss = _Shininess; } ENDCG } // Simple quality settings -- drop the bump map SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Lambert sampler2D _MainTex; fixed4 _Color; struct Input { float2 uv_MainTex; }; void surf (Input IN, inout SurfaceOutput o) { half4 tex = tex2D(_MainTex, IN.uv_MainTex); o.Albedo = lerp(tex.rgb, tex.rgb * _Color.rgb, tex.a); o.Alpha = _Color.a; } ENDCG } Fallback "Diffuse" }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Examples/Models/Orc Armor/Orc Armor.shader
ShaderLab
asf20
2,361
Shader "NGUI/Examples/Orc Skin" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Diffuse (RGB), Specular (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} } // Good quality or above SubShader { Tags { "RenderType"="Opaque" } LOD 300 CGPROGRAM #pragma surface surf PPL sampler2D _MainTex; sampler2D _BumpMap; fixed4 _Color; float _Shininess; struct Input { float2 uv_MainTex; }; // Forward lighting half4 LightingPPL (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) { half3 nNormal = normalize(s.Normal); half shininess = s.Gloss * 250.0 + 4.0; #ifndef USING_DIRECTIONAL_LIGHT lightDir = normalize(lightDir); #endif // Phong shading model //half reflectiveFactor = max(0.0, dot(-viewDir, reflect(lightDir, nNormal))); // Blinn-Phong shading model half reflectiveFactor = max(0.0, dot(nNormal, normalize(lightDir + viewDir))); half diffuseFactor = max(0.0, dot(nNormal, lightDir)); half specularFactor = pow(reflectiveFactor, shininess) * s.Specular; half4 c; c.rgb = (s.Albedo * diffuseFactor + _SpecColor.rgb * specularFactor) * _LightColor0.rgb; c.rgb *= (atten * 2.0); c.a = s.Alpha; return c; } void surf (Input IN, inout SurfaceOutput o) { half4 tex = tex2D(_MainTex, IN.uv_MainTex) * _Color; o.Albedo = tex.rgb; o.Alpha = _Color.a; o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex)); o.Specular = tex.a; o.Gloss = _Shininess; } ENDCG } // Simple quality -- drop the normal map SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf PPL sampler2D _MainTex; fixed4 _Color; float _Shininess; struct Input { float2 uv_MainTex; }; // Forward lighting half4 LightingPPL (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) { half3 nNormal = normalize(s.Normal); half shininess = s.Gloss * 250.0 + 4.0; #ifndef USING_DIRECTIONAL_LIGHT lightDir = normalize(lightDir); #endif // Phong shading model half reflectiveFactor = max(0.0, dot(-viewDir, reflect(lightDir, nNormal))); // Blinn-Phong shading model //half reflectiveFactor = max(0.0, dot(nNormal, normalize(lightDir + viewDir))); half diffuseFactor = max(0.0, dot(nNormal, lightDir)); half specularFactor = pow(reflectiveFactor, shininess) * s.Specular; half4 c; c.rgb = (s.Albedo * diffuseFactor + _SpecColor.rgb * specularFactor) * _LightColor0.rgb; c.rgb *= (atten * 2.0); c.a = s.Alpha; return c; } void surf (Input IN, inout SurfaceOutput o) { half4 tex = tex2D(_MainTex, IN.uv_MainTex) * _Color; o.Albedo = tex.rgb; o.Alpha = _Color.a; o.Specular = tex.a; o.Gloss = _Shininess; } ENDCG } Fallback "Diffuse" }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Examples/Models/Orc/Orc Skin.shader
ShaderLab
asf20
3,042
Shader "Unlit/Masked Colored" { Properties { _MainTex ("Base (RGB) Mask (A)", 2D) = "black" {} _Color ("Tint Color", Color) = (1,1,1,1) } SubShader { Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } LOD 200 Cull Off Lighting Off ZWrite Off Fog { Mode Off } ColorMask RGB Blend Off Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma fragmentoption ARB_precision_hint_fastest #include "UnityCG.cginc" sampler2D _MainTex; fixed4 _Color; struct appdata_t { float4 vertex : POSITION; fixed4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; fixed4 color : COLOR; float2 texcoord : TEXCOORD0; }; float4 _MainTex_ST; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); return o; } fixed4 frag (v2f i) : COLOR { half4 col = tex2D(_MainTex, i.texcoord) * i.color; return half4( lerp(col.rgb, col.rgb * _Color.rgb, col.a), col.a ); } ENDCG } } SubShader { Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } LOD 100 Cull Off Lighting Off ZWrite Off Fog { Mode Off } ColorMask RGB AlphaTest Greater .01 Blend Off Pass { ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } SetTexture [_MainTex] { ConstantColor [_Color] Combine Previous * Constant } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Examples/Shaders/Unlit - Masked Colored.shader
ShaderLab
asf20
1,668
Shader "Unlit/Depth Cutout" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {} } SubShader { LOD 100 Tags { "Queue" = "Background" "IgnoreProjector" = "True" } Pass { Cull Off Lighting Off Blend Off ColorMask 0 ZWrite On ZTest Less AlphaTest Greater .99 ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Examples/Shaders/Unlit - Depth Cutout.shader
ShaderLab
asf20
435
Shader "Unlit/Depth" { SubShader { Lod 100 Tags { "Queue" = "Geometry+1" "RenderType"="Opaque" } Pass { ZWrite On ZTest LEqual ColorMask 0 } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Examples/Shaders/Unlit - Depth.shader
ShaderLab
asf20
219
Shader "Transparent/Refractive" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {} _BumpMap ("Normal Map (RGB)", 2D) = "bump" {} _Mask ("Specularity (R), Shininess (G), Refraction (B)", 2D) = "black" {} _Color ("Color Tint", Color) = (1,1,1,1) _Specular ("Specular Color", Color) = (0,0,0,0) _Focus ("Focus", Range(-100.0, 100.0)) = -100.0 _Shininess ("Shininess", Range(0.01, 1.0)) = 0.2 } Category { Tags { "Queue" = "Transparent+1" "IgnoreProjector" = "True" "RenderType" = "Transparent" } SubShader { LOD 500 GrabPass { Name "BASE" Tags { "LightMode" = "Always" } } Cull Off ZWrite Off ZTest LEqual Blend SrcAlpha OneMinusSrcAlpha AlphaTest Greater 0 CGPROGRAM #pragma exclude_renderers gles #pragma vertex vert #pragma surface surf PPL alpha #include "UnityCG.cginc" sampler2D _GrabTexture; sampler2D _MainTex; sampler2D _BumpMap; sampler2D _Mask; fixed4 _Color; fixed4 _Specular; half4 _GrabTexture_TexelSize; half _Focus; half _Shininess; struct Input { float4 position : POSITION; float2 uv_MainTex : TEXCOORD0; float4 color : COLOR; float4 proj : TEXCOORD1; }; void vert (inout appdata_full v, out Input o) { #if SHADER_API_D3D11 UNITY_INITIALIZE_OUTPUT(Input, o); #endif o.position = mul(UNITY_MATRIX_MVP, v.vertex); #if UNITY_UV_STARTS_AT_TOP float scale = -1.0; #else float scale = 1.0; #endif o.proj.xy = (float2(o.position.x, o.position.y * scale) + o.position.w) * 0.5; o.proj.zw = o.position.zw; } void surf (Input IN, inout SurfaceOutput o) { half4 tex = tex2D(_MainTex, IN.uv_MainTex); half3 nm = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex)); half3 mask = tex2D(_Mask, IN.uv_MainTex); float2 offset = nm.xy * _GrabTexture_TexelSize.xy * _Focus; IN.proj.xy = offset * IN.proj.z + IN.proj.xy; half4 ref = tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(IN.proj)); half4 col; col.rgb = lerp(IN.color.rgb * tex.rgb, _Color.rgb * ref.rgb, mask.b); col.a = IN.color.a * _Color.a * tex.a; o.Albedo = col.rgb; o.Normal = nm; o.Specular = mask.r; o.Gloss = _Shininess * mask.g; o.Alpha = col.a; } // Forward lighting half4 LightingPPL (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) { half3 nNormal = normalize(s.Normal); half shininess = s.Gloss * 250.0 + 4.0; #ifndef USING_DIRECTIONAL_LIGHT lightDir = normalize(lightDir); #endif // Phong shading model half reflectiveFactor = max(0.0, dot(-viewDir, reflect(lightDir, nNormal))); // Blinn-Phong shading model //half reflectiveFactor = max(0.0, dot(nNormal, normalize(lightDir + viewDir))); half diffuseFactor = max(0.0, dot(nNormal, lightDir)); half specularFactor = pow(reflectiveFactor, shininess) * s.Specular; half4 c; c.rgb = (s.Albedo * diffuseFactor + _Specular.rgb * specularFactor) * _LightColor0.rgb; c.rgb *= (atten * 2.0); c.a = s.Alpha; return c; } ENDCG } SubShader { LOD 400 Cull Off ZWrite Off ZTest LEqual Blend SrcAlpha OneMinusSrcAlpha AlphaTest Greater 0 CGPROGRAM #pragma surface surf PPL alpha #include "UnityCG.cginc" sampler2D _MainTex; sampler2D _BumpMap; sampler2D _Mask; float4 _Color; float4 _Specular; float _Shininess; struct Input { float4 position : POSITION; float2 uv_MainTex : TEXCOORD0; float4 color : COLOR; }; void surf (Input IN, inout SurfaceOutput o) { half4 tex = tex2D(_MainTex, IN.uv_MainTex); half3 nm = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex)); half3 mask = tex2D(_Mask, IN.uv_MainTex); half4 col; col.rgb = IN.color.rgb * tex.rgb; col.rgb = lerp(col.rgb, _Color.rgb, mask.b * 0.5); col.a = IN.color.a * _Color.a * tex.a; o.Albedo = col.rgb; o.Normal = nm; o.Specular = mask.r; o.Gloss = _Shininess * mask.g; o.Alpha = col.a; } // Forward lighting half4 LightingPPL (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) { half3 nNormal = normalize(s.Normal); half shininess = s.Gloss * 250.0 + 4.0; #ifndef USING_DIRECTIONAL_LIGHT lightDir = normalize(lightDir); #endif // Phong shading model half reflectiveFactor = max(0.0, dot(-viewDir, reflect(lightDir, nNormal))); // Blinn-Phong shading model //half reflectiveFactor = max(0.0, dot(nNormal, normalize(lightDir + viewDir))); half diffuseFactor = max(0.0, dot(nNormal, lightDir)); half specularFactor = pow(reflectiveFactor, shininess) * s.Specular; half4 c; c.rgb = (s.Albedo * diffuseFactor + _Specular.rgb * specularFactor) * _LightColor0.rgb; c.rgb *= (atten * 2.0); c.a = s.Alpha; return c; } ENDCG } SubShader { LOD 300 Cull Off ZWrite Off ZTest LEqual Blend SrcAlpha OneMinusSrcAlpha AlphaTest Greater 0 CGPROGRAM #pragma surface surf BlinnPhong alpha #include "UnityCG.cginc" sampler2D _MainTex; sampler2D _Mask; float4 _Color; struct Input { float4 position : POSITION; float2 uv_MainTex : TEXCOORD0; float4 color : COLOR; }; void surf (Input IN, inout SurfaceOutput o) { half4 tex = tex2D(_MainTex, IN.uv_MainTex); half3 mask = tex2D(_Mask, IN.uv_MainTex); half4 col; col.rgb = IN.color.rgb * tex.rgb; col.rgb = lerp(col.rgb, _Color.rgb, mask.b * 0.5); col.a = IN.color.a * _Color.a * tex.a; o.Albedo = col.rgb; o.Alpha = col.a; } ENDCG } SubShader { LOD 100 Cull Off Lighting Off ZWrite Off Fog { Mode Off } ColorMask RGB AlphaTest Greater .01 Blend SrcAlpha OneMinusSrcAlpha Pass { ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } } } } Fallback Off }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Examples/Shaders/Refractive.shader
ShaderLab
asf20
5,978
Shader "Unlit/Additive Colored" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } LOD 100 Cull Off Lighting Off ZWrite Off Fog { Mode Off } ColorMask RGB AlphaTest Greater .01 Blend One One Pass { ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Examples/Shaders/Unlit - Additive Colored.shader
ShaderLab
asf20
480
Shader "Unlit/Transparent Colored" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 100 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Cull Off Lighting Off ZWrite Off Fog { Mode Off } Offset -1, -1 Blend SrcAlpha OneMinusSrcAlpha Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata_t { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; fixed4 color : COLOR; }; struct v2f { float4 vertex : SV_POSITION; half2 texcoord : TEXCOORD0; fixed4 color : COLOR; }; sampler2D _MainTex; float4 _MainTex_ST; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.texcoord = v.texcoord; o.color = v.color; return o; } fixed4 frag (v2f i) : COLOR { fixed4 col = tex2D(_MainTex, i.texcoord) * i.color; return col; } ENDCG } } SubShader { LOD 100 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Fog { Mode Off } Offset -1, -1 ColorMask RGB AlphaTest Greater .01 Blend SrcAlpha OneMinusSrcAlpha ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Transparent Colored.shader
ShaderLab
asf20
1,458
Shader "Unlit/Premultiplied Colored" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off AlphaTest Off Fog { Mode Off } Offset -1, -1 ColorMask RGB Blend One OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _MainTex_ST; struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; return o; } half4 frag (v2f IN) : COLOR { half4 col = tex2D(_MainTex, IN.texcoord) * IN.color; //col.rgb = lerp(half3(0.0, 0.0, 0.0), col.rgb, col.a); return col; } ENDCG } } SubShader { LOD 100 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off AlphaTest Off Fog { Mode Off } Offset -1, -1 ColorMask RGB Blend One OneMinusSrcAlpha ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Premultiplied Colored.shader
ShaderLab
asf20
1,524
Shader "Hidden/Unlit/Premultiplied Colored 2" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off AlphaTest Off Fog { Mode Off } Offset -1, -1 ColorMask RGB Blend One OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs0 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange1 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs1 = float4(1000.0, 1000.0, 0.0, 1.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float4 worldPos : TEXCOORD1; }; float2 Rotate (float2 v, float2 rot) { float2 ret; ret.x = v.x * rot.y - v.y * rot.x; ret.y = v.x * rot.x + v.y * rot.y; return ret; } v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos.xy = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; o.worldPos.zw = Rotate(v.vertex.xy, _ClipArgs1.zw) * _ClipRange1.zw + _ClipRange1.xy; return o; } half4 frag (v2f IN) : COLOR { // First clip region float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos.xy)) * _ClipArgs0.xy; float f = min(factor.x, factor.y); // Second clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos.zw)) * _ClipArgs1.xy; f = min(f, min(factor.x, factor.y)); // Sample the texture half4 col = tex2D(_MainTex, IN.texcoord) * IN.color; float fade = clamp(f, 0.0, 1.0); col.a *= fade; col.rgb = lerp(half3(0.0, 0.0, 0.0), col.rgb, fade); return col; } ENDCG } } SubShader { LOD 100 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off AlphaTest Off Fog { Mode Off } Offset -1, -1 ColorMask RGB Blend One OneMinusSrcAlpha ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Premultiplied Colored 2.shader
ShaderLab
asf20
2,443
Shader "Hidden/Unlit/Text 1" { Properties { _MainTex ("Alpha (A)", 2D) = "white" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } //ColorMask RGB AlphaTest Greater .01 Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float2 _ClipArgs0 = float2(1000.0, 1000.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float2 worldPos : TEXCOORD1; }; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; return o; } half4 frag (v2f IN) : COLOR { // Softness factor float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos)) * _ClipArgs0; // Sample the texture half4 col = IN.color; col.a *= tex2D(_MainTex, IN.texcoord).a; col.a *= clamp( min(factor.x, factor.y), 0.0, 1.0); return col; } ENDCG } } Fallback "Unlit/Text" }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Text 1.shader
ShaderLab
asf20
1,453
Shader "Unlit/Text" { Properties { _MainTex ("Alpha (A)", 2D) = "white" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } Blend SrcAlpha OneMinusSrcAlpha Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; sampler2D _MainTex; float4 _MainTex_ST; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.texcoord = v.texcoord; o.color = v.color; return o; } half4 frag (v2f i) : COLOR { half4 col = i.color; col.a *= tex2D(_MainTex, i.texcoord).a; return col; } ENDCG } } SubShader { Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off } Blend SrcAlpha OneMinusSrcAlpha BindChannels { Bind "Color", color Bind "Vertex", vertex Bind "TexCoord", texcoord } Pass { SetTexture [_MainTex] { combine primary, texture } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Text.shader
ShaderLab
asf20
1,452
Shader "Hidden/Unlit/Text 2" { Properties { _MainTex ("Alpha (A)", 2D) = "white" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } //ColorMask RGB AlphaTest Greater .01 Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs0 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange1 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs1 = float4(1000.0, 1000.0, 0.0, 1.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float4 worldPos : TEXCOORD1; }; float2 Rotate (float2 v, float2 rot) { float2 ret; ret.x = v.x * rot.y - v.y * rot.x; ret.y = v.x * rot.x + v.y * rot.y; return ret; } v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos.xy = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; o.worldPos.zw = Rotate(v.vertex.xy, _ClipArgs1.zw) * _ClipRange1.zw + _ClipRange1.xy; return o; } half4 frag (v2f IN) : COLOR { // First clip region float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos.xy)) * _ClipArgs0.xy; float f = min(factor.x, factor.y); // Second clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos.zw)) * _ClipArgs1.xy; f = min(f, min(factor.x, factor.y)); // Sample the texture half4 col = IN.color; col.a *= tex2D(_MainTex, IN.texcoord).a; col.a *= clamp(f, 0.0, 1.0); return col; } ENDCG } } Fallback "Unlit/Text" }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Text 2.shader
ShaderLab
asf20
1,989
Shader "Unlit/Transparent Packed" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } ColorMask RGB Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; half4 _MainTex_ST; struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; return o; } half4 frag (v2f IN) : COLOR { half4 mask = tex2D(_MainTex, IN.texcoord); half4 mixed = saturate(ceil(IN.color - 0.5)); half4 col = saturate((mixed * 0.51 - IN.color) / -0.49); mask *= mixed; col.a *= mask.r + mask.g + mask.b + mask.a; return col; } ENDCG } } Fallback Off }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Transparent Packed.shader
ShaderLab
asf20
1,232
Shader "Hidden/Unlit/Transparent Packed 1" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } ColorMask RGB Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float2 _ClipArgs0 = float2(1000.0, 1000.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float2 worldPos : TEXCOORD1; }; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; return o; } half4 frag (v2f IN) : COLOR { half4 mask = tex2D(_MainTex, IN.texcoord); half4 mixed = saturate(ceil(IN.color - 0.5)); half4 col = saturate((mixed * 0.51 - IN.color) / -0.49); // Softness factor float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos)) * _ClipArgs0; mask *= mixed; col.a *= clamp( min(factor.x, factor.y), 0.0, 1.0); col.a *= mask.r + mask.g + mask.b + mask.a; return col; } ENDCG } } Fallback Off }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Transparent Packed 1.shader
ShaderLab
asf20
1,571
Shader "Hidden/Unlit/Text 3" { Properties { _MainTex ("Alpha (A)", 2D) = "white" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } //ColorMask RGB AlphaTest Greater .01 Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs0 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange1 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs1 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange2 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs2 = float4(1000.0, 1000.0, 0.0, 1.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float4 worldPos : TEXCOORD1; float2 worldPos2 : TEXCOORD2; }; float2 Rotate (float2 v, float2 rot) { float2 ret; ret.x = v.x * rot.y - v.y * rot.x; ret.y = v.x * rot.x + v.y * rot.y; return ret; } v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos.xy = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; o.worldPos.zw = Rotate(v.vertex.xy, _ClipArgs1.zw) * _ClipRange1.zw + _ClipRange1.xy; o.worldPos2 = Rotate(v.vertex.xy, _ClipArgs2.zw) * _ClipRange2.zw + _ClipRange2.xy; return o; } half4 frag (v2f IN) : COLOR { // First clip region float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos.xy)) * _ClipArgs0.xy; float f = min(factor.x, factor.y); // Second clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos.zw)) * _ClipArgs1.xy; f = min(f, min(factor.x, factor.y)); // Third clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos2)) * _ClipArgs2.xy; f = min(f, min(factor.x, factor.y)); // Sample the texture half4 col = IN.color; col.a *= tex2D(_MainTex, IN.texcoord).a; col.a *= clamp(f, 0.0, 1.0); return col; } ENDCG } } Fallback "Unlit/Text" }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Text 3.shader
ShaderLab
asf20
2,355
Shader "Hidden/Unlit/Transparent Colored 1" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } ColorMask RGB AlphaTest Greater .01 Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float2 _ClipArgs0 = float2(1000.0, 1000.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float2 worldPos : TEXCOORD1; }; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; return o; } half4 frag (v2f IN) : COLOR { // Softness factor float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos)) * _ClipArgs0; // Sample the texture half4 col = tex2D(_MainTex, IN.texcoord) * IN.color; col.a *= clamp( min(factor.x, factor.y), 0.0, 1.0); return col; } ENDCG } } SubShader { LOD 100 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Fog { Mode Off } ColorMask RGB AlphaTest Greater .01 Blend SrcAlpha OneMinusSrcAlpha ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Transparent Colored 1.shader
ShaderLab
asf20
1,834
Shader "Hidden/Unlit/Premultiplied Colored 1" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off AlphaTest Off Fog { Mode Off } Offset -1, -1 ColorMask RGB Blend One OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs0 = float4(1000.0, 1000.0, 0.0, 1.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float2 worldPos : TEXCOORD1; }; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; return o; } half4 frag (v2f IN) : COLOR { // Softness factor float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos)) * _ClipArgs0.xy; // Sample the texture half4 col = tex2D(_MainTex, IN.texcoord) * IN.color; float fade = clamp( min(factor.x, factor.y), 0.0, 1.0); col.a *= fade; col.rgb = lerp(half3(0.0, 0.0, 0.0), col.rgb, fade); return col; } ENDCG } } SubShader { LOD 100 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off AlphaTest Off Fog { Mode Off } Offset -1, -1 ColorMask RGB Blend One OneMinusSrcAlpha ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Premultiplied Colored 1.shader
ShaderLab
asf20
1,920
Shader "Hidden/Unlit/Transparent Colored 3" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } ColorMask RGB AlphaTest Greater .01 Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs0 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange1 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs1 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange2 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs2 = float4(1000.0, 1000.0, 0.0, 1.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float4 worldPos : TEXCOORD1; float2 worldPos2 : TEXCOORD2; }; float2 Rotate (float2 v, float2 rot) { float2 ret; ret.x = v.x * rot.y - v.y * rot.x; ret.y = v.x * rot.x + v.y * rot.y; return ret; } v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos.xy = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; o.worldPos.zw = Rotate(v.vertex.xy, _ClipArgs1.zw) * _ClipRange1.zw + _ClipRange1.xy; o.worldPos2 = Rotate(v.vertex.xy, _ClipArgs2.zw) * _ClipRange2.zw + _ClipRange2.xy; return o; } half4 frag (v2f IN) : COLOR { // First clip region float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos.xy)) * _ClipArgs0.xy; float f = min(factor.x, factor.y); // Second clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos.zw)) * _ClipArgs1.xy; f = min(f, min(factor.x, factor.y)); // Third clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos2)) * _ClipArgs2.xy; f = min(f, min(factor.x, factor.y)); // Sample the texture half4 col = tex2D(_MainTex, IN.texcoord) * IN.color; col.a *= clamp(f, 0.0, 1.0); return col; } ENDCG } } SubShader { LOD 100 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Fog { Mode Off } ColorMask RGB AlphaTest Greater .01 Blend SrcAlpha OneMinusSrcAlpha ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Transparent Colored 3.shader
ShaderLab
asf20
2,734
Shader "Hidden/Unlit/Transparent Colored 2" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } ColorMask RGB AlphaTest Greater .01 Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs0 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange1 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs1 = float4(1000.0, 1000.0, 0.0, 1.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float4 worldPos : TEXCOORD1; }; float2 Rotate (float2 v, float2 rot) { float2 ret; ret.x = v.x * rot.y - v.y * rot.x; ret.y = v.x * rot.x + v.y * rot.y; return ret; } v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos.xy = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; o.worldPos.zw = Rotate(v.vertex.xy, _ClipArgs1.zw) * _ClipRange1.zw + _ClipRange1.xy; return o; } half4 frag (v2f IN) : COLOR { // First clip region float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos.xy)) * _ClipArgs0.xy; float f = min(factor.x, factor.y); // Second clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos.zw)) * _ClipArgs1.xy; f = min(f, min(factor.x, factor.y)); // Sample the texture half4 col = tex2D(_MainTex, IN.texcoord) * IN.color; col.a *= clamp(f, 0.0, 1.0); return col; } ENDCG } } SubShader { LOD 100 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Fog { Mode Off } ColorMask RGB AlphaTest Greater .01 Blend SrcAlpha OneMinusSrcAlpha ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Transparent Colored 2.shader
ShaderLab
asf20
2,367
Shader "Hidden/Unlit/Transparent Packed 2" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } ColorMask RGB Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs0 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange1 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs1 = float4(1000.0, 1000.0, 0.0, 1.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float4 worldPos : TEXCOORD1; }; float2 Rotate (float2 v, float2 rot) { float2 ret; ret.x = v.x * rot.y - v.y * rot.x; ret.y = v.x * rot.x + v.y * rot.y; return ret; } v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos.xy = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; o.worldPos.zw = Rotate(v.vertex.xy, _ClipArgs1.zw) * _ClipRange1.zw + _ClipRange1.xy; return o; } half4 frag (v2f IN) : COLOR { half4 mask = tex2D(_MainTex, IN.texcoord); half4 mixed = saturate(ceil(IN.color - 0.5)); half4 col = saturate((mixed * 0.51 - IN.color) / -0.49); // First clip region float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos.xy)) * _ClipArgs0.xy; float f = min(factor.x, factor.y); // Second clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos.zw)) * _ClipArgs1.xy; f = min(f, min(factor.x, factor.y)); mask *= mixed; col.a *= clamp(f, 0.0, 1.0); col.a *= mask.r + mask.g + mask.b + mask.a; return col; } ENDCG } } Fallback Off }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Transparent Packed 2.shader
ShaderLab
asf20
2,107
Shader "Hidden/Unlit/Premultiplied Colored 3" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off AlphaTest Off Fog { Mode Off } Offset -1, -1 ColorMask RGB Blend One OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs0 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange1 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs1 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange2 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs2 = float4(1000.0, 1000.0, 0.0, 1.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float4 worldPos : TEXCOORD1; float2 worldPos2 : TEXCOORD2; }; float2 Rotate (float2 v, float2 rot) { float2 ret; ret.x = v.x * rot.y - v.y * rot.x; ret.y = v.x * rot.x + v.y * rot.y; return ret; } v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos.xy = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; o.worldPos.zw = Rotate(v.vertex.xy, _ClipArgs1.zw) * _ClipRange1.zw + _ClipRange1.xy; o.worldPos2 = Rotate(v.vertex.xy, _ClipArgs2.zw) * _ClipRange2.zw + _ClipRange2.xy; return o; } half4 frag (v2f IN) : COLOR { // First clip region float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos.xy)) * _ClipArgs0.xy; float f = min(factor.x, factor.y); // Second clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos.zw)) * _ClipArgs1.xy; f = min(f, min(factor.x, factor.y)); // Third clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos2)) * _ClipArgs2.xy; f = min(f, min(factor.x, factor.y)); // Sample the texture half4 col = tex2D(_MainTex, IN.texcoord) * IN.color; float fade = clamp(f, 0.0, 1.0); col.a *= fade; col.rgb = lerp(half3(0.0, 0.0, 0.0), col.rgb, fade); return col; } ENDCG } } SubShader { LOD 100 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off AlphaTest Off Fog { Mode Off } Offset -1, -1 ColorMask RGB Blend One OneMinusSrcAlpha ColorMaterial AmbientAndDiffuse SetTexture [_MainTex] { Combine Texture * Primary } } } }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Premultiplied Colored 3.shader
ShaderLab
asf20
2,810
Shader "Hidden/Unlit/Transparent Packed 3" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } ColorMask RGB Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs0 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange1 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs1 = float4(1000.0, 1000.0, 0.0, 1.0); float4 _ClipRange2 = float4(0.0, 0.0, 1.0, 1.0); float4 _ClipArgs2 = float4(1000.0, 1000.0, 0.0, 1.0); struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float4 worldPos : TEXCOORD1; float2 worldPos2 : TEXCOORD2; }; float2 Rotate (float2 v, float2 rot) { float2 ret; ret.x = v.x * rot.y - v.y * rot.x; ret.y = v.x * rot.x + v.y * rot.y; return ret; } v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.color = v.color; o.texcoord = v.texcoord; o.worldPos.xy = v.vertex.xy * _ClipRange0.zw + _ClipRange0.xy; o.worldPos.zw = Rotate(v.vertex.xy, _ClipArgs1.zw) * _ClipRange1.zw + _ClipRange1.xy; o.worldPos2 = Rotate(v.vertex.xy, _ClipArgs2.zw) * _ClipRange2.zw + _ClipRange2.xy; return o; } half4 frag (v2f IN) : COLOR { half4 mask = tex2D(_MainTex, IN.texcoord); half4 mixed = saturate(ceil(IN.color - 0.5)); half4 col = saturate((mixed * 0.51 - IN.color) / -0.49); // First clip region float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos.xy)) * _ClipArgs0.xy; float f = min(factor.x, factor.y); // Second clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos.zw)) * _ClipArgs1.xy; f = min(f, min(factor.x, factor.y)); // Third clip region factor = (float2(1.0, 1.0) - abs(IN.worldPos2)) * _ClipArgs2.xy; f = min(f, min(factor.x, factor.y)); mask *= mixed; col.a *= clamp(f, 0.0, 1.0); col.a *= mask.r + mask.g + mask.b + mask.a; return col; } ENDCG } } Fallback Off }
zzzstrawhatzzz
trunk/client/Assets/NGUI/Resources/Shaders/Unlit - Transparent Packed 3.shader
ShaderLab
asf20
2,474
package net.tools; import net.base.BaseDao; import net.base.Tools; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; /** * Created by IntelliJ IDEA. * User: jxw * Date: 12-2-24 * Time: 上午10:00 * To change this template use File | Settings | File Templates. */ public class ExcelUtil { public BaseDao dao; public ExcelUtil(){ dao = (BaseDao)BeansHelp.getBeanInstance("baseDao"); } /** * 导出excel * @param request */ public void exportExcel(HttpServletRequest request, HttpServletResponse response){ Map map = Tools.parserRequest(request); String sqlid = (String) map.get("SQLID_EXPORT"); try { int rowsCount = Integer.parseInt(map.get("ExportMaxRows").toString()); String title = (String)map.get("TITLE"); map.put("START", 0); map.put("END", rowsCount); List list = dao.getList(sqlid,map); String heads =map.get("HeadsName").toString(); String[] headsName = heads.split(","); String properies = map.get("ProperiesName").toString(); String[] properiesName = properies.split(","); int[] colswidth = null; try{ String cols = map.get("ColsWidth").toString(); String[] colswidth_str = cols.split(","); colswidth = new int[colswidth_str.length]; for(int i=0;i<colswidth_str.length;i++){ colswidth[i] = (Integer.parseInt(colswidth_str[i])); } }catch(Exception e){ colswidth = null; } String[] aligns = ((String)map.get("Aligns")).split(","); GridExportUtil gridexport = new GridExportUtil(request,response); gridexport.exportXLS(title, list, properiesName, headsName,colswidth, aligns,Map.class); } catch (Exception e) { e.printStackTrace(); } } }
zzfls-pj
trunk/src/net/tools/ExcelUtil.java
Java
asf20
2,121
package net.tools.jspupload; /** * Date:2008-9-24<br> * * @author <a href="mailto:yanghongjian@htjs.net">YangHongJian</a> * @version 2.0 * @since 1.4.2 */ public class SmartUploadException extends Exception { SmartUploadException(String s) { super(s); } }
zzfls-pj
trunk/src/net/tools/jspupload/SmartUploadException.java
Java
asf20
291
package net.tools.jspupload; import javax.servlet.ServletException; import java.io.ByteArrayInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.math.BigInteger; import java.sql.ResultSet; import java.sql.SQLException; /** * Date:2008-9-24<br> * * @author <a href="mailto:yanghongjian@htjs.net">YangHongJian</a> * @version 2.0 * @since 1.4.2 */ public class File { private SmartUpload m_parent; private int m_startData; private int m_endData; private int m_size; private String m_fieldname; private String m_filename; private String m_fileExt; private String m_filePathName; private String m_contentType; private String m_contentDisp; private String m_typeMime; private String m_subTypeMime; private boolean m_isMissing; public static final int SAVEAS_AUTO = 0; public static final int SAVEAS_VIRTUAL = 1; public static final int SAVEAS_PHYSICAL = 2; File() { m_startData = 0; m_endData = 0; m_size = 0; m_fieldname = ""; m_filename = ""; m_fileExt = ""; m_filePathName = ""; m_contentType = ""; m_contentDisp = ""; m_typeMime = ""; m_subTypeMime = ""; m_isMissing = true; } public void saveAs(String s) throws IOException, SmartUploadException { saveAs(s, 0); } public void saveAs(String s, int i) throws IOException, SmartUploadException { String s1; s1 = m_parent.getPhysicalPath(s, i); if (s1 == null) throw new IllegalArgumentException("There is no specified destination file (1140)."); try { java.io.File file = new java.io.File(s1); FileOutputStream fileoutputstream = new FileOutputStream(file); fileoutputstream.write(m_parent.m_binArray, m_startData, m_size); fileoutputstream.close(); } catch (IOException ioexception) { throw new SmartUploadException("File can't be saved (1120)."); } } public void fileToField(ResultSet resultset, String s) throws ServletException, IOException, SmartUploadException, SQLException { long l; int i = 0x10000; int j; int k = m_startData; if (resultset == null) throw new IllegalArgumentException("The RecordSet cannot be null (1145)."); if (s == null) throw new IllegalArgumentException("The columnName cannot be null (1150)."); if (s.length() == 0) throw new IllegalArgumentException("The columnName cannot be empty (1155)."); l = BigInteger.valueOf(m_size).divide(BigInteger.valueOf(i)).longValue(); j = BigInteger.valueOf(m_size).mod(BigInteger.valueOf(i)).intValue(); try { for (int i1 = 1; (long) i1 < l; i1++) { resultset.updateBinaryStream(s, new ByteArrayInputStream(m_parent.m_binArray, k, i), i); k = k != 0 ? k : 1; k = i1 * i + m_startData; } if (j > 0) resultset.updateBinaryStream(s, new ByteArrayInputStream(m_parent.m_binArray, k, j), j); } catch (SQLException sqlexception) { byte abyte0[] = new byte[m_size]; System.arraycopy(m_parent.m_binArray, m_startData, abyte0, 0, m_size); resultset.updateBytes(s, abyte0); } catch (Exception exception) { throw new SmartUploadException("Unable to save file in the DataBase (1130)."); } } public boolean isMissing() { return m_isMissing; } public String getFieldName() { return m_fieldname; } public String getFileName() { return m_filename; } public String getFilePathName() { return m_filePathName; } public String getFileExt() { return m_fileExt; } public String getContentType() { return m_contentType; } public String getContentDisp() { return m_contentDisp; } public String getContentString() { return new String(m_parent.m_binArray, m_startData, m_size); } public String getTypeMIME() throws IOException { return m_typeMime; } public String getSubTypeMIME() { return m_subTypeMime; } public int getSize() { return m_size; } protected int getStartData() { return m_startData; } protected int getEndData() { return m_endData; } protected void setParent(SmartUpload smartupload) { m_parent = smartupload; } protected void setStartData(int i) { m_startData = i; } protected void setEndData(int i) { m_endData = i; } protected void setSize(int i) { m_size = i; } protected void setIsMissing(boolean flag) { m_isMissing = flag; } protected void setFieldName(String s) { m_fieldname = s; } protected void setFileName(String s) { m_filename = s; } protected void setFilePathName(String s) { m_filePathName = s; } protected void setFileExt(String s) { m_fileExt = s; } protected void setContentType(String s) { m_contentType = s; } protected void setContentDisp(String s) { m_contentDisp = s; } protected void setTypeMIME(String s) { m_typeMime = s; } protected void setSubTypeMIME(String s) { m_subTypeMime = s; } public byte getBinaryData(int i) { if (m_startData + i > m_endData) throw new ArrayIndexOutOfBoundsException("Index Out of range (1115)."); if (m_startData + i <= m_endData) return m_parent.m_binArray[m_startData + i]; else return 0; } }
zzfls-pj
trunk/src/net/tools/jspupload/File.java
Java
asf20
6,114
package net.tools.jspupload; import java.util.Enumeration; import java.util.Hashtable; /** * Date:2008-9-24<br> * * @author <a href="mailto:yanghongjian@htjs.net">YangHongJian</a> * @version 2.0 * @since 1.4.2 */ public class Request { private Hashtable m_parameters; Request() { m_parameters = new Hashtable(); } protected void putParameter(String s, String s1) { if(s == null) throw new IllegalArgumentException("The name of an element cannot be null."); if(m_parameters.containsKey(s)) { Hashtable hashtable = (Hashtable)m_parameters.get(s); hashtable.put(new Integer(hashtable.size()), s1); } else { Hashtable hashtable1 = new Hashtable(); hashtable1.put(new Integer(0), s1); m_parameters.put(s, hashtable1); } } public String getParameter(String s) { if(s == null) throw new IllegalArgumentException("Form's name is invalid or does not exist (1305)."); Hashtable hashtable = (Hashtable)m_parameters.get(s); if(hashtable == null) return null; else return (String)hashtable.get(new Integer(0)); } public Enumeration getParameterNames() { return m_parameters.keys(); } public String[] getParameterValues(String s) { if(s == null) throw new IllegalArgumentException("Form's name is invalid or does not exist (1305)."); Hashtable hashtable = (Hashtable)m_parameters.get(s); if(hashtable == null) return null; String as[] = new String[hashtable.size()]; for(int i = 0; i < hashtable.size(); i++) as[i] = (String)hashtable.get(new Integer(i)); return as; } }
zzfls-pj
trunk/src/net/tools/jspupload/Request.java
Java
asf20
1,893
package net.tools.jspupload; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.PageContext; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Vector; /** * Date:2008-9-24<br> * * @author <a href="mailto:yanghongjian@htjs.net">YangHongJian</a> * @version 2.0 * @since 1.4.2 */ public class SmartUpload { protected byte m_binArray[]; protected HttpServletRequest m_request; protected HttpServletResponse m_response; protected ServletContext m_application; private int m_totalBytes; private int m_currentIndex; private int m_startData; private int m_endData; private String m_boundary; private long m_totalMaxFileSize; private long m_maxFileSize; private Vector m_deniedFilesList; private Vector m_allowedFilesList; private boolean m_denyPhysicalPath; private String m_contentDisposition; public static final int SAVE_AUTO = 0; public static final int SAVE_VIRTUAL = 1; public static final int SAVE_PHYSICAL = 2; private Files m_files; private Request m_formRequest; public SmartUpload() { m_totalBytes = 0; m_currentIndex = 0; m_startData = 0; m_endData = 0; m_boundary = ""; m_totalMaxFileSize = 0L; m_maxFileSize = 0L; m_deniedFilesList = new Vector(); m_allowedFilesList = new Vector(); m_denyPhysicalPath = false; m_contentDisposition = ""; m_files = new Files(); m_formRequest = new Request(); } public final void init(ServletConfig servletconfig) throws ServletException { m_application = servletconfig.getServletContext(); } public void service(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws ServletException, IOException { m_request = httpservletrequest; m_response = httpservletresponse; } public final void initialize(ServletConfig servletconfig, HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws ServletException { m_application = servletconfig.getServletContext(); m_request = httpservletrequest; m_response = httpservletresponse; } public final void initialize(PageContext pagecontext) throws ServletException { m_application = pagecontext.getServletContext(); m_request = (HttpServletRequest) pagecontext.getRequest(); m_response = (HttpServletResponse) pagecontext.getResponse(); } public final void initialize(ServletContext servletcontext, HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws ServletException { m_application = servletcontext; m_request = httpservletrequest; m_response = httpservletresponse; } public void upload() throws ServletException, IOException, SmartUploadException { int i = 0; long l = 0L; boolean flag1 = false; String s4 = ""; String s5 = ""; String s6 = ""; String s7 = ""; String s8 = ""; String s9 = ""; String s10 = ""; m_totalBytes = m_request.getContentLength(); m_binArray = new byte[m_totalBytes]; int j; for (; i < m_totalBytes; i += j) try { m_request.getInputStream(); j = m_request.getInputStream().read(m_binArray, i, m_totalBytes - i); } catch (Exception exception) { throw new SmartUploadException("Unable to upload."); } for (; !flag1 && m_currentIndex < m_totalBytes; m_currentIndex++) if (m_binArray[m_currentIndex] == 13) flag1 = true; else m_boundary = m_boundary + (char) m_binArray[m_currentIndex]; if (m_currentIndex == 1) return; for (m_currentIndex++; m_currentIndex < m_totalBytes; m_currentIndex = m_currentIndex + 2) { String s1 = getDataHeader(); m_currentIndex = m_currentIndex + 2; boolean flag3 = s1.indexOf("filename") > 0; String s3 = getDataFieldValue(s1, "name"); if (flag3) { s6 = getDataFieldValue(s1, "filename"); s4 = getFileName(s6); s5 = getFileExt(s4); s7 = getContentType(s1); s8 = getContentDisp(s1); s9 = getTypeMIME(s7); s10 = getSubTypeMIME(s7); } getDataSection(); if (flag3 && s4.length() > 0) { if (m_deniedFilesList.contains(s5)) throw new SecurityException("The extension of the file is denied to be uploaded (1015)."); if (!m_allowedFilesList.isEmpty() && !m_allowedFilesList.contains(s5)) throw new SecurityException("The extension of the file is not allowed to be uploaded (1010)."); if (m_maxFileSize > 0L && (long) ((m_endData - m_startData) + 1) > m_maxFileSize) throw new SecurityException("Size exceeded for this file : " + s4 + " (1105)."); l += (m_endData - m_startData) + 1; if (m_totalMaxFileSize > 0L && l > m_totalMaxFileSize) throw new SecurityException("Total File Size exceeded (1110)."); } if (flag3) { File file = new File(); file.setParent(this); file.setFieldName(s3); file.setFileName(s4); file.setFileExt(s5); file.setFilePathName(s6); file.setIsMissing(s6.length() == 0); file.setContentType(s7); file.setContentDisp(s8); file.setTypeMIME(s9); file.setSubTypeMIME(s10); if (s7.indexOf("application/x-macbinary") > 0) m_startData = m_startData + 128; file.setSize((m_endData - m_startData) + 1); file.setStartData(m_startData); file.setEndData(m_endData); m_files.addFile(file); } else { String s11 = new String(m_binArray, m_startData, (m_endData - m_startData) + 1); m_formRequest.putParameter(s3, s11); } if ((char) m_binArray[m_currentIndex + 1] == '-') break; } } public int save(String s) throws ServletException, IOException, SmartUploadException { return save(s, 0); } public int save(String s, int i) throws ServletException, IOException, SmartUploadException { int j = 0; if (s == null) s = m_application.getRealPath("/"); if (s.indexOf("/") != -1) { if (s.charAt(s.length() - 1) != '/') s = s + "/"; } else if (s.charAt(s.length() - 1) != '\\') s = s + "\\"; for (int k = 0; k < m_files.getCount(); k++) if (!m_files.getFile(k).isMissing()) { m_files.getFile(k).saveAs(s + m_files.getFile(k).getFileName(), i); j++; } return j; } public int getSize() { return m_totalBytes; } public byte getBinaryData(int i) { byte byte0; try { byte0 = m_binArray[i]; } catch (Exception exception) { throw new ArrayIndexOutOfBoundsException("Index out of range (1005)."); } return byte0; } public Files getFiles() { return m_files; } public Request getRequest() { return m_formRequest; } public void downloadFile(String s) throws ServletException, IOException, SmartUploadException { downloadFile(s, null, null); } public void downloadFile(String s, String s1) throws ServletException, IOException, SmartUploadException { downloadFile(s, s1, null); } public void downloadFile(String s, String s1, String s2) throws ServletException, IOException, SmartUploadException { downloadFile(s, s1, s2, 65000); } public void downloadFile(String s, String s1, String s2, int i) throws ServletException, IOException, SmartUploadException { if (s == null) throw new IllegalArgumentException("File '" + s + "' not found (1040)."); if (s.equals("")) throw new IllegalArgumentException("File '" + s + "' not found (1040)."); if (!isVirtual(s) && m_denyPhysicalPath) throw new SecurityException("Physical path is denied (1035)."); if (isVirtual(s)) s = m_application.getRealPath(s); java.io.File file = new java.io.File(s); FileInputStream fileinputstream = new FileInputStream(file); long l = file.length(); int k = 0; byte abyte0[] = new byte[i]; if (s1 == null) m_response.setContentType("application/x-msdownload"); else if (s1.length() == 0) m_response.setContentType("application/x-msdownload"); else m_response.setContentType(s1); m_response.setContentLength((int) l); m_contentDisposition = m_contentDisposition != null ? m_contentDisposition : "attachment;"; if (s2 == null) m_response.setHeader("Content-Disposition", m_contentDisposition + " filename=" + getFileName(s)); else if (s2.length() == 0) m_response.setHeader("Content-Disposition", m_contentDisposition); else m_response.setHeader("Content-Disposition", m_contentDisposition + " filename=" + s2); while ((long) k < l) { int j = fileinputstream.read(abyte0, 0, i); k += j; m_response.getOutputStream().write(abyte0, 0, j); } fileinputstream.close(); } public void downloadField(ResultSet resultset, String s, String s1, String s2) throws ServletException, IOException, SQLException { if (resultset == null) throw new IllegalArgumentException("The RecordSet cannot be null (1045)."); if (s == null) throw new IllegalArgumentException("The columnName cannot be null (1050)."); if (s.length() == 0) throw new IllegalArgumentException("The columnName cannot be empty (1055)."); byte abyte0[] = resultset.getBytes(s); if (s1 == null) m_response.setContentType("application/x-msdownload"); else if (s1.length() == 0) m_response.setContentType("application/x-msdownload"); else m_response.setContentType(s1); m_response.setContentLength(abyte0.length); if (s2 == null) m_response.setHeader("Content-Disposition", "attachment;"); else if (s2.length() == 0) m_response.setHeader("Content-Disposition", "attachment;"); else m_response.setHeader("Content-Disposition", "attachment; filename=" + s2); m_response.getOutputStream().write(abyte0, 0, abyte0.length); } public void fieldToFile(ResultSet resultset, String s, String s1) throws ServletException, IOException, SmartUploadException, SQLException { try { if (m_application.getRealPath(s1) != null) s1 = m_application.getRealPath(s1); InputStream inputstream = resultset.getBinaryStream(s); FileOutputStream fileoutputstream = new FileOutputStream(s1); int i; while ((i = inputstream.read()) != -1) fileoutputstream.write(i); fileoutputstream.close(); } catch (Exception exception) { throw new SmartUploadException("Unable to save file from the DataBase (1020)."); } } private String getDataFieldValue(String s, String s1) { String s2; String s3 = ""; int i; s2 = s1 + "=" + '"'; i = s.indexOf(s2); if (i > 0) { int j = i + s2.length(); int k; k = j; s2 = "\""; int l = s.indexOf(s2, j); if (k > 0 && l > 0) s3 = s.substring(k, l); } return s3; } private String getFileExt(String s) { if (s == null) return null; String s1; int i = s.lastIndexOf(46) + 1; int j = s.length(); s1 = s.substring(i, j); if (s.lastIndexOf(46) > 0) return s1; else return ""; } private String getContentType(String s) { String s1; String s2 = ""; s1 = "Content-Type:"; int i = s.indexOf(s1) + s1.length(); if (i != -1) { int j = s.length(); s2 = s.substring(i, j); } return s2; } private String getTypeMIME(String s) { int i = s.indexOf("/"); if (i != -1) return s.substring(1, i); else return s; } private String getSubTypeMIME(String s) { int i = s.indexOf("/") + 1; if (i != -1) { int j = s.length(); return s.substring(i, j); } else { return s; } } private String getContentDisp(String s) { int i, j; i = s.indexOf(":") + 1; j = s.indexOf(";"); return s.substring(i, j); } private void getDataSection() { int i = m_currentIndex; int j = 0; int k = m_boundary.length(); m_startData = m_currentIndex; m_endData = 0; while (i < m_totalBytes) if (m_binArray[i] == (byte) m_boundary.charAt(j)) { if (j == k - 1) { m_endData = ((i - k) + 1) - 3; break; } i++; j++; } else { i++; j = 0; } m_currentIndex = m_endData + k + 3; } private String getDataHeader() { int i = m_currentIndex; int j = 0; for (boolean flag1 = false; !flag1;) if (m_binArray[m_currentIndex] == 13 && m_binArray[m_currentIndex + 2] == 13) { flag1 = true; j = m_currentIndex - 1; m_currentIndex = m_currentIndex + 2; } else { m_currentIndex++; } return new String(m_binArray, i, (j - i) + 1); } private String getFileName(String s) { int i; i = s.lastIndexOf(47); if (i != -1) return s.substring(i + 1, s.length()); i = s.lastIndexOf(92); if (i != -1) return s.substring(i + 1, s.length()); else return s; } public void setDeniedFilesList(String s) throws ServletException, IOException, SQLException { if (s != null) { String s2 = ""; for (int i = 0; i < s.length(); i++) if (s.charAt(i) == ',') { if (!m_deniedFilesList.contains(s2)) m_deniedFilesList.addElement(s2); s2 = ""; } else { s2 = s2 + s.charAt(i); } if (!s2.equals("")) m_deniedFilesList.addElement(s2); } else { m_deniedFilesList = null; } } public void setAllowedFilesList(String s) { if (s != null) { String s2 = ""; for (int i = 0; i < s.length(); i++) if (s.charAt(i) == ',') { if (!m_allowedFilesList.contains(s2)) m_allowedFilesList.addElement(s2); s2 = ""; } else { s2 = s2 + s.charAt(i); } if (!s2.equals("")) m_allowedFilesList.addElement(s2); } else { m_allowedFilesList = null; } } public void setDenyPhysicalPath(boolean flag) { m_denyPhysicalPath = flag; } public void setForcePhysicalPath() { } public void setContentDisposition(String s) { m_contentDisposition = s; } public void setTotalMaxFileSize(long l) { m_totalMaxFileSize = l; } public void setMaxFileSize(long l) { m_maxFileSize = l; } protected String getPhysicalPath(String s, int i) throws IOException { String s1 = ""; String s2 = ""; String s3; boolean flag = false; s3 = System.getProperty("file.separator"); if (s == null) throw new IllegalArgumentException("There is no specified destination file (1140)."); if (s.equals("")) throw new IllegalArgumentException("There is no specified destination file (1140)."); if (s.lastIndexOf("\\") >= 0) { s1 = s.substring(0, s.lastIndexOf("\\")); s2 = s.substring(s.lastIndexOf("\\") + 1); } if (s.lastIndexOf("/") >= 0) { s1 = s.substring(0, s.lastIndexOf("/")); s2 = s.substring(s.lastIndexOf("/") + 1); } s1 = s1.length() != 0 ? s1 : "/"; java.io.File file = new java.io.File(s1); if (file.exists()) flag = true; if (i == 0) { if (isVirtual(s1)) { s1 = m_application.getRealPath(s1); if (s1.endsWith(s3)) s1 = s1 + s2; else s1 = s1 + s3 + s2; return s1; } if (flag) { if (m_denyPhysicalPath) throw new IllegalArgumentException("Physical path is denied (1125)."); else return s; } else { throw new IllegalArgumentException("This path does not exist (1135)."); } } if (i == 1) { if (isVirtual(s1)) { s1 = m_application.getRealPath(s1); if (s1.endsWith(s3)) s1 = s1 + s2; else s1 = s1 + s3 + s2; return s1; } if (flag) throw new IllegalArgumentException("The path is not a virtual path."); else throw new IllegalArgumentException("This path does not exist (1135)."); } if (i == 2) { if (flag) if (m_denyPhysicalPath) throw new IllegalArgumentException("Physical path is denied (1125)."); else return s; if (isVirtual(s1)) throw new IllegalArgumentException("The path is not a physical path."); else throw new IllegalArgumentException("This path does not exist (1135)."); } else { return null; } } public void uploadInFile(String s) throws IOException, SmartUploadException { int i; int j = 0; if (s == null) throw new IllegalArgumentException("There is no specified destination file (1025)."); if (s.length() == 0) throw new IllegalArgumentException("There is no specified destination file (1025)."); if (!isVirtual(s) && m_denyPhysicalPath) throw new SecurityException("Physical path is denied (1035)."); i = m_request.getContentLength(); m_binArray = new byte[i]; int k; for (; j < i; j += k) try { k = m_request.getInputStream().read(m_binArray, j, i - j); } catch (Exception exception) { throw new SmartUploadException("Unable to upload."); } if (isVirtual(s)) s = m_application.getRealPath(s); try { java.io.File file = new java.io.File(s); FileOutputStream fileoutputstream = new FileOutputStream(file); fileoutputstream.write(m_binArray); fileoutputstream.close(); } catch (Exception exception1) { throw new SmartUploadException("The Form cannot be saved in the specified file (1030)."); } } private boolean isVirtual(String s) { if (m_application.getRealPath(s) != null) { java.io.File file = new java.io.File(m_application.getRealPath(s)); return file.exists(); } else { return false; } } }
zzfls-pj
trunk/src/net/tools/jspupload/SmartUpload.java
Java
asf20
21,626
package net.tools.jspupload; import java.io.IOException; import java.util.Collection; import java.util.Enumeration; import java.util.Hashtable; /** * Date:2008-9-24<br> * * @author <a href="mailto:yanghongjian@htjs.net">YangHongJian</a> * @version 2.0 * @since 1.4.2 */ public class Files { private Hashtable m_files; private int m_counter; Files() { m_files = new Hashtable(); m_counter = 0; } protected void addFile(File file) { if (file == null) { throw new IllegalArgumentException("newFile cannot be null."); } else { m_files.put(new Integer(m_counter), file); m_counter++; } } public File getFile(int i) { if (i < 0) throw new IllegalArgumentException("File's index cannot be a negative value (1210)."); File file = (File) m_files.get(new Integer(i)); if (file == null) throw new IllegalArgumentException("Files' name is invalid or does not exist (1205)."); else return file; } public int getCount() { return m_counter; } public long getSize() throws IOException { long l = 0L; for (int i = 0; i < m_counter; i++) l += getFile(i).getSize(); return l; } public Collection getCollection() { return m_files.values(); } public Enumeration getEnumeration() { return m_files.elements(); } }
zzfls-pj
trunk/src/net/tools/jspupload/Files.java
Java
asf20
1,554
package net.tools; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; public final class BeansHelp { private static Logger log = Logger.getLogger(BeansHelp.class); private static ApplicationContext ctx; private static WebApplicationContext webCtx; protected BeansHelp() { } static { if (ctx == null) { try{ webCtx = WebApplicationContextUtils .getRequiredWebApplicationContext(ServletActionContext .getServletContext()); log.info("从web.xml容器中加载spring-config.xml"); }catch(Exception e){ log.info("直接加载spring-config.xml"); } if (webCtx == null) ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); } } /** * 通过beanID获取bean实例 * * @param beanID * bean的代码 * @return 返回对应的实例 * bean没有定义 */ public static Object getBeanInstance(String beanID) throws RuntimeException { // log.info("在spring容器中获取Bean对象 ID=" + beanID); Object obj; if (BeansHelp.ctx == null) { if (BeansHelp.webCtx.containsBeanDefinition(beanID)) { obj = BeansHelp.webCtx.getBean(beanID); } else { log.info("beanID=" + beanID + "没有定义"); throw new RuntimeException(beanID + "没有定义!"); } } else { if (BeansHelp.ctx.containsBeanDefinition(beanID)) { obj = BeansHelp.ctx.getBean(beanID); } else { log.info("beanID=" + beanID + "没有定义"); throw new RuntimeException(beanID + "没有定义!"); } } // if (BeansHelp.ctx.containsBeanDefinition(beanID)) { // obj = BeansHelp.ctx.getBean(beanID); // } else { // log.info("beanID=" + beanID + "没有定义"); // throw new NoSuchBeanException(beanID + "没有定义!"); // } return obj; } }
zzfls-pj
trunk/src/net/tools/BeansHelp.java
Java
asf20
2,183
package net.tools; import jxl.Workbook; import jxl.format.UnderlineStyle; import jxl.write.WritableFont; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; import java.util.Map; public class GridExportUtil { private int rowsHeight = 400; // 单行高度 private HttpServletRequest request; private HttpServletResponse response; public GridExportUtil(HttpServletRequest request, HttpServletResponse response) { setRequest(request); setResponse(response); } public HttpServletRequest getRequest() { return request; } public void setRequest(HttpServletRequest request) { this.request = request; } public HttpServletResponse getResponse() { return response; } public void setResponse(HttpServletResponse response) { this.response = response; } public void exportXLS(List data, Class beanClass) throws IOException { // List cols = this.getDisplayColumnInfo(); // int len = cols.size(); // int len = 12; // String[] properiesName = new String[len]; // String[] headsName = new String[len]; //// List titlelist = new ArrayList(); // for (int i = 0; i < len; i++) { //// ColumnInfo colInfo = (ColumnInfo) cols.get(i); // properiesName[i] = colInfo.getFieldIndex(); // headsName[i] = colInfo.getHeader(); //// titlelist.add(map); // } //properiesName 数据id headsName title // exportXLS(data, properiesName, headsName, beanClass); } /** * 导出xls文件 * * @param data 导出的数捄1?7 list<Object> * @param properiesName map的key * @param headsName key对应的title * @param beanClass Object类型 * @throws java.io.IOException */ public void exportXLS(String title, List data, String[] properiesName, String[] headsName, int[] colswidth, String[] aligns, Class beanClass) throws IOException { ByteArrayOutputStream baos = null; BufferedOutputStream bos = null; jxl.write.WritableWorkbook wwb = null; jxl.write.WritableSheet ws = null; try { baos = new ByteArrayOutputStream(); bos = new BufferedOutputStream(baos); wwb = Workbook.createWorkbook(bos); ws = wwb.createSheet("当前数据", 0); setExcel(title, data, properiesName, headsName, colswidth, aligns, ws, 1); wwb.write(); } catch (Exception e) { e.printStackTrace(); } try { bos.close(); wwb.close(); } catch (Exception e) { e.printStackTrace(); } try { byte[] bs = baos.toByteArray(); outPutExcel("data.xls", bs); // 输出文件 } catch (Exception e) { //e.printStackTrace(); } } /** * 设置excel字段 * * @return byte[] * @throws Exception */ private int setExcel(String bigtitle, List valueList, String[] properiesName, String[] headsName, int[] colswidth, String[] aligns, jxl.write.WritableSheet ws, int rownum) throws Exception { try { int[] colsWidth = new int[headsName.length]; if (colswidth != null) { colsWidth = colswidth; } // 列宽设置 bigtitle = convert(bigtitle); //合并单元格 if ("".equals(bigtitle)) { rownum = 0; } else { // 设置大标题栏样式 jxl.write.WritableFont wfcdtt = new jxl.write.WritableFont( WritableFont.ARIAL, 20, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK); jxl.write.WritableCellFormat wcfFCdtt = new jxl.write.WritableCellFormat( wfcdtt); wcfFCdtt.setAlignment(jxl.format.Alignment.CENTRE); wcfFCdtt.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); // 设置标题栄1?7 jxl.write.Label headdttCell = new jxl.write.Label(0, 0, bigtitle, wcfFCdtt); ws.addCell(headdttCell); ws.mergeCells(0, 0, headsName.length - 1, 0); ws.setRowView(0, rowsHeight + rowsHeight); } // 设置标题栏样式 jxl.write.WritableFont wfc = new jxl.write.WritableFont( WritableFont.ARIAL, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK); jxl.write.WritableCellFormat wcfFC = new jxl.write.WritableCellFormat( wfc); wcfFC.setAlignment(jxl.format.Alignment.CENTRE); wcfFC.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); // 设置标题 for (int i = 0; i < headsName.length; i++) { String title = (String) headsName[i]; title = convert(title); jxl.write.Label headCell = new jxl.write.Label(i, 0 + rownum, title, wcfFC); ws.addCell(headCell); } jxl.write.WritableCellFormat cellFormat = new jxl.write.WritableCellFormat(); cellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); // 设置数据区域 int size = valueList.size(); for (int i = 0; i < size; i++) { Map map = (Map) valueList.get(i); for (int j = 0; j < properiesName.length; j++) { String value = ""; String key = properiesName[j]; String straligns = aligns[j]; // if("RIGHT".equals(straligns)){ // cellFormat.setAlignment(jxl.format.Alignment.RIGHT); // }else if("CENTER".equals(straligns)){ // cellFormat.setAlignment(jxl.format.Alignment.CENTRE); // }else{ // cellFormat.setAlignment(jxl.format.Alignment.LEFT); // } try { value = String.valueOf((map.get(key) == null ? "" : map.get(key))); value = convert(value); } catch (Exception e) { e.printStackTrace(); value = ""; } try { jxl.write.Label datCell = new jxl.write.Label(j, i + 1 + rownum, value, cellFormat); ws.addCell(datCell); } catch (Exception e) { e.printStackTrace(); } } } //设置列宽 for (int i = 0; i < colsWidth.length; i++) { if (colsWidth[i] < 16) { colsWidth[i] = 16; } ws.setColumnView(i, colsWidth[i]); } //设置列高 for (int i = 0; i <= valueList.size(); i++) { ws.setRowView(i + rownum, rowsHeight); } } catch (Exception e) { e.printStackTrace(); } return rownum + valueList.size() + 1; } /** * 把计算结果输出到Excel */ public void outPutExcel(String fileName, byte[] bs) throws Exception { javax.servlet.ServletOutputStream outfile = null; try { getResponse().reset(); String CONTENT_TYPE = "text/html; charset=UTF-8"; getResponse().setContentType(CONTENT_TYPE); getResponse().setContentType("application/octet-stream"); getResponse().setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); outfile = getResponse().getOutputStream(); outfile.write(bs); } catch (Exception e) { //e.printStackTrace(); } finally { outfile.close(); } } public String convert(String str) { // if (str == null) // str = ""; // str = str.trim(); // if (str.length() > 0) { // try { // str = new String(str.getBytes("ISO-8859-1"), "GBK"); // } catch (Exception e) { // e.printStackTrace(); // } // } return str; } }
zzfls-pj
trunk/src/net/tools/GridExportUtil.java
Java
asf20
8,872
package net.actions.site; import java.util.Iterator; import java.util.List; import java.util.Map; import net.base.BaseAction; import net.base.BaseDao; import org.apache.log4j.Logger; public class SiteItemAction extends BaseAction{ private BaseDao dao = null; public BaseDao getDao() { return dao; } public void setDao(BaseDao dao) { this.dao = dao; } private Logger log = Logger.getLogger(this.getClass()); /** * 取新闻栏目树 * @return */ public String getSiteItemTree(){ try{ StringBuffer rtn = new StringBuffer(); rtn.append("["); List list = dao.getList("site.site_item.getSITE_ITEM", null); for(Iterator it=list.iterator();it.hasNext();){ Map map = (Map)it.next(); rtn.append("{id:" +map.get("ID") + ",pId:" + map.get("PID")+",name:\""+ map.get("NAME") +"\"},"); } if(rtn.length()>1) rtn = new StringBuffer(rtn.substring(0,rtn.length()-1)); rtn.append("]"); this.msg = rtn.toString(); }catch(Exception e){ e.printStackTrace(); log.error(e.toString()); this.code = -1; this.msg = "查询失败!\n" + e.toString(); this.expMsg = getExceptionMessage(e); } return getResult(); } }
zzfls-pj
trunk/src/net/actions/site/SiteItemAction.java
Java
asf20
1,353
package net.actions.sys; import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.Iterator; import org.apache.log4j.Logger; import net.base.BaseAction; import net.base.BaseDao; import net.base.MD5; public class UserAction extends BaseAction { private BaseDao dao = null; public BaseDao getDao() { return dao; } public void setDao(BaseDao dao) { this.dao = dao; } private Logger log = Logger.getLogger(this.getClass()); /** * 添加用户 */ public void insertUser() throws Exception { try { Map map = this.parserRequest(this.getRequest()); Map user = dao.getMap("user.selectUserBY_ACC", map); if (user != null) { this.setResult("01", "该账号已被使用,请换用其他账号!"); } else { MD5 md5 = new MD5(); String user_pwd = md5.getMD5ofStr(String.valueOf(map.get("USER_PWD"))); map.put("USER_PWD", user_pwd); dao.insert("user.insertUser", map); this.setResult("00", "添加成功!"); } } catch (Exception e) { log.error(e.toString()); this.setResult("99", "添加失败!\n" + e.toString()); throw new Exception(); } } /** * 修改用户密码 */ public void insertUserPwd() throws Exception { try { Map map = this.parserRequest(this.getRequest()); MD5 md5 = new MD5(); String user_pwd = md5.getMD5ofStr(String.valueOf(map.get("USER_PWD"))); map.put("USER_PWD", user_pwd); dao.update("user.updateUserPWD", map); this.setResult("00", "修改成功!"); } catch (Exception e) { log.error(e.toString()); this.setResult("99", "修改失败!\n" + e.toString()); throw new Exception(); } } /** * 用户分配角色保存 */ public void insertUserRole() throws Exception { try { Map map = this.parserRequest(this.getRequest()); String user_dm = String.valueOf(map.get("USER_DM")); String[] role_dm = String.valueOf(map.get("ROLE_DM")).split(","); // 先删除原来的角色 dao.delete("user.deleteUserRole", user_dm); // 插入新分配得角色 for (int n = 0; n < role_dm.length; n++) { Map parMap = new HashMap(); parMap.put("USER_DM", user_dm); parMap.put("ROLE_DM", role_dm[n]); dao.insert("user.insertUserRole", parMap); } this.setResult("00", "添加成功!"); } catch (Exception e) { log.error(e.toString()); this.setResult("99", "添加失败!\n" + e.toString()); throw new Exception(); } } public void deleteUser() throws Exception { try { Map map = this.parserRequest(this.getRequest()); String[] user_dm = String.valueOf(map.get("IDS")).split(","); // 循环删除用户 for (int n = 0; n < user_dm.length; n++) { // 先删除用户角色的关系 dao.delete("user.deleteUserRole", user_dm[n]); // 删除用户 dao.delete("user.deleteUser", user_dm[n]); } this.setResult("00", "删除成功!"); } catch (Exception e) { log.error(e.toString()); this.setResult("99", "删除失败!\n" + e.toString()); throw new Exception(); } } /** * 取登录用户操作模块树 */ public void getModuleTreeByUserDM() { try { StringBuffer xml = new StringBuffer(); String module_dm_sj = this.getRequest().getParameter("MODULE_DM_SJ"); Map userMap = (Map) this.getSession().get("SYS_USER"); String user_dm = String.valueOf(userMap.get("USER_DM")); xml.append("<?xml version=\"1.0\" encoding=\"GBK\"?>"); xml.append("<tree id=\"0\">"); xml.append(getTreeString(module_dm_sj, user_dm)); xml.append("</tree>"); this.setResult("00", xml.toString()); } catch (Exception e) { log.error(e.toString()); this.setResult("99", "操作失败!\n" + e.toString()); } } private String getTreeString(String module_dm_sj, String user_dm) throws Exception { StringBuffer xml = new StringBuffer(); Map parMap = new HashMap(); parMap.put("MODULE_DM_SJ", module_dm_sj); parMap.put("USER_DM", user_dm); List list = dao.getList("user.selectModuleTreeByUserDM", parMap); Iterator it = list.iterator(); while (it.hasNext()) { Map m = (Map) it.next(); String text = ""; if (m.get("MODULE_URL") == null || "".equals(m.get("MODULE_URL")) || "null".equals(m.get("MODULE_URL"))) { text = (String) m.get("MODULE_NAME"); } else { String s = ((String) m.get("MODULE_URL")).indexOf("?") > 0 ? "&" : "?"; String url = m.get("MODULE_URL") + s + "MODULE_DM=" + m.get("MODULE_DM"); text = "&lt;a href=javascript:openTabInRightFrame('" + url + "','" + m.get("MODULE_NAME") + "','" + m.get("MODULE_DM") + "');&gt;" + m.get("MODULE_NAME") + "&lt;/a&gt;"; } xml.append("<item text=\"" + text).append("\""). append(" id=\"").append(m.get("MODULE_DM")) .append("\" im0=\"tombs.gif\" im1=\"folderOpen.gif\" im2=\"iconSafe.gif\">"); xml.append(getTreeString(String.valueOf(m.get("MODULE_DM")), user_dm)); xml.append("</item>"); } return xml.toString(); } }
zzfls-pj
trunk/src/net/actions/sys/UserAction.java
Java
asf20
6,087
package net.actions.sys; import java.util.Map; import java.util.HashMap; import java.util.List; import java.util.Iterator; import net.base.BaseAction; import net.base.BaseDao; import org.apache.log4j.Logger; public class RoleAction extends BaseAction { private BaseDao dao = null; public BaseDao getDao() { return dao; } public void setDao(BaseDao dao) { this.dao = dao; } private Logger log = Logger.getLogger(this.getClass()); public void deleteRole() throws Exception { try { Map map = this.parserRequest(this.getRequest()); String[] role_dm = String.valueOf(map.get("IDS")).split(","); // 循环删除角色 for (int n = 0; n < role_dm.length; n++) { // 先删除角色模块的关系 dao.delete("role.deleteRoleModuleByRoleDM", role_dm[n]); //删除角色用户的关系 dao.delete("role.deleteRoleUserByRoleDM", role_dm[n]); // 删除角色 dao.delete("role.deleteRole", role_dm[n]); } this.setResult("00", "删除成功!"); } catch (Exception e) { log.error(e.toString()); this.setResult("99", "删除失败!\n" + e.toString()); throw new Exception(); } } /** * 根据角色代码取角色的权限树 */ public void getModuleTreeByRoleDM() { try { StringBuffer xml = new StringBuffer(); String module_dm_sj = this.getRequest().getParameter("MODULE_DM_SJ"); String role_dm = this.getRequest().getParameter("ROLE_DM"); String user_dm = this.getRequest().getParameter("USER_DM"); xml.append("<?xml version=\"1.0\" encoding=\"GBK\"?>"); xml.append("<tree id=\"0\">"); xml.append(getTreeString(module_dm_sj, role_dm,user_dm)); xml.append("</tree>"); this.setResult("00", xml.toString()); } catch (Exception e) { log.error(e.toString()); this.setResult("99", "操作失败!\n" + e.toString()); } } /** * 取角色的权限树xml * * @param module_dm_sj * @param role_dm * @return * @throws Exception */ private String getTreeString(String module_dm_sj, String role_dm,String user_dm) throws Exception { StringBuffer xml = new StringBuffer(); Map parMap = new HashMap(); parMap.put("MODULE_DM_SJ", module_dm_sj); parMap.put("ROLE_DM", role_dm); parMap.put("USER_DM", user_dm); List list = dao.getList("role.selectModuleByRoleDM", parMap); Iterator it = list.iterator(); while (it.hasNext()) { Map m = (Map) it.next(); String check = ""; if ("1".equals(m.get("LX"))) { //叶子节点才添加选中操作 check = (String) m.get("BZ"); } xml.append("<item text=\"" + m.get("MODULE_NAME")).append("\""). append(" id=\"").append(m.get("MODULE_DM")).append("\" checked=\"").append(check) .append("\" im0=\"tombs.gif\" im1=\"folderOpen.gif\" im2=\"iconSafe.gif\">"); xml.append(getTreeString(String.valueOf(m.get("MODULE_DM")), role_dm,user_dm)); xml.append("</item>"); } return xml.toString(); } /** * 保存角色模块关系 */ public void insertRoleModule() throws Exception { try { String[] module_dms = this.getRequest().getParameter("MODULE_DMS").split(","); String role_dm = this.getRequest().getParameter("ROLE_DM"); dao.delete("role.deleteRoleModuleByRoleDM", role_dm); for (int i = 0; i < module_dms.length; i++) { Map parMap = new HashMap(); parMap.put("ROLE_DM", role_dm); parMap.put("MODULE_DM", module_dms[i]); dao.insert("role.insertRoleModule", parMap); } this.setResult("00", "模块分配成功!"); } catch (Exception e) { log.error(e.toString()); this.setResult("99", "模块分配失败!\n" + e.toString()); throw new Exception(); } } }
zzfls-pj
trunk/src/net/actions/sys/RoleAction.java
Java
asf20
4,437
package net.actions.sys; import net.base.BaseAction; import net.base.BaseDao; import net.base.MD5; import net.base.Tools; import org.apache.log4j.Logger; import java.util.Map; import com.opensymphony.xwork2.Action; /** * Created by IntelliJ IDEA. * User: Administrator * Date: 2010-11-20 * Time: 18:54:41 * To change this template use File | Settings | File Templates. */ public class LoginAction extends BaseAction { private BaseDao dao = null; public BaseDao getDao() { return dao; } public void setDao(BaseDao dao) { this.dao = dao; } private Logger log = Logger.getLogger(this.getClass()); public void doLogin() { try { Map map = this.parserRequest(this.getRequest()); map.put("ACCOUNT", map.get("ACCOUNT")); Map userMap = dao.getMap("user.selectUserBY_ACC", map); MD5 md5 = new MD5(); String pass = md5.getMD5ofStr(String.valueOf(map.get("USER_PWD"))); System.out.println(userMap.get("YXBZ") + " " + "1".equals(userMap.get("YXBZ"))); if (userMap == null) { this.setResult("01", "该账号不存在!"); } else if (!pass.equals(userMap.get("USER_PWD"))) { this.setResult("02", "用户密码不正确!"); } else if (!"1".equals(userMap.get("YXBZ"))) { this.setResult("03", "该用户已被禁用!"); } else { this.getSession().put("SYS_USER", userMap); this.setResult("00", Tools.toJsonByMap(userMap)); } } catch (Exception e) { log.error(e.toString()); this.setResult("99", "操作失败!\n" + e.toString()); } } /** * 退出登录 */ public void loginOut() { this.getSession().clear(); this.setResult("00", "操作成功"); } /* 取登录用户session */ public void getUserSession() { String json = Tools.toJsonByMap((Map) this.getSession().get("SYS_USER")); this.setResult("00", json.substring(0, json.length() - 1)); } }
zzfls-pj
trunk/src/net/actions/sys/LoginAction.java
Java
asf20
2,209
package net.actions.sys; import java.util.Map; import java.util.List; import java.util.HashMap; import java.util.Iterator; import net.base.BaseAction; import net.base.BaseDao; import org.apache.log4j.Logger; public class ModuleAction extends BaseAction { private BaseDao dao = null; public BaseDao getDao() { return dao; } public void setDao(BaseDao dao) { this.dao = dao; } private Logger log = Logger.getLogger(this.getClass()); public String insertModule() throws Exception{ try{ Map map = this.parserRequest(this.getRequest()); log.info("执行sql+++++++++++++++++++" + map.get("SQLID")); Object i = dao.insert((String) map.get("SQLID"), map); //保存 超级管理员的权限 Map paramMap = new HashMap(); paramMap.put("ROLE_DM","1"); paramMap.put("MODULE_DM",i); dao.insert("role.insertRoleModule",paramMap); }catch (Exception e){ e.printStackTrace(); log.error(e.toString()); code = -1; msg = "模块添加失败!\n" + e.getMessage(); expMsg = getExceptionMessage(e); throw new Exception(); } return getResult(); } public void deleteModule() throws Exception{ try { Map map = this.parserRequest(this.getRequest()); String[] module_dm = String.valueOf(map.get("IDS")).split(","); // 循环删除模块 for (int n = 0; n < module_dm.length; n++) { // 先删除模块 deleteModuleBySJ(module_dm[n]); //删除角色模块的对应关系 dao.delete("role.deleteRoleModuleByModuleDM", module_dm[n]); //删除模块 dao.delete("module.deleteModule", module_dm[n]); } this.setResult("00", "删除成功!"); } catch (Exception e) { log.error(e.toString()); this.setResult("99", "删除失败!\n" + e.toString()); throw new Exception(); } } private void deleteModuleBySJ(String module_dm_sj) throws Exception { Map parMap = new HashMap(); parMap.put("MODULE_DM_SJ", module_dm_sj); List list = dao.getList("module.selectModuleAll", parMap); Iterator it = list.iterator(); while (it.hasNext()) { Map m = (Map) it.next(); deleteModuleBySJ(String.valueOf(m.get("MODULE_DM"))); } dao.delete("module.deleteModuleByMODULE_DM_SJ", module_dm_sj); //删除角色模块的对应关系 dao.delete("role.deleteRoleModuleByModuleDM", module_dm_sj); } /** * 取模块树 */ public void getModuleTree() { try { StringBuffer xml = new StringBuffer(); Map map = this.parserRequest(this.getRequest()); xml.append("<?xml version=\"1.0\" encoding=\"GBK\"?>"); xml.append("<tree id=\"0\">"); xml.append(getTreeString( map)); xml.append("</tree>"); this.setResult("00", xml.toString()); } catch (Exception e) { log.error(e.toString()); this.setResult("99", "操作失败!\n" + e.toString()); } } /** * 取模块树xml * * @param map * @return * @throws Exception */ private String getTreeString(Map map) throws Exception { StringBuffer xml = new StringBuffer(); List list = dao.getList("module.selectModuleAll", map); Iterator it = list.iterator(); while (it.hasNext()) { Map m = (Map) it.next(); xml.append("<item text=\"" + m.get("MODULE_NAME")).append("\""). append(" id=\"").append(m.get("MODULE_DM")).append("-").append(m.get("ORDERSALL")).append("\" checked=\"").append("") .append("\" im0=\"tombs.gif\" im1=\"folderOpen.gif\" im2=\"iconSafe.gif\">"); map.put("MODULE_DM_SJ",m.get("MODULE_DM")); xml.append(getTreeString(map)); xml.append("</item>"); } return xml.toString(); } }
zzfls-pj
trunk/src/net/actions/sys/ModuleAction.java
Java
asf20
4,342
package net.result; import com.opensymphony.xwork2.ActionInvocation; import net.base.ToolsAction; import net.sf.json.JSONObject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.ServletActionContext; import org.apache.struts2.dispatcher.StrutsRequestWrapper; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * Created by IntelliJ IDEA. * User: Administrator * Date: 11-9-17 * Time: 下午3:29 * To change this template use File | Settings | File Templates. */ public class JsonMutiHTMLResult extends BaseResult { private static final Log log = LogFactory.getLog(JsonHTMLResult.class); private String location; private String errorPage = "/commons/common/error.jsp"; protected boolean isAjax = true; public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } public String getErrorPage() { return errorPage; } public void setErrorPage(String errorPage) { this.errorPage = errorPage; } public JsonMutiHTMLResult() { // TODO Auto-generated constructor stub super(); } public JsonMutiHTMLResult(String location) { // TODO Auto-generated constructor stub super(location); } public void execute(ActionInvocation invocation) throws Exception { // TODO Auto-generated method stub long startTime = System.currentTimeMillis(); ServletContext sc = ServletActionContext.getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); System.out.println("charset:" + request.getCharacterEncoding()); response.setCharacterEncoding(request.getCharacterEncoding()); response.setContentType("application/json;charset=" + request.getCharacterEncoding()); StrutsRequestWrapper requestWrapper = new StrutsRequestWrapper(request); PrintWriter output = response.getWriter(); ToolsAction baseAction = (ToolsAction) invocation.getAction(); try { // request.setAttribute("model", baseAction.getModel()); String viewName = request.getParameter("viewName") == null ? this.location : request.getParameter("viewName"); List resultList = new ArrayList(); String[] viewNames = viewName.split(";"); for (int i = 0; i < viewNames.length; i++) { String vName = viewNames[i]; RequestDispatcher dispatcher = request.getRequestDispatcher(vName); ResponseWrapper responseWrapper = new ResponseWrapper(response); dispatcher.include(requestWrapper, responseWrapper); String content = responseWrapper.getContent(); resultList.add(content.trim()); responseWrapper.finalize(); } JSONObject js = new JSONObject(); js.put("code", new Integer(baseAction.getCode())); js.put("msg", baseAction.getMsg()); js.put("expMsg", baseAction.getExpMsg()); js.put("data", resultList); String resultContent = js.toString(); log.info(resultContent); output.write(resultContent); output.flush(); } catch (Exception ex) { HashMap hashMap = new HashMap(); hashMap.put("code", "-1"); hashMap.put("type", "err"); hashMap.put("msg", "发生错误"); hashMap.put("mx", ex.getMessage()); JSONObject js = new JSONObject(); js.put("msg", hashMap); output.write(js.toString()); } finally { if (output != null) output.close(); } log.info("use time " + (System.currentTimeMillis() - startTime) + " ms"); } protected void doExecute(String location, ActionInvocation invocation) throws Exception { // TODO Auto-generated method stub this.location = location; this.execute(invocation); } }
zzfls-pj
trunk/src/net/result/JsonMutiHTMLResult.java
Java
asf20
4,512
package net.result; import com.opensymphony.xwork2.ActionInvocation; import net.base.ToolsAction; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import org.apache.struts2.ServletActionContext; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; import java.util.HashMap; public class JsonResult extends BaseResult { protected boolean isAjax = true; protected void doExecute(String arg0, ActionInvocation invocation) throws Exception { // TODO Auto-generated method stub this.execute(invocation); } public void execute(ActionInvocation invocation) throws Exception { ServletContext sc = ServletActionContext.getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); response.setCharacterEncoding(request.getCharacterEncoding()); response.setContentType("application/json"); PrintWriter output = response.getWriter(); ToolsAction baseAction = (ToolsAction) invocation.getAction(); output.flush(); try { JsonConfig jsonConfig = new JsonConfig(); jsonConfig.registerJsonValueProcessor(java.sql.Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); jsonConfig.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); JSONObject js = JSONObject.fromObject(baseAction.getModel(), jsonConfig); js.put("code", new Integer(baseAction.getCode())); js.put("msg", baseAction.getMsg()); js.put("expMsg", baseAction.getExpMsg()); js.write(output); System.out.println(this.getClass() + "->" + js.toString()); } catch (Exception ex) { HashMap hashMap = new HashMap(); hashMap.put("code", "-1"); hashMap.put("type", "err"); hashMap.put("msg", "发生错误"); hashMap.put("mx", ex.getMessage()); JSONObject js = new JSONObject(); js.put("msg", hashMap); output.write(js.toString()); } finally { if (output != null) output.close(); } } }
zzfls-pj
trunk/src/net/result/JsonResult.java
Java
asf20
2,391
package net.result; import com.opensymphony.xwork2.ActionInvocation; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.DomDriver; import net.base.ToolsAction; import org.apache.struts2.ServletActionContext; import javax.servlet.ServletContext; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.Map; public class XmlResult extends BaseResult { protected void doExecute(String arg0, ActionInvocation invocation) throws Exception { // TODO Auto-generated method stub // TODO Auto-generated method stub ServletContext sc = ServletActionContext.getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); // response.setCharacterEncoding(response.getCharacterEncoding()); response.setContentType("text/html;charset=UTF-8"); ToolsAction baseAction = (ToolsAction) invocation.getAction(); ServletOutputStream output = response.getOutputStream(); XStream xstream = new XStream(new DomDriver()); xstream.alias("item", Map.class); xstream.alias("items", ArrayList.class); xstream.registerConverter(new net.result.MapConverter(xstream.getMapper())); String result = xstream.toXML(baseAction.getModel()); xstream.toXML(baseAction.getModel(), output); System.out.println(result); } }
zzfls-pj
trunk/src/net/result/XmlResult.java
Java
asf20
1,615
package net.result; import com.opensymphony.xwork2.ActionInvocation; import net.base.ToolsAction; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.ServletActionContext; import org.apache.struts2.dispatcher.StrutsRequestWrapper; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; import java.util.HashMap; public class JsonHTMLResult extends BaseResult { private static final Log log = LogFactory.getLog(JsonHTMLResult.class); private String location; private String errorPage = "/commons/common/error.jsp"; protected boolean isAjax=true; public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } public String getErrorPage() { return errorPage; } public void setErrorPage(String errorPage) { this.errorPage = errorPage; } public JsonHTMLResult() { // TODO Auto-generated constructor stub super(); } public JsonHTMLResult(String location) { // TODO Auto-generated constructor stub super(location); } public void execute(ActionInvocation invocation) throws Exception { // TODO Auto-generated method stub long startTime = System.currentTimeMillis(); ServletContext sc = ServletActionContext.getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); System.out.println("charset:" + request.getCharacterEncoding()); response.setCharacterEncoding(request.getCharacterEncoding()); response.setContentType("application/json;charset="+request.getCharacterEncoding()); StrutsRequestWrapper requestWrapper = new StrutsRequestWrapper(request); ResponseWrapper responseWrapper = new ResponseWrapper(response); PrintWriter output = response.getWriter(); ToolsAction baseAction = (ToolsAction) invocation.getAction(); try { // request.setAttribute("model", baseAction.getModel()); String viewName=request.getParameter("viewName")==null?this.location:request.getParameter("viewName"); viewName = viewName==null||viewName.equals("")?String.valueOf(baseAction.getModel().get("HTML_PATH")):viewName; RequestDispatcher dispatcher = request.getRequestDispatcher(viewName); dispatcher.include(requestWrapper, responseWrapper); String content=responseWrapper.getContent(); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.registerJsonValueProcessor(java.sql.Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); jsonConfig.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); JSONObject js=JSONObject.fromObject(baseAction.getModel(),jsonConfig); js.put("code",new Integer(baseAction.getCode())); js.put("msg", baseAction.getMsg()); js.put("expMsg", baseAction.getExpMsg()); js.put("data", content.trim()); content = js.toString(); log.info(content); output.write(content); output.flush(); responseWrapper.finalize(); } catch (Exception ex) { HashMap hashMap = new HashMap(); hashMap.put("code", "-1"); hashMap.put("type", "err"); hashMap.put("msg","发生错误"); hashMap.put("mx", ex.getMessage()); JSONObject js = new JSONObject(); js.put("msg", hashMap); output.write(js.toString()); } finally { if (output != null) output.close(); } log.info("use time " + (System.currentTimeMillis() - startTime) + " ms"); } protected void doExecute(String location, ActionInvocation invocation) throws Exception { // TODO Auto-generated method stub this.location = location; this.execute(invocation); } }
zzfls-pj
trunk/src/net/result/JsonHTMLResult.java
Java
asf20
4,222
package net.result; import javax.servlet.ServletOutputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; public class BufferServletOutputStream extends ServletOutputStream { ByteArrayOutputStream output; public BufferServletOutputStream(ByteArrayOutputStream out) { this.output = out; } public void write(int arg0) throws IOException { this.output.write(arg0); } public void write(byte[] b) throws IOException { this.output.write(b); } public void write(byte[] b, int off, int len) throws IOException { this.output.write(b, off, len); } public void print(String s) throws IOException { super.print(s); } public void println(String s) throws IOException { super.println(s); } }
zzfls-pj
trunk/src/net/result/BufferServletOutputStream.java
Java
asf20
859
package net.result; import net.result.BufferServletOutputStream; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; import java.io.*; public class ResponseWrapper extends HttpServletResponseWrapper { ByteArrayOutputStream os = new ByteArrayOutputStream(); BufferServletOutputStream outputStream = null; PrintWriter printWriter = null; public ResponseWrapper(HttpServletResponse response) { super(response); } public ServletOutputStream getOutputStream() throws IOException { if (outputStream == null) { outputStream = new BufferServletOutputStream(os); } return outputStream; } public PrintWriter getWriter() throws IOException { if (printWriter == null) { printWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), this.getCharacterEncoding())); } return printWriter; } public void flushBuffer() throws IOException { super.flushBuffer(); if (outputStream != null) { outputStream.flush(); } if (printWriter != null) { printWriter.flush(); } } public void reset() { super.reset(); os.reset(); } public byte[] toByteArray() throws IOException { this.flushBuffer(); return os.toByteArray(); } public void writeTo(OutputStream outputStream) throws IOException { this.flushBuffer(); os.writeTo(outputStream); } protected void finalize() { try { super.finalize(); if (printWriter != null) { printWriter.close(); } if (outputStream != null) { outputStream.close(); } if (os != null) { os.close(); } } catch (Throwable e) { e.printStackTrace(); } } public String getContent() { String content = ""; try { this.flushBuffer(); content = os.toString(this.getCharacterEncoding()); } catch (Exception e) { e.printStackTrace(); } return content; } }
zzfls-pj
trunk/src/net/result/ResponseWrapper.java
Java
asf20
2,384
package net.result; import com.opensymphony.xwork2.ActionInvocation; import freemarker.template.Configuration; import freemarker.template.Template; import net.base.ToolsAction; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.ServletActionContext; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; import java.io.StringWriter; import java.util.HashMap; public class JsonFreemarkerResult extends BaseResult { private static final Log log = LogFactory.getLog(JsonFreemarkerResult.class); private String location; private String errorPage = "/commons/common/error.jsp"; protected boolean isAjax=true; public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } public String getErrorPage() { return errorPage; } public void setErrorPage(String errorPage) { this.errorPage = errorPage; } public JsonFreemarkerResult() { // TODO Auto-generated constructor stub super(); } public JsonFreemarkerResult(String location) { // TODO Auto-generated constructor stub super(location); } public void execute(ActionInvocation invocation) throws Exception { // TODO Auto-generated method stub long startTime = System.currentTimeMillis(); ServletContext sc = ServletActionContext.getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); System.out.println("charset:" + request.getCharacterEncoding()); response.setCharacterEncoding(request.getCharacterEncoding()); response.setContentType("application/json;charset="+request.getCharacterEncoding()); PrintWriter output = response.getWriter(); ToolsAction baseAction = (ToolsAction) invocation.getAction(); try { String viewName=request.getParameter("viewName")==null?this.location:request.getParameter("viewName"); Configuration cfg = new Configuration(); cfg.setServletContextForTemplateLoading(baseAction.getRequest().getSession().getServletContext(), "/"); Template t = cfg.getTemplate(viewName,"UTF-8"); StringWriter writer = new StringWriter(); t.process(baseAction.getModel(), writer); String content=writer.toString(); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.registerJsonValueProcessor(java.sql.Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); jsonConfig.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); JSONObject js=JSONObject.fromObject(baseAction.getModel(),jsonConfig); js.put("code",new Integer(baseAction.getCode())); js.put("msg", baseAction.getMsg()); js.put("expMsg", baseAction.getExpMsg()); js.put("data", content.trim()); content = js.toString(); log.info(content); output.write(content); output.flush(); } catch (Exception ex) { ex.printStackTrace(); HashMap hashMap = new HashMap(); hashMap.put("code", "-1"); hashMap.put("type", "err"); hashMap.put("msg","发生错误"); hashMap.put("mx", ex.getMessage()); JSONObject js = new JSONObject(); js.put("msg", hashMap); output.write(js.toString()); } finally { if (output != null) output.close(); } log.info("use time " + (System.currentTimeMillis() - startTime) + " ms"); } protected void doExecute(String location, ActionInvocation invocation) throws Exception { // TODO Auto-generated method stub this.location = location; this.execute(invocation); } }
zzfls-pj
trunk/src/net/result/JsonFreemarkerResult.java
Java
asf20
4,182
/* * Copyright (C) 2003, 2004, 2005 Joe Walnes. * Copyright (C) 2006, 2007, 2008, 2010, 2011 XStream Committers. * All rights reserved. * * The software in this package is published under the terms of the BSD * style license a copy of which has been included with this distribution in * the LICENSE.txt file. * * Created on 26. September 2003 by Joe Walnes */ package net.result; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.converters.UnmarshallingContext; import com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import com.thoughtworks.xstream.mapper.Mapper; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; /** * Converts a java.util.Map to XML, specifying an 'entry' element with 'key' and * 'value' children. * <p> * Note: 'key' and 'value' is not the name of the generated tag. The children * are serialized as normal elements and the implementation expects them in the * order 'key'/'value'. * </p> * <p> * Supports java.util.HashMap, java.util.Hashtable and java.util.LinkedHashMap. * </p> * * @author Joe Walnes */ public class MapConverter extends AbstractCollectionConverter { public MapConverter(Mapper mapper) { super(mapper); } public boolean canConvert(Class type) { return type.equals(HashMap.class) || type.equals(Hashtable.class) || type.getName().equals("java.util.LinkedHashMap") || type.getName().equals("sun.font.AttributeMap"); } public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { Map map = (Map) source; for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); writer.startNode((String) entry.getKey()); context.convertAnother(entry.getValue()); writer.endNode(); } } public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { Map map = (Map) createCollection(context.getRequiredType()); populateMap(reader, context, map); return map; } protected void populateMap(HierarchicalStreamReader reader, UnmarshallingContext context, Map map) { populateMap(reader, context, map, map); } protected void populateMap(HierarchicalStreamReader reader, UnmarshallingContext context, Map map, Map target) { while (reader.hasMoreChildren()) { reader.moveDown(); putCurrentEntryIntoMap(reader, context, map, target); reader.moveUp(); } } protected void putCurrentEntryIntoMap(HierarchicalStreamReader reader, UnmarshallingContext context, Map map, Map target) { reader.moveDown(); Object key = readItem(reader, context, map); reader.moveUp(); reader.moveDown(); Object value = readItem(reader, context, map); reader.moveUp(); target.put(key, value); } }
zzfls-pj
trunk/src/net/result/MapConverter.java
Java
asf20
2,984
package net.result; import net.sf.json.JsonConfig; import net.sf.json.processors.JsonValueProcessor; import java.text.SimpleDateFormat; import java.util.Date; public class DateJsonValueProcessor implements JsonValueProcessor { private String dateFormat = "yyyy-MM-dd"; public String getDateFormat() { return dateFormat; } public void setDateFormat(String dateFormat) { this.dateFormat = dateFormat; } public DateJsonValueProcessor() { } public DateJsonValueProcessor(String format) { this.dateFormat = format; } public Object processArrayValue(Object value, JsonConfig jsonConfig) { String[] obj = {}; if (value != null) { if (value instanceof Date[]) { SimpleDateFormat sf = new SimpleDateFormat(dateFormat); Date[] dates = (Date[]) value; obj = new String[dates.length]; for (int i = 0; i < dates.length; i++) { obj[i] = sf.format(dates[i]); } } } return obj; } public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) { if (value != null) { if (value instanceof Date) { String str = new SimpleDateFormat(dateFormat).format((Date) value); return str; } } return value; } }
zzfls-pj
trunk/src/net/result/DateJsonValueProcessor.java
Java
asf20
1,279
package net.base; import com.opensymphony.xwork2.Action; import java.util.List; import java.util.Map; import java.util.HashMap; import org.apache.log4j.Logger; /** * @author: jiangxiangwei * @date: 2009-12-18 */ public class BaseAction extends ToolsAction implements Action { private BaseDao dao = null; public BaseDao getDao() { return dao; } public void setDao(BaseDao dao) { this.dao = dao; } private Logger log = Logger.getLogger(this.getClass()); /** * 插入数据库操作 */ public String insert() throws Exception { try { Map map = this.parserRequest(this.getRequest()); log.info("执行sql+++++++++++++++++++" + map.get("SQLID")); Object i = dao.insert((String) map.get("SQLID"), map); this.setResult("00", "添加成功!"); } catch (Exception e) { e.printStackTrace(); log.error(e.toString()); this.setResult("99", "添加失败!\n" + e.toString()); throw new Exception(); } return null; } /** * 更新数据操作 */ public String update() throws Exception { try { Map map = this.parserRequest(this.getRequest()); log.info("执行sql+++++++++++++++++++" + map.get("SQLID")); int i = dao.update((String) map.get("SQLID"), map); if (i != 0) this.setResult("00", "更新成功!"); else this.setResult("99", "更新失败!"); } catch (Exception e) { e.printStackTrace(); log.error(e.toString()); this.setResult("99", "更新失败!\n" + e.toString()); throw new Exception(); } return null; } /** * 删除数据操作 */ public String delete() throws Exception { try { String[] id = this.getRequest().getParameter("IDS").split(","); String sqlid = this.getRequest().getParameter("SQLID"); log.info("执行sql+++++++++++++++++++" + sqlid); if (id.equals("")) { this.setResult("01", "请选择要删除的记录!"); return null; } int i = 0; for (int n = 0; n < id.length; n++) { i = dao.delete(sqlid, id[n]); } this.setResult("00", "删除成功!"); } catch (Exception e) { e.printStackTrace(); log.error(e.toString()); this.setResult("99", "删除失败!\n" + e.toString()); throw new Exception(); } return null; } /** * 查询所有数据,不带分页 */ public String selectAll() { try { Map map = this.parserRequest(this.getRequest()); log.info("执行sql+++++++++++++++++++" + map.get("SQLID")); List list = dao.getList((String) map.get("SQLID"), map); if (getResult().equals("jsonHtml") || getResult().equals("jsonResult")) { model.put("HTML_PATH", map.get("HTML_PATH")); model.put("data", list); } else if (getResult().equalsIgnoreCase("success")) { this.setResult("00", list); return null; } else { model.put("data", list); } } catch (Exception e) { e.printStackTrace(); if (getResult().equalsIgnoreCase("success")) { this.setResult("99", e.toString()); } else { code = -1; msg = e.getMessage(); expMsg = getExceptionMessage(e); } log.error(e.toString()); } return getResult(); } /** * 查询数据库操作 带分页 */ public String select() { try { Map map = this.parserRequest(this.getRequest()); log.info("执行sql+++++++++++++++++++" + map.get("SQLID")); int totalCount = 0; if (map.containsKey("TOTALCOUNT")) { totalCount = Integer.parseInt(String.valueOf(map .get("TOTALCOUNT"))); } if (totalCount <= 0) { totalCount = dao.getListCount(map.get("SQLID") + "_Count", map); } int curpage = 0; if (map.containsKey("CURPAGE")) curpage = Integer.parseInt(String.valueOf(map.get("CURPAGE"))); int pagesize = Integer .parseInt(String.valueOf(map.get("PAGESIZE"))); int start = (curpage) * pagesize; int totalPage = totalCount % pagesize == 0 ? totalCount / pagesize : totalCount / pagesize + 1; map.put("START", start); map.put("END", map.get("PAGESIZE")); List list = dao.getList((String) map.get("SQLID"), map); Map pMap = new HashMap(); pMap.put("TOTALCOUNT", totalCount); pMap.put("CURPAGE", curpage); pMap.put("TOTALPAGE", totalPage); pMap.put("PAGESIZE", pagesize); PageList pList = new PageList(); pList.setDataList(list); pList.setPageMap(pMap); if (getResult().equals("jsonHtml") || getResult().equals("jsonResult")) { model.put("HTML_PATH", map.get("HTML_PATH")); model.put("data", list); model.put("pages", pMap); } else if (getResult().equalsIgnoreCase("success")) { this.setResult("00", pList); return null; } else { model.put("data", list); model.put("pages", pMap); } } catch (Exception e) { e.printStackTrace(); log.error(e.toString()); if (getResult().equalsIgnoreCase("success")) { this.setResult("99", e.toString()); } else { code = -1; msg = e.getMessage(); expMsg = getExceptionMessage(e); } } return getResult(); } /** * 取单条数据操作 */ public String selectByID() { try { Map map = this.parserRequest(this.getRequest()); log.info("执行sql+++++++++++++++++++" + map.get("SQLID")); Map rtnmap = dao.getMap((String) map.get("SQLID"), map); this.setResult("00", rtnmap); } catch (Exception e) { e.printStackTrace(); log.error(e.toString()); this.setResult("99", e.toString()); } return null; } }
zzfls-pj
trunk/src/net/base/BaseAction.java
Java
asf20
6,937
package net.base; import javax.servlet.http.HttpServletRequest; import java.util.*; /** * @author: jiangxiangwei * @date: 2009-12-18 */ public class Tools { /** * 将map转为json串 * * @param map * @return */ public static String toJsonByMap(Map map) { if (map == null || map.size() == 0) return "\"\","; StringBuffer sb = new StringBuffer("{"); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Object key = entry.getKey(); Object value = entry.getValue(); sb.append("\"").append(key).append("\":").append("\"").append( nullToString(value)).append("\","); } int len = sb.length(); sb.delete(len - 1, len); sb.append("},"); return sb.toString(); } /** * 将map转为json串,list转json时使用 * * @param map * @return */ public static String toJsonByMap2(Map map) { if (map == null || map.size() == 0) return "{},"; StringBuffer sb = new StringBuffer("{"); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Object key = entry.getKey(); Object value = entry.getValue(); sb.append("\"").append(key).append("\":").append("\"").append( nullToString(value)).append("\","); } int len = sb.length(); sb.delete(len - 1, len); sb.append("},"); return sb.toString(); } /** * 将list转为json串 * * @param list * @return */ public static String toJsonByList(List list) { if (list == null || list.size() == 0) return "[],"; StringBuffer sb = new StringBuffer("["); Iterator it = list.iterator(); while (it.hasNext()) { Map map = (Map) it.next(); sb.append(toJsonByMap2(map)); } int len = sb.length(); sb.delete(len - 1, len); sb.append("],"); return sb.toString(); } public static Object nullToString(Object str) { if (str == null || "null".equals(str)) return ""; else return string2Json(String.valueOf(str)); } /** * 将 String 对象编码为 JSON 格式时,只需处理好特殊字符即可。另外,必须用 (") 而非 (') 表示字符串 * * @param s * 需要转化的字符串 * @return 返回转化好的字符串 */ public static String string2Json(String s) { StringBuffer sb = new StringBuffer(s.length() + 20); // sb.append('\"'); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); switch (c) { case '\"': sb.append("\\\""); break; case '\\': sb.append("\\\\"); break; case '/': sb.append("\\/"); break; case '\b': sb.append("\\b"); break; case '\f': sb.append("\\f"); break; case '\n': sb.append("\\n"); break; case '\r': sb.append("\\r"); break; case '\t': sb.append("\\t"); break; default: sb.append(c); } } // sb.append('\"'); return sb.toString(); } public static Map parserRequest(HttpServletRequest request) { Map map = new HashMap(); Enumeration enume = request.getParameterNames(); while (enume.hasMoreElements()) { String pName = (String) enume.nextElement(); String value = request.getParameter(pName); if (value != null && !value.equals("")) map.put(pName, convert(request.getParameter(pName))); value = null; } return map; } public static Map parserString(String str) { Map map = new HashMap(); String[] str1 = str.split("&"); for (int i = 0; i < str1.length; i++) { String[] str2 = str1[i].split("="); //System.out.println("数组长度" + str2.length); if (str2.length == 1) { map.put(str2[0], ""); } else { map.put(str2[0], str2[1]); } } return map; } /* 字符串编码转换为UTF-8 * * @param str 被处理的字符串 * @return String 将数据库中读出的数据进行转换 */ public static String convert(String str) { String str1 = ""; if (str != null) { try { str1 = new String(str.getBytes("ISO8859_1"), "UTF-8"); } catch (Exception e) { str1 = ""; } } return str1; } /** * 字符串编码反转换为ISO8859_1 * * @param str 被处理的字符串 * @return String 将jsp提交的数据进行转换放入数据库中 */ public static String reconvert(String str) { String str1 = null; if (str != null) { try { str1 = new String(str.getBytes("UTF-8"), "ISO8859_1"); } catch (Exception e) { return str1; } } return str1; } }
zzfls-pj
trunk/src/net/base/Tools.java
Java
asf20
5,018
package net.base; import java.util.List; import java.util.Map; /** * Created by IntelliJ IDEA. * User: jiangxiangwei * Date: 2010-2-2 * Time: 11:20:58 */ public class PageList { private List dataList = null;//数据 private Map pageMap = null; //分页 public Map getPageMap() { return pageMap; } public void setPageMap(Map pageMap) { this.pageMap = pageMap; } public List getDataList() { return dataList; } public void setDataList(List dataList) { this.dataList = dataList; } }
zzfls-pj
trunk/src/net/base/PageList.java
Java
asf20
593
package net.base; /** * 功能: * * @version 1.0 */ public final class MD5 { /* 下面这些S11-S44实际上是一个4*4的矩阵,在原始的C实现中是用#define 实现的, 这里把它们实现成为static final是表示了只读,切能在同一个进程空间内的多个 Instance间共享*/ static final int S11 = 7; static final int S12 = 12; static final int S13 = 17; static final int S14 = 22; static final int S21 = 5; static final int S22 = 9; static final int S23 = 14; static final int S24 = 20; static final int S31 = 4; static final int S32 = 11; static final int S33 = 16; static final int S34 = 23; static final int S41 = 6; static final int S42 = 10; static final int S43 = 15; static final int S44 = 21; static final byte[] PADDING = {-128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; /* 下面的三个成员是MD5计算过程中用到的3个核心数据,在原始的C实现中 * 被定义到MD5_CTX结构中 * */ private long[] state = new long[4]; // state (ABCD) private long[] count = new long[2]; // number of bits, modulo 2^64 (lsb first) private byte[] buffer = new byte[64]; // input buffer /* digestHexStr是MD5的唯一一个公共成员,是最新一次计算结果的   16进制ASCII表示. */ public String digestHexStr; /* digest,是最新一次计算结果的2进制内部表示,表示128bit的MD5值. */ private byte[] digest = new byte[16]; /* getMD5ofStr是类MD5最主要的公共方法,入口参数是你想要进行MD5变换的字符串 返回的是变换完的结果,这个结果是从公共成员digestHexStr取得的. */ public String getMD5ofStr(String inbuf) { md5Init(); md5Update(inbuf.getBytes(), inbuf.length()); md5Final(); digestHexStr = ""; for (int i = 0; i < 16; i++) { digestHexStr += byteHEX(digest[i]); } return digestHexStr; } // 这是MD5这个类的标准构造函数,JavaBean要求有一个public的并且没有参数的构造函数 public MD5() { md5Init(); return; } /* md5Init是一个初始化函数,初始化核心变量,装入标准的幻数 */ private void md5Init() { count[0] = 0L; count[1] = 0L; ///* Load magic initialization constants. state[0] = 0x67452301L; state[1] = 0xefcdab89L; state[2] = 0x98badcfeL; state[3] = 0x10325476L; return; } /* F, G, H ,I 是4个基本的MD5函数,在原始的MD5的C实现中,由于它们是 * 简单的位运算,可能出于效率的考虑把它们实现成了宏,在java中,我们把它们  * 实现成了private方法,名字保持了原来C中的。 */ private long F(long x, long y, long z) { return (x & y) | ((~x) & z); } private long G(long x, long y, long z) { return (x & z) | (y & (~z)); } private long H(long x, long y, long z) { return x ^ y ^ z; } private long I(long x, long y, long z) { return y ^ (x | (~z)); } /* FF,GG,HH和II将调用F,G,H,I进行近一步变换 FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. Rotation is separate from addition to prevent recomputation. */ private long FF(long a, long b, long c, long d, long x, long s, long ac) { a += F(b, c, d) + x + ac; a = ((int) a << s) | ((int) a >>> (32 - s)); a += b; return a; } private long GG(long a, long b, long c, long d, long x, long s, long ac) { a += G(b, c, d) + x + ac; a = ((int) a << s) | ((int) a >>> (32 - s)); a += b; return a; } private long HH(long a, long b, long c, long d, long x, long s, long ac) { a += H(b, c, d) + x + ac; a = ((int) a << s) | ((int) a >>> (32 - s)); a += b; return a; } private long II(long a, long b, long c, long d, long x, long s, long ac) { a += I(b, c, d) + x + ac; a = ((int) a << s) | ((int) a >>> (32 - s)); a += b; return a; } /* md5Update是MD5的主计算过程,inbuf是要变换的字节串,inputlen是长度,这个 函数由getMD5ofStr调用,调用之前需要调用md5init,因此把它设计成private的 */ private void md5Update(byte[] inbuf, int inputLen) { int i, index, partLen; byte[] block = new byte[64]; index = (int) (count[0] >>> 3) & 0x3F; // /* Update number of bits */ if ((count[0] += (inputLen << 3)) < (inputLen << 3)) count[1]++; count[1] += (inputLen >>> 29); partLen = 64 - index; // Transform as many times as possible. if (inputLen >= partLen) { md5Memcpy(buffer, inbuf, index, 0, partLen); md5Transform(buffer); for (i = partLen; i + 63 < inputLen; i += 64) { md5Memcpy(block, inbuf, 0, i, 64); md5Transform(block); } index = 0; } else { i = 0; } ///* Buffer remaining input */ md5Memcpy(buffer, inbuf, index, i, inputLen - i); } /* md5Final整理和填写输出结果 */ private void md5Final() { byte[] bits = new byte[8]; int index, padLen; ///* Save number of bits */ Encode(bits, count, 8); ///* Pad out to 56 mod 64. index = (int) (count[0] >>> 3) & 0x3f; padLen = (index < 56) ? (56 - index) : (120 - index); md5Update(PADDING, padLen); ///* Append length (before padding) */ md5Update(bits, 8); ///* Store state in digest */ Encode(digest, state, 16); } /* md5Memcpy是一个内部使用的byte数组的块拷贝函数,从input的inpos开始把len长度的       字节拷贝到output的outpos位置开始 */ private void md5Memcpy(byte[] output, byte[] input, int outpos, int inpos, int len) { int i; for (i = 0; i < len; i++) output[outpos + i] = input[inpos + i]; } /* md5Transform是MD5核心变换程序,有md5Update调用,block是分块的原始字节 */ private void md5Transform(byte block[]) { long a = state[0], b = state[1], c = state[2], d = state[3]; long[] x = new long[16]; Decode(x, block, 64); /* Round 1 */ a = FF(a, b, c, d, x[0], S11, 0xd76aa478L); /* 1 */ d = FF(d, a, b, c, x[1], S12, 0xe8c7b756L); /* 2 */ c = FF(c, d, a, b, x[2], S13, 0x242070dbL); /* 3 */ b = FF(b, c, d, a, x[3], S14, 0xc1bdceeeL); /* 4 */ a = FF(a, b, c, d, x[4], S11, 0xf57c0fafL); /* 5 */ d = FF(d, a, b, c, x[5], S12, 0x4787c62aL); /* 6 */ c = FF(c, d, a, b, x[6], S13, 0xa8304613L); /* 7 */ b = FF(b, c, d, a, x[7], S14, 0xfd469501L); /* 8 */ a = FF(a, b, c, d, x[8], S11, 0x698098d8L); /* 9 */ d = FF(d, a, b, c, x[9], S12, 0x8b44f7afL); /* 10 */ c = FF(c, d, a, b, x[10], S13, 0xffff5bb1L); /* 11 */ b = FF(b, c, d, a, x[11], S14, 0x895cd7beL); /* 12 */ a = FF(a, b, c, d, x[12], S11, 0x6b901122L); /* 13 */ d = FF(d, a, b, c, x[13], S12, 0xfd987193L); /* 14 */ c = FF(c, d, a, b, x[14], S13, 0xa679438eL); /* 15 */ b = FF(b, c, d, a, x[15], S14, 0x49b40821L); /* 16 */ /* Round 2 */ a = GG(a, b, c, d, x[1], S21, 0xf61e2562L); /* 17 */ d = GG(d, a, b, c, x[6], S22, 0xc040b340L); /* 18 */ c = GG(c, d, a, b, x[11], S23, 0x265e5a51L); /* 19 */ b = GG(b, c, d, a, x[0], S24, 0xe9b6c7aaL); /* 20 */ a = GG(a, b, c, d, x[5], S21, 0xd62f105dL); /* 21 */ d = GG(d, a, b, c, x[10], S22, 0x2441453L); /* 22 */ c = GG(c, d, a, b, x[15], S23, 0xd8a1e681L); /* 23 */ b = GG(b, c, d, a, x[4], S24, 0xe7d3fbc8L); /* 24 */ a = GG(a, b, c, d, x[9], S21, 0x21e1cde6L); /* 25 */ d = GG(d, a, b, c, x[14], S22, 0xc33707d6L); /* 26 */ c = GG(c, d, a, b, x[3], S23, 0xf4d50d87L); /* 27 */ b = GG(b, c, d, a, x[8], S24, 0x455a14edL); /* 28 */ a = GG(a, b, c, d, x[13], S21, 0xa9e3e905L); /* 29 */ d = GG(d, a, b, c, x[2], S22, 0xfcefa3f8L); /* 30 */ c = GG(c, d, a, b, x[7], S23, 0x676f02d9L); /* 31 */ b = GG(b, c, d, a, x[12], S24, 0x8d2a4c8aL); /* 32 */ /* Round 3 */ a = HH(a, b, c, d, x[5], S31, 0xfffa3942L); /* 33 */ d = HH(d, a, b, c, x[8], S32, 0x8771f681L); /* 34 */ c = HH(c, d, a, b, x[11], S33, 0x6d9d6122L); /* 35 */ b = HH(b, c, d, a, x[14], S34, 0xfde5380cL); /* 36 */ a = HH(a, b, c, d, x[1], S31, 0xa4beea44L); /* 37 */ d = HH(d, a, b, c, x[4], S32, 0x4bdecfa9L); /* 38 */ c = HH(c, d, a, b, x[7], S33, 0xf6bb4b60L); /* 39 */ b = HH(b, c, d, a, x[10], S34, 0xbebfbc70L); /* 40 */ a = HH(a, b, c, d, x[13], S31, 0x289b7ec6L); /* 41 */ d = HH(d, a, b, c, x[0], S32, 0xeaa127faL); /* 42 */ c = HH(c, d, a, b, x[3], S33, 0xd4ef3085L); /* 43 */ b = HH(b, c, d, a, x[6], S34, 0x4881d05L); /* 44 */ a = HH(a, b, c, d, x[9], S31, 0xd9d4d039L); /* 45 */ d = HH(d, a, b, c, x[12], S32, 0xe6db99e5L); /* 46 */ c = HH(c, d, a, b, x[15], S33, 0x1fa27cf8L); /* 47 */ b = HH(b, c, d, a, x[2], S34, 0xc4ac5665L); /* 48 */ /* Round 4 */ a = II(a, b, c, d, x[0], S41, 0xf4292244L); /* 49 */ d = II(d, a, b, c, x[7], S42, 0x432aff97L); /* 50 */ c = II(c, d, a, b, x[14], S43, 0xab9423a7L); /* 51 */ b = II(b, c, d, a, x[5], S44, 0xfc93a039L); /* 52 */ a = II(a, b, c, d, x[12], S41, 0x655b59c3L); /* 53 */ d = II(d, a, b, c, x[3], S42, 0x8f0ccc92L); /* 54 */ c = II(c, d, a, b, x[10], S43, 0xffeff47dL); /* 55 */ b = II(b, c, d, a, x[1], S44, 0x85845dd1L); /* 56 */ a = II(a, b, c, d, x[8], S41, 0x6fa87e4fL); /* 57 */ d = II(d, a, b, c, x[15], S42, 0xfe2ce6e0L); /* 58 */ c = II(c, d, a, b, x[6], S43, 0xa3014314L); /* 59 */ b = II(b, c, d, a, x[13], S44, 0x4e0811a1L); /* 60 */ a = II(a, b, c, d, x[4], S41, 0xf7537e82L); /* 61 */ d = II(d, a, b, c, x[11], S42, 0xbd3af235L); /* 62 */ c = II(c, d, a, b, x[2], S43, 0x2ad7d2bbL); /* 63 */ b = II(b, c, d, a, x[9], S44, 0xeb86d391L); /* 64 */ state[0] += a; state[1] += b; state[2] += c; state[3] += d; } /*Encode把long数组按顺序拆成byte数组,因为java的long类型是64bit的, 只拆低32bit,以适应原始C实现的用途 */ private void Encode(byte[] output, long[] input, int len) { int i, j; for (i = 0, j = 0; j < len; i++, j += 4) { output[j] = (byte) (input[i] & 0xffL); output[j + 1] = (byte) ((input[i] >>> 8) & 0xffL); output[j + 2] = (byte) ((input[i] >>> 16) & 0xffL); output[j + 3] = (byte) ((input[i] >>> 24) & 0xffL); } } /*Decode把byte数组按顺序合成成long数组,因为java的long类型是64bit的, 只合成低32bit,高32bit清零,以适应原始C实现的用途 */ private void Decode(long[] output, byte[] input, int len) { int i, j; for (i = 0, j = 0; j < len; i++, j += 4) output[i] = b2iu(input[j]) | (b2iu(input[j + 1]) << 8) | (b2iu(input[j + 2]) << 16) | (b2iu(input[j + 3]) << 24); return; } /* b2iu是我写的一个把byte按照不考虑正负号的原则的"升位"程序,因为java没有unsigned运算 */ public static long b2iu(byte b) { return b < 0 ? b & 0x7F + 128 : b; } /*byteHEX(),用来把一个byte类型的数转换成十六进制的ASCII表示,  因为java中的byte的toString无法实现这一点,我们又没有C语言中的 sprintf(outbuf,"%02X",ib) */ public static String byteHEX(byte ib) { char[] Digit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; char[] ob = new char[2]; ob[0] = Digit[(ib >>> 4) & 0X0F]; ob[1] = Digit[ib & 0X0F]; String s = new String(ob); return s; } public static void main(String args[]) { MD5 m = new MD5(); //if (Array.getLength(args) == 0) { //如果没有参数,执行标准的Test Suite //System.out.println("MD5(\"\"):" + m.getMD5ofStr("sys")); //System.out.println("MD5(\"1\"):" + m.getMD5ofStr("1")); //System.out.println("MD5(\"a\"):" + m.getMD5ofStr("a")); //System.out.println("MD5(\"abc\"):" + m.getMD5ofStr("abc")); //System.out.println("MD5(\"message digest\"):" + m.getMD5ofStr("message digest")); //System.out.println("MD5(\"abcdefghijklmnopqrstuvwxyz\"):" + // m.getMD5ofStr("abcdefghijklmnopqrstuvwxyz")); //System.out.println("MD5(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\"):" + // m.getMD5ofStr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")); // } else //System.out.println("MD5(" + args[0] + ")=" + m.getMD5ofStr(args[0])); } }
zzfls-pj
trunk/src/net/base/MD5.java
Java
asf20
14,175
package net.base; public class BaseException extends Exception { public BaseException() { super(); } public BaseException(String string) { super(string); } public BaseException(String string, Throwable throwable) { super(string, throwable); } public BaseException(Throwable throwable) { super(throwable); } }
zzfls-pj
trunk/src/net/base/BaseException.java
Java
asf20
393
package net.base; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sf.json.JSONNull; import net.sf.json.JSONObject; import net.sf.json.JSONString; import net.sf.json.JsonConfig; import net.sf.json.processors.DefaultValueProcessor; import net.sf.json.processors.JsonValueProcessor; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; /** * @author: jiangxiangwei * @date: Dec 18, 2008 */ public class ToolsAction extends ActionSupport { /** * */ private static final long serialVersionUID = 1L; Map model = null; private Logger log = Logger.getLogger(this.getClass()); protected int code = 0; protected String msg = "操作成功!"; protected String expMsg = ""; public ToolsAction() { model = new HashMap(); } public Map getModel() { return model; } public void setModel(Map model) { this.model = model; } public int getCode() { return code; } public void setCode(int code) { this.code = code; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public String getExpMsg() { return expMsg; } public void setExpMsg(String expMsg) { this.expMsg = expMsg; } public Object findValue(String name) { return ActionContext.getContext().getValueStack().findValue(name); } public void setValue(String name, Object value) throws Exception { ActionContext.getContext().getValueStack().setValue(name, value); } /** * 将字符串向前台输出json结果 * * @param code * @param str */ public void setResult(String code, String str) { HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("text/html;charset=UTF-8"); try { PrintWriter out = response.getWriter(); out.println(strToJson(code, Tools.string2Json(str))); out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } /** * 将list转为json输出前台 * * @param code * @param list */ public void setResult(String code, List list) { HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("text/html;charset=UTF-8"); try { PrintWriter out = response.getWriter(); out.println(listToJson(code, list)); out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } /** * 将list转为json输出前台 带分页信息 * * @param code * @param list */ public void setResult(String code, PageList list) { HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("text/html;charset=UTF-8"); try { PrintWriter out = response.getWriter(); out.println(pageListToJson(code, list)); out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } /** * 将map转为json输出前台 * * @param code * @param map */ public void setResult(String code, Map map) { HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("text/html;charset=UTF-8"); try { PrintWriter out = response.getWriter(); out.println(mapToJson(code, map)); out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } /** * 字符串转为json * * @param code * @param str * @return */ public String strToJson(String code, String str) { StringBuffer sb = new StringBuffer(); sb.append("{"); sb.append("code:\"").append(code).append("\","); sb.append("data:[\"").append(str).append("\"]"); sb.append("}"); log.debug(sb); return sb.toString(); } /** * map转为json * * @param code * @param map * @return */ public String mapToJson(String code, Map map) { StringBuffer sb = new StringBuffer(); sb.append("{"); sb.append("code:\"").append(code).append("\","); sb.append("data:").append(Tools.toJsonByMap(map)); sb.append("}"); sb.replace(sb.length() - 2, sb.length() - 1, ""); log.debug(sb); return sb.toString(); } /** * list转为json * * @param code * @param list * @return */ public String listToJson(String code, List list) { StringBuffer sb = new StringBuffer(); sb.append("{"); sb.append("code:\"").append(code).append("\","); sb.append("data:").append(Tools.toJsonByList(list)) .append("}"); sb.replace(sb.length() - 2, sb.length() - 1, ""); log.debug(sb); return sb.toString(); } /** * list 转为json 带分页信息 * * @param code * @param pList * @return */ public String pageListToJson(String code, PageList pList) { // Map map = pList.getPageMap(); // StringBuffer page = new StringBuffer(); // page.append("pages:{") // .append("TOTALCOUNT:\"").append(map.get("TOTALCOUNT")).append("\",") // .append("CURPAGE:\"").append(map.get("CURPAGE")).append("\",") // .append("TOTALPAGE:\"").append(map.get("TOTALPAGE")).append("\",") // .append("PAGESIZE:\"").append(map.get("PAGESIZE")).append("\"") // .append("}"); // // StringBuffer sb = new StringBuffer(); // List list = pList.getDataList(); // sb.append("{"); // sb.append("code:\"").append(code).append("\","); // sb.append("data:").append(tools.toJsonByList(list)) // .append(","); // sb.replace(sb.length() - 2, sb.length() - 1, ""); // sb.append(page).append("}"); // log.debug(sb); List list = pList.getDataList(); Map map = pList.getPageMap(); Map jsonMap = new HashMap(); jsonMap.put("code",code); jsonMap.put("data", list); jsonMap.put("pages", map); JSONObject js = JSONObject.fromObject(jsonMap); return js.toString(); } /** * 从rquest中截取参数,放入map中 * * @param request * @return */ public Map parserRequest(HttpServletRequest request) { Map map = new HashMap(); Enumeration enume = request.getParameterNames(); while (enume.hasMoreElements()) { String pName = (String) enume.nextElement(); String value =request.getParameter(pName); if (value != null && !value.equals("")) map.put(pName, value); value = null; } return map; } public HttpServletResponse getResponse() { return (HttpServletResponse) ActionContext.getContext().get( "com.opensymphony.xwork2.dispatcher.HttpServletResponse"); } public HttpServletRequest getRequest() { return (HttpServletRequest) ActionContext.getContext().get( "com.opensymphony.xwork2.dispatcher.HttpServletRequest"); } public Map getSession() { return ActionContext.getContext().getSession(); } public String getParamter(String paramName) { List list = new ArrayList(); try { list = Arrays.asList((String[]) getRequest().getParameterMap().get(paramName)); } catch (NullPointerException e) { // log.error("读取参数->" + paramName + "=" + e.getMessage()); } String val = ""; for (int i = 0; i < list.size(); i++) val += (String) list.get(i) + ','; return val.length() > 0 ? (val.substring(0, val.length() - 1)) : val; } public String getResult() { //保存数据 // JsonHelp.getRequest().setAttribute("data",resultMapData); String result = getParamter("RESULT_TYPE"); return result.length() == 0 ? SUCCESS : result; } public String getExceptionMessage(Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); return sw.toString().replaceAll("\r\n","<br>"); } }
zzfls-pj
trunk/src/net/base/ToolsAction.java
Java
asf20
9,178
package net.base; import java.util.List; import java.util.Map; import org.apache.log4j.Logger; import com.ibatis.sqlmap.client.SqlMapClient; /** * @author: jiangxiangwei * @date: 2009-12-15 */ public class BaseDaoImpl implements BaseDao { public Logger log = Logger.getLogger(this.getClass()); public SqlMapClient sqlMapClient; public SqlMapClient getSqlMapClient() { return sqlMapClient; } public void setSqlMapClient(SqlMapClient sqlMapClient) { this.sqlMapClient = sqlMapClient; } /** * 数据库插入操作 单条插入 * * @param sqlid * @param map * @return * @throws Exception */ public Object insert(String sqlid, Map map) throws Exception { return sqlMapClient.insert(sqlid, map); } /** * 数据库删除操作 批量删除 * * @param sqlid * @param ids * @return * @throws Exception */ public int delete(String sqlid, String id) throws Exception { return sqlMapClient.delete(sqlid, id); } /** * 数据库更新操作 单条更新 * * @param sqlid * @param map * @return * @throws Exception */ public int update(String sqlid, Map map) throws Exception { return sqlMapClient.update(sqlid, map); } /** * 取列表 返回list * * @param sqlid * @param map * @return * @throws Exception */ public List getList(String sqlid, Map map) throws Exception { return sqlMapClient.queryForList(sqlid, map); } /** * 取记录总数 * * @param sqlid * @param map * @return * @throws Exception */ public int getListCount(String sqlid, Map map) throws Exception { Integer rtn = new Integer(0); rtn = (Integer) sqlMapClient.queryForObject(sqlid, map); return rtn; } /** * 取单条数据 返回map * * @param sqlid * @param map * @return * @throws Exception */ public Map getMap(String sqlid, Map map) throws Exception { return (Map) sqlMapClient.queryForObject(sqlid, map); } }
zzfls-pj
trunk/src/net/base/BaseDaoImpl.java
Java
asf20
2,019
package net.base; import java.util.List; import java.util.Map; /** * @author: jiangxiangwei * @date: 2009-12-15 */ public interface BaseDao { /** * 数据库插入操作 单条插入 * * @param sqlid * @param map * @return * @throws Exception */ public Object insert(String sqlid, Map map) throws Exception; /** * 数据库更新操作 单条更新 * * @param sqlid * @param map * @return * @throws Exception */ public int update(String sqlid, Map map) throws Exception; /** * 数据库删除操作 批量删除 * * @param sqlid * @param id * @return * @throws Exception */ public int delete(String sqlid, String id) throws Exception; /** * 取列表 返回list * * @param sqlid * @param map * @return * @throws Exception */ public List getList(String sqlid, Map map) throws Exception; /** * 取记录总数 * * @param sqlid * @param map * @return * @throws Exception */ public int getListCount(String sqlid, Map map) throws Exception; /** * 取单条数据 返回map * * @param sqlid * @param map * @return * @throws Exception */ public Map getMap(String sqlid, Map map) throws Exception; }
zzfls-pj
trunk/src/net/base/BaseDao.java
Java
asf20
1,276
<%-- Created by IntelliJ IDEA. User: jxw Date: 12-3-4 Time: 下午7:10 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <% //response.sendRedirect("websites/service/wdszzbm/index.jsp"); %> <html> <head> <title></title> </head> <body> </body> </html>
zzfls-pj
trunk/WebRoot/index.jsp
Java Server Pages
asf20
370
var zTreeObj; function initPage() { getModuleOperationByUserDMAndModuleDM(parent.parent.session.USER_DM, myTools.getQueryString("MODULE_DM"), '1', "securityDIV"); //取模块权限按钮 getItemTree(); } function getItemTree() { var json = { url:contextPath + "/server/site/getSiteItemTree.do", msg:"数据加载中.....", params:{ }, callback:[getItemTreeCallBack] }; AjaxTools.ajax(json); } function getItemTreeCallBack(result) { var setting = { data:{ simpleData:{ enable:true, idKey:"id", pIdKey:"pId", rootPId:0 } }, callback:{ onClick:function (event, treeId, treeNode, clickFlag) { document.getElementById("PID").value = treeNode.id; searchSiteItem(); } } }; var zTreeNodes = result.msg; zTreeObj = $.fn.zTree.init($("#tree"), setting, zTreeNodes); } function searchSiteItem() { var json = { url:contextPath + "/server/base/select.do", msg:"数据加载中.....", form:"searchForm", params:{ "SQLID":"site.site_item.getSITE_ITEM", "HTML_PATH":"/service/site/site_item/viewList.jsp", "RESULT_TYPE":"jsonHtml" }, callback:[searchSiteItemCallBack] }; AjaxTools.ajax(json); } /** * 翻页 * @param page * @return */ function queryPage(page) { var json = { url:contextPath + "/server/base/select.do", msg:"数据加载中.....", form:"searchForm", params:{ "SQLID":"site.site_item.getSITE_ITEM", "CURPAGE":page, "HTML_PATH":"/service/site/site_item/viewList.jsp", "RESULT_TYPE":"jsonHtml" }, callback:[searchSiteItemCallBack] }; AjaxTools.ajax(json); } function searchSiteItemCallBack(result) { if (result.code == "00") { document.getElementById("editAreaDiv").innerHTML = result.data; } else { alert(result.data); } } /** *显示添加栏目窗口 */ function addItem() { win.open('addItem', '添加新闻栏目', '../../../service/site/site_item/addItem.jsp?pid=' + document.getElementById("PID").value, 350, 250, true, true); } /** *显示修改栏目窗口 */ function editItem() { //var id = myTable.getSelectedID(); var row = window.row; var id = row.getAttribute("id"); if (id) win.open('editUser', '修改新闻栏目', '../../../service/site/site_item/editItem.jsp?ID=' + id, 350, 250, true, true); } /** * 删除栏目 */ function delItem() { var ids = myTable.getSelectedIDS(); var row = window.row; var id = row.getAttribute("id"); ids = ids.length==0?id:ids; if (ids) { if (confirm("是否确认删除?")) { var json = { url:contextPath + "/server/base/delete.do", msg:"数据删除中.....", params:{ "IDS":ids, "SQLID":"site.site_item.delSITE_ITEM" }, callback:[delItemCallBack] }; AjaxTools.ajax(json); } } } function delItemCallBack(json) { var code = json.code; if (code == "00") { alert(json.data); searchSiteItem(); } else { alert(json.data); } } function updateStatus(flg) { var row = window.row; var id = row.getAttribute("id"); if (id) { var json = { url:contextPath + "/server/base/update.do", msg:"数据保存中.....", params:{ "SQLID":"site.site_item.updateSITE_ITEMDynamic", "ID":id, "STATUS":flg }, callback:[updateStatusCallBack] }; AjaxTools.ajax(json); } } function updateStatusCallBack(json) { var code = json.code; if (code == "00") { alert("状态更新成功!"); searchSiteItem(); } else { alert(json.data); } }
zzfls-pj
trunk/WebRoot/service/site/site_item/index.js
JavaScript
asf20
4,270
/** *初始化editModule页面 取要修改的模块数据 */ function initPage() { win.crebtn('editWindow_btnCancel', '关闭', win.close); win.crebtn('editWindow_btnSave', '保存', editItem); var json = { url:contextPath + "/server/base/selectByID.do", msg:"数据加载中.....", params:{ "ID": myTools.getQueryString("ID"), "SQLID":"site.site_item.getSITE_ITEM" }, callback:[getItemCallBack] }; AjaxTools.ajax(json); Validator.validate(document.getElementById(("editForm")), 3); } function getItemCallBack(json) { myTools.bindForm("editForm", json.data); } /** *修改模块 */ function editItem() { if (!Validator.validate(document.getElementById(("editForm")), 4)) return false; var json = { url:contextPath + "/server/base/update.do", msg:"数据保存中.....", form:"editForm", params:{ "SQLID":"site.site_item.updateSITE_ITEM" }, callback:[editItemCallBack] }; AjaxTools.ajax(json); } function editItemCallBack(json) { var code = json.code; if (code == "00") { alert(json.data); window.parent.parent.searchSiteItem(); win.close('editWindow'); } else { alert(json.data); } }
zzfls-pj
trunk/WebRoot/service/site/site_item/editItem.js
JavaScript
asf20
1,361
<%@ page language="java" pageEncoding="UTF-8"%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../../include/jsp/include.jsp"/> <html> <html> <head> <title></title> <script type="text/javascript" src="../../../include/js/window/lhgdialog.js"></script> <link type="text/css" rel="stylesheet" href="../../../include/js/zTree/css/zTreeStyle/zTreeStyle.css"/> <script type="text/javascript" src="../../../include/js/zTree/js/jquery.ztree.all-3.2.min.js"></script> <script type="text/javascript" src="index.js"></script> </head> <body onload="initPage();"> <table style="width:100%;height:99%;" cellpadding="0" cellspacing="0"> <tr> <td style="width:230px;" valign="top"> <table style="width:99%;height:99%;border: 1px solid #1baae6;margin: 2px 2px 2px 2px;" cellpadding="0" cellspacing="0"> <tr> <td valign="top" style="height: 20px;text-align: center;background: url(../../../include/images/img/bottom_bg.gif);font-weight: bold;">栏目树</td> </tr> <tr> <td valign="top" style="height: 100%;"> <ul id="tree" class="ztree" style="width:230px; overflow:auto;"></ul> </td> </tr> </table> </td> <td valign="top"> <table style="width:99%;height:99%;border: 1px solid #1baae6;margin: 2px 2px 2px 2px;" cellpadding="0" cellspacing="0"> <tr> <td valign="top" style="height: 20px;text-align: left;background: url(../../../include/images/img/bottom_bg.gif);font-weight: bold;padding-left: 15px;">栏目管理</td> </tr> <tr> <td valign="top" style="height: 100%;"> <!-- 右侧内容 --> <div style="padding-top:10px;"> <form id="searchForm" name="searchForm"> <input type="hidden" name="PAGESIZE" value="10"> <input type="hidden" id="PID" name="PID" value="0"> <table class="table_search"> <tr> <td align="right">栏目名称:</td> <td><input type="text" name="NAME" id="NAME" class="input"></td> <td align="right">有效标志:</td> <td> <select name="STATUS"> <option value="">全部</option> <option value="1">启用</option> <option value="0">禁用</option> </select> </td> </tr> </table> </form> </div> <div class="security" id="securityDIV"> </div> <div id="editAreaDiv" class="editAreaDiv"></div> </td> </tr> </table> </td> </tr> </table> </body> </html>
zzfls-pj
trunk/WebRoot/service/site/site_item/index.jsp
Java Server Pages
asf20
3,034
/** * 初始化页面 */ function initPage() { win.crebtn('addWindow_btnCancel', '关闭', win.close); win.crebtn('addWindow_btnSave', '保存', addItem); //document.getElementById("MODULE_NAME").focus(); Validator.validate(document.getElementById(("addItemForm")), 3); } /** *添加栏目 */ function addItem() { if (!Validator.validate(document.getElementById(("addItemForm")), 4)) return false; var json = { url:contextPath + "/server/base/insert.do", msg:"数据保存中.....", form:"addItemForm", params:{ "SQLID":"site.site_item.insertSITE_ITEM" }, callback:[addItemCallBack] }; AjaxTools.ajax(json); } function addItemCallBack(data) { var code = data.code; if (code == "00") { alert(data.data); window.parent.parent.getItemTree(); win.close('addWindow'); } else { alert(data.data); } }
zzfls-pj
trunk/WebRoot/service/site/site_item/addItem.js
JavaScript
asf20
988
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="addItem.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <form id="addItemForm" name="addItemForm"> <input type="hidden" id="PID" name="PID" value="${param.pid}"> <table class="table_add"> <tr> <td align="right">栏目名称:</td> <td><input type="text" class="input_bt" id="NAME" name="NAME" validatorRules="Require" msg0="必填项" /></td> </tr> <tr> <td align="right">有效标志:</td> <td> <select id="STATUS" name="STATUS"> <option value="1">有效</option> <option value="0">无效</option> </select> </td> </tr> </table> </form> </div> </body> </html>
zzfls-pj
trunk/WebRoot/service/site/site_item/addItem.jsp
Java Server Pages
asf20
1,035
<%-- Created by IntelliJ IDEA. User: jxw Date: 12-2-23 Time: 上午9:07 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@include file="../../../include/jsp/taglib.jsp"%> <table id="wdsTable" class='datagrid2'> <tr> <th style="width:20px;"></th> <th style="width:30px;"><a href='javascript:myTable.checkAll()'>全选</a></th> <th>栏目id</th> <th>栏目名称</th> <th>父级栏目</th> <th style="width:30px;">状态</th> </tr> <c:forEach var="result" items="${model.data}" varStatus="s"> <tr class="tableRow" oldClass="tableRow" onmouseover="if(this.className != 'tableRowSelected')this.className='tableRowOver';" onmouseout="if(this.className != 'tableRowSelected')this.className='tableRow'" onclick="RowSelect(this)" id="${result.ID}" > <td align="center" class="TableCellIndex"> <c:out value="${s.index + 1}"/> </td> <td align="center"> <input type='checkbox' name='options' value='<c:out value="${result.ID}"/>'> </td> <td> <c:out value="${result.ID}"/> </td> <td> <c:out value="${result.NAME}"/> </td> <td align="center"> <c:out value="${result.PNAME}"/> </td> <td align="center"> <c:if test="${result.STATUS == 1}"> <img src="<c:url value="/include/images/img/icon_true.gif"/>"> </c:if> <c:if test="${result.STATUS == 0}"> <img src="<c:url value="/include/images/img/icon_false.gif"/>"> </c:if> </td> </tr> </c:forEach> </table> <div style='width:98%;text-align:right;'> <a href="javascript:queryPage('0')">首页</a> <c:if test="${model.pages.CURPAGE<=0}"> <a href="javascript:queryPage('0')">上一页</a> </c:if> <c:if test="${model.pages.CURPAGE>0}"> <a href="javascript:queryPage('${model.pages.CURPAGE - 1}')">上一页</a> </c:if> <c:if test="${(model.pages.CURPAGE +1)>=model.pages.TOTALPAGE}"> <a href="javascript:queryPage('${model.pages.TOTALPAGE - 1}')">下一页</a> </c:if> <c:if test="${(model.pages.CURPAGE+1)<model.pages.TOTALPAGE}"> <a href="javascript:queryPage('${model.pages.CURPAGE + 1}')">下一页</a> </c:if> <a href="javascript:queryPage('${model.pages.TOTALPAGE - 1}')">尾页</a> 共${model.pages.TOTALCOUNT}条记录 第<fmt:formatNumber value="${(model.pages.CURPAGE * 1 + 1)/model.pages.TOTALPAGE}" pattern="0"/>页 共${model.pages.TOTALPAGE}页 </div>
zzfls-pj
trunk/WebRoot/service/site/site_item/viewList.jsp
Java Server Pages
asf20
2,831
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="editItem.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <form id="editForm" name="editForm"> <input type="hidden" id="editForm_ID" name="ID"> <input type="hidden" id="editForm_PID" name="PID"> <table class="table_add"> <tr> <td align="right">栏目名称:</td> <td><input type="text" class="input_bt" id="editForm_NAME" name="NAME" validatorRules="Require" msg0="必填项"></td> </tr> <tr> <td align="right">有效标志:</td> <td> <select id="editForm_STATUS" name="STATUS"> <option value="1">有效</option> <option value="0">无效</option> </select> </td> </tr> </table> </form> </div> </body> </html>
zzfls-pj
trunk/WebRoot/service/site/site_item/editItem.jsp
Java Server Pages
asf20
1,180
/** * 初始化页面 */ function initPage() { getModuleOperationByUserDMAndModuleDM(parent.parent.session.USER_DM, myTools.getQueryString("MODULE_DM"), '1', "securityDIV"); //取模块权限按钮 getUser(); } /** *取得用户列表 */ function getUser() { var json = { url:contextPath + "/server/base/select.do", msg:"数据加载中.....", form:"searchForm", params:{ "SQLID":"user.selectUser" }, callback:[getUserCallBack] }; AjaxTools.ajax(json); } /** * 翻页 * @param page * @return */ function queryPage(page) { var json = { url:contextPath + "/server/base/select.do", msg:"数据加载中.....", form:"searchForm", params:{ "SQLID":"user.selectUser", "CURPAGE":page }, callback:[getUserCallBack] }; AjaxTools.ajax(json); } function getUserCallBack(json) { if (json.code == "00") { var a = { priKey:"USER_DM", header:["用户帐号","用户名称","用户描述"], column:["ACCOUNT","USER_NAME","USER_DESC"], aligns:["center","left","left"], width:[60,90,], data:json, pageFun:"queryPage" }; myGrid.grid(a); } else { alert(json.data); } } /** *显示添加用户窗口 */ function addUser() { win.open('addUser', '添加用户', '../../../admin/user/addUser.jsp', 550, 250, true, true); } /** *显示修改用户窗口 */ function editUser() { var id = myGrid.getSelectedID(); if (id) win.open('editUser', '修改用户', '../../../admin/user/editUser.jsp?USER_DM=' + id, 450, 250, true, true); } /** *显示分配角色窗口 */ function addUserRole() { var id = myGrid.getSelectedID(); if (id) win.open('addUserRole', '分配角色', '../../../admin/user/addUserRole.jsp?USER_DM=' + id, 450, 250, true, true); } /** * 删除用户 */ function delUser() { var ids = myGrid.getSelectedIDS(); if (ids) { if (confirm("是否确认删除?")) { var json = { url:contextPath + "/server/sys/deleteUser.do", msg:"数据删除中.....", params:{ "IDS":ids }, callback:[delUserCallBack] }; AjaxTools.ajax(json); } } } function delUserCallBack(json) { var code = json.code; if (code == "00") { alert(json.data); getUser(); } else { alert(json.data); } } function changePWD() { var id = myGrid.getSelectedID(); if (id) { if (confirm("密码将被重置为000000,是否继续?")) { var json = { url:contextPath + "/server/sys/insertUserPwd.do", msg:"数据保存中.....", params:{ "USER_DM":id, "USER_PWD":"000000" }, callback:[changePWDCallBack] }; AjaxTools.ajax(json); } } } function changePWDCallBack(json) { var code = json.code; if (code == "00") { alert("密码重置成功!"); } else { alert(json.data); } }
zzfls-pj
trunk/WebRoot/admin/user/index.js
JavaScript
asf20
3,425
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <script type="text/javascript" src="../../include/js/window/lhgdialog.js"></script> <script src="../../include/js/grid.js"></script> <script src="index.js"></script> </head> <body onload="initPage();"> <div style="padding-top:10px;"> <form id="searchForm" name="searchForm"> <input type="hidden" name="PAGESIZE" value="10"> <table class="table_search"> <tr> <td align="right">用户帐号:</td> <td><input type="text" name="ACCOUNT" class="input"></td> <td align="right">用户名称:</td> <td><input type="text" name="USER_NAME" class="input"></td> </tr> </table> </form> </div> <div class="security" id="securityDIV"> </div> <div id="editAreaDiv" class="editAreaDiv"></div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/user/index.jsp
Java Server Pages
asf20
1,014
/** * 初始化页面 */ function initPage() { win.crebtn('addWindow_btnCancel', '关闭', win.close); win.crebtn('addWindow_btnSave', '保存', addUser); //document.getElementById("MODULE_NAME").focus(); Validator.validate(document.getElementById(("addUserForm")), 3); } /** *添加用户 */ function addUser() { if (!Validator.validate(document.getElementById(("addUserForm")), 4)) return false; var json = { url:contextPath + "/server/sys/insertUser.do", msg:"数据保存中.....", form:"addUserForm", callback:[addUserCallBack] }; AjaxTools.ajax(json); } function addUserCallBack(data) { var code = data.code; if (code == "00") { alert(data.data); window.parent.parent.getUser(); win.close('addWindow'); } else { alert(data.data); } } //检查用户账号是否已被注册 function checkAcc(){ var acc = document.getElementById("ACCOUNT").value; if(acc == "") return; var json = { url:contextPath + "/server/base/selectByID.do", msg:"检测中.....", params:{ "SQLID":"user.selectUserBY_ACC", "ACCOUNT":acc }, callback:[checkAccCallBack] }; AjaxTools.ajax(json); } function checkAccCallBack(json){ var data = json.data; if(data!=""){ alert("该账号已被使用,请换用其他账号!"); } }
zzfls-pj
trunk/WebRoot/admin/user/addUser.js
JavaScript
asf20
1,499
/** * 初始化页面 */ function initPage() { win.crebtn('addUserRole_btnCancel', '关闭', win.close); win.crebtn('addUserRole_btnSave', '保存', addUserRole); getUserRole(); } /** * 取得用户角色列表 */ function getUserRole() { var json = { url : contextPath + "/server/base/selectAll.do", msg : "数据加载中.....", params : { "SQLID" : "user.selectUserRole", "USER_DM" : myTools.getQueryString("USER_DM") }, callback : [ getUserRoleCallBack ] }; AjaxTools.ajax(json); } function getUserRoleCallBack(json) { if (json.code == "00") { var a = { priKey : "ROLE_DM", header : [ "角色代码", "角色名称", "角色描述" ], column : [ "ROLE_DM", "ROLE_NAME", "ROLE_DESC" ], aligns : [ "center", "left", "left" ], width : [ 60, 90, ], data : json }; myGrid.grid(a); } else { alert(json.data); } } /** * 保存用户的角色 * * @return */ function addUserRole() { var ids = myGrid.getSelectedIDS(); if (ids) { var json = { url :contextPath + "/server/sys/insertUserRole.do", msg : "数据删除中.....", params : { "ROLE_DM" : ids, "USER_DM":myTools.getQueryString("USER_DM") }, callback : [addUserRoleCallBack] }; AjaxTools.ajax(json); } } function addUserRoleCallBack(json) { var code = json.code; if (code == "00") { alert(json.data); win.close(); } else { alert(json.data); } }
zzfls-pj
trunk/WebRoot/admin/user/addUserRole.js
JavaScript
asf20
1,500
/** *初始化editModule页面 取要修改的模块数据 */ function initPage() { win.crebtn('editWindow_btnCancel', '关闭', win.close); win.crebtn('editWindow_btnSave', '保存', editUser); var json = { url:contextPath + "/server/base/selectByID.do", msg:"数据加载中.....", params:{ "USER_DM": myTools.getQueryString("USER_DM"), "SQLID":"user.selectUserBY_ID" }, callback:[getUserCallBack] }; AjaxTools.ajax(json); Validator.validate(document.getElementById(("editForm")), 3); } function getUserCallBack(json) { myTools.bindForm("editForm", json.data); } /** *修改模块 */ function editUser() { if (!Validator.validate(document.getElementById(("editForm")), 4)) return false; var json = { url:contextPath + "/server/base/update.do", msg:"数据保存中.....", form:"editForm", params:{ "SQLID":"user.updateUser" }, callback:[editUserCallBack] }; AjaxTools.ajax(json); } function editUserCallBack(json) { var code = json.code; if (code == "00") { alert(json.data); window.parent.parent.getUser(); win.close('editWindow'); } else { alert(json.data); } }
zzfls-pj
trunk/WebRoot/admin/user/editUser.js
JavaScript
asf20
1,343
/** * 初始化页面 */ function initPage() { Validator.validate(document.getElementById(("changeUserPWDForm")), 3); document.getElementById("USER_DM").value = parent.parent.session.USER_DM; document.getElementById("ACCOUNT").value = parent.parent.session.ACCOUNT; } /** *添加用户 */ function save() { if (!Validator.validate(document.getElementById(("changeUserPWDForm")), 4)) return false; var json = { url:contextPath + "/server/sys/insertUserPwd.do", msg:"数据保存中.....", form:"changeUserPWDForm", callback:[saveCallBack] }; AjaxTools.ajax(json); } function saveCallBack(data) { var code = data.code; if (code == "00") { alert(data.data); } else { alert(data.data); } }
zzfls-pj
trunk/WebRoot/admin/user/changePWD.js
JavaScript
asf20
824
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="addUser.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <form id="addUserForm" name="addUserForm"> <input type="hidden" id="USER_PWD" name="USER_PWD" value="000000"/> <table class="table_add"> <tr> <td align="right">用户账号:</td> <td><input type="text" class="input_bt" id="ACCOUNT" name="ACCOUNT" validatorRules="Require" msg0="必填项" onblur="checkAcc();"/><font color="red">默认密码000000</font></td> <td align="right">用户名称:</td> <td><input type="text" class="input_bt" id="USER_NAME" name="USER_NAME" validatorRules="Require" msg0="必填项"/></td> </tr> <tr> <td align="right">所属部门:</td> <td><input type="text" class="input" id="ORG_DM" name="ORG_DM"></td> <td align="right">有效标志:</td> <td> <select id="YXBZ" name="YXBZ"> <option value="1">有效</option> <option value="0">无效</option> </select> </td> </tr> <tr> <td align="right">用户描述:</td> <td colspan="3"><textarea rows="3" style="width:100%" id="USER_DESC" name="USER_DESC"></textarea></td> </tr> </table> </form> </div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/user/addUser.jsp
Java Server Pages
asf20
1,613
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <script src="../../include/js/grid.js"></script> <script src="addUserRole.js"></script> </head> <body onload="initPage();"> <div id="editAreaDiv" class="editAreaDiv"></div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/user/addUserRole.jsp
Java Server Pages
asf20
363
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="editUser.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <form id="editForm" name="editForm"> <input type="hidden" id="editForm_USER_DM" name="USER_DM"> <table class="table_add"> <tr> <td align="right">用户账号:</td> <td><input type="text" class="input_bt" id="editForm_ACCOUNT" name="ACCOUNT" validatorRules="Require" msg0="必填项" readonly></td> <td align="right">用户名称:</td> <td><input type="text" class="input_bt" id="editForm_USER_NAME" name="USER_NAME" validatorRules="Require" msg0="必填项"></td> </tr> <tr> <td align="right">所属部门:</td> <td><input type="text" class="input" id="editForm_ORG_DM" name="ORG_DM"></td> <td align="right">有效标志:</td> <td> <select id="editForm_YXBZ" name="YXBZ"> <option value="1">有效</option> <option value="0">无效</option> </select> </td> </tr> <tr> <td align="right">用户描述:</td> <td colspan="3"><textarea rows="3" style="width:100%" id="editForm_USER_DESC" name="USER_DESC"></textarea></td> </tr> </table> </form> </div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/user/editUser.jsp
Java Server Pages
asf20
1,599
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="changePWD.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <form id="changeUserPWDForm" name="changeUserPWDForm"> <input type="hidden" id="USER_DM" name="USER_DM"/> <table class="table_add"> <tr> <td align="right">账号:</td> <td><input type="text" class="input_bt" id="ACCOUNT" name="ACCOUNT" readonly/></td> </tr> <tr> <td align="right">新密码:</td> <td><input type="password" class="input_bt" id="USER_PWD" name="USER_PWD" validatorRules="Require" msg0="必填项"/></td> </tr> <tr> <td align="right">再次确认新密码:</td> <td><input type="password" class="input_bt" id="USER_PWD_1" name="USER_PWD_1" validatorRules="Repeat" to="USER_PWD" msg0="必填项"/></td> </tr> <tr> <td align="center" colspan="2"> <input type="button" class="button" value="保存" onclick="save();"> </td> </tr> </table> </form> </div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/user/changePWD.jsp
Java Server Pages
asf20
1,316
/** *初始化页面 */ function initPage() { getModuleOperationByUserDMAndModuleDM(parent.parent.session.USER_DM,myTools.getQueryString("MODULE_DM"),'1',"securityDIV");//取模块权限按钮 getModule(); } /** *查询模块列表 */ function getModule() { var json = { url:contextPath + "/server/base/select.do", form:"moduleForm", params:{ "SQLID":"module.selectModule", "LX":"0" }, callback:[getModuleCallBack] }; //new Ajax().sendData(json); AjaxTools.ajax(json); } function getModuleCallBack(json) { if (json.code == "00") { var a = { priKey:"MODULE_DM", header:["模块代码","模块名称","上级模块","模块地址"], column:["MODULE_DM","MODULE_NAME","MODULE_SJ_NAME","MODULE_URL"], aligns:["center","left","left","left"], width:[60,90,90,150], data:json, pageFun:"queryPage" }; myGrid.grid(a); } else { alert(json.data); } //根节点不可编辑 var options = document.getElementsByName("options"); var flg = false; var id = ""; for (var i = 0; i < options.length; i++) { if (options[i].value =="1") { options[i].disabled = true; options[i].value = ""; } } } function queryPage(page) { var json = { url:contextPath +"/server/base/select.do", form:"moduleForm", params:{ "SQLID":"module.selectModule", "CURPAGE":page, "LX":"0" }, callback:[getModuleCallBack] }; //new Ajax().sendData(json); AjaxTools.ajax(json); } /** *显示添加模块窗口 */ function addModule() { win.open('addWindow', '添加模块', '../../../admin/module/addModule.jsp', 550, 450, true, true); } /** *显示修改模块窗口 */ function editModule() { var id = myGrid.getSelectedID(); if (id) win.open('editWindow', '修改模块', '../../../admin/module/editModule.jsp?MODULE_DM=' + id, 550, 450, true, true); } /** * 删除模块 */ function delModule() { var ids = myGrid.getSelectedIDS(); if (ids) { if (confirm("是否确认删除?")) { var json = { url:contextPath +"/server/sys/deleteModule.do", msg:"数据删除中.....", params:{ "IDS":ids }, callback:[delModuleCallBack] }; //new Ajax().sendData(json); AjaxTools.ajax(json); } } } function delModuleCallBack(json) { var code = json.code; if (code == "00") { alert(json.data); getModule(); } else { alert(json.data); } } /** *显示模块操作页面 */ function viewAddModuleAction() { var id = myGrid.getSelectedID(); if (id) win.open('moduleActionWindow', '模块操作管理', '../../../admin/module/moduleAction.jsp?MODULE_DM=' + id, 500, 350, true, true); }
zzfls-pj
trunk/WebRoot/admin/module/index.js
JavaScript
asf20
3,169
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="../../include/js/window/lhgdialog.js"></script> <script src="addModule.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <form id="addModuleForm" name="addModuleForm"> <input type="hidden" id="LX" name="LX" value = "0"/> <table class="table_add"> <tr> <td align="right">模块名称:</td> <td><input type="text" class="input_bt" id="MODULE_NAME" name="MODULE_NAME" validatorRules="Require" msg0="必填项"></td> <td align="right">父模块:</td> <td><input type="text" class="input_bt" id="MODULE_DM_SJ_NAME" name="MODULE_DM_SJ_NAME" validatorRules="Require" msg0="必填项" readonly> <input type="hidden" id="MODULE_DM_SJ" name="MODULE_DM_SJ"/> <input type="hidden" id="ORDERSALL_SJ" name="ORDERSALL_SJ"/> <input type="button" class="button" value="选择" onclick="onSelectModule('MODULE_DM_SJ','MODULE_DM_SJ_NAME','ORDERSALL_SJ');"/> </td> </tr> <tr> <td align="right">模块地址:</td> <td><input type="text" class="input" id="MODULE_URL" name="MODULE_URL"></td> <td align="right">模块顺序:</td> <td><input type="text" class="input" id="ORDERS" name="ORDERS" require="false" validatorRules="zzs" msg0="请输入正整数" value="1" maxlength="3"></td> </tr> <tr> <td align="right">是否有效:</td> <td colspan="3"> <select id="YXBZ" name="YXBZ"> <option value="1">有效</option> <option value="0">无效</option> </select> </td> </tr> <tr> <td align="right">模块描述:</td> <td colspan="3"><textarea rows="3" style="width:100%" name="MODULE_DESC"></textarea></td> </tr> </table> </form> </div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/module/addModule.jsp
Java Server Pages
asf20
2,230
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="addModuleAction.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <form id="addModuleActionForm" name="addModuleActionForm"> <input type="hidden" id="MODULE_DM_SJ" name="MODULE_DM_SJ" /> <input type="hidden" id="LX" name="LX" value="1" /> <input type="hidden" id="ORDERSALL" name="ORDERSALL" value="" /> <input type="hidden" id="ORDERSALL_SJ" name="ORDERSALL_SJ" value="" /> <table class="table_add"> <tr> <td align="right">操作名称:</td> <td><input type="text" class="input_bt" id="MODULE_NAME" name="MODULE_NAME" validatorRules="Require" msg0="必填项"></td> </tr> <tr> <td align="right">操作地址:</td> <td><input type="text" class="input_bt" id="MODULE_URL" name="MODULE_URL" validatorRules="Require" msg0="必填项"></td> </tr> <tr> <td align="right">显示级别:</td> <td><input type="text" class="input" id="PAGE_JB" name="PAGE_JB" validatorRules="zzs" msg0="请输入正整数"></td> </tr> <tr> <td align="right">显示顺序:</td> <td><input type="text" class="input" id="ORDERS" name="ORDERS" require="false" validatorRules="zzs" msg0="请输入正整数"></td> </tr> <tr> <td align="right">是否有效:</td> <td> <select id="YXBZ" name="YXBZ"> <option value="1">有效</option> <option value="0">无效</option> </select> </td> </tr> <tr> <td align="right">操作描述:</td> <td><textarea rows="3" style="width:100%" id="MODULE_DESC" name="MODULE_DESC"></textarea></td> </tr> </table> </form> </div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/module/addModuleAction.jsp
Java Server Pages
asf20
2,148
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <script type="text/javascript" src="../../include/js/window/lhgdialog.js"></script> <script src="../../include/js/grid.js"></script> <script src="index.js"></script> </head> <body onload="initPage();"> <form action="" id="moduleForm" name="moduleForm"> <input type="hidden" name="PAGESIZE" value="15"> <div style="padding-top:10px;"> <table class="table_search"> <tr> <td align="right">模块代码:</td> <td><input type="text" name="MODULE_DM" class="input"></td> <td align="right">模块名称:</td> <td><input type="text" name="MODULE_NAME" class="input"></td> </tr> </table> </div> <div class="security" id="securityDIV"> </div> <div id="editAreaDiv" class="editAreaDiv" style="width:100%;"></div> </form> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br><br><br> </body> </html>
zzfls-pj
trunk/WebRoot/admin/module/index.jsp
Java Server Pages
asf20
1,080
/** * 初始化页面 */ function initPage() { win.crebtn('addWindow_btnCancel', '关闭', win.close); win.crebtn('addWindow_btnSave', '保存', addModule); document.getElementById("MODULE_NAME").focus(); Validator.validate(document.getElementById(("addModuleForm")), 3); } /** *添加模块 */ function addModule() { if (!Validator.validate(document.getElementById(("addModuleForm")), 4)) return false; var orders = document.getElementById("ORDERS").value; var ordersall_sj = document.getElementById("ORDERSALL_SJ").value; var ordersall = ordersall_sj + "" + LPad(orders,'0',3); var json = { url:contextPath +"/server/sys/insertModule.do", msg:"数据保存中.....", form:"addModuleForm", params:{ "SQLID":"module.insertModule", "ORDERSALL":ordersall }, callback:[addModuleCallBack] }; AjaxTools.ajax(json); } function addModuleCallBack(data) { var code = data.code; if (code == "0") { alert(data.msg); window.parent.parent.getModule(); win.close('addWindow'); } else { alert(data.msg); } } function onSelectModule(id, name,ordersall) { var selectedID = document.getElementById(id).value; win.open('ModuleTreeWindow', '模块树', '../../../admin/module/moduleTree.jsp?RTN_ID=' + id + "&RTN_NAME=" + name + "&RTN_ORDERSALL=" + ordersall + "&selectedID=" + selectedID, 250, 350, true, true, '', '', '', 'two'); }
zzfls-pj
trunk/WebRoot/admin/module/addModule.js
JavaScript
asf20
1,547
/** * 初始化页面 */ var parent_id = null; var parent_name = null; var parent_ordersall = null; var moduleTree = null; var selectedID = null; function initPage() { win.crebtn('moduleTree_btnCancel', '关闭', win.close); win.crebtn('moduleTree_btnSave', '确定', save); parent_id = myTools.getQueryString("RTN_ID"); parent_name = myTools.getQueryString("RTN_NAME"); parent_ordersall = myTools.getQueryString("RTN_ORDERSALL"); selectedID = myTools.getQueryString("selectedID"); getModuleTree(); } function getModuleTree() { var json = { url:contextPath +"/server/sys/getModuleTree.do", msg:"数据加载中.....", params:{ "MODULE_DM_SJ":"-1",//-1 根 "YXBZ":"1", "LX":"0" }, callback:[getModuleTreeByCallBack] }; AjaxTools.ajax(json); } function getModuleTreeByCallBack(data) { moduleTree = new dhtmlXTreeObject(document.getElementById('treeBox'), "100%", "100%", 0); moduleTree.setImagePath("../../include/js/components/xTree/xTree_imgs/csh_bluebooks/"); moduleTree.enableCheckBoxes(true); // moduleTree.enableThreeStateCheckboxes(true); moduleTree.loadXMLString(data.data); moduleTree.closeAllItems(0); moduleTree.setCheck(selectedID, 1); moduleTree.openItem(selectedID); } /** *选择模块 */ function save() { var ids = moduleTree.getAllChecked(); if (ids.split(",").length > 1) { alert("只能选择一个模块"); return; } var id = ids.split("-")[0]; var ordersall = ids.split("-")[1]; var module_name = moduleTree.getItemText(ids); window.parent.parent.document.getElementById(parent_id).value = id; window.parent.parent.document.getElementById(parent_name).value = module_name; window.parent.parent.document.getElementById(parent_ordersall).value = ordersall; win.close(); }
zzfls-pj
trunk/WebRoot/admin/module/moduleTree.js
JavaScript
asf20
1,955
/** *初始化editModule页面 取要修改的模块数据 */ function initPage() { win.crebtn('editWindow_btnCancel', '关闭', win.close); win.crebtn('editWindow_btnSave', '保存', editModule); var json = { url:contextPath +"/server/base/selectByID.do", msg:"数据加载中.....", params:{ "MODULE_DM": myTools.getQueryString("MODULE_DM"), "SQLID":"module.selectModuleBY_ID" }, callback:[getModuleCallBack] }; AjaxTools.ajax(json); Validator.validate(document.getElementById(("editForm")), 3); } function getModuleCallBack(json) { myTools.bindForm("editForm", json.data); } /** *修改模块 */ function editModule() { if (!Validator.validate(document.getElementById(("editForm")), 4)) return false; var orders = document.getElementById("editForm_ORDERS").value; var ordersall_sj = document.getElementById("editForm_ORDERSALL_SJ").value; if(ordersall_sj!=""){//修改了父模块 document.getElementById("editForm_ORDERSALL").value = ordersall_sj + "" + LPad(orders,'0',3); }else{ var ordersall = document.getElementById("editForm_ORDERSALL").value; //alert(ordersall.substring(0,ordersall.length-3)); document.getElementById("editForm_ORDERSALL").value = ordersall.substring(0,ordersall.length-3) + "" + LPad(orders,'0',3); } var json = { url:contextPath +"/server/base/update.do", msg:"数据保存中.....", form:"editForm", params:{ "SQLID":"module.updateModule" }, callback:[editModuleCallBack] }; AjaxTools.ajax(json); } function editModuleCallBack(json) { var code = json.code; if (code == "00") { alert(json.data); window.parent.parent.getModule(); win.close('editWindow'); } else { alert(json.data); } } function onSelectModule(id, name,ordersall) { var selectedID = document.getElementById(id).value; win.open('ModuleTreeWindow', '模块树', '../../../admin/module/moduleTree.jsp?RTN_ID=' + id + "&RTN_NAME=" + name + "&RTN_ORDERSALL=" + ordersall + "&selectedID=" + selectedID, 250, 350, true, true, '', '', '', 'two'); }
zzfls-pj
trunk/WebRoot/admin/module/editModule.js
JavaScript
asf20
2,287
/** * 初始化页面 */ function initPage() { win.crebtn('addWindow_btnCancel', '关闭', win.close); win.crebtn('addWindow_btnSave', '保存', addModuleAction); document.getElementById("MODULE_DM_SJ").value = myTools.getQueryString("MODULE_DM_SJ"); getModuleSJOrder(); Validator.validate(document.getElementById(("addModuleActionForm")), 3); } /** *保存模块操作 */ function addModuleAction() { if (!Validator.validate(document.getElementById(("addModuleActionForm")), 4)) return false; var orders = document.getElementById("ORDERS").value; var ordersall_sj = document.getElementById("ORDERSALL_SJ").value; var ordersall = ordersall_sj + "" + LPad(orders, '0', 3); document.getElementById("ORDERSALL").value = ordersall; var json = { url:contextPath +"/server/sys/insertModule.do", msg:"数据保存中.....", form:"addModuleActionForm", params:{ "SQLID":"module.insertModule" }, callback:[addModuleActionCallBack] }; AjaxTools.ajax(json); } function addModuleActionCallBack(data) { var code = data.code; if (code == "0") { alert(data.msg); window.parent.parent.getModuleAction(); win.close('addWindow'); } else { alert(data.msg); } } /** 取上级模块的全局顺序 */ function getModuleSJOrder() { var json = { url:contextPath +"/server/base/selectByID.do", msg:"数据加载中.....", params:{ "MODULE_DM": myTools.getQueryString("MODULE_DM_SJ"), "SQLID":"module.selectModuleBY_ID" }, callback:[getModuleSJOrderCallBack] }; AjaxTools.ajax(json); } function getModuleSJOrderCallBack(json) { document.getElementById("ORDERSALL_SJ").value = json.data.ORDERSALL; }
zzfls-pj
trunk/WebRoot/admin/module/addModuleAction.js
JavaScript
asf20
1,891
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <script type="text/javascript" src="../../include/js/components/comm_js/dhtmlxcommon.js"></script> <link href="../../include/js/components/xTree/xTree_css/dhtmlxtree.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="../../include/js/components/xTree/xTree_js/dhtmlxtree.js"></script> <script src="moduleTree.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <div id="treeBox"></div> </div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/module/moduleTree.jsp
Java Server Pages
asf20
703
/** *初始化editModule页面 取要修改的模块数据 */ function initPage() { win.crebtn('editWindow_btnCancel', '关闭', win.close); win.crebtn('editWindow_btnSave', '保存', editModuleAction); var json = { url:contextPath +"/server/base/selectByID.do", msg:"数据加载中.....", params:{ "MODULE_DM": myTools.getQueryString("MODULE_DM"), "SQLID":"module.selectModuleBY_ID" }, callback:[getModuleActionCallBack] }; AjaxTools.ajax(json); Validator.validate(document.getElementById(("editForm")), 3); } function getModuleActionCallBack(json) { myTools.bindForm("editForm", json.data); getModuleSJOrder(); } /** *修改模块 */ function editModuleAction() { if (!Validator.validate(document.getElementById(("editForm")), 4)) return false; var orders = document.getElementById("ORDERS").value; var ordersall_sj = document.getElementById("ORDERSALL_SJ").value; var ordersall = ordersall_sj + "" + LPad(orders, '0', 3); document.getElementById("ORDERSALL").value = ordersall; var json = { url:contextPath +"/server/base/update.do", msg:"数据保存中.....", form:"editForm", params:{ "SQLID":"module.updateModule" }, callback:[editModuleActionCallBack] }; AjaxTools.ajax(json); } function editModuleActionCallBack(json) { var code = json.code; if (code == "00") { alert(json.data); window.parent.parent.getModuleAction(); win.close('editWindow'); } else { alert(json.data); } } /** 取上级模块的全局顺序 */ function getModuleSJOrder() { var json = { url:contextPath +"/server/base/selectByID.do", msg:"数据加载中.....", params:{ "MODULE_DM": document.getElementById("editForm_MODULE_DM_SJ").value, "SQLID":"module.selectModuleBY_ID" }, callback:[getModuleSJOrderCallBack] }; AjaxTools.ajax(json); } function getModuleSJOrderCallBack(json) { document.getElementById("ORDERSALL_SJ").value = json.data.ORDERSALL; }
zzfls-pj
trunk/WebRoot/admin/module/editModuleAction.js
JavaScript
asf20
2,237
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="editModuleAction.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <form id="editForm" name="editForm"> <input type="hidden" id="editForm_MODULE_DM_SJ" name="MODULE_DM_SJ"> <input type="hidden" id="editForm_MODULE_DM" name="MODULE_DM"> <input type="hidden" id="editForm_LX" name="LX" value="1" /> <input type="hidden" id="ORDERSALL" name="ORDERSALL" value="" /> <input type="hidden" id="ORDERSALL_SJ" name="ORDERSALL_SJ" value="" /> <table class="table_add"> <tr> <td align="right">操作名称:</td> <td><input type="text" class="input_bt" id="editForm_MODULE_NAME" name="MODULE_NAME" validatorRules="Require" msg0="必填项"></td> </tr> <tr> <td align="right">操作地址:</td> <td><input type="text" class="input_bt" id="editForm_MODULE_URL" name="MODULE_URL" validatorRules="Require" msg0="必填项"></td> </tr> <tr> <td align="right">显示级别:</td> <td><input type="text" class="input" id="editForm_PAGE_JB" name="PAGE_JB" require="false" validatorRules="zzs" msg0="请输入正整数"></td> </tr> <tr> <td align="right">显示顺序:</td> <td><input type="text" class="input" id="editForm_ORDERS" name="ORDERS" require="false" validatorRules="zzs" msg0="请输入正整数"></td> </tr> <tr> <td align="right">是否有效:</td> <td> <select id="editForm_YXBZ" name="YXBZ"> <option value="1">有效</option> <option value="0">无效</option> </select> </td> </tr> <tr> <td align="right">操作描述:</td> <td><textarea rows="3" style="width:100%" id="editForm_MODULE_DESC" name="MODULE_DESC"></textarea></td> </tr> </table> </form> </div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/module/editModuleAction.jsp
Java Server Pages
asf20
2,281
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="../../include/js/window/lhgdialog.js"></script> <script src="editModule.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <form id="editForm" name="editForm"> <input type="hidden" id="editForm_MODULE_DM" name="MODULE_DM"> <input type="hidden" id="editForm_LX" name="LX" value = "0"/> <table class="table_add"> <tr> <td align="right">模块名称:</td> <td><input type="text" class="input_bt" id="editForm_MODULE_NAME" name="MODULE_NAME" validatorRules="Require" msg0="必填项"></td> <td align="right">父模块:</td> <td> <input type="text" class="input_bt" id="editForm_MODULE_SJ_NAME" name="MODULE_SJ_NAME" validatorRules="Require" msg0="必填项"> <input type="hidden" id="editForm_MODULE_DM_SJ" name="MODULE_DM_SJ"/> <input type="hidden" id="editForm_ORDERSALL_SJ" name="ORDERSALL_SJ"/> <input type="hidden" id="editForm_ORDERSALL" name="ORDERSALL"/> <input type="button" class="button" value="选择" onclick="onSelectModule('editForm_MODULE_DM_SJ','editForm_MODULE_SJ_NAME','editForm_ORDERSALL_SJ');"/> </td> </tr> <tr> <td align="right">模块地址:</td> <td><input type="text" class="input" id="editForm_MODULE_URL" name="MODULE_URL"></td> <td align="right">模块顺序:</td> <td><input type="text" class="input" id="editForm_ORDERS" name="ORDERS" require="false" validatorRules="zzs" msg0="请输入正整数"></td> </tr> <tr> <td align="right">是否有效:</td> <td colspan="3"> <select id="editForm_YXBZ" name="YXBZ"> <option value="1">有效</option> <option value="0">无效</option> </select> </td> </tr> <tr> <td align="right">模块描述:</td> <td colspan="3"><textarea rows="3" style="width:100%" id="editForm_MODULE_DESC" name="MODULE_DESC"></textarea></td> </tr> </table> </form> </div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/module/editModule.jsp
Java Server Pages
asf20
2,452
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <script type="text/javascript" src="../../include/js/window/lhgdialog.js"></script> <script src="../../include/js/grid.js"></script> <script src="moduleAction.js"></script> </head> <body onload="initPage();"> <form action="" id="moduleForm" name="moduleForm"> <input type="hidden" id="MODULE_DM_SJ" name="MODULE_DM_SJ" /> <div id="editAreaDiv" class="editAreaDiv" style="width:100%;"></div> </form> </body> </html>
zzfls-pj
trunk/WebRoot/admin/module/moduleAction.jsp
Java Server Pages
asf20
587
function initPage() { document.getElementById("MODULE_DM_SJ").value = myTools.getQueryString("MODULE_DM"); win.crebtn('editWindow_btnClose', '关闭',win.close); win.crebtn('editWindow_btnDel', '删除',delModuleAction); win.crebtn('editWindow_btnEdit', '修改', editModuleAction); win.crebtn('editWindow_btnAdd', '添加', addModuleAction); getModuleAction(); } function getModuleAction() { var json = { url:contextPath +"/server/base/select.do", msg:"数据加载中.....", params:{ "SQLID":"module.selectModule", "LX":"1", "MODULE_DM_SJ":myTools.getQueryString("MODULE_DM"), "PAGESIZE":"15" }, callback:[getModuleActionCallBack] }; AjaxTools.ajax(json); } function queryPage(page) { var json = { url:contextPath +"/server/base/select.do", msg:"数据加载中.....", form:"moduleForm", params:{ "SQLID":"module.selectModule", "CURPAGE":page, "LX":"1", "MODULE_DM_SJ":myTools.getQueryString("MODULE_DM"), "PAGESIZE":"15" }, callback:[getModuleActionCallBack] }; AjaxTools.ajax(json); } function getModuleActionCallBack(json) { if (json.code == "00") { var a = { priKey:"MODULE_DM", header:["操作名称","操作地址","页面级别","显示顺序"], column:["MODULE_NAME","MODULE_URL","PAGE_JB","ORDERS"], aligns:["left","left","center","center"], width:[90,,60,60], data:json, pageFun:"queryPage" }; myGrid.grid(a); } else { alert(json.data); } } /** *显示添加模块窗口 */ function addModuleAction() { win.open('addWindow', '添加操作', '../../../admin/module/addModuleAction.jsp?MODULE_DM_SJ=' + document.getElementById("MODULE_DM_SJ").value, 450, 250, true, true, '', '', '', 'two'); } /** *显示修改模块窗口 */ function editModuleAction() { var id = myGrid.getSelectedID(); if (id) win.open('editWindow', '修改操作', '../../../admin/module/editModuleAction.jsp?MODULE_DM=' + id, 450, 250, true, true, '', '', '', 'two'); } /** * 删除模块 */ function delModuleAction() { var ids = myGrid.getSelectedIDS(); if (ids) { if (confirm("是否确认删除?")) { var json = { url:contextPath +"/server/base/delete.do", msg:"数据删除中.....", params:{ "SQLID":"module.deleteModule", "IDS":ids }, callback:[delModuleCallBack] }; AjaxTools.ajax(json); } } } function delModuleCallBack(json) { var code = json.code; if (code == "00") { alert(json.data); getModuleAction(); } else { alert(json.data); } }
zzfls-pj
trunk/WebRoot/admin/module/moduleAction.js
JavaScript
asf20
3,053
/** * 初始化页面 */ function initPage() { getModuleOperationByUserDMAndModuleDM(parent.parent.session.USER_DM,myTools.getQueryString("MODULE_DM"),'1',"securityDIV");//取模块权限按钮 getRole(); } /** *取得角色列表 */ function getRole() { var json = { url:contextPath + "/server/base/select.do", msg:"数据加载中.....", form:"searchForm", params:{ "SQLID":"role.selectRole" }, callback:[getRoleCallBack] }; AjaxTools.ajax(json); } function getRoleCallBack(json) { if (json.code == "00") { var a = { priKey:"ROLE_DM", header:["角色代码","角色名称","角色描述"], column:["ROLE_DM","ROLE_NAME","ROLE_DESC"], aligns:["center","left","left"], width:[60,90,], data:json, pageFun:"queryPage" }; myGrid.grid(a); } else { alert(json.data); } } /** * 翻页 * @param page * @return */ function queryPage(page) { var json = { url:contextPath + "/server/base/select.do", msg:"数据加载中.....", form:"searchForm", params:{ "SQLID":"role.selectRole", "CURPAGE":page }, callback:[getRoleCallBack] }; AjaxTools.ajax(json); } /** *显示添加角色窗口 */ function addRole() { win.open('addRole', '添加角色', '../../../admin/role/addRole.jsp', 450, 250, true, true); } /** *显示修改角色窗口 */ function editRole() { var id = myGrid.getSelectedID(); if (id) win.open('editRole', '修改角色', '../../../admin/role/editRole.jsp?ROLE_DM=' + id, 450, 250, true, true); } /** *显示分配模块窗口 */ function addRoleModule() { var id = myGrid.getSelectedID(); if (id) win.open('addRoleModule', '分配模块', '../../../admin/role/addRoleModule.jsp?ROLE_DM=' + id, 300, 450, true, true); } /** * 删除角色 */ function delRole() { var ids = myGrid.getSelectedIDS(); if (ids) { if (confirm("是否确认删除?")) { var json = { url:contextPath + "/server/sys/deleteRole.do", msg:"数据删除中.....", params:{ "IDS":ids }, callback:[delRoleCallBack] }; AjaxTools.ajax(json); } } } function delRoleCallBack(json) { var code = json.code; if (code == "00") { alert(json.data); getRole(); } else { alert(json.data); } }
zzfls-pj
trunk/WebRoot/admin/role/index.js
JavaScript
asf20
2,708
/** * 初始化页面 */ var roleModuleTree = null; function initPage(){ win.crebtn('addRole_btnCancel', '关闭', win.close); win.crebtn('addRole_btnSave', '保存', addRoleModule); getModuleTreeByRoleDM(); } function getModuleTreeByRoleDM(){ var json = { url:contextPath + "/server/sys/getModuleTreeByRoleDM.do", msg:"数据加载中.....", params:{ "MODULE_DM_SJ":"1", "ROLE_DM":myTools.getQueryString("ROLE_DM"), "USER_DM":window.parent.parent.parent.parent.session.USER_DM }, callback:[getModuleTreeByRoleDMCallBack] }; AjaxTools.ajax(json); } function getModuleTreeByRoleDMCallBack(data) { roleModuleTree = new dhtmlXTreeObject(document.getElementById('treeBox'), "100%", "100%", 0); roleModuleTree.setImagePath("../../include/js/components/xTree/xTree_imgs/csh_bluebooks/"); roleModuleTree.enableCheckBoxes(true); roleModuleTree.enableThreeStateCheckboxes(true); roleModuleTree.loadXMLString(data.data); roleModuleTree.closeAllItems(0); } /** *添加角色 */ function addRoleModule() { var json = { url:contextPath + "/server/sys/insertRoleModule.do", msg:"数据保存中.....", params:{ "MODULE_DMS":roleModuleTree.getAllCheckedBranches(), "ROLE_DM":myTools.getQueryString("ROLE_DM") }, callback:[addRoleModuleCallBack] }; AjaxTools.ajax(json); } function addRoleModuleCallBack(data) { var code = data.code; if (code == "00") { alert(data.data); window.parent.parent.getRole(); win.close('addRole'); } else { alert(data.data); } }
zzfls-pj
trunk/WebRoot/admin/role/addRoleModule.js
JavaScript
asf20
1,770
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <script src="../../include/js/grid.js"></script> <script type="text/javascript" src="../../include/js/window/lhgdialog.js"></script> <script src="index.js"></script> </head> <body onload="initPage();"> <div style="padding-top: 10px;"> <form id="searchForm" name="searchForm"> <input type="hidden" name="PAGESIZE" value="10"> <table class="table_search"> <tr> <td align="right"> 角色代码: </td> <td> <input type="text" name="ROLE_DM" class="input"> </td> <td align="right"> 角色名称: </td> <td> <input type="text" name="ROLE_NAME" class="input"> </td> </tr> </table> </form> </div> <div class="security" id="securityDIV"> </div> <div id="editAreaDiv" class="editAreaDiv"></div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/role/index.jsp
Java Server Pages
asf20
1,186
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <script type="text/javascript" src="../../include/js/components/comm_js/dhtmlxcommon.js"></script> <link href="../../include/js/components/xTree/xTree_css/dhtmlxtree.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="../../include/js/components/xTree/xTree_js/dhtmlxtree.js"></script> <script src="addRoleModule.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <div id="treeBox"></div> </div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/role/addRoleModule.jsp
Java Server Pages
asf20
724
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <script src="editRole.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <form id="editRoleForm" name="editRoleForm"> <input type="hidden" id="editRoleForm_ROLE_DM" name="ROLE_DM"> <table class="table_add"> <tr> <td>角色名称:</td> <td><input type="text" class="input_bt" id="editRoleForm_ROLE_NAME" name="ROLE_NAME" validatorRules="Require" msg0="必填项"></td> </tr> <tr> <td>角色描述:</td> <td><input type="text" class="input" id="editRoleForm_ROLE_DESC" name="ROLE_DESC"></td> </tr> <tr> <td>是否有效:</td> <td colspan="3"> <select name="YXBZ" id="editRoleForm_YXBZ"> <option value="1">是</option> <option value="0">否</option> </select> </td> </tr> </table> </form> </div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/role/editRole.jsp
Java Server Pages
asf20
1,278
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../../include/jsp/include.jsp"/> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <script src="addRole.js"></script> </head> <body onload="initPage();"> <div style="height:90%;"> <form id="addRoleForm" name="addRoleForm"> <table class="table_add"> <tr> <td align="right">角色名称:</td> <td><input type="text" class="input_bt" id="ROLE_NAME" name="ROLE_NAME" validatorRules="Require" msg0="必填项"></td> </tr> <tr> <td align="right">角色描述:</td> <td><input type="text" class="input" id="ROLE_DESC" name="ROLE_DESC"></td> </tr> <tr> <td align="right">是否有效:</td> <td colspan="3"> <select id="YXBZ" name="YXBZ"> <option value="1">是</option> <option value="0">否</option> </select> </td> </tr> </table> </form> </div> </body> </html>
zzfls-pj
trunk/WebRoot/admin/role/addRole.jsp
Java Server Pages
asf20
1,205
/** * 初始化页面 */ function initPage(){ win.crebtn('addRole_btnCancel', '关闭', win.close); win.crebtn('addRole_btnSave', '保存', addRole); Validator.validate(document.getElementById(("addRoleForm")), 3); } /** *添加角色 */ function addRole() { if (!Validator.validate(document.getElementById(("addRoleForm")), 4)) return false; var json = { url:contextPath + "/server/base/insert.do", msg:"数据保存中.....", form:"addRoleForm", params:{ "SQLID":"role.insertRole" }, callback:[addRoleCallBack] }; AjaxTools.ajax(json); } function addRoleCallBack(data) { var code = data.code; if (code == "00") { alert(data.data); window.parent.parent.getRole(); win.close('addRole'); } else { alert(data.data); } }
zzfls-pj
trunk/WebRoot/admin/role/addRole.js
JavaScript
asf20
899
/** *初始化editRole页面 取要修改的角色数据 */ function initPage() { win.crebtn('editRole_btnCancel', '关闭', win.close); win.crebtn('editRole_btnSave', '保存', editRole); var json = { url:contextPath + "/server/base/selectByID.do", msg:"数据加载中.....", params:{ "ROLE_DM": myTools.getQueryString("ROLE_DM"), "SQLID":"role.selectRoleBY_ID" }, callback:[getRoleCallBack] }; AjaxTools.ajax(json); } function getRoleCallBack(json) { myTools.bindForm("editRoleForm", json.data); Validator.validate(document.getElementById(("editRoleForm")), 3); } /** *修改模块 */ function editRole() { if (!Validator.validate(document.getElementById(("editRoleForm")), 4)) return false; var json = { url:contextPath + "/server/base/update.do", msg:"数据保存中.....", form:"editRoleForm", params:{ "SQLID":"role.updateRole" }, callback:[editRoleCallBack] }; AjaxTools.ajax(json); } function editRoleCallBack(json) { var code = json.code; if (code == "00") { alert(json.data); window.parent.parent.getRole(); win.close('editRole'); } else { alert(json.data); } }
zzfls-pj
trunk/WebRoot/admin/role/editRole.js
JavaScript
asf20
1,352
function initPage() { document.getElementById("ACCOUNT").focus(); Validator.validate(document.getElementById(("loginForm")), 3); } function checkLogin() { if (!Validator.validate(document.getElementById(("loginForm")), 4)) return false; var account = document.getElementById("ACCOUNT").value; var user_pwd = document.getElementById("USER_PWD").value; var json = { url:contextPath + "/server/sys/doLogin.do", msg:"登录中.....", params:{ "ACCOUNT":account, "USER_PWD":user_pwd }, callback:[checkLoginCallBack] }; AjaxTools.ajax(json); } function checkLoginCallBack(data) { if (data.code == "00") { //登录成功 跳转 var sTarget = "mainframe.jsp"; //window.location.href = sTarget; var sw = screen.width + 9; var sh = screen.height + 9; var w = 650; var h = 350; var l = -10; var t = -10; var win = window.open(sTarget, "_blank", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + w + ",height=" + h + ",left=" + l + ",top=" + t); if (win != null) { // window.opener = null; // window.close(); //ie7有时提示是否关闭 此代码屏蔽了提示 ie678通用 window.opener = null window.open("", "_self") window.close(); } else { msg.style.display = "block"; } } else { alert(data.data); } }
zzfls-pj
trunk/WebRoot/main/login.js
JavaScript
asf20
1,643
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <jsp:include page="../include/jsp/include.jsp"/> <HTML> <HEAD> <TITLE>管理系统</TITLE> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <link rel="stylesheet" type="text/css" href="../include/js/components/xLayout/xLayout_css/dhtmlxlayout.css"> <link rel="stylesheet" type="text/css" href="../include/js/components/xLayout/xLayout_css/dhtmlxlayout_dhx_blue.css"> <link rel="stylesheet" type="text/css" href="../include/js/components/xWindow/xWindow_css/dhtmlxwindows.css"> <link rel="stylesheet" type="text/css" href="../include/js/components/xWindow/xWindow_css/dhtmlxwindows_dhx_blue.css"> <link rel="stylesheet" type="text/css" href="../include/js/components/xAccordion/xAccordion_css/dhtmlxaccordion_dhx_blue.css"> <script src="../include/js/components/comm_js/dhtmlxcommon.js"></script> <script src="../include/js/components/xLayout/xLayout_js/dhtmlxlayout.js"></script> <script src="../include/js/components/xWindow/xWindow_js/dhtmlxwindows.js"></script> <script src="../include/js/components/xWindow/xWindow_js/dhtmlxwindows_sb.js"></script> <script src="../include/js/components/xAccordion/xAccordion_js/dhtmlxaccordion.js"></script> <script> var session = null; function openwin_max(){ var scrWidth=screen.availWidth; var scrHeight=screen.availHeight; window.moveTo(-4,-4); window.resizeTo(scrWidth+9,scrHeight+9); } function getSession(){ var json = { url:contextPath + "/server/sys/getUserSession.do", showMsg:false, async:false, callback:[getSessionCallBack] }; AjaxTools.ajax(json); } function getSessionCallBack(json){ session = eval("(" + json.data + ")"); } </script> </HEAD> <body style="width: 100%; height: 100%; margin: 0px; overflow: hidden;" onload="openwin_max();"> <script> getSession(); //生成系统布局 var dhxLayout = new dhtmlXLayoutObject(document.body, "3T"); dhxLayout.cells("b").setWidth(180); dhxLayout.cells("a").setHeight(60); dhxLayout.cells("a").hideHeader(); dhxLayout.cells("b").setText("登录用户:" + session.USER_NAME); dhxLayout.cells("c").hideHeader(); dhxLayout.cells("a").fixSize(true, true); //生成状态栏 var status = dhxLayout.attachStatusBar(); var statusStr = "<div style='width:29%;float:left;border:#C2D5DC 1px solid;'>"; //statusStr +="&nbsp;&nbsp;您目前操作的模块是:<span id='status_nvg'>用户管理</span>"; statusStr +="</div>"; statusStr +="<div style='width:70%;text-align:right;float:right;margin-left:2px;border:#C2D5DC 1px solid;'>"; statusStr +="版权所有:XXXXXXXXXXXX&nbsp;&nbsp;2010--2011&nbsp;"; statusStr +="</div>"; status.setText(statusStr); dhxLayout.cells("a").attachURL("top.html"); //dhxLayout.cells("b").attachURL("left_menu.html"); dhxLayout.cells("c").attachURL("main.html"); //生成活动面板 var dhxAccord = dhxLayout.cells("b").attachAccordion(); dhxAccord.addItem("a1", "我的工作台"); dhxAccord.addItem("a2", "我的收藏夹"); dhxAccord.openItem("a1"); dhxAccord.cells("a1").attachURL("left_menu.html"); //dhxAccord.cells("a2").attachURL("left_menu.html"); </script> </BODY> </HTML>
zzfls-pj
trunk/WebRoot/main/mainframe.jsp
Java Server Pages
asf20
3,359
<HTML> <HEAD> </HEAD> <body style="margin: 0px;overflow: hidden;" scroll="no"> <div id="gridbox" width="100%" height="130px" style="background-color:white;overflow:hidden"></div> </BODY> </HTML>
zzfls-pj
trunk/WebRoot/main/desk.html
HTML
asf20
210