Beispiel #1
0
        public ActionResult Product()
        {
            ViewBag.Title = "کپی محصول";

            AjaxSettings settings = new AjaxSettings
            {
                Url = "/Copy/SearchProducts"
            };

            return(View(model: settings));
        }
Beispiel #2
0
        public ActionResult Index(int keywordID)
        {
            ViewBag.Title = "مدیریت " + Keywords.GetByID(keywordID).Title;

            AjaxSettings settings = new AjaxSettings
            {
                Url = "/ProductKeywords/Search"
            };

            return(View(model: settings));
        }
Beispiel #3
0
        public ActionResult Index(int homeBoxID)
        {
            ViewBag.Title = "مدیریت " + HomeBoxes.GetByID(homeBoxID).Title;

            AjaxSettings settings = new AjaxSettings
            {
                Url = "/HomeBoxProducts/Search"
            };

            return(View(model: settings));
        }
Beispiel #4
0
        public void SendCommand(string command, object data)
        {
            var ajaxSettings = new AjaxSettings
            {
                url      = serverAddress + command,
                cache    = false,
                data     = data,
                dataType = "",
                // success = Success
            };

            jQuery.ajax(ajaxSettings);
        }
Beispiel #5
0
        public ActionResult Index(int productID)
        {
            string title = Products.GetTitleByID(productID);

            ViewBag.Title     = "محصولات مرتبط با کالای « " + title + " » ";
            ViewBag.ProductID = productID;

            AjaxSettings settings = new AjaxSettings
            {
                Url = "/RelatedProducts/Search"
            };

            return(View(model: settings));
        }
        public ActionResult Index(int productID)
        {
            string title = Products.GetTitleByID(productID);

            ViewBag.Title     = "لوازم جانبی کالای « " + title + " » ";
            ViewBag.ProductID = productID;

            AjaxSettings settings = new AjaxSettings
            {
                Url = "/ProductAccessories/Search"
            };

            return(View(model: settings));
        }
        public ActionResult Index(int productID)
        {
            string title = Products.GetTitleByID(productID);

            ViewBag.Title     = "هدایای « " + title + " » ";
            ViewBag.ProductID = productID;

            AjaxSettings settings = new AjaxSettings
            {
                Url = "/ProductGifts/Search"
            };

            return(View(model: settings));
        }
        public ActionResult Index(int articleID)
        {
            string title = Articles.GetTitleByID(articleID).Title;

            ViewBag.Title     = "مطالب مرتبط با مقاله « " + title + " » ";
            ViewBag.ArticleID = articleID;

            AjaxSettings settings = new AjaxSettings
            {
                Url = "/RelatedArticles/Search"
            };

            return(View(model: settings));
        }
Beispiel #9
0
        public object SendQuery(string query, object data)
        {
            var ajaxSettings = new AjaxSettings
            {
                url      = serverAddress + query,
                cache    = false,
                data     = data,
                dataType = "",
                // success = Success
            };

            jQuery.ajax(ajaxSettings);

            return("");
        }
Beispiel #10
0
        /// <summary>
        /// Adds the converter.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="converter">The converter.</param>
        /// <param name="replace">if set to <c>true</c> [replace].</param>
        internal static void AddConverter(AjaxSettings settings, IJavaScriptConverter converter, bool replace)
        {
            Type t;

            for (int i = 0; i < converter.SerializableTypes.Length; i++)
            {
                t = converter.SerializableTypes[i];

                if (settings.SerializableConverters.ContainsKey(t))
                {
                    if (replace)
                        settings.SerializableConverters[t] = converter;
                    continue;
                }

                settings.SerializableConverters.Add(t, converter);
            }

            for (int i = 0; i < converter.DeserializableTypes.Length; i++)
            {
                t = converter.DeserializableTypes[i];

                if (settings.DeserializableConverters.ContainsKey(t))
                {
                    if (replace)
                        settings.DeserializableConverters[t] = converter;
                    continue;
                }

                settings.DeserializableConverters.Add(t, converter);
            }
        }
Beispiel #11
0
 /// <summary>
 /// Adds the converter.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="converter">The converter.</param>
 internal static void AddConverter(AjaxSettings settings, IJavaScriptConverter converter)
 {
     AddConverter(settings, converter, false);
 }
Beispiel #12
0
        /// <summary>
        /// Removes the converter.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="t">The t.</param>
        internal static void RemoveConverter(AjaxSettings settings, Type t)
        {
            Type key;
            bool removed = false;
            IEnumerator m = settings.SerializableConverters.Keys.GetEnumerator();

            while (!removed && m.MoveNext())
            {
                key = (Type)m.Current;
                if (settings.SerializableConverters[key].GetType() == t)
                {
                    settings.SerializableConverters.Remove(key);
                    removed = true;
                }
            }

            removed = false;
            m = settings.DeserializableConverters.Keys.GetEnumerator();

            while (!removed && m.MoveNext())
            {
                key = (Type)m.Current;
                if (settings.DeserializableConverters[key].GetType() == t)
                {
                    settings.DeserializableConverters.Remove(key);
                    removed = true;
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// Adds the default converter.
        /// </summary>
        /// <param name="settings">The settings.</param>
        internal static void AddDefaultConverter(AjaxSettings settings)
        {
            #region Default Converters

            AddConverter(settings, new StringConverter());
            AddConverter(settings, new PrimitiveConverter());
            AddConverter(settings, new GuidConverter());
            AddConverter(settings, new ExceptionConverter());
            AddConverter(settings, new EnumConverter());
            AddConverter(settings, new DecimalConverter());

            AddConverter(settings, new NameValueCollectionConverter());

            AddConverter(settings, new DateTimeConverter());

            AddConverter(settings, new DataSetConverter());
            AddConverter(settings, new DataTableConverter());
            AddConverter(settings, new DataViewConverter());

            AddConverter(settings, new IJavaScriptObjectConverter());

#if(NET20)
            AddConverter(settings, new ProfileBaseConverter());
#endif

            AddConverter(settings, new IDictionaryConverter());
            AddConverter(settings, new IListConverter());
            AddConverter(settings, new HashtableConverter());
            AddConverter(settings, new IEnumerableConverter());

            AddConverter(settings, new DataRowConverter());
            AddConverter(settings, new HtmlControlConverter());

            #endregion
        }
        /// <summary>
        /// Creates a configuration section handler.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="configContext">Configuration context object.</param>
        /// <param name="section"></param>
        /// <returns>The created section handler object.</returns>
		public object Create(object parent, object configContext, System.Xml.XmlNode section)
		{
			AjaxSettings settings = new AjaxSettings();
			Utility.AddDefaultConverter(settings);

			foreach(XmlNode n in section.ChildNodes)
			{
#if(!JSONLIB)
				if(n.Name == "coreScript")
				{
					if(n.InnerText != null && n.InnerText.Length > 0) 
					{
						settings.ScriptReplacements.Add("core", n.InnerText);
					}
				}
				else if(n.Name == "scriptReplacements")
				{
					foreach(XmlNode file in n.SelectNodes("file"))
					{
						string name = "";
						string path = "";

						if(file.Attributes["name"] != null)
						{
							name = file.Attributes["name"].InnerText;
							if(file.Attributes["path"] != null) path = file.Attributes["path"].InnerText;

							if(settings.ScriptReplacements.ContainsKey(name))
								settings.ScriptReplacements[name] = path;
							else
								settings.ScriptReplacements.Add(name, path);
						}
					}
				}
				else if(n.Name == "urlNamespaceMappings")
				{
					settings.OnlyAllowTypesInList = n.SelectSingleNode("@allowListOnly[.='true']") != null;
					settings.UseAssemblyQualifiedName = n.SelectSingleNode("@useAssemblyQualifiedName[.='true']") != null;

					XmlNode ns, url;

					foreach(XmlNode e in n.SelectNodes("add"))
					{
						ns = e.SelectSingleNode("@type");
						url = e.SelectSingleNode("@path");
#if(NET20)
						if(ns == null || String.IsNullOrEmpty(ns.InnerText) || url == null || String.IsNullOrEmpty(url.InnerText))
#else
						if(ns == null || ns.InnerText.Length == 0 || url == null || url.InnerText.Length == 0)
#endif
							continue;

						if(settings.UrlNamespaceMappings.Contains(url.InnerText))
							throw new Exception("Duplicate namespace mapping '" + url.InnerText + "'.");

						settings.UrlNamespaceMappings.Add(url.InnerText, ns.InnerText);
					}
				}
				else if (n.Name == "providers" || n.Name == "provider")
				{
					foreach (XmlNode p in n.ChildNodes)
					{
						if (p.Name == "securityProvider")
						{
							if (p.SelectSingleNode("@type") != null)
							{
								string securityProviderType = p.SelectSingleNode("@type").InnerText;

								AjaxSecurity sec = new AjaxSecurity(securityProviderType);

								if (sec.Init())
								{
									settings.Security = sec;
								}
							}
						}
						else if (p.Name == "typeJavaScriptProvider")
						{
							if (p.SelectSingleNode("@type") != null)
							{
								settings.TypeJavaScriptProvider = p.SelectSingleNode("@type").InnerText;
							}
						}
					}
				}
				else if (n.Name == "token")
				{
					// settings.TokenEnabled = n.SelectSingleNode("@enabled") != null && n.SelectSingleNode("@enabled").InnerText == "true";
					settings.TokenSitePassword = n.SelectSingleNode("@sitePassword") != null ? n.SelectSingleNode("@sitePassword").InnerText : settings.TokenSitePassword;
				}
				else if (n.Name == "debug")
				{
					if (n.SelectSingleNode("@enabled") != null && n.SelectSingleNode("@enabled").InnerText == "true")
						settings.DebugEnabled = true;
				}
				else if (n.Name == "oldStyle" || n.Name == "configuration")
				{
					foreach (XmlNode sn in n.ChildNodes)
					{
						switch (sn.Name)
						{
							case "useSimpleObjectNaming":
								settings.UseSimpleObjectNaming = true;
								break;

							default:
								settings.OldStyle.Add(sn.Name);
								break;
						}
					}
				}
				else
#endif
					if (n.Name == "jsonConverters")
					{
						if (n.SelectSingleNode("@includeTypeProperty") != null && n.SelectSingleNode("@includeTypeProperty").InnerText == "true")
						{
							settings.IncludeTypeProperty = true;
						}

						XmlNodeList jsonConverters = n.SelectNodes("add");

						foreach (XmlNode j in jsonConverters)
						{
							XmlNode t = j.SelectSingleNode("@type");

							if (t == null)
								continue;

							Type type = Type.GetType(t.InnerText);

							if (type == null)
							{
								// throw new ArgumentException("Could not find type " + t.InnerText + ".");
								continue;
							}

							if (!typeof(IJavaScriptConverter).IsAssignableFrom(type))
							{
								// throw new ArgumentException("Type " + t.InnerText + " does not inherit from JavaScriptObjectConverter.");
								continue;
							}

							StringDictionary d = new StringDictionary();
							foreach (XmlAttribute a in j.Attributes)
							{
								if (d.ContainsKey(a.Name)) continue;
								d.Add(a.Name, a.Value);
							}

							IJavaScriptConverter c = (IJavaScriptConverter)Activator.CreateInstance(type);
							c.Initialize(d);

							Utility.AddConverter(settings, c, true);
						}


						jsonConverters = n.SelectNodes("remove");

						foreach (XmlNode j in jsonConverters)
						{
							XmlNode t = j.SelectSingleNode("@type");

							if (t == null)
								continue;

							Type type = Type.GetType(t.InnerText);

							if (type == null)
							{
								// throw new ArgumentException("Could not find type " + t.InnerText + ".");
								continue;
							}

							Utility.RemoveConverter(settings, type);
						}
					}
			}

			return settings;
		}
        /// <summary>
        /// Creates a configuration section handler.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="configContext">Configuration context object.</param>
        /// <param name="section"></param>
        /// <returns>The created section handler object.</returns>
		public object Create(object parent, object configContext, System.Xml.XmlNode section)
		{
			AjaxSettings settings = new AjaxSettings();
			Utility.AddDefaultConverter(settings);

			foreach(XmlNode n in section.ChildNodes)
			{
#if(!JSONLIB)
				if(n.Name == "urlClassMappings")
				{
					settings.UseAssemblyQualifiedName = n.SelectSingleNode("@useAssemblyQualifiedName[.='true']") != null;

					XmlNode ns, url;

					foreach(XmlNode e in n.SelectNodes("add"))
					{
						ns = e.SelectSingleNode("@type");
						url = e.SelectSingleNode("@path");
#if(NET20)
						if(ns == null || String.IsNullOrEmpty(ns.InnerText) || url == null || String.IsNullOrEmpty(url.InnerText))
#else
						if(ns == null || ns.InnerText.Length == 0 || url == null || url.InnerText.Length == 0)
#endif
							continue;

						if(settings.UrlClassMappings.Contains(url.InnerText))
							throw new Exception("Duplicate namespace mapping '" + url.InnerText + "'.");

						settings.UrlClassMappings.Add(url.InnerText, ns.InnerText);
					}
				}
                else if (n.Name == "security")
                {
                    if (n.SelectSingleNode("@provider") != null)
                    {
                        string securityProviderType = n.SelectSingleNode("@provider").InnerText;

                        AjaxSecurity sec = new AjaxSecurity(securityProviderType);

                        if (sec.Init())
                        {
                            settings.Security = sec;
                        }
                    }
                    if (n.SelectSingleNode("@token") != null)
                    {
                        // settings.TokenEnabled = n.SelectSingleNode("@enabled") != null && n.SelectSingleNode("@enabled").InnerText == "true";
                        settings.TokenSitePassword = n.SelectSingleNode("@token") != null ? n.SelectSingleNode("@token").InnerText : settings.TokenSitePassword;
                    }
                }
                else if (n.Name == "typeJavaScriptGenerator")
                {
                    if (n.SelectSingleNode("@type") != null)
                    {
                        settings.TypeJavaScriptGenerator = n.SelectSingleNode("@type").InnerText;
                    }
                }
                else if (n.Name == "debug")
                {
                    if (n.SelectSingleNode("@enabled") != null && n.SelectSingleNode("@enabled").InnerText == "true")
                        settings.DebugEnabled = true;
                }
                else
#endif
                    if (n.Name == "jsonConverters")
                    {
                        if (n.SelectSingleNode("@includeTypeProperty") != null && n.SelectSingleNode("@includeTypeProperty").InnerText == "true")
                        {
                            settings.IncludeTypeProperty = true;
                        }
                        if (n.SelectSingleNode("@useSimpleObjectNaming") != null && n.SelectSingleNode("@useSimpleObjectNaming").InnerText == "true")
                        {
                            settings.UseSimpleObjectNaming = true;
                        }

                        XmlNodeList jsonConverters = n.SelectNodes("add");

                        foreach (XmlNode j in jsonConverters)
                        {
                            XmlNode t = j.SelectSingleNode("@type");

                            if (t == null)
                                continue;

                            Type type = Type.GetType(t.InnerText);

                            if (type == null)
                            {
                                // throw new ArgumentException("Could not find type " + t.InnerText + ".");
                                continue;
                            }

                            if (!typeof(JavaScriptConverter).IsAssignableFrom(type))
                            {
                                // throw new ArgumentException("Type " + t.InnerText + " does not inherit from JavaScriptObjectConverter.");
                                continue;
                            }

                            StringDictionary d = new StringDictionary();
                            foreach (XmlAttribute a in j.Attributes)
                            {
                                if (d.ContainsKey(a.Name)) continue;
                                d.Add(a.Name, a.Value);
                            }

                            JavaScriptConverter c = (JavaScriptConverter)Activator.CreateInstance(type);
                            c.Initialize(d);

                            Utility.AddConverter(settings, c, true);
                        }


                        jsonConverters = n.SelectNodes("remove");

                        foreach (XmlNode j in jsonConverters)
                        {
                            XmlNode t = j.SelectSingleNode("@type");

                            if (t == null)
                                continue;

                            Type type = Type.GetType(t.InnerText);

                            if (type == null)
                            {
                                // throw new ArgumentException("Could not find type " + t.InnerText + ".");
                                continue;
                            }

                            Utility.RemoveConverter(settings, type);
                        }
                    }
			}

			return settings;
		}
Beispiel #16
0
 public AjaxPromise(string url, AjaxSettings settings) : this()
 {
     _url      = url;
     _settings = settings;
 }