Esempio n. 1
0
        /// <summary>
        /// Opens the URL sync.
        /// </summary>
        /// <param name="url">url to open</param>
        /// <param name="data">The data to be posted.</param>
        /// <param name="eventhandler">The event handler.</param>
        /// <param name="userToken">The user token.</param>
        public void OpenUrl(string url, string data, UploadDataCompletedEventHandler eventhandler, object userToken)
        {
            if (url.StartsWith("http", StringComparison.OrdinalIgnoreCase) == false)
            {
                url = string.Format("http://{0}", url);
            }
            UrlDelegate dc = OpenUrl;

            Asynchronous.FireAndForget(dc, url, data, eventhandler, userToken, false);
        }
Esempio n. 2
0
        /// <summary>
        /// This method is for sending out html emails asynchronously, the
        /// e-mail addresses are added into a thread-pool by the program and processed.
        /// Useful if your application need to send mass e-mails.
        /// IMPORTANT: "Async" Property for your web page has to be turned on to use this Method.
        /// </summary>
        /// <param name="message">E-mail message you want to send</param>
        /// <param name="smtpserver">smtp server for this e-mail</param>
        /// <remarks>This asynchronous method are logged at Windows EventLog (Application category) if any error. </remarks>
        public void SendEmail(MailMessage message, string smtpserver)
        {
            if (string.IsNullOrEmpty(smtpserver))
            {
                smtpserver = GridConfig.Get("WGSMTPSERVER", (string)null);
            }

            SendMailMessageDelegate dc = SendMailMessage;

            Asynchronous.FireAndForget(dc, message, smtpserver);
        }
Esempio n. 3
0
        /// <summary>
        /// Buttons the specified grid.
        /// </summary>
        /// <param name="grid">The grid.</param>
        /// <param name="buttonValue">The button value.</param>
        /// <param name="eventName">Name of the event upon post back/callback</param>
        /// <param name="eventparameters">Parameters for the event</param>
        /// <param name="htmlButtonType">HTML button type.</param>
        /// <returns></returns>
        internal static string Button(Grid grid, string buttonValue, string eventName, string[] eventparameters,
                                      string htmlButtonType)
        {
            if (grid.Page == null)
            {
                return(string.Empty);
            }
            string        param = String.Join("!", eventparameters);
            StringBuilder s     = new StringBuilder();

            s.AppendFormat("<input type=\"{0}\" value=\"{1}\"", htmlButtonType, buttonValue);
            string link = grid.EnableCallBack ? Asynchronous.GetCallbackEventReference(grid, string.Format("{0}!{1}", eventName, param), false, string.Empty,
                                                                                       string.Empty) : grid.Page.ClientScript.GetPostBackEventReference(grid, string.Format("{0}!{1}", eventName, param));

            s.AppendFormat(" onclick=\"{0};\"/>", link);
            return(s.ToString());
        }
Esempio n. 4
0
        /// <summary>
        /// Anchors the specified grid.
        /// </summary>
        /// <param name="grid">The grid.</param>
        /// <param name="text">The text.</param>
        /// <param name="eventName">Name of the event upon post back/callback</param>
        /// <param name="eventparameters">Parameters for the event</param>
        /// <param name="confirmText">The confirm text.</param>
        /// <param name="alternativeText">The alternative text.</param>
        /// <param name="css">The CSS class.</param>
        /// <returns></returns>
        /// <param name="elementid">Client identifier for the element</param>
        /// <param name="isButton"></param>
        internal static string Anchor(Grid grid, string text, string eventName, string[] eventparameters, string confirmText,
                                      string alternativeText, string css, string elementid, bool isButton)
        {
            StringBuilder content = new StringBuilder();

            string param = eventparameters != null?String.Join("!", eventparameters) : string.Empty;

            string eventScript = null;

            if (grid.Page != null)
            {
                if (!grid.EnableCallBack)
                {
                    PostBackOptions linkpostback = new PostBackOptions(grid, string.Format("{0}!{1}", eventName, param))
                    {
                        ClientSubmit = true
                    };
                    eventScript = grid.Page.ClientScript.GetPostBackEventReference(linkpostback);
                }
                else
                {
                    string command = string.Format("{0}!{1}", eventName, param);
                    eventScript =
                        Asynchronous.GetCallbackEventReference(grid, command, false, string.Empty,
                                                               string.Empty);
                }
            }

            if (grid.IsUsingJQueryUICSSFramework && isButton)
            {
                css = "SlaveGridClick" == eventName
                          ? "ui-button wgbutton ui-state-default ui-corner-top " + css
                          : "ui-button wgbutton ui-state-default ui-corner-all " + css;
                content.Append("<button");
            }
            else
            {
                content.Append("<a");
            }

            if (string.IsNullOrEmpty(alternativeText) == false)
            {
                content.AppendFormat(" title=\"{0}\"", alternativeText);
            }
            if (string.IsNullOrEmpty(css) == false)
            {
                content.AppendFormat(" class=\"{0}\"", css);
            }

            if (string.IsNullOrEmpty(elementid) == false)
            {
                content.AppendFormat(" id=\"{0}\"", elementid);
            }

            content.Append(" href=\"#\" onclick=\"");
            if (string.IsNullOrEmpty(confirmText) == false)
            {
                content.AppendFormat("if (wgconfirm('{0}',this,'{1}'))", confirmText.Replace("'", "\\'"), grid.DialogTitle.Replace("'", "\\'"));
            }

            if (grid.IsUsingJQueryUICSSFramework && isButton)
            {
                content.AppendFormat("{0};return false;\">{1}</button>", eventScript, text);
            }
            else
            {
                content.AppendFormat("{0};return false;\">{1}</a>", eventScript, text);
            }
            return(content.ToString());
        }