commit e00ed5d458630abe9b8acd7a0a3db96fbb5f22de Author: robin <3504557@qq,com> Date: Thu Sep 27 12:01:27 2018 +0800 init diff --git a/DogAuth.BO/B3DogAuth.csproj b/DogAuth.BO/B3DogAuth.csproj new file mode 100644 index 0000000..bd6d8c7 --- /dev/null +++ b/DogAuth.BO/B3DogAuth.csproj @@ -0,0 +1,100 @@ + + + + Debug + AnyCPU + + + 2.0 + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE} + Library + Properties + BWP.B3DogAuth + B3DogAuth + v4.0 + 512 + TSingSoft + + + true + full + false + bin\Debug\ + TRACE;DEBUG;CODE_ANALYSIS + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\tsref\Debug\B3Frameworks.dll + + + False + False + + + False + False + + + False + False + + + False + + + False + + + False + + + False + + + False + ..\..\..\tsref\Debug\TSingSoft.WebControls2.dll + + + False + False + + + False + False + + + False + False + + + + + tslib_version.cs + + + + + + + + + + + \ No newline at end of file diff --git a/DogAuth.BO/DogAuthConfig.cs b/DogAuth.BO/DogAuthConfig.cs new file mode 100644 index 0000000..14d1c41 --- /dev/null +++ b/DogAuth.BO/DogAuthConfig.cs @@ -0,0 +1,30 @@ +using Forks.EnterpriseServices; +using Forks.Utils.Configuration; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3DogAuth { + [ConfigurationEnabled] + public class DogAuthConfig { + public DogAuthConfig() { + ConfigurationUtil.Fill(this); + } + + private BoolConfigRef _closeMobileVerifyCode = new BoolConfigRef(false); + + [LogicName("关闭手机验证码登陆")] + public BoolConfigRef CloseMobileVerifyCode { + get { return _closeMobileVerifyCode; } + set { _closeMobileVerifyCode = value; } + } + + private StringListConfigRef _canLoginWithMobileVerifyCode = new StringListConfigRef(); + + [LogicName("允许使用手机验证码登陆的用户")] + [ConfigurationItemDescription("关闭手机验证码登陆时生效")] + public StringListConfigRef CanLoginWithMobileVerifyCode { + get { return _canLoginWithMobileVerifyCode; } + set { _canLoginWithMobileVerifyCode = value; } + } + + } +} diff --git a/DogAuth.BO/DogAuthPlugin.cs b/DogAuth.BO/DogAuthPlugin.cs new file mode 100644 index 0000000..1f4b3c2 --- /dev/null +++ b/DogAuth.BO/DogAuthPlugin.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using Bwp.MainSystem.Auth; +using Forks.EnterpriseServices.BusinessInterfaces; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.SqlDoms; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3DogAuth { + public class DogAuthPlugin : IAuthPlugin { + public void Auth(IDictionary context) { + if (UserAndPasswordOnly(context)) { + return; + } + if (context.ContainsKey("SkipPasswordAuth")) { + return; + } + var name = (string)context["Name"]; + + if (context.ContainsKey("VerifyCode")) { + var verifyCode = (string)context["VerifyCode"]; + if (!MobileAuthCenter.Auth(name, verifyCode)) { + throw new Exception("验证码不正确"); + } + } + else { + int dogNo; + if (int.TryParse(name, out dogNo)) { + context["Name"] = DogNoToUserName(dogNo); + context.Add("DogAuthNo", name); + } + else { + if (AllowNoDog) { + CheckNoDogUserName(name); + } + else { + throw new WpfException("Internal error: 43bb83d0-3388-4cde-9459-4dc9a44918e4 " + name); + } + } + } + } + + static bool UserAndPasswordOnly(IDictionary context) { + return context.EGetDefault("UserAndPasswordOnly"); + } + + static string DogNoToUserName(int dogNo) { + IDogLoginUserBL bl = BIFactory.Create(); + var dogLoginUser = bl.Load(dogNo); + if (dogLoginUser == null) { + throw new WpfException(string.Format("您当前的黑贝序号是{0},没有在黑贝认证中定义", dogNo)); + } + return dogLoginUser.User_Name; + } + + static void CheckNoDogUserName(string userName) { + var query = new DQueryDom(new JoinAlias(typeof(DogLoginUser))); + query.Where.Conditions.Add(DQCondition.EQ("User_Name", userName)); + query.Range = SelectRange.Top(1); + query.Columns.Add(DQSelectColumn.Field("ID")); + using (IDmoSession session = Dmo.NewSession()) { + if (session.ExecuteScalar(query) != null) { + throw new Exception(string.Format("用户名{0}必须使用黑贝登录", userName)); + } + } + } + + public static bool AllowNoDog { + get { return Wpf.Parameters.AsBool("B3DogAuth.AllowUnConfigedDog"); } + } + + } +} diff --git a/DogAuth.BO/DogLoginUser.cs b/DogAuth.BO/DogLoginUser.cs new file mode 100644 index 0000000..7d370bf --- /dev/null +++ b/DogAuth.BO/DogLoginUser.cs @@ -0,0 +1,42 @@ +using System; +using BWP.B3Frameworks.BO; +using Forks.EnterpriseServices; +using Forks.EnterpriseServices.DataForm; +using Forks.EnterpriseServices.DomainObjects2; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3DogAuth { + [LogicName("黑贝认证")] + [Serializable] + [DFClass] + [KeyField("ID", KeyGenType.assigned)] + [DFCPrompt("序号", Property = "ID")] + public class DogLoginUser : Base { + [LogicName("用户ID")] + [DFNotEmpty] + public long User_ID { + get; + set; + } + + [ReferenceTo(typeof(WpfUser), "Name")] + [Join("User_ID", "ID")] + [LogicName("用户名")] + public string User_Name { + get; + set; + } + + + [ReferenceTo(typeof(WpfUser), "Stopped")] + [Join("User_ID", "ID")] + [LogicName("停用")] + public bool? Stopped { get; set; } + + [LogicName("备注")] + public string Remark { + get; + set; + } + } +} diff --git a/DogAuth.BO/IDogLoginUserBL.cs b/DogAuth.BO/IDogLoginUserBL.cs new file mode 100644 index 0000000..df94fb1 --- /dev/null +++ b/DogAuth.BO/IDogLoginUserBL.cs @@ -0,0 +1,32 @@ +using System; +using BWP.B3Frameworks.BL; +using Forks.EnterpriseServices.BusinessInterfaces; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; + +namespace BWP.B3DogAuth { + [BusinessInterface(typeof(DogLoginUserBL))] + public interface IDogLoginUserBL : IBaseBL { + + } + + public class DogLoginUserBL : BaseBL, IDogLoginUserBL { + + protected override void beforeInsert(DogLoginUser dmo) { + if (dmo.ID == 0) + throw new Exception("黑贝序号不能为空"); + + if (dmo.User_ID == 0) + throw new Exception("用户名不能为空"); + + DQueryDom query = new DQueryDom(new JoinAlias(typeof(DogLoginUser))); + query.Where.Conditions.Add(DQCondition.Or(DQCondition.EQ("ID", dmo.ID), DQCondition.EQ("User_ID", dmo.User_ID))); + query.Columns.Add(DQSelectColumn.Field("ID")); + if (Session.ExecuteScalar(query) != null) { + throw new Exception("黑贝序号或用户已定义"); + } + + base.beforeInsert(dmo); + } + } +} diff --git a/DogAuth.BO/MobileAuthCenter.cs b/DogAuth.BO/MobileAuthCenter.cs new file mode 100644 index 0000000..2759110 --- /dev/null +++ b/DogAuth.BO/MobileAuthCenter.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Concurrent; +using System.Text; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3DogAuth { + public class MobileAuthCenter { + static ConcurrentDictionary> mDic = new ConcurrentDictionary>(); + + public static string GenVerifyCode(string username) { + var code = GenRandomCode(); + var tuple = GenRandomCode(); + mDic.AddOrUpdate(username, tuple, (arg1, arg2) => tuple); + return tuple.Item1; + } + + public static bool Auth(string username, string verifyCode) { + Tuple tuple; + if (mDic.TryGetValue(username, out tuple)) { + if (tuple.Item2 < BLContext.Now) { + mDic.TryRemove(username, out tuple); + return false; + } + else if (tuple.Item1 == verifyCode) { + return true; + } + else { + return false; + } + } + else { + return false; + } + } + + + static Tuple GenRandomCode() { + var rand = new Random(BLContext.Now.GetHashCode()); + var builder = new StringBuilder(); + for (int i = 0; i < 4; i++) { + builder.Append(rand.Next(9)); + } + return new Tuple(builder.ToString(), BLContext.Now.AddMinutes(5)); + } + + } +} diff --git a/DogAuth.BO/Properties/AssemblyInfo.cs b/DogAuth.BO/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e2083ed --- /dev/null +++ b/DogAuth.BO/Properties/AssemblyInfo.cs @@ -0,0 +1,39 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Forks.EnterpriseServices.DomainObjects2; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DogAutho.BO")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DogAutho.BO")] +[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ff948712-0f29-4c17-90ae-30221d8da53b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] + +[assembly: AssemblyMapToTablePrefix("DogAuth_")] + diff --git a/DogAuth.Web/B3DogAuth.Web.csproj b/DogAuth.Web/B3DogAuth.Web.csproj new file mode 100644 index 0000000..f35b5c0 --- /dev/null +++ b/DogAuth.Web/B3DogAuth.Web.csproj @@ -0,0 +1,125 @@ + + + + Debug + AnyCPU + + + 2.0 + {ACA4C314-5B8F-4888-9D58-49B925B233D6} + Library + Properties + Bwp.Web.Pages + B3DogAuth.Web + v4.0 + 512 + TSingSoft + + + true + full + false + bin\Debug\ + TRACE;DEBUG;CODE_ANALYSIS + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\tsref\Debug\B3Frameworks.dll + + + False + ..\..\..\tsref\Debug\B3Frameworks.Web.dll + + + False + False + + + False + False + + + False + False + + + False + False + + + False + + + False + + + False + + + False + + + + False + + + False + False + + + False + False + + + False + False + + + False + False + + + + + tslib_version.cs + + + + ASPXCodeBehind + + + + + + + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE} + B3DogAuth + False + + + + + + + + + + + \ No newline at end of file diff --git a/DogAuth.Web/DogAuthLoginPlugin.cs b/DogAuth.Web/DogAuthLoginPlugin.cs new file mode 100644 index 0000000..e3f9693 --- /dev/null +++ b/DogAuth.Web/DogAuthLoginPlugin.cs @@ -0,0 +1,402 @@ +using System; +using System.Collections.Generic; +using System.Web.UI.HtmlControls; +using Bwp.Web.Pages.FrameworkPages; +using TSingSoft.WebControls2; +using TSingSoft.WebPluginFramework; +using System.Web.UI; +using TSingSoft.WebPluginFramework.Exports; +using System.Web.UI.WebControls; +using Forks.EnterpriseServices.BusinessInterfaces; +using System.Web; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using Forks.EnterpriseServices.DomainObjects2; +using Bwp.MainSystem.BO; +using Forks.EnterpriseServices.SqlDoms; +using System.Collections.Concurrent; +using System.Text; +using System.Web.Script.Serialization; +using BWP.B3DogAuth; +using BWP.B3Frameworks.BL; +using BWP.B3Frameworks.BO; +using BWP.B3Frameworks.BO.NamedValueTemplate; + +[assembly: WebResource("Bwp.Web.Pages.TSSecurityInstall2.exe", Mimes.OctetStream)] + +namespace Bwp.Web.Pages { + class DogAuthLoginPlugin : IWpfLoginPlugin { + + class GetUserInfo : WebControl, ICallbackEventHandler { + public string GetCallbackResult() { + return result; + } + + string result = string.Empty; + + public void RaiseCallbackEvent(string eventArgument) { + long dogNo; + if (!long.TryParse(eventArgument, out dogNo)) { + IUserBL userBL = BIFactory.Create(); + if (!userBL.Exist(eventArgument)) + result = "用户不存在"; + return; + } + IDogLoginUserBL bl = BIFactory.Create(); + DogLoginUser user = bl.Load(dogNo); + if (user == null) { + result = "未配置"; + } + else { + result = user.User_Name; + } + } + } + + + class SendMobileVerifyCode : WebControl, ICallbackEventHandler { + + string mResult = string.Empty; + public string GetCallbackResult() { + return mResult; + } + + public void RaiseCallbackEvent(string eventArgument) { + var serializer = new JavaScriptSerializer(); + var info = serializer.Deserialize>(eventArgument); + var username = info["username"]; + var password = info["password"]; + var config = new DogAuthConfig(); + if (config.CloseMobileVerifyCode) { + bool loginByMobileVerifyCode = false; + foreach (var user in config.CanLoginWithMobileVerifyCode.Value) { + if (user == username) { + loginByMobileVerifyCode = true; + break; + } + } + if (!loginByMobileVerifyCode) { + mResult = "手机验证码登陆功能已关闭"; + return; + } + } + var wpfuser =new JoinAlias(typeof(WpfUser)); + var pro = new JoinAlias(typeof(UserBasicProfile)); + var query = new DQueryDom(pro); + query.From.AddJoin(JoinType.Left,new DQDmoSource(wpfuser),DQCondition.EQ(wpfuser,"ID",pro,"ID") ); + query.Where.Conditions.Add(DQCondition.EQ(wpfuser,"Name", username)); + query.Columns.Add(DQSelectColumn.Field("Mobile",pro)); + query.Range = SelectRange.Top(1); + var mobile = query.EExecuteScalar(); + if (string.IsNullOrEmpty(mobile)) { + mResult = string.Format("用户{0}不存在或未设置手机号", username); + return; + } + + var userBL = BIFactory.Create(); + try { + userBL.ValidUser(username, password); + } + catch { + mResult = "用户名或密码错误"; + return; + } + + var verifyCode = MobileAuthCenter.GenVerifyCode(username); + var externalMessage = new ExternalMessage(); + externalMessage.Content = string.Format("您的登录验证码是{0},5分钟后该验证码将失效", verifyCode); + externalMessage.Receiver = mobile; + externalMessage.ReceiverName = username; + externalMessage.Type = ExternalMessageType.短信; + try { + var messageBL = BIFactory.Create(); + using (var scope = new WpfInternalUserScope()) { +#if !DEBUG + messageBL.Insert(externalMessage); +#endif + } + mResult = "验证码已发送"; +#if DEBUG + mResult += verifyCode; +#endif + } + catch (Exception ex) { + mResult = string.Format("短信发送失败:" + ex.Message); + } + + } + } + + static HtmlTableRow CreateClientDogDownloadRow() { + HtmlTableRow tr = new HtmlTableRow(); + var cell = tr.EAdd(new HtmlTableCell { + ColSpan = 2, + Align = "center", + InnerHtml = "下载黑贝客户端" + }); + + return tr; + } + + GetUserInfo getUserInfo; + + SendMobileVerifyCode sendMobileVerifyCode; + + LinkButton switchDogButton; + public void CreateExtraControls(WpfLogin self, HtmlTable tbl) { + if (BrowserIsIE) { + CreateExtraControl_IE(self, tbl); + } + else { + CreateExtraControl_NotIE(self, tbl); + } + } + + TextBox verifyCodeInput; + private void CreateExtraControl_NotIE(WpfLogin self, HtmlTable tbl) { + sendMobileVerifyCode = new SendMobileVerifyCode(); + tbl.Rows[0].Cells[0].Controls.Add(sendMobileVerifyCode); + + var row = new HtmlTableRow(); + tbl.Rows.Insert(2, row); + var cell1 = new HtmlTableCell(); + cell1.ColSpan = 2; + cell1.Attributes["class"] = "verifyCodeLabel"; + row.Cells.Add(cell1); + verifyCodeInput = new TextBox() { Width = Unit.Pixel(80) }; + verifyCodeInput.CssClass = "verifyCodeInput"; + verifyCodeInput.Attributes["placeholder"] = "输入验证码"; + cell1.Controls.Add(verifyCodeInput); + + var row2 = new HtmlTableRow(); + var verifyCodeCell = new HtmlTableCell(); + verifyCodeCell.Style.Add(HtmlTextWriterStyle.Color, "red"); + verifyCodeCell.Controls.Add(new LiteralControl("")); + verifyCodeCell.ColSpan = 2; + row2.Cells.Add(verifyCodeCell); + tbl.Rows.Insert(3, row2); + + } + + private void CreateExtraControl_IE(WpfLogin self, HtmlTable tbl) { + tbl.EAdd(CreateClientDogDownloadRow()); + + getUserInfo = new GetUserInfo(); + HtmlTableRow tr = new HtmlTableRow(); + HtmlTableCell td = new HtmlTableCell(); + td.ColSpan = 2; + tr.Cells.Add(td); + tbl.Rows.Add(tr); + td.Controls.Add(getUserInfo); + + switchDogButton = new LinkButton(); + if (DogAuthPlugin.AllowNoDog) { + td.Controls.Add(switchDogButton); + switchDogButton.Click += (sender, e) => { + if (!mAllowNoDog) { + self.Page.Response.Cookies.Add(new HttpCookie("NoDog", "NoDog") { Expires = DateTime.MaxValue }); + AspUtil.Redirect(self.Page.Request.RawUrl); + self.Page.Response.Redirect(self.Page.Request.RawUrl); + } + else { + self.Page.Response.Cookies["NoDog"].Expires = DateTime.Now.AddYears(-1); + AspUtil.Redirect(self.Page.Request.RawUrl); + } + }; + } + } + + public void InitPamContext(WpfLogin self, IDictionary pamContext) { + //这里不能根据verifyCodeInput是否为空来判断,当verifyCodeInput被用到后就不再为空 + //可能和asp.net页面的内部机制有关系 + if (!BrowserIsIE && verifyCodeInput != null) { + pamContext.Add("VerifyCode", verifyCodeInput.Text); + } + } + + bool BrowserIsIE { + get { + return BrowserContext.Current.Browser == "IE"; + } + } + + bool mAllowNoDog = false; + public void OnLoad(WpfLogin self) { + if (BrowserIsIE) { + mAllowNoDog = DogAuthPlugin.AllowNoDog && self.Page.Request.Cookies["NoDog"] != null; + if (!mAllowNoDog) { + switchDogButton.Text = "切换到不使用黑贝登录"; + self.UserNameTextBox.ReadOnly = true; + RegisterClientDog(self); + } + else { + switchDogButton.Text = "切换到使用黑贝登录"; + } + } + else { + RegisterMobileLogin(self); + } + } + + private void RegisterMobileLogin(WpfLogin self) { + + var script = @" +function GetVerifyCode(){ + var username = $('input[type=text]:first').val(); + var password = $('input[type=password]:first').val(); + var callbackdata = JSON.stringify({username:username,password:password}); + {Callback} +} + +function ReceiveServerData(value){ +$('#VerifyCodeInfo').text(value); +} +$(""获取验证码"").insertAfter(""input[type=password]:first"") +"; + script = script.Replace("{Callback}", self.Page.ClientScript.GetCallbackEventReference(sendMobileVerifyCode, "callbackdata", "ReceiveServerData", null)); + + self.Page.ClientScript.RegisterStartupScript(typeof(WpfLogin), "ClientDog", script, true); + } + + void RegisterClientDog(WpfLogin self) { + self.UserNameTextBox.Attributes["onchange"] = "SetDogInfo();"; + + string script = + "var dogDate='" + new DateTime(2000, 1, 1).ToString("yyyy-MM-dd") + "';" + + "var uid=document.all." + self.UserNameTextBox.ClientID + ";" + + "var btn=document.all." + self.LoginButton.ClientID + ";" + + @" +btn.disabled = true; +var checkObj; + +var dog = -1; +function SetDogInfo() +{ +{Callback} +} +function ReceiveServerData(value) +{ + var span = uid.nextSibling; + if(span == null || span.tagName != 'SPAN') + { + span = document.createElement('span'); + $(span).css('color',$(uid).css('color')); + $(span).css('fontSize',$(uid).css('fontSize')); + $(span).css('fontFamily',$(uid).css('fontFamily')); + uid.insertAdjacentElement('afterEnd',span); + } + span.innerText = value; + span.innerText += '|' + uid.value;; +} +function CheckSign() { + if(checkObj.DogNo == dog) { + dog = checkObj.DogNo; + window.setTimeout('CheckSign()',1000); + return; + } + + var msg = checkObj.CheckSign(dogDate); + if(msg != '') { + var result = confirm(msg+',继续吗?'); + if(!result){return;} + uid.value = ''; + btn.disabled = true; + window.setTimeout('CheckSign()',1000); + } else { + dog = checkObj.DogNo; + uid.value=dog; + SetDogInfo(); + uid.style.display='none'; + btn.disabled = false; + window.setTimeout('CheckSign()',1000); + } +} +var driverInstall = false; +try { + checkObj = new ActiveXObject('TSSecurity.UserSign'); + driverInstall = true; +} catch(e) { + lnkdownload.style.visibility = 'visible'; + alert('没有安装客户端狗的驱动,不能使用本系统.'); +} + +if(driverInstall == true) + CheckSign(); +"; + script = script.Replace("{Callback}", self.Page.ClientScript.GetCallbackEventReference(getUserInfo, "uid.value", "ReceiveServerData", null)); + self.Page.ClientScript.RegisterStartupScript(typeof(WpfLogin), "ClientDog", script, true); + // RegisterAjaxScript(self.Page); + } + +// public void RegisterAjaxScript(Page page) { +// const string script = @" +//"; +// page.ClientScript.RegisterClientScriptBlock(page.GetType(), "Ajax", script); +// } + } +} diff --git a/DogAuth.Web/DogLoginUserList.cs b/DogAuth.Web/DogLoginUserList.cs new file mode 100644 index 0000000..66345c7 --- /dev/null +++ b/DogAuth.Web/DogLoginUserList.cs @@ -0,0 +1,92 @@ +using System; +using TSingSoft.Web.Pages; +using TSingSoft.WebControls2; +using System.Web.UI; +using BWP.B3DogAuth; +using BWP.B3Frameworks; +using BWP.Web; +using BWP.Web.Utils; +using Forks.EnterpriseServices.BusinessInterfaces; + +namespace Bwp.Web.Pages { + class DogLoginUserList : ListPage { + + protected override void CreateDFBrowseGridColumns(DFBrowseGrid grid) { + AddDFBrowseGridColumn(grid, "ID"); + AddDFBrowseGridColumn(grid, "User_Name"); + AddDFBrowseGridColumn(grid, "Remark"); + AddDFBrowseGridColumn(grid, "Stopped"); + grid.AllowDeletion = CheckDefaultRole("删除"); + } + + protected override void InitGridToolbar(HLayoutPanel toolbar) { + AddInputControls(toolbar ); + } + + private IDogLoginUserBL bl = BIFactory.Create(); + + + void AddInputControls(HLayoutPanel hPanel) { + if (!CheckDefaultRole("新建")) + return; + + var dfContainer = new DFContainer(); + + hPanel.Add(new LiteralControl("序号:")); + DFTextBox idInput = hPanel.Add(dfContainer.Add(InputCreator.DFTextBox, "ID")); + hPanel.Add(new LiteralControl("用户:")); + DFChoiceBox userInput = hPanel.Add(dfContainer.Add(InputCreator.DFChoiceBox("Wpf_Users", "User_Name"), "User_ID")); + hPanel.Add(new LiteralControl("备注:")); + DFTextBox remarkInput = hPanel.Add(dfContainer.Add(InputCreator.DFTextBoxFromRemark, "Remark")); + TSButton button = new TSButton("新建"); + hPanel.Add(button); + button.Click += delegate(object sender, EventArgs e) { + dfContainer.DFObject = new DogLoginUser(); + dfContainer.GetFromUI(); + bl.Insert(dfContainer.DFObject); + + idInput.Text = string.Empty; + userInput.Value = string.Empty; + userInput.DisplayValue = string.Empty; + remarkInput.Text = string.Empty; + StartQuery(); + }; + } + + + protected override void AddQueryControls(VLayoutPanel vPanel) { + var tablePanel = new TableLayoutPanel(8, 2); + vPanel.Add(tablePanel); + int row = 0; + const int labelWidth = 4; + + tablePanel.Add(0, 1, row, row + 1, new DFLabel(mDFInfo.Fields["ID"], labelWidth)); + tablePanel.Add(1, 2, row, row + 1, mQueryContainer.Add(new DFTextBox(mDFInfo.Fields["ID"]), "ID")); + + tablePanel.Add(2, 3, row, row + 1, new DFLabel(mDFInfo.Fields["User_Name"], 4)); + tablePanel.Add(3, 4, row, row + 1, mQueryContainer.Add(new DFTextBox(mDFInfo.Fields["User_Name"]), "User_Name")); + + tablePanel.Add(4, 5, row, row + 1, new SimpleLabel("是否停用", 4)); + DFBoolComboBox boolComboBox; + tablePanel.Add(5, 6, row, row + 1, boolComboBox = mQueryContainer.Add(QueryCreator.DFBoolComboBox(mDFInfo.Fields["Stopped"]), "Stopped")); + boolComboBox.Value = false; + + tablePanel.Add(6, 7, row, row + 1, new DFLabel(mDFInfo.Fields["Remark"], 4)); + tablePanel.Add(7,8, row, row + 1, mQueryContainer.Add(new DFTextBox(mDFInfo.Fields["Remark"]), "Remark")); + } + + protected bool CheckDefaultRole(string lastRoleName, bool notExistsAsTrue = false) { + string fullRoleName = PluginName + "." + LogicName + "." + lastRoleName; + return CurrentUser.EIsInRole(fullRoleName, notExistsAsTrue); + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if (!IsPostBack) + { + StartQuery(); + } + } + } +} diff --git a/DogAuth.Web/DogLoginUserList.xml b/DogAuth.Web/DogLoginUserList.xml new file mode 100644 index 0000000..20ee878 --- /dev/null +++ b/DogAuth.Web/DogLoginUserList.xml @@ -0,0 +1,29 @@ + + diff --git a/DogAuth.Web/PluginClass.cs b/DogAuth.Web/PluginClass.cs new file mode 100644 index 0000000..ed7558f --- /dev/null +++ b/DogAuth.Web/PluginClass.cs @@ -0,0 +1,24 @@ + +using Bwp.MainSystem; +using Bwp.Web.Pages.FrameworkPages; +using Forks.Utils; +using TSingSoft.WebPluginFramework; +using TSingSoft.WebPluginFramework.DefinedParameters; +using BWP.B3DogAuth; + +namespace Bwp.Web.Pages { + class PluginClass : IPluginClass { + const string PluginName = "B3DogAuth"; + + public void OnInit() { + + Config.GlobalVars.Add("ClientDogCheck", true); + + Global.RegisterCustomPrePam(new DogAuthPlugin()); + WpfLogin.RegisterPlugin(new DogAuthLoginPlugin()); + var plugin = PluginManager.Current.FindByName(PluginName); + Wpf.ParameterManager.Define(plugin, Parameter.Boolean(PluginName + ".AllowUnConfigedDog", "允许不使用黑贝登录", true)); + } + + } +} diff --git a/DogAuth.Web/Properties/AssemblyInfo.cs b/DogAuth.Web/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..69747a2 --- /dev/null +++ b/DogAuth.Web/Properties/AssemblyInfo.cs @@ -0,0 +1,38 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using TSingSoft.WebPluginFramework; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DogNoAuth.Web")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DogNoAuth.Web")] +[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("71bc7718-5d5e-4c37-8c6e-62473254eb12")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] + + diff --git a/DogAuth.Web/TSSecurityInstall2.exe b/DogAuth.Web/TSSecurityInstall2.exe new file mode 100644 index 0000000..968526a Binary files /dev/null and b/DogAuth.Web/TSSecurityInstall2.exe differ diff --git a/DogAuth.sln b/DogAuth.sln new file mode 100644 index 0000000..58babeb --- /dev/null +++ b/DogAuth.sln @@ -0,0 +1,74 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebFolder", "WebFolder\", "{E469B325-BFC0-43BD-A2D9-608CEA64291E}" + ProjectSection(WebsiteProperties) = preProject + TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0" + ProjectReferences = "{ACA4C314-5B8F-4888-9D58-49B925B233D6}|DogAuth.Web.dll;{269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}|DogAuth.BO.dll;" + Debug.AspNetCompiler.VirtualPath = "/WebFolder" + Debug.AspNetCompiler.PhysicalPath = "WebFolder\" + Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\WebFolder\" + Debug.AspNetCompiler.Updateable = "true" + Debug.AspNetCompiler.ForceOverwrite = "true" + Debug.AspNetCompiler.FixedNames = "false" + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.VirtualPath = "/WebFolder" + Release.AspNetCompiler.PhysicalPath = "WebFolder\" + Release.AspNetCompiler.TargetPath = "PrecompiledWeb\WebFolder\" + Release.AspNetCompiler.Updateable = "true" + Release.AspNetCompiler.ForceOverwrite = "true" + Release.AspNetCompiler.FixedNames = "false" + Release.AspNetCompiler.Debug = "False" + VWDPort = "42895" + DefaultWebSiteLanguage = "Visual C#" + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "B3DogAuth", "DogAuth.BO\B3DogAuth.csproj", "{269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "B3DogAuth.Web", "DogAuth.Web\B3DogAuth.Web.csproj", "{ACA4C314-5B8F-4888-9D58-49B925B233D6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|.NET = Debug|.NET + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Release|.NET = Release|.NET + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E469B325-BFC0-43BD-A2D9-608CEA64291E}.Debug|.NET.ActiveCfg = Debug|.NET + {E469B325-BFC0-43BD-A2D9-608CEA64291E}.Debug|.NET.Build.0 = Debug|.NET + {E469B325-BFC0-43BD-A2D9-608CEA64291E}.Debug|Any CPU.ActiveCfg = Debug|.NET + {E469B325-BFC0-43BD-A2D9-608CEA64291E}.Debug|Mixed Platforms.ActiveCfg = Debug|.NET + {E469B325-BFC0-43BD-A2D9-608CEA64291E}.Debug|Mixed Platforms.Build.0 = Debug|.NET + {E469B325-BFC0-43BD-A2D9-608CEA64291E}.Release|.NET.ActiveCfg = Debug|.NET + {E469B325-BFC0-43BD-A2D9-608CEA64291E}.Release|.NET.Build.0 = Debug|.NET + {E469B325-BFC0-43BD-A2D9-608CEA64291E}.Release|Any CPU.ActiveCfg = Debug|.NET + {E469B325-BFC0-43BD-A2D9-608CEA64291E}.Release|Mixed Platforms.ActiveCfg = Debug|.NET + {E469B325-BFC0-43BD-A2D9-608CEA64291E}.Release|Mixed Platforms.Build.0 = Debug|.NET + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}.Debug|.NET.ActiveCfg = Debug|Any CPU + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}.Release|.NET.ActiveCfg = Release|Any CPU + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}.Release|Any CPU.Build.0 = Release|Any CPU + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {269C33B6-9ACC-4E3F-9BD2-B2AAB620E5DE}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {ACA4C314-5B8F-4888-9D58-49B925B233D6}.Debug|.NET.ActiveCfg = Debug|Any CPU + {ACA4C314-5B8F-4888-9D58-49B925B233D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ACA4C314-5B8F-4888-9D58-49B925B233D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ACA4C314-5B8F-4888-9D58-49B925B233D6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {ACA4C314-5B8F-4888-9D58-49B925B233D6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {ACA4C314-5B8F-4888-9D58-49B925B233D6}.Release|.NET.ActiveCfg = Release|Any CPU + {ACA4C314-5B8F-4888-9D58-49B925B233D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ACA4C314-5B8F-4888-9D58-49B925B233D6}.Release|Any CPU.Build.0 = Release|Any CPU + {ACA4C314-5B8F-4888-9D58-49B925B233D6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {ACA4C314-5B8F-4888-9D58-49B925B233D6}.Release|Mixed Platforms.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/WebFolder/config/Plugins/B3DogAuth.plugin b/WebFolder/config/Plugins/B3DogAuth.plugin new file mode 100644 index 0000000..d875c05 --- /dev/null +++ b/WebFolder/config/Plugins/B3DogAuth.plugin @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file