// Called when loop is created public bool Initialize() { // Find the process if (RemotePlayProcess == null || (RemotePlayProcess != null && RemotePlayProcess.HasExited)) { RemotePlayProcess = ScriptUtility.FindRemotePlayProcess(); } // Find panel in process var panelHandle = ScriptUtility.FindStreamingPanel(RemotePlayProcess); // Check for panel if (panelHandle == null || panelHandle == IntPtr.Zero) { throw new Exception("Streaming panel not found in child handles"); } // Create WindowControl WindowControl = new WindowControl(RemotePlayProcess.MainWindowHandle, panelHandle); // Resize window WindowControl.ResizeWindow(Config.TargetSize); // Remember that this happened IsInitialized = true; return(true); }
private void RegisterStarupScriptIfNeeded(BocBooleanValueRenderingContext renderingContext, BocBooleanValueResourceSet resourceSet) { string startUpScriptKey = s_startUpScriptKeyPrefix + resourceSet.ResourceKey; if (!renderingContext.Control.Page.ClientScript.IsStartupScriptRegistered(typeof(BocBooleanValueRenderer), startUpScriptKey)) { string trueValue = true.ToString(); string falseValue = false.ToString(); string nullValue = c_nullString; string startupScript = string.Format( "BocBooleanValue_InitializeGlobals ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}');", resourceSet.ResourceKey, trueValue, falseValue, nullValue, ScriptUtility.EscapeClientScript(resourceSet.DefaultTrueDescription), ScriptUtility.EscapeClientScript(resourceSet.DefaultFalseDescription), ScriptUtility.EscapeClientScript(resourceSet.DefaultNullDescription), resourceSet.TrueIconUrl, resourceSet.FalseIconUrl, resourceSet.NullIconUrl); renderingContext.Control.Page.ClientScript.RegisterStartupScriptBlock( renderingContext.Control, typeof(BocBooleanValueRenderer), startUpScriptKey, startupScript); } }
private string GetItemScript(int itemIndex) { const string itemTemplate = "new ListMenuItemInfo ('{0}', '{1}', {2}, {3}, {4}, {5}, {6}, {7}, {8})"; var menuItem = (WebMenuItem)_control.MenuItems[itemIndex]; string href; string target = "null"; if (menuItem.Command.Type == CommandType.Href) { href = menuItem.Command.HrefCommand.FormatHref(itemIndex.ToString(), menuItem.ItemID); href = "'" + href + "'"; target = "'" + menuItem.Command.HrefCommand.Target + "'"; } else { string argument = itemIndex.ToString(); href = _control.Page.ClientScript.GetPostBackClientHyperlink(_control, argument) + ";"; href = ScriptUtility.EscapeClientScript(href); href = "'" + href + "'"; } return(string.Format( itemTemplate, _control.ClientID + "_" + itemIndex, menuItem.Category, menuItem.Style != WebMenuItemStyle.Icon ? "'" + menuItem.Text + "'" : "null", menuItem.Style != WebMenuItemStyle.Text ? "'" + menuItem.Icon.Url.TrimStart('~') + "'" : "null", menuItem.Style != WebMenuItemStyle.Text ? "'" + menuItem.DisabledIcon.Url.TrimStart('~') + "'" : "null", (int)menuItem.RequiredSelection, (itemIndex == 4) ? "true" : "false", href, target)); }
void ShowComponent(SerializedProperty arrayProperty, int index, SerializedProperty property) { var script = ScriptUtility.FindScript(currentComponent.GetType()); var label = GUIContent.none; if (script == null) { var name = currentComponent.GetTypeName(); if (name.EndsWith("Component")) { name = name.Substring(0, name.Length - "Component".Length); } label = name.ToGUIContent(); } else { var position = GUILayoutUtility.GetRect(label, EditorStyles.label, GUILayout.Height(0f)); position.width -= 38f; position.height = 16f; EditorGUI.ObjectField(position, script, typeof(MonoScript), false); } ObjectField(currentComponent, label); }
public object Execute(ScriptUtility x, object input) { if(!x.TaskBag.Has(SETTING_BROWSING_SESSION)) { x.TaskBag.Set(SETTING_BROWSING_SESSION, _context.Resolve<IBrowsingSession>()); } return x.TaskBag.Get<IBrowsingSession>(SETTING_BROWSING_SESSION); }
private void InitScriptUtility(IComponentContext context) { if (scriptUtility == null) { scriptUtility = context.Resolve<ScriptUtility>(); scriptUtility.Settings = Settings; } }
private void InitScriptUtility(IComponentContext context) { if (scriptUtility == null) { scriptUtility = context.Resolve <ScriptUtility>(); scriptUtility.Settings = Settings; } }
public object Execute(ScriptUtility x, object input) { if (!x.TaskBag.Has(SETTING_BROWSING_SESSION)) { x.TaskBag.Set(SETTING_BROWSING_SESSION, _context.Resolve <IBrowsingSession>()); } return(x.TaskBag.Get <IBrowsingSession>(SETTING_BROWSING_SESSION)); }
/// <summary> /// Run selected script with 2/3 parameters for all rows of SQL. /// If you choose isWithAsk=true /// </summary> /// <param name="model"></param> /// <param name="sql"></param> /// <param name="function"></param> /// <param name="isWithAsk">Ask if execute, skip script execution or break altogether</param> /// <returns></returns> public static bool RunScriptWithAsk(Model model, string sql, ScriptFunction function, bool isWithAsk = false) { string scriptName = function.Owner.Name; string functionName = function.Name; int scriptParCount = function.NumberOfParameters; // Check parameter count of function if (scriptParCount < 2 || scriptParCount > 3) { MessageBox.Show($@"Function: '{scriptName}:{functionName} count of parameters={scriptParCount}", @"Count of parameters for function shall be 2 or 3 (object_type, Id, Model), Break!!!!"); return false; } // get SQL string xml = model.SqlQueryWithException(sql); if (xml == null) return false; // Output the query in EA Search Window string target = model.MakeEaXmlOutput(xml); model.Repository.RunModelSearch("", "", "", target); // get rows / items to call function List<EaItem> eaItemList = model.MakeEaItemListFromQuery(XDocument.Parse(xml)); int countCurrent = 0; int count = eaItemList.Count; foreach (EaItem item in eaItemList) { switch (scriptParCount) { case 2: case 3: // run script bool run = true; if (isWithAsk) { // run the function with two or three parameters DialogResult result = MessageBox.Show($@"Function '{functionName}', Item {countCurrent} of {count}", @"YES=Execute,No=Skip execution, Cancel=Break,", MessageBoxButtons.YesNoCancel); if (result.Equals(DialogResult.No)) run = false; if (result.Equals(DialogResult.Cancel)) return false; } if (run) // run script { countCurrent += 1; if (countCurrent%20 == 0) model.Repository.WriteOutput("Script", $"{functionName}: {countCurrent} of {count}", 0); if (ScriptUtility.RunScriptFunction(model, function, item.EaObjectType, item.EaObject) == false) return false; } continue; default: MessageBox.Show($@"Script parameter count shall be 2 or 3, is {scriptParCount}", @"Invalid count of function parameters, Break!!!!"); break; } } return true; }
private void AppendMenuItem(DropDownMenuRenderingContext renderingContext, StringBuilder stringBuilder, WebMenuItem menuItem, int menuItemIndex) { string href = "null"; string target = "null"; bool isCommandEnabled = true; if (menuItem.Command != null) { bool isActive = menuItem.Command.Show == CommandShow.Always || renderingContext.Control.IsReadOnly && menuItem.Command.Show == CommandShow.ReadOnly || !renderingContext.Control.IsReadOnly && menuItem.Command.Show == CommandShow.EditMode; isCommandEnabled = isActive && menuItem.Command.Type != CommandType.None; if (isCommandEnabled) { bool isPostBackCommand = menuItem.Command.Type == CommandType.Event || menuItem.Command.Type == CommandType.WxeFunction; if (isPostBackCommand) { // Clientside script creates an anchor with href="#" and onclick=function string argument = menuItemIndex.ToString(); href = renderingContext.Control.Page.ClientScript.GetPostBackClientHyperlink(renderingContext.Control, argument); href = ScriptUtility.EscapeClientScript(href); href = "'" + href + "'"; } else if (menuItem.Command.Type == CommandType.Href) { href = menuItem.Command.HrefCommand.FormatHref(menuItemIndex.ToString(), menuItem.ItemID); href = "'" + renderingContext.Control.ResolveClientUrl(href) + "'"; target = "'" + menuItem.Command.HrefCommand.Target + "'"; } } } bool showIcon = menuItem.Style == WebMenuItemStyle.Icon || menuItem.Style == WebMenuItemStyle.IconAndText; bool showText = menuItem.Style == WebMenuItemStyle.Text || menuItem.Style == WebMenuItemStyle.IconAndText; string icon = GetIconUrl(renderingContext, menuItem, showIcon); string disabledIcon = GetDisabledIconUrl(renderingContext, menuItem, showIcon); string text = showText ? "'" + menuItem.Text + "'" : "null"; bool isDisabled = !menuItem.EvaluateEnabled() || !isCommandEnabled; stringBuilder.AppendFormat( "\t\tnew DropDownMenu_ItemInfo ('{0}', '{1}', {2}, {3}, {4}, {5}, {6}, {7}, {8})", menuItemIndex, menuItem.Category, text, icon, disabledIcon, (int)menuItem.RequiredSelection, isDisabled ? "true" : "false", href, target); }
/// <summary> /// Invokes the ScriptFunction with 2 or 3 Parameters. /// </summary> /// <param name="model"></param> /// <returns></returns> public string Invoke(Model model) { if (ScriptFunction != null) { EA.ObjectType eaObjectType = model.Repository.GetContextItemType(); object eaObject = model.Repository.GetContextObject(); ScriptUtility.RunScriptFunction(model, ScriptFunction, eaObjectType, eaObject); } return(null); }
public object Execute(ScriptUtility x, object input) { var uri = input as Uri; var browser = x.Exec<IBrowsingSession>("GetBrowsingSession") as StatefullBrowsingSessionWrapper; if (browser != null) { x.Exec("ClearCacheEntry", input); } return x.Exec<IBrowsingSession>("GetBrowsingSession").TrySwitchProxy(uri); }
public object Execute(ScriptUtility x, object input) { var script = input as string; x.Flow.AddMessage("RunGoalInline: " + script); var task = taskFactory.InitTaskFromContainer(script, x.Settings.AsDictionary()); task.Progress.Update += (p) => x.Flow.AddMessage(p.Message); x.Flow.IsTrue(taskFactory.RunTaskUntilFinished(task)>=ScheduleMessageState.Error).Fail("Inline action error"); return null; }
private void ResizeRemotePlayForm_Load(object sender, EventArgs e) { try { var size = ScriptUtility.GetWindowSize(); widthNumericUpDown.Value = size.Width; heightNumericUpDown.Value = size.Height; } catch {} }
public string Archive(FormCollection form) { string id = form["id"]; //文档编号 Member member; //会员 //提交留言 if (form["action"] == "comment") { id = form["ce_id"]; string view_name = form["ce_nickname"]; string content = form["ce_content"]; int memberID; member = UserState.Member.Current; //校验验证码 if (!CheckVerifyCode(form["ce_verifycode"])) { return(ScriptUtility.ParentClientScriptCall("cetip(false,'验证码不正确!');cms.$('ce_verifycode').nextSibling.onclick();")); } else if (String.Compare(content, "请在这里输入评论内容", true) == 0 || content.Length == 0) { return(ScriptUtility.ParentClientScriptCall("cetip(false,'请输入内容!'); ")); } else if (content.Length > 200) { return(ScriptUtility.ParentClientScriptCall("cetip(false,'评论内容长度不能大于200字!'); ")); } if (member == null) { if (String.IsNullOrEmpty(view_name)) { //会员未登录时,需指定名称 return(ScriptUtility.ParentClientScriptCall("cetip(false,'不允许匿名评论!'); ")); } else { //补充用户 content = String.Format("(u:'{0}'){1}", view_name, content); memberID = 0; } } else { memberID = UserState.Member.Current.ID; } cmbll.InsertComment(id, memberID, Request.UserHostAddress, content); return(ScriptUtility.ParentClientScriptCall("cetip(false,'提交成功!'); setTimeout(function(){location.reload();},500);")); } //其他操作 return(String.Empty); }
public object Execute(ScriptUtility x, object input) { var uri = input as Uri; var browser = x.Exec <IBrowsingSession>("GetBrowsingSession") as StatefullBrowsingSessionWrapper; if (browser != null) { x.Exec("ClearCacheEntry", input); } return(x.Exec <IBrowsingSession>("GetBrowsingSession").TrySwitchProxy(uri)); }
protected void AppendStringValueOrNullToScript(StringBuilder scriptBuilder, string stringValue) { if (string.IsNullOrEmpty(stringValue)) { scriptBuilder.Append("null"); } else { scriptBuilder.Append("'").Append(ScriptUtility.EscapeClientScript(stringValue)).Append("'"); } }
public object Execute(ScriptUtility x, object input) { var script = input as string; x.Flow.AddMessage("RunGoalInline: " + script); var task = taskFactory.InitTaskFromContainer(script, x.Settings.AsDictionary()); task.Progress.Update += (p) => x.Flow.AddMessage(p.Message); x.Flow.IsTrue(taskFactory.RunTaskUntilFinished(task) >= ScheduleMessageState.Error).Fail("Inline action error"); return(null); }
private void RefreshMetadata() { Variables = ScriptUtility.LoadMultiTag(text, @"<<(\w+?)>>").Distinct(); subsets = ScriptUtility.LoadMultiTag(text, @"{{Subset=([\w<>]+?)}}").ToList(); timeout = ScriptUtility.LoadTag(text, @"{{Timeout=([\w<>]+?)}}") ?? "6000"; warning = ScriptUtility.LoadTag(text, @"{{Warning=(.+?)}}"); database = ScriptUtility.LoadTag(text, @"{{Database=(.+?)}}"); }
public string Invoke(Model model) { if (Function != null) { EA.ObjectType objectType = model.Repository.GetContextItemType(); object oContext = (object)model.Repository.GetContextObject(); object[] par = { oContext, objectType, }; //Function.Execute(par); ScriptUtility.RunScriptFunction(model, Function, objectType, oContext); } return(null); }
public void Init( SchedulerTaskScriptDependencies dependencies, ITaskSettings settings, ScriptFlow flow, ScriptUtility utils ) { this.x = utils; this.Settings = settings; this.Flow = flow; this.Dependencies = dependencies; if (dependencies!=null && dependencies.GetType() != DependencyClassType) throw new InvalidOperationException("Wrong dependency class provided"); }
private void resizeButton_Click(object sender, EventArgs e) { try { Size size = new Size((int)widthNumericUpDown.Value, (int)heightNumericUpDown.Value); ScriptUtility.ResizeWindow(size); Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Resize Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// create property gameobject on the ui from the script's variables /// </summary> /// <param name="extract"></param> /// <param name="script"></param> /// <returns></returns> private Tuple <ScriptProperty, Action <string> >[] CreateScriptProperties(ScriptProperty[] extract, Script script) { if (extract == null) { extract = ScriptUtility.ExtractProperties(script); } var properties = new Tuple <ScriptProperty, Action <string> > [extract.Length]; for (var i = 0; i < properties.Length; ++i) { var index = i; var prop = extract[index]; Action <string> callback = null; switch (prop.type) { case PropertyType.Boolean: callback = s => { prop.value = s; extract[index] = prop; ScriptUtility.ApplyProperties(script, extract); }; break; case PropertyType.Number: callback = s => { var num = default(double); if (double.TryParse(s, out num)) { prop.value = s.ToString(); extract[index] = prop; ScriptUtility.ApplyProperties(script, extract); } }; break; case PropertyType.String: callback = s => { prop.value = s; extract[index] = prop; ScriptUtility.ApplyProperties(script, extract); }; break; } properties[i] = new Tuple <ScriptProperty, Action <string> > (prop, callback); } return(properties); }
/// <summary> /// Run Script for Tree selected Elements /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void runTreeSelectedToolStripMenuItem_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; // get Script DataGridViewRow rowToRun = dataGridViewScripts.Rows[_rowScriptsIndex]; DataRowView row = rowToRun.DataBoundItem as DataRowView; var scriptFunction = row["FunctionObj"] as ScriptFunction; foreach (EA.Element el in Repository.GetTreeSelectedElements()) { ScriptUtility.RunScriptFunction(Model, scriptFunction, el.ObjectType, el); } Cursor.Current = Cursors.Default; }
public object Execute(ScriptUtility x, object input) { var uri = input as Uri; var browser = x.Exec<IBrowsingSession>("GetBrowsingSession") as StatefullBrowsingSessionWrapper; if (browser != null) { browser.ClearCacheEntry(uri); x.Flow.AddMessage("Entry clean done for " + uri.Host); } else { throw new Exception("Not a StatefullBrowsingSession"); } return null; }
public void ResetPowerups() { foreach (Powerup p in ScriptUtility.GetComponentsOfType <Powerup>()) { if (p.isOwner) { p.Remove(); } } spawnPoints.ForEach(point => { if (point.isOwner) { point.Free(); } }); //Safety free spawnPoints.ForEach(point => point.SpawnPowerup()); }
public object Execute(ScriptUtility x, object input) { var uri = input as Uri; var browser = x.Exec <IBrowsingSession>("GetBrowsingSession") as StatefullBrowsingSessionWrapper; if (browser != null) { browser.ClearDomainCacheFor(uri); x.Flow.AddMessage("State clean done for " + uri.Host); } else { throw new Exception("Not a StatefullBrowsingSession"); } return(null); }
public object Execute(ScriptUtility x, object input) { var name = input as string; var sess = context.ResolveNamed<IBrowsingSession>(name); if (sess == null) throw new Exception("Session name '" + name + "' is not found"); var browser = x.Exec<IBrowsingSession>("GetBrowsingSession") as StatefullBrowsingSessionWrapper; if (browser != null) { browser.Parent = sess; } else { x.TaskBag.Set(GetBrowsingSessionScriptCommand.SETTING_BROWSING_SESSION, sess); } return null; }
/// <summary> /// Run Script for Context Item. Element, Attribute, Operation, Package, Diagram, Diagram Objects, Diagram Connector /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void runScriptSelectedItemToolStripMenuItem_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; // get Script DataGridViewRow rowToRun = dataGridViewScripts.Rows[_rowScriptsIndex]; DataRowView row = rowToRun.DataBoundItem as DataRowView; var scriptFunction = row["FunctionObj"] as ScriptFunction; ObjectType objectType = Repository.GetContextItemType(); switch (objectType) { case ObjectType.otDiagram: EA.Diagram dia = (EA.Diagram)Repository.GetContextObject(); if (dia.SelectedObjects.Count > 0) { foreach (EA.Element el in dia.SelectedObjects) { ScriptUtility.RunScriptFunction(Model, scriptFunction, ObjectType.otElement, el); } Cursor.Current = Cursors.Default; return; } if (dia.SelectedConnector != null) { ScriptUtility.RunScriptFunction(Model, scriptFunction, ObjectType.otConnector, dia.SelectedConnector); Cursor.Current = Cursors.Default; return; } ScriptUtility.RunScriptFunction(Model, scriptFunction, ObjectType.otDiagram, dia); break; default: ScriptUtility.RunScriptFunction(Model, scriptFunction, objectType, Repository.GetContextObject()); break; } Cursor.Current = Cursors.Default; }
public void ApplyScript() { var isScriptValid = false; try { var table = script.script.Globals; var dynValue = new List <DynValue> (); foreach (var key in table.Keys) { var value = table.Get(key); var dataType = value.Type; if (dataType == DataType.String || dataType == DataType.Boolean || dataType == DataType.Number) { dynValue.Add(key); } } foreach (var thing in dynValue) { table.Remove(thing); } script.script.DoString(input.text); errorMessage.SetActive(false); isScriptValid = true; } catch { Debug.LogWarning("Error on script! Will not apply"); errorMessage.SetActive(true); errorMessage.GetComponent <Animator> ().Play("Error Msg Shake"); isScriptValid = false; } if (isScriptValid) { var candidate = script.CreateCopy(); candidate.code = input.text; candidate.properties = ScriptUtility.ExtractProperties(script.script); entity.Script = candidate; eventTable.Invoke <IEntityContainer> ("OnScriptApply", entity); } }
private string GetStatusIsSubmittingMessage() { string statusIsSubmittingMessage = "null"; IResourceManager resourceManager = GetResourceManager(); if (_page.IsStatusIsSubmittingMessageEnabled) { string temp; if (string.IsNullOrEmpty(_page.StatusIsSubmittingMessage)) { temp = resourceManager.GetString(ResourceIdentifier.StatusIsSubmittingMessage); } else { temp = _page.StatusIsSubmittingMessage; } statusIsSubmittingMessage = "'" + ScriptUtility.EscapeClientScript(temp) + "'"; } return(statusIsSubmittingMessage); }
private string GetAbortMessage() { string abortMessage = "null"; IResourceManager resourceManager = GetResourceManager(); if (_page.IsAbortConfirmationEnabled) { string temp; if (string.IsNullOrEmpty(_page.AbortMessage)) { temp = resourceManager.GetString(ResourceIdentifier.AbortMessage); } else { temp = _page.AbortMessage; } abortMessage = "'" + ScriptUtility.EscapeClientScript(temp) + "'"; } return(abortMessage); }
public object Execute(ScriptUtility x, object input) { var name = input as string; var sess = context.ResolveNamed <IBrowsingSession>(name); if (sess == null) { throw new Exception("Session name '" + name + "' is not found"); } var browser = x.Exec <IBrowsingSession>("GetBrowsingSession") as StatefullBrowsingSessionWrapper; if (browser != null) { browser.Parent = sess; } else { x.TaskBag.Set(GetBrowsingSessionScriptCommand.SETTING_BROWSING_SESSION, sess); } return(null); }
private void PrepareScriptTemplates() { var scripts = scriptDatabase.Scripts; var options = new List <Dropdown.OptionData> (); for (var i = 0; i < scripts.Length; ++i) { options.Add(new Dropdown.OptionData { text = scripts[i].name }); } dropdownMenu.ClearOptions(); dropdownMenu.AddOptions(options); dropdownMenu.onValueChanged.AddListener(i => { var overwrite = scriptDatabase.Scripts[i]; var script = entity.Script; var isValidated = true; try { script.script.DoString(overwrite.script); } catch { Debug.LogWarning("Error on code!"); isValidated = false; } // If the code passes the Moonsharp text, finalize the script values if (isValidated) { script.code = overwrite.script; script.properties = ScriptUtility.ExtractProperties(script.script); entity.Script = script; eventTable?.Invoke <Tuple <ScriptProperty, Action <string> >[]> ("OnPropertiesInspect", CreateScriptProperties(script.properties, script.script)); eventTable?.Invoke <IEntityContainer, LuaScript> ("OnScriptEditorOpen", entity, entity.Script); } }); }
public static void PressScriptButtonOnHost() { Process p = ScriptUtility.FindProcess(); if (p == null) { return; } EnumChildWindows(p.MainWindowHandle, (IntPtr hwndChild, ref IntPtr lParam) => { var sb = new StringBuilder(50); GetWindowText(hwndChild, sb, 50); var str = sb.ToString(); if (!string.IsNullOrWhiteSpace(str) && str == "Script") { ClickButton(p.MainWindowHandle, hwndChild, hwndChild.ToInt32()); return(false); } return(true); }, 0); }
/// <summary> /// 文档页提交 /// </summary> /// <param name="context"></param> /// <param name="allhtml"></param> public static void PostArchive(CmsContext context, string allhtml) { var req = context.HttpContext.Request; var rsp = context.HttpContext.Response; //检测网站状态 if (!context.CheckSiteState()) { return; } string id = req.Form("id"); //文档编号 Member member; //会员 //提交留言 if (req.Form("action") == "comment") { id = req.Form("ce_id"); string view_name = req.Form("ce_nickname"); string content = req.Form("ce_content"); int memberID; member = UserState.Member.Current; //校验验证码 if (!CheckVerifyCode(req.Form("ce_verify_code"))) { rsp.WriteAsync( ScriptUtility.ParentClientScriptCall( "ce_tip(false,'验证码不正确!');jr.$('ce_verify_code').nextSibling.onclick();")); return; } else if (string.Compare(content, "请在这里输入评论内容", StringComparison.OrdinalIgnoreCase) == 0 || content.Length == 0) { rsp.WriteAsync(ScriptUtility.ParentClientScriptCall("ce_tip(false,'请输入内容!'); ")); return; } else if (content.Length > 200) { rsp.WriteAsync(ScriptUtility.ParentClientScriptCall("ce_tip(false,'评论内容长度不能大于200字!'); ")); return; } if (member == null) { if (string.IsNullOrEmpty(view_name)) { //会员未登录时,需指定名称 rsp.WriteAsync(ScriptUtility.ParentClientScriptCall("ce_tip(false,'不允许匿名评论!'); ")); return; } else { //补充用户 content = string.Format("(u:'{0}'){1}", view_name, content); memberID = 0; } } else { memberID = UserState.Member.Current.ID; } CmsLogic.Comment.InsertComment(id, memberID, WebCtx.Current.UserIpAddress, content); rsp.WriteAsync( ScriptUtility.ParentClientScriptCall( "ce_tip(false,'提交成功!'); setTimeout(function(){location.reload();},500);")); return; } }
public void SetUp() { Initialize(); _resourceSet = new BocBooleanValueResourceSet( "ResourceKey", "TrueIconUrl", "FalseIconUrl", "NullIconUrl", "DefaultTrueDescription", "DefaultFalseDescription", "DefaultNullDescription" ); _booleanValue = MockRepository.GenerateMock <IBocBooleanValue>(); var clientScriptManagerMock = MockRepository.GenerateMock <IClientScriptManager>(); _booleanValue.Stub(mock => mock.ClientID).Return(c_clientID); _booleanValue.Stub(stub => stub.ControlType).Return("BocBooleanValue"); _booleanValue.Stub(mock => mock.GetValueName()).Return(c_keyValueName); _booleanValue.Stub(mock => mock.GetDisplayValueName()).Return(c_displayValueName); string startupScriptKey = typeof(BocBooleanValueRenderer).FullName + "_Startup_" + _resourceSet.ResourceKey; _startupScript = string.Format( "BocBooleanValue_InitializeGlobals ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}');", _resourceSet.ResourceKey, "true", "false", "null", ScriptUtility.EscapeClientScript(_resourceSet.DefaultTrueDescription), ScriptUtility.EscapeClientScript(_resourceSet.DefaultFalseDescription), ScriptUtility.EscapeClientScript(_resourceSet.DefaultNullDescription), _resourceSet.TrueIconUrl, _resourceSet.FalseIconUrl, _resourceSet.NullIconUrl); clientScriptManagerMock.Expect(mock => mock.RegisterStartupScriptBlock(_booleanValue, typeof(BocBooleanValueRenderer), startupScriptKey, _startupScript)); clientScriptManagerMock.Stub(mock => mock.IsStartupScriptRegistered(Arg <Type> .Is.NotNull, Arg <string> .Is.NotNull)).Return(false); clientScriptManagerMock.Stub(mock => mock.GetPostBackEventReference(_booleanValue, string.Empty)).Return(c_postbackEventReference); _clickScript = "BocBooleanValue_SelectNextCheckboxValue ('ResourceKey', $(this).parent().children('a').children('img').first()[0], " + "$(this).parent().children('span').first()[0], $(this).parent().children('input').first()[0], false, " + "'" + c_trueDescription + "', '" + c_falseDescription + "', '" + c_nullDescription + "');return false;"; _keyDownScript = "BocBooleanValue_OnKeyDown (this);"; var pageStub = MockRepository.GenerateStub <IPage>(); pageStub.Stub(stub => stub.ClientScript).Return(clientScriptManagerMock); _booleanValue.Stub(mock => mock.Value).PropertyBehavior(); _booleanValue.Stub(mock => mock.IsDesignMode).Return(false); _booleanValue.Stub(mock => mock.ShowDescription).Return(true); _booleanValue.Stub(mock => mock.Page).Return(pageStub); _booleanValue.Stub(mock => mock.TrueDescription).Return(c_trueDescription); _booleanValue.Stub(mock => mock.FalseDescription).Return(c_falseDescription); _booleanValue.Stub(mock => mock.NullDescription).Return(c_nullDescription); _booleanValue.Stub(mock => mock.CssClass).PropertyBehavior(); StateBag stateBag = new StateBag(); _booleanValue.Stub(mock => mock.Attributes).Return(new AttributeCollection(stateBag)); _booleanValue.Stub(mock => mock.Style).Return(_booleanValue.Attributes.CssStyle); _booleanValue.Stub(mock => mock.LabelStyle).Return(new Style(stateBag)); _booleanValue.Stub(mock => mock.ControlStyle).Return(new Style(stateBag)); _booleanValue.Stub(stub => stub.CreateResourceSet()).Return(_resourceSet); }