Exemplo n.º 1
0
        private void InitTargetControl(IAttributeAccessor target)
        {
            if (target != null)
            {
                target.SetAttribute("onclick", string.Format("event.returnValue = false; if (!this.disabled) $find(\"{0}\")._doOperation();return false;", this.ClientID));
                target.SetAttribute("class", "enable");

                if (this.Visible)
                {
                    if (NeedToRender == false)
                    {
                        target.SetAttribute("disabled", "true");
                        target.SetAttribute("class", "disable");
                    }

                    if (target is IButtonControl)
                    {
                        IButtonControl button = (IButtonControl)target;

                        string buttonText = "退件";

                        if (WfClientContext.Current.CurrentActivity != null)
                        {
                            buttonText = WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("ReturnButtonName", "退件");
                        }

                        button.Text = button.Text.Replace("退件", HttpUtility.HtmlEncode(buttonText));
                    }
                }
                else
                {
                    ((Control)target).Visible = false;
                }
            }
        }
Exemplo n.º 2
0
        private static void InitTraceControlEntry(IAttributeAccessor target, string resourceID, string processID)
        {
            target.SetAttribute("resourceID", resourceID);
            target.SetAttribute("feature", GetWindowFeature().ToWindowFeatureClientString());

            ResourceUriSettings settings = ResourceUriSettings.GetConfig();

            string path = "/MCSWebApp/OACommonPages/AppTrace/appTraceViewer.aspx";

            if (settings.Paths.ContainsKey("appTrace"))
            {
                path = settings.Paths["appTrace"].Uri.ToString();
            }

            target.SetAttribute("href",
                                string.Format(path + "?resourceID={0}&processID={1}&{2}={3}",
                                              resourceID,
                                              processID,
                                              GlobalizationWebHelper.LanguageParameterName,
                                              HttpUtility.UrlEncode(GlobalizationWebHelper.GetCurrentHandlerLanguageID())));

            target.SetAttribute("target", "WfTrace" + resourceID.Replace("-", string.Empty));

            target.SetAttribute("onclick", "onWfTraceButtonClick()");
        }
        private void InitScript()
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SignInScriptOnload", Resource.changePasswordScript, true);

            Page.ClientScript.RegisterStartupScript(this.GetType(), "ChangePasswordScriptOnload",
                                                    string.Format("window.attachEvent(\"onload\", new Function(\"initControlsFocus('{0}', '{1}')\"));",
                                                                  PassportWebControlHelper.GetControlValue(this.TemplateControl, "signInName", "ClientID", string.Empty),
                                                                  PassportWebControlHelper.GetControlValue(this.TemplateControl, "oldPassword", "ClientID", string.Empty)), true);

            Control detailErrorMessageLink = PassportWebControlHelper.FindControlRecursively(this.TemplateControl, "detailErrorMessageLink");

            if (detailErrorMessageLink != null && detailErrorMessageLink is HtmlContainerControl)
            {
                ((HtmlContainerControl)detailErrorMessageLink).Attributes["onclick"] =
                    string.Format("doDetailErrorMessageClick(\"{0}\")",
                                  PassportWebControlHelper.GetControlValue(this.TemplateControl, "detailErrorMessage", "ClientID", string.Empty));
            }

            this.updateButton.OnClientClick = string.Format("beforeSubmit(\"{0}\", \"{1}\", \"{2}\", \"{3}\")",
                                                            PassportWebControlHelper.GetControlValue(this.TemplateControl, "signInName", "ClientID", string.Empty),
                                                            PassportWebControlHelper.GetControlValue(this.TemplateControl, "errorMessage", "ClientID", string.Empty),
                                                            PassportWebControlHelper.GetControlValue(this.TemplateControl, "newPassword", "ClientID", string.Empty),
                                                            PassportWebControlHelper.GetControlValue(this.TemplateControl, "confirmPassword", "ClientID", string.Empty));

            IAttributeAccessor backButton = (IAttributeAccessor)PassportWebControlHelper.FindControlRecursively(this.TemplateControl, "backButton");

            if (backButton != null)
            {
                backButton.SetAttribute("backUrl", this.GetBackUrl());
                backButton.SetAttribute("onclick", "onBackButtonClick();");
            }
        }
Exemplo n.º 4
0
        private void ApplyChangesToRuntimeChoice_helper(
            PropertyDescriptor property,
            Object sourceTarget,
            Object destTarget,
            String prefix
            )
        {
            Object oldValue = property.GetValue(sourceTarget);
            Object newValue = property.GetValue(destTarget);

            String propertyName = prefix + property.Name;

            if (property.Converter is ExpandableObjectConverter)
            {
                PropertyDescriptorCollection properties =
                    TypeDescriptor.GetProperties(
                        newValue.GetType()
                        );
                foreach (PropertyDescriptor embeddedProperty in properties)
                {
                    if (IsDeviceOverridable(embeddedProperty))
                    {
                        ApplyChangesToRuntimeChoice_helper(
                            embeddedProperty,
                            oldValue,
                            newValue,
                            propertyName + "-"
                            );
                    }
                }
            }
            else if (IsDeviceOverridable(property))
            {
                IAttributeAccessor overrides      = (IAttributeAccessor)_choice;
                String             oldValueString =
                    property.Converter.ConvertToInvariantString(
                        oldValue
                        );
                String newValueString =
                    property.Converter.ConvertToInvariantString(
                        newValue
                        );
                if (newValueString != oldValueString)
                {
                    overrides.SetAttribute(propertyName, newValueString);
                }
                else
                {
                    // Clear any previous values we might have loaded
                    overrides.SetAttribute(propertyName, null);
                }
            }
        }
Exemplo n.º 5
0
 private void InitTargetControl(IAttributeAccessor target)
 {
     if (NeedToRender == false)
     {
         target.SetAttribute("disabled", "true");
         target.SetAttribute("class", "disable");
         target.SetAttribute("style", "display:none");
     }
     else
     {
         target.SetAttribute("href", "#");
         target.SetAttribute("class", "enable");
     }
 }
Exemplo n.º 6
0
 private void InitTargetControl(IAttributeAccessor target)
 {
     if (NeedToRender == false)
     {
         target.SetAttribute("disabled", "true");
         target.SetAttribute("class", "disable");
         target.SetAttribute("onclick", "return false;");
     }
     else
     {
         InitCopyFormTargetControl(target);
         target.SetAttribute("class", "enable");
     }
 }
Exemplo n.º 7
0
        private void InitTargetControl(IAttributeAccessor target)
        {
            if (target != null)
            {
                target.SetAttribute("onclick", string.Format("event.returnValue = false; if (!this.disabled) $find(\"{0}\")._doOperation();return false;", this.ClientID));
                target.SetAttribute("class", "enable");

                if (NeedToRender == false)
                {
                    //target.SetAttribute("disabled", "true");
                    target.SetAttribute("class", "invisible");
                }
            }
        }
Exemplo n.º 8
0
        private void CopyChildAttributes()
        {
            // Copy the attribute values from the ChildControl to the GenericWebPart properties.
            IAttributeAccessor childAttributeAccessor = ChildControl as IAttributeAccessor;

            if (childAttributeAccessor != null)
            {
                base.AuthorizationFilter = childAttributeAccessor.GetAttribute("AuthorizationFilter");
                base.CatalogIconImageUrl = childAttributeAccessor.GetAttribute("CatalogIconImageUrl");
                base.Description         = childAttributeAccessor.GetAttribute("Description");

                string exportMode = childAttributeAccessor.GetAttribute("ExportMode");
                if (exportMode != null)
                {
                    base.ExportMode = (WebPartExportMode)(Util.GetEnumAttribute(
                                                              "ExportMode", exportMode, typeof(WebPartExportMode)));
                }

                // Don't need to check base.Subtitle, since we always want to use the Subtitle on the
                // ChildControl if it is present.  Also, the property is not settable on WebPart, so we
                // know that base.Subtitle will always be String.Empty.
                _subtitle = childAttributeAccessor.GetAttribute("Subtitle");

                base.Title             = childAttributeAccessor.GetAttribute("Title");
                base.TitleIconImageUrl = childAttributeAccessor.GetAttribute("TitleIconImageUrl");
                base.TitleUrl          = childAttributeAccessor.GetAttribute("TitleUrl");
            }

            // Remove all the attributes from the ChildControl, whether or not they were copied
            // to the GenericWebPart property.  We want to remove the attributes so they are not
            // rendered on the ChildControl.  (VSWhidbey 313674)
            WebControl childWebControl = ChildControl as WebControl;

            if (childWebControl != null)
            {
                // If the ChildControl is a WebControl, we want to completely remove the attributes.
                childWebControl.Attributes.Remove("AuthorizationFilter");
                childWebControl.Attributes.Remove("CatalogIconImageUrl");
                childWebControl.Attributes.Remove("Description");
                childWebControl.Attributes.Remove("ExportMode");
                childWebControl.Attributes.Remove("Subtitle");
                childWebControl.Attributes.Remove("Title");
                childWebControl.Attributes.Remove("TitleIconImageUrl");
                childWebControl.Attributes.Remove("TitleUrl");
            }
            else if (childAttributeAccessor != null)
            {
                // If the ChildControl is not a WebControl, we cannot remove the attributes, so we set
                // them to null instead.
                childAttributeAccessor.SetAttribute("AuthorizationFilter", null);
                childAttributeAccessor.SetAttribute("CatalogIconImageUrl", null);
                childAttributeAccessor.SetAttribute("Description", null);
                childAttributeAccessor.SetAttribute("ExportMode", null);
                childAttributeAccessor.SetAttribute("Subtitle", null);
                childAttributeAccessor.SetAttribute("Title", null);
                childAttributeAccessor.SetAttribute("TitleIconImageUrl", null);
                childAttributeAccessor.SetAttribute("TitleUrl", null);
            }
        }
        private void ControlOnDataBinding(object sender, EventArgs e)
        {
            ScriptTemplateControl scriptTemplateControl = ScriptTemplateControl.GetScriptTemplateControl(this);


            object evaluatedCode = scriptTemplateControl.EvaluateDataBindingExpression(
                this, Code.Trim(), Line);

            // Don't perform the assignment if we got back null/DBNull
            if (evaluatedCode != null && evaluatedCode != DBNull.Value)
            {
                if (_propInfo != null)
                {
                    // Convert the value to a string if needed
                    // TODO: more generic type conversion logic?
                    if (_propInfo.PropertyType == typeof(string) && !(evaluatedCode is string))
                    {
                        evaluatedCode = evaluatedCode.ToString();
                    }

                    _propInfo.SetValue(sender, evaluatedCode, null);
                }
                else
                {
                    _attributeAccessor.SetAttribute(AttributeName, evaluatedCode.ToString());
                }
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// 将属性添加到控件中
 /// </summary>
 /// <param name="accessor"></param>
 /// <param name="attributeName"></param>
 /// <param name="attributeValue"></param>
 public static void AddAttribute(IAttributeAccessor accessor, string attributeName, string attributeValue)
 {
     if (accessor != null && attributeName != null)
     {
         accessor.SetAttribute(attributeName, attributeValue);
     }
 }
Exemplo n.º 11
0
 private void SetCssAttribute(IAttributeAccessor aa, string cssName)
 {
     if (string.IsNullOrEmpty(aa.GetAttribute("class")))
     {
         aa.SetAttribute("class", cssName);
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Registers the static control.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="wrapper">The wrapper.</param>
        /// <param name="controlUid">The control uid.</param>
        public static void RegisterStaticControl(Control control, IAttributeAccessor wrapper, string controlUid)
        {
            if (!IsDynamicControl(control))
            {
                ControlSettings cs = PageDocument.Current.StaticNode.Controls[control.ID];
                if (cs == null)
                {
                    cs = new ControlSettings();
                    PageDocument.Current.StaticNode.Controls.Add(control.ID, cs);
                }
                else
                {
                    if (control is ICmsDataAdapter)
                    {
                        ControlSettings settings = PageDocument.Current.StaticNode.Controls[control.ID];
                        ((ICmsDataAdapter)control).SetParamInfo(settings);
                    }
                }

                // Since it is a static control, add a properties dialog
                if (CMSContext.Current.IsDesignMode && wrapper != null)
                {
                    string controlId = controlUid;
                    string command   = CmsPlaceHolder.CreatePropertiesCommand(control.ID, controlId);
                    if (!String.IsNullOrEmpty(command))
                    {
                        wrapper.SetAttribute("ondblclick", command);
                    }
                }
            }
        }
Exemplo n.º 13
0
        internal void PreRender()
        {
            if (!_bridgeTo.Visible)
            {
                return;
            }

            this.RenderCss();
            this.RenderMeta();

            IMobileControl     control    = _bridgeTo as IMobileControl;
            IAttributeAccessor attributes = _bridgeTo as IAttributeAccessor;

            if (attributes == null)              // we're dealing with an extender
            {
                attributes = control.TargetControl as IAttributeAccessor;
            }

            if (attributes == null)              // couldn't get the attributes accessor of the bridged control or it's target control. get the heck out.
            {
                return;
            }

            if (control.Role != null)
            {
                attributes.SetAttribute("data-role", control.Role);
            }

            var options = (from property in TypeDescriptor.GetProperties(_bridgeTo).OfType <PropertyDescriptor>()
                           let attribute = property.Attributes.OfType <WidgetOptionAttribute>().SingleOrDefault()
                                           where attribute != null
                                           select new { Option = attribute, Property = property }).ToList();

            // at the moment, there aren't any jQuery Mobile options which accept an array. if this changes, we need to test arrays here.

            foreach (var o in options)
            {
                object current = o.Property.GetValue(_bridgeTo);

                if ((current == null && o.Option.DefaultValue != null) || (current != null && !current.Equals(o.Option.DefaultValue)))
                {
                    attributes.SetAttribute(String.Concat("data-", o.Option.Name), current.ToString().ToLower());
                }
            }
        }
Exemplo n.º 14
0
        private void InitInnerControlAttributes(IAttributeAccessor target, Button innerBtn, string script, bool visible, bool changeText)
        {
            if (target != null)
            {
                string clickScript = string.Format("event.returnValue = false; {0}return false;",
                                                   string.IsNullOrEmpty(script) ? string.Empty : script + " ");

                target.SetAttribute("onclick", clickScript);

                ((Control)target).Visible = visible;
                target.SetAttribute("class", "enable");

                if (changeText)
                {
                    WfControlNextStep step = null;

                    if (NextSteps.Count > 0)
                    {
                        step = NextSteps[0];
                    }

                    if (step != null)
                    {
                        if (WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("MoveToButtonNameSameAsTransitionName", false))
                        {
                            if (step.TransitionDescriptor != null)
                            {
                                string btnName = step.TransitionDescriptor.Name;

                                if (string.IsNullOrEmpty(btnName))
                                {
                                    btnName = step.TransitionDescriptor.Description;
                                }

                                if (btnName.IsNotEmpty())
                                {
                                    string originalText = ((IButtonControl)target).Text;
                                    ((IButtonControl)target).Text = originalText.Replace("送签", HttpUtility.HtmlEncode(btnName));
                                }
                            }
                        }
                    }
                }
            }
        }
        private void InitShowDialogControl()
        {
            if (TargetControl != null)
            {
                IAttributeAccessor target = (IAttributeAccessor)TargetControl;

                if (NeedToRender == false)
                {
                    target.SetAttribute("disabled", "true");
                    target.SetAttribute("class", "disable");
                }
                else
                {
                    target.SetAttribute("class", "enable");
                    target.SetAttribute("onclick", string.Format("$find('{0}').open(); return false;", this.ClientID));
                }
            }
        }
Exemplo n.º 16
0
        public static void SetAttribute(IAttributeAccessor iaa, string key, string value, AttributeValuePosition csp, char separator)
        {
            string attribute = iaa.GetAttribute(key);

            if (string.IsNullOrEmpty(attribute))
            {
                iaa.SetAttribute(key, value);
            }
            else if (csp == AttributeValuePosition.First)
            {
                attribute = attribute.TrimStart(new char[] { separator });
                iaa.SetAttribute(key, value + separator + attribute);
            }
            else if (csp == AttributeValuePosition.Last)
            {
                iaa.SetAttribute(key, attribute.TrimEnd(new char[] { separator }) + separator + value);
            }
        }
Exemplo n.º 17
0
        private void InitProcessControl(IAttributeAccessor target)
        {
            if (target != null)
            {
                target.SetAttribute("onclick", string.Format("if (!event.srcElement.disabled) $find('{0}').doInternalOperation(); return false;", this.ClientID));

                SetTargetControlVisible((Control)target);
            }
        }
Exemplo n.º 18
0
        internal static void ApplyRolesFilterRecursive(Control c, IPrincipal currentUser, IVersionable versionableObject)
        {
            IAttributeAccessor attributeAccessor = c as IAttributeAccessor;

            if (attributeAccessor != null)
            {
                string             attribute          = attributeAccessor.GetAttribute("SetRoles");
                string             attribute2         = attributeAccessor.GetAttribute("DataBoundProperty");
                PropertyDefinition propertyDefinition = (versionableObject != null && !string.IsNullOrEmpty(attribute2)) ? versionableObject.ObjectSchema[attribute2] : null;
                if (propertyDefinition != null && !versionableObject.IsPropertyAccessible(propertyDefinition))
                {
                    Properties.HideControl(c, Properties.FindAssociatedLabel(c));
                }
                else if ((!string.IsNullOrEmpty(attribute) && !LoginUtil.IsInRoles(currentUser, attribute.Split(new char[]
                {
                    ','
                }))) || (!string.IsNullOrEmpty(attribute2) && versionableObject != null && versionableObject.IsReadOnly))
                {
                    string attribute3      = attributeAccessor.GetAttribute("NoRoleState");
                    Label  associatedLabel = Properties.FindAssociatedLabel(c);
                    if (!string.IsNullOrEmpty(attribute3) && NoRoleState.Hide == (NoRoleState)Enum.Parse(typeof(NoRoleState), attribute3))
                    {
                        Properties.HideControl(c, associatedLabel);
                    }
                    else
                    {
                        Properties.MakeControlRbacDisabled(c, associatedLabel);
                        if (!string.IsNullOrEmpty(attributeAccessor.GetAttribute("helpId")))
                        {
                            attributeAccessor.SetAttribute("helpId", string.Empty);
                        }
                        attributeAccessor.SetAttribute("MandatoryParam", null);
                    }
                }
            }
            if (c.HasControls())
            {
                foreach (object obj in c.Controls)
                {
                    Control c2 = (Control)obj;
                    Properties.ApplyRolesFilterRecursive(c2, currentUser, versionableObject);
                }
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 设置实现了IAttributeAccessor接口的控件的Attribute(保留原来同Key的Attribute)
        /// </summary>
        /// <param name="iaa">实现了IAttributeAccessor接口的控件</param>
        /// <param name="key">属性的名称</param>
        /// <param name="value">属性的值</param>
        /// <param name="csp">属性的值的位置</param>
        /// <param name="separator">属性分隔符</param>
        public static void SetAttribute(IAttributeAccessor iaa, string key, string value, AttributeValuePosition csp, char separator)
        {
            string tmp = iaa.GetAttribute(key);

            if (String.IsNullOrEmpty(tmp))
            {
                iaa.SetAttribute(key, value);
            }
            else if (csp == AttributeValuePosition.First)
            {
                tmp = tmp.TrimStart(separator);
                iaa.SetAttribute(key, value + separator + tmp);
            }
            else if (csp == AttributeValuePosition.Last)
            {
                tmp = tmp.TrimEnd(separator);
                iaa.SetAttribute(key, tmp + separator + value);
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// 将属性添加到控件中
 /// </summary>
 /// <param name="accessor">控件</param>
 /// <param name="attributes">属性集合</param>
 public static void AddAttributes(IAttributeAccessor accessor, StringDictionary attributes)
 {
     if (accessor != null && attributes != null)
     {
         foreach (string key in attributes.Keys)
         {
             accessor.SetAttribute(key, attributes[key]);
         }
     }
 }
Exemplo n.º 21
0
        // This has become pure decoration. I still think it's nice to have for developmental purposes/reference.
        public void SetWidgetNameOnTarget(IAttributeAccessor targetControl)
        {
            String attr = targetControl.GetAttribute("data-ui-widget") ?? String.Empty;

            if (!attr.Contains(Widget.WidgetName))
            {
                attr = String.IsNullOrEmpty(attr) ? Widget.WidgetName : String.Join(",", attr, Widget.WidgetName);

                targetControl.SetAttribute("data-ui-widget", attr);
            }
        }
Exemplo n.º 22
0
        private static void InitTraceControlEntry(IAttributeAccessor target, string resourceID, string processID)
        {
            target.SetAttribute("resourceID", resourceID);

            ResourceUriSettings settings = ResourceUriSettings.GetConfig();

            string path = "/MCSWebApp/OACommonPages/AppTrace/appTraceViewer.aspx";

            if (settings.Paths.ContainsKey("appTrace"))
            {
                path = settings.Paths["appTrace"].Uri.ToString();
            }

            target.SetAttribute("href",
                                string.Format(path + "?resourceID={0}&processID={1}",
                                              resourceID, processID));

            target.SetAttribute("target", "WfTrace" + resourceID.Replace("-", string.Empty));

            target.SetAttribute("onclick", "onWfTraceButtonClick()");
        }
Exemplo n.º 23
0
        /// <summary>
        /// 如果此控件不存在此属性,将属性添加到控件中
        /// </summary>
        /// <param name="accessor"></param>
        /// <param name="attributeName"></param>
        /// <param name="attributeValue"></param>
        public static void AddAttributeIfNotExists(IAttributeAccessor accessor, string attributeName, string attributeValue)
        {
            if (accessor == null || attributeName == null)
            {
                return;
            }

            if (accessor.GetAttribute(attributeName) == null)
            {
                accessor.SetAttribute(attributeName, attributeValue);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// 验证控件是否绑定了验证规则 如果绑定了, 加入到控件属性中
        /// </summary>
        /// <param name="c">继承了WebControl或是IAttributeAccessor接口的控件 </param>
        protected void Validator(IAttributeAccessor c)
        {
            string validator = Control.Params["validator"] ?? "";

            if (validator.Length > 0)
            {
                List <Dictionary <string, string> > list = JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(validator);
                foreach (Dictionary <string, string> t in list)
                {
                    if (t.ContainsKey("rule") && t.ContainsKey("val"))
                    {
                        c.SetAttribute(t["rule"], t["val"]);
                    }
                }
            }
            //匹配以前的验证方式
            if (Control.Required && c.GetAttribute("required") == null)
            {
                c.SetAttribute("required", "required");
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// 将属性添加到控件中
        /// </summary>
        /// <param name="accessor">控件</param>
        /// <param name="attributes">属性集合</param>
        public static void AddAttributes(IAttributeAccessor accessor, StringDictionary attributes)
        {
            if (accessor == null || attributes == null)
            {
                return;
            }

            foreach (string key in attributes.Keys)
            {
                accessor.SetAttribute(key, attributes[key]);
            }
        }
Exemplo n.º 26
0
        private void InitCopyFormTargetControl(IAttributeAccessor target)
        {
            string resourceID     = WfClientContext.Current.OriginalActivity.Process.ResourceID;
            string processDescKey = WfClientContext.Current.OriginalActivity.RootActivity.Descriptor.Process.Key;
            string appName        = WfClientContext.Current.OriginalActivity.Process.Descriptor.ApplicationName;
            string programName    = WfClientContext.Current.OriginalActivity.Process.Descriptor.ProgramName;

            target.SetAttribute("resourceID", resourceID);
            target.SetAttribute("feature", GetWindowFeature().ToWindowFeatureClientString());

            ResourceUriSettings settings = ResourceUriSettings.GetConfig();

            string path = WfClientContext.Current.EntryUri.ToString();

            target.SetAttribute("href",
                                string.Format(path + "?processDescKey={0}&sourceResourceID={1}&appName={2}&programName={3}",
                                              HttpUtility.UrlEncode(processDescKey),
                                              HttpUtility.UrlEncode(resourceID),
                                              HttpUtility.UrlEncode(appName),
                                              HttpUtility.UrlEncode(programName)));

            target.SetAttribute("target", "_blank" + resourceID.Replace("-", string.Empty));
            target.SetAttribute("onclick", "onOpenFormButtonClick();top.$HBRootNS.WfProcessControlBase.close();");
        }
Exemplo n.º 27
0
        /// <summary>
        /// 如果此控件不存在此属性,将属性添加到控件中
        /// </summary>
        /// <param name="accessor">控件</param>
        /// <param name="attributes">属性集合</param>
        public static void AddAttributesIfNotExists(IAttributeAccessor accessor, Dictionary <string, string> attributes)
        {
            if (accessor == null || attributes == null)
            {
                return;
            }

            foreach (var key in attributes.Keys)
            {
                if (accessor.GetAttribute(key) == null)
                {
                    accessor.SetAttribute(key, attributes[key]);
                }
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// 如果此控件不存在此属性,将属性添加到控件中
        /// </summary>
        /// <param name="accessor">控件</param>
        /// <param name="attributes">属性集合</param>
        public static void AddAttributesIfNotExists(IAttributeAccessor accessor, NameValueCollection attributes)
        {
            if (accessor == null || attributes == null)
            {
                return;
            }

            foreach (var key in attributes.AllKeys)
            {
                if (accessor.GetAttribute(key) == null)
                {
                    accessor.SetAttribute(key, attributes[key]);
                }
            }
        }
Exemplo n.º 29
0
        public static bool Attribute([NotNull] this IAttributeAccessor thisValue, string attribute, string value)
        {
            bool result;

            try
            {
                thisValue.SetAttribute(attribute, value);
                result = true;
            }
            catch
            {
                result = false;
            }

            return(result);
        }
Exemplo n.º 30
0
        private void CopyChildAttributes()
        {
            IAttributeAccessor childControl = this.ChildControl as IAttributeAccessor;

            if (childControl != null)
            {
                base.AuthorizationFilter = childControl.GetAttribute("AuthorizationFilter");
                base.CatalogIconImageUrl = childControl.GetAttribute("CatalogIconImageUrl");
                base.Description         = childControl.GetAttribute("Description");
                string attribute = childControl.GetAttribute("ExportMode");
                if (attribute != null)
                {
                    base.ExportMode = (WebPartExportMode)Util.GetEnumAttribute("ExportMode", attribute, typeof(WebPartExportMode));
                }
                this._subtitle         = childControl.GetAttribute("Subtitle");
                base.Title             = childControl.GetAttribute("Title");
                base.TitleIconImageUrl = childControl.GetAttribute("TitleIconImageUrl");
                base.TitleUrl          = childControl.GetAttribute("TitleUrl");
            }
            WebControl control = this.ChildControl as WebControl;

            if (control != null)
            {
                control.Attributes.Remove("AuthorizationFilter");
                control.Attributes.Remove("CatalogIconImageUrl");
                control.Attributes.Remove("Description");
                control.Attributes.Remove("ExportMode");
                control.Attributes.Remove("Subtitle");
                control.Attributes.Remove("Title");
                control.Attributes.Remove("TitleIconImageUrl");
                control.Attributes.Remove("TitleUrl");
            }
            else if (childControl != null)
            {
                childControl.SetAttribute("AuthorizationFilter", null);
                childControl.SetAttribute("CatalogIconImageUrl", null);
                childControl.SetAttribute("Description", null);
                childControl.SetAttribute("ExportMode", null);
                childControl.SetAttribute("Subtitle", null);
                childControl.SetAttribute("Title", null);
                childControl.SetAttribute("TitleIconImageUrl", null);
                childControl.SetAttribute("TitleUrl", null);
            }
        }
Exemplo n.º 31
0
        public void GetSetAttributes() {
            // Setup
            DummyMvcControl c = new DummyMvcControl();
            IAttributeAccessor attrAccessor = (IAttributeAccessor)c;
            IDictionary<string, string> attrs = c.Attributes;

            // Execute and Verify
            string value;
            value = attrAccessor.GetAttribute("xyz");
            Assert.IsNull(value);

            attrAccessor.SetAttribute("a1", "v1");
            value = attrAccessor.GetAttribute("a1");
            Assert.AreEqual<string>("v1", value);
            Assert.AreEqual<int>(1, attrs.Count);
            value = c.Attributes["a1"];
            Assert.AreEqual<string>("v1", value);
        }
Exemplo n.º 32
0
        private static void InitTraceControlEntry(IAttributeAccessor target, string resourceID, string processID)
        {
            target.SetAttribute("resourceID", resourceID);
            target.SetAttribute("feature", GetWindowFeature().ToWindowFeatureClientString());

            ResourceUriSettings settings = ResourceUriSettings.GetConfig();

            string path = "/MCSWebApp/OACommonPages/AppTrace/appTraceViewer.aspx";

            if (settings.Paths.ContainsKey("appTrace"))
                path = settings.Paths["appTrace"].Uri.ToString();

            target.SetAttribute("href",
                string.Format(path + "?resourceID={0}&processID={1}&{2}={3}",
                resourceID, 
                processID,
                GlobalizationWebHelper.LanguageParameterName,
                HttpUtility.UrlEncode(GlobalizationWebHelper.GetCurrentHandlerLanguageID())));

            target.SetAttribute("target", "WfTrace" + resourceID.Replace("-", string.Empty));

            target.SetAttribute("onclick", "onWfTraceButtonClick()");
        }
Exemplo n.º 33
0
 private void InitTargetControl(IAttributeAccessor target)
 {
     if (NeedToRender == false)
     {
         target.SetAttribute("disabled", "true");
         target.SetAttribute("class", "disable");
         target.SetAttribute("style", "display:none");
     }
     else
     {
         target.SetAttribute("href", "#");
         target.SetAttribute("class", "enable");
     }
 }
Exemplo n.º 34
0
        // This has become pure decoration. I still think it's nice to have for developmental purposes/reference.
        public void SetWidgetNameOnTarget(IAttributeAccessor targetControl)
        {
            String attr = targetControl.GetAttribute("data-ui-widget") ?? String.Empty;

            if(!attr.Contains(Widget.WidgetName)) {
                attr = String.IsNullOrEmpty(attr) ? Widget.WidgetName : String.Join(",", attr, Widget.WidgetName);

                targetControl.SetAttribute("data-ui-widget", attr);
            }
        }
 public static void RegisterCloseControl(IAttributeAccessor control, UpdatePanel updatepanel)
 {
     control.SetAttribute("uppHide", "true");
     control.SetAttribute("uppTarget", updatepanel.ClientID);
 }
Exemplo n.º 36
0
		private void InitTargetControl(IAttributeAccessor target)
		{
			if (target != null)
			{
				target.SetAttribute("onclick", string.Format("event.returnValue = false; if (!this.disabled) $find(\"{0}\")._doOperation();return false;", this.ClientID));
				target.SetAttribute("class", "enable");

				if (NeedToRender == false)
				{
					//target.SetAttribute("disabled", "true");
					target.SetAttribute("class", "invisible");
				}
			}
		}
Exemplo n.º 37
0
        private void InitTargetControl(IAttributeAccessor target)
        {
            if (target != null)
            {
                target.SetAttribute("onclick", string.Format("event.returnValue = false; if (!this.disabled) $find(\"{0}\")._doOperation();return false;", this.ClientID));
                target.SetAttribute("class", "enable");

                if (this.Visible)
                {
                    if (NeedToRender == false)
                    {
                        target.SetAttribute("disabled", "true");
                        target.SetAttribute("class", "disable");
                    }

                    if (target is IButtonControl)
                    {
                        IButtonControl button = (IButtonControl)target;

                        string buttonText = "退件";

                        if (WfClientContext.Current.CurrentActivity != null)
                            buttonText = WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("ReturnButtonName", "退件");

                        button.Text = button.Text.Replace("退件", HttpUtility.HtmlEncode(buttonText));
                    }
                }
                else
                {
                    ((Control)target).Visible = false;
                }
            }
        }
Exemplo n.º 38
0
		private void InitCopyFormTargetControl(IAttributeAccessor target)
		{
			string resourceID = WfClientContext.Current.OriginalActivity.Process.ResourceID;
			string processDescKey = WfClientContext.Current.OriginalActivity.RootActivity.Descriptor.Process.Key;
			string appName = WfClientContext.Current.OriginalActivity.Process.Descriptor.ApplicationName;
			string programName = WfClientContext.Current.OriginalActivity.Process.Descriptor.ProgramName;

			target.SetAttribute("resourceID", resourceID);
			target.SetAttribute("feature", GetWindowFeature().ToWindowFeatureClientString());

			ResourceUriSettings settings = ResourceUriSettings.GetConfig();

			string path = WfClientContext.Current.EntryUri.ToString();

			target.SetAttribute("href",
				string.Format(path + "?processDescKey={0}&sourceResourceID={1}&appName={2}&programName={3}",
				HttpUtility.UrlEncode(processDescKey),
				HttpUtility.UrlEncode(resourceID),
				HttpUtility.UrlEncode(appName),
				HttpUtility.UrlEncode(programName)));

			target.SetAttribute("target", "_blank" + resourceID.Replace("-", string.Empty));
			target.SetAttribute("onclick", "onOpenFormButtonClick();top.$HBRootNS.WfProcessControlBase.close();");
		}
Exemplo n.º 39
0
        private void InitBoundProperty(object obj, BoundPropertyEntry entry,
            ref DataBindingCollection dataBindings, ref IAttributeAccessor attributeAccessor) {

            string expressionPrefix = entry.ExpressionPrefix == null ? String.Empty : entry.ExpressionPrefix.Trim();
            // If we're in the designer, add the bound properties to the collections
            if (InDesigner) {
                if (String.IsNullOrEmpty(expressionPrefix)) {
                    if (dataBindings == null && obj is IDataBindingsAccessor) {
                        dataBindings = ((IDataBindingsAccessor)obj).DataBindings;
                    }

                    dataBindings.Add(new DataBinding(entry.Name, entry.Type, entry.Expression.Trim()));
                }
                else {
                    if (obj is IExpressionsAccessor) {
                        string expression = entry.Expression == null ? String.Empty : entry.Expression.Trim();
                        ((IExpressionsAccessor)obj).Expressions.Add(new ExpressionBinding(entry.Name, entry.Type, expressionPrefix, expression, entry.Generated, entry.ParsedExpressionData));
                    }
                }
            }
            // If we're in no-compile mode, set the values for expressions that support evaluate
            else {
                if (!String.IsNullOrEmpty(expressionPrefix)) {
                    ExpressionBuilder eb = entry.ExpressionBuilder;
                    Debug.Assert(eb != null, "Did not expect null expression builder");
                    if (eb.SupportsEvaluate) {
                        string name = entry.Name;

                        // DevDiv Bugs 160497: Create the expression context with whatever information we have.
                        // We used to always use the TemplateControl one, but sometimes it's null, so we should
                        // fall back to the VirtualPath one if we can.
                        ExpressionBuilderContext expressionContext;
                        if (TemplateControl != null) {
                            expressionContext = new ExpressionBuilderContext(TemplateControl);
                        }
                        else {
                            expressionContext = new ExpressionBuilderContext(VirtualPath);
                        }
                        object value = eb.EvaluateExpression(obj, entry,
                            entry.ParsedExpressionData, expressionContext);

                        if (entry.UseSetAttribute) {
                            if (attributeAccessor == null) {
                                Debug.Assert(obj is IAttributeAccessor);
                                attributeAccessor = (IAttributeAccessor)obj;
                            }

                            attributeAccessor.SetAttribute(name, value.ToString());
                        }
                        else {
                            try {
                                PropertyMapper.SetMappedPropertyValue(obj, name, value, InDesigner);
                            }
                            catch (Exception e) {
                                throw new HttpException(SR.GetString(SR.Cannot_set_property, entry.ExpressionPrefix + ":" + entry.Expression, name), e);
                            }
                        }
                    }
                    else {
                        Debug.Fail("Got a ExpressionBuilder that does not support Evaluate in a non-compiled page");
                    }
                }
                else {
                    // no-compile Bind property handling
                    ((Control)obj).DataBinding += new EventHandler(DataBindingMethod);
                }
            }
        }
Exemplo n.º 40
0
		private void InitTargetControl(IAttributeAccessor target)
		{
			if (NeedToRender == false)
			{
				target.SetAttribute("disabled", "true");
				target.SetAttribute("class", "disable");
				target.SetAttribute("onclick", "return false;");
			}
			else
			{
				InitCopyFormTargetControl(target);
				target.SetAttribute("class", "enable");
			}
		}
 private void InitBoundProperty(object obj, BoundPropertyEntry entry, ref DataBindingCollection dataBindings, ref IAttributeAccessor attributeAccessor)
 {
     string str = (entry.ExpressionPrefix == null) ? string.Empty : entry.ExpressionPrefix.Trim();
     if (this.InDesigner)
     {
         if (string.IsNullOrEmpty(str))
         {
             if ((dataBindings == null) && (obj is IDataBindingsAccessor))
             {
                 dataBindings = ((IDataBindingsAccessor) obj).DataBindings;
             }
             dataBindings.Add(new DataBinding(entry.Name, entry.Type, entry.Expression.Trim()));
         }
         else if (obj is IExpressionsAccessor)
         {
             string expression = (entry.Expression == null) ? string.Empty : entry.Expression.Trim();
             ((IExpressionsAccessor) obj).Expressions.Add(new ExpressionBinding(entry.Name, entry.Type, str, expression, entry.Generated, entry.ParsedExpressionData));
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(str))
         {
             ExpressionBuilderContext context;
             ExpressionBuilder expressionBuilder = entry.ExpressionBuilder;
             if (!expressionBuilder.SupportsEvaluate)
             {
                 return;
             }
             string name = entry.Name;
             if (this.TemplateControl != null)
             {
                 context = new ExpressionBuilderContext(this.TemplateControl);
             }
             else
             {
                 context = new ExpressionBuilderContext(this.VirtualPath);
             }
             object obj2 = expressionBuilder.EvaluateExpression(obj, entry, entry.ParsedExpressionData, context);
             if (entry.UseSetAttribute)
             {
                 if (attributeAccessor == null)
                 {
                     attributeAccessor = (IAttributeAccessor) obj;
                 }
                 attributeAccessor.SetAttribute(name, obj2.ToString());
                 return;
             }
             try
             {
                 PropertyMapper.SetMappedPropertyValue(obj, name, obj2, this.InDesigner);
                 return;
             }
             catch (Exception exception)
             {
                 throw new HttpException(System.Web.SR.GetString("Cannot_set_property", new object[] { entry.ExpressionPrefix + ":" + entry.Expression, name }), exception);
             }
         }
         ((Control) obj).DataBinding += new EventHandler(this.DataBindingMethod);
     }
 }
		private void SetCssAttribute(IAttributeAccessor aa, string cssName)
		{
			if (string.IsNullOrEmpty(aa.GetAttribute("class")))
				aa.SetAttribute("class", cssName);
		}
Exemplo n.º 43
0
		private void InitInnerControlAttributes(IAttributeAccessor target, Button innerBtn, string script, bool visible, bool changeText)
		{
			if (target != null)
			{
				string clickScript = string.Format("event.returnValue = false; {0}return false;",
					string.IsNullOrEmpty(script) ? string.Empty : script + " ");

				target.SetAttribute("onclick", clickScript);

				((Control)target).Visible = visible;
				target.SetAttribute("class", "enable");

				if (changeText)
				{
					WfControlNextStep step = null;

					if (NextSteps.Count > 0)
						step = NextSteps[0];

					if (step != null)
					{
						if (WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("MoveToButtonNameSameAsTransitionName", false))
						{
							if (step.TransitionDescriptor != null)
							{
								string btnName = step.TransitionDescriptor.Name;

								if (string.IsNullOrEmpty(btnName))
									btnName = step.TransitionDescriptor.Description;

								if (btnName.IsNotEmpty())
								{
									string originalText = ((IButtonControl)target).Text;
									((IButtonControl)target).Text = originalText.Replace("送签", HttpUtility.HtmlEncode(btnName));
								}
							}
						}
					}
				}
			}
		}
Exemplo n.º 44
0
 public void SetWidgetNameOnTarget(IAttributeAccessor targetControl)
 {
     targetControl.SetAttribute("data-ui-widget", Widget.WidgetName);
 }
Exemplo n.º 45
0
		private void InitProcessControl(IAttributeAccessor target)
		{
			if (target != null)
			{
				target.SetAttribute("onclick", string.Format("if (!event.srcElement.disabled) $find('{0}').doInternalOperation(); return false;", this.ClientID));

				SetTargetControlVisible((Control)target);
			}
		}
 private void SetOnClick(IAttributeAccessor ctrl, string value)
 {
     if (ctrl == null) return;
     ctrl.SetAttribute("onclick", value);
 }