/// <summary>
		/// Copies the elements of the specified <see cref="ModuleInfo">ModuleInfo</see> array to the end of the collection.
		/// </summary>
		/// <param name="value">An array of type <see cref="ModuleInfo">ModuleInfo</see> containing the Components to add to the collection.</param>
		public void AddRange(ModuleInfo[] value) 
		{
			for (int i = 0;	(i < value.Length); i = (i + 1)) 
			{
				this.Add(value[i]);
			}
		}
Beispiel #2
0
		/// <summary>
		/// 更新指定的Module信息
		/// </summary>
		/// <param name="moduleInfo"></param>
		/// <returns></returns>
		public bool UpdateModule(ModuleInfo moduleInfo)
		{
			IDataParameter[] parms =
			{
				DbHelper.MakeInParam("@moduleid", (DbType)SqlDbType.Int, 4, moduleInfo.ModuleID),
				DbHelper.MakeInParam("@tabid", (DbType)SqlDbType.Int, 4, moduleInfo.TabID),
				DbHelper.MakeInParam("@uid", (DbType)SqlDbType.Int, 4, moduleInfo.Uid),
				DbHelper.MakeInParam("@moduledefid", (DbType)SqlDbType.Int, 4, moduleInfo.ModuleDefID),
				DbHelper.MakeInParam("@panename", (DbType)SqlDbType.VarChar, 10, moduleInfo.PaneName),
				DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int, 4, moduleInfo.DisplayOrder),
				DbHelper.MakeInParam("@userpref", (DbType)SqlDbType.NVarChar, 4000, moduleInfo.UserPref),
				DbHelper.MakeInParam("@val", (DbType)SqlDbType.TinyInt, 1, moduleInfo.Val),
				DbHelper.MakeInParam("@moduleurl", (DbType)SqlDbType.VarChar, 255, moduleInfo.ModuleUrl),
				DbHelper.MakeInParam("@moduletype", (DbType)SqlDbType.TinyInt, 2, moduleInfo.ModuleType)
			};

			string sql = string.Format(@"UPDATE [{0}spacemodules] SET [tabid]=@tabid, [moduledefid]=@moduledefid, [panename]=@panename, [displayorder]=@displayorder,[userpref]=@userpref,[val]=@val, moduleurl=@moduleurl, moduletype=@moduletype WHERE [moduleid]=@moduleid AND [uid]=@uid", BaseConfigs.GetTablePrefix);

			return RunExecuteSql(sql, parms);
		}
Beispiel #3
0
		/// <summary>
		/// 添加Module至数据库
		/// </summary>
		/// <param name="moduleInfo"></param>
		/// <returns></returns>
		public bool AddModule(ModuleInfo moduleInfo)
		{
			IDataParameter[] parms =
			{
				DbHelper.MakeInParam("@moduleid", (DbType)SqlDbType.Int, 4, moduleInfo.ModuleID),
				DbHelper.MakeInParam("@tabid", (DbType)SqlDbType.Int, 4, moduleInfo.TabID),
				DbHelper.MakeInParam("@uid", (DbType)SqlDbType.Int, 4, moduleInfo.Uid),
				DbHelper.MakeInParam("@moduledefid", (DbType)SqlDbType.Int, 4, moduleInfo.ModuleDefID),
				DbHelper.MakeInParam("@panename", (DbType)SqlDbType.VarChar, 10, moduleInfo.PaneName),
				DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int, 4, moduleInfo.DisplayOrder),
				DbHelper.MakeInParam("@userpref", (DbType)SqlDbType.NVarChar, 4000, moduleInfo.UserPref),
				DbHelper.MakeInParam("@val", (DbType)SqlDbType.TinyInt, 1, moduleInfo.Val),
				DbHelper.MakeInParam("@moduleurl", (DbType)SqlDbType.VarChar, 255, moduleInfo.ModuleUrl),
				DbHelper.MakeInParam("@moduletype", (DbType)SqlDbType.TinyInt, 2, moduleInfo.ModuleType)
			};

			string sql = string.Format(@"INSERT INTO [{0}spacemodules]([moduleid], [tabid], [uid], [moduledefid], [panename], [displayorder], [userpref], [val], [moduleurl], [moduletype]) VALUES(@moduleid, @tabid, @uid, @moduledefid, @panename, @displayorder, @userpref, @val, @moduleurl, @moduletype)", BaseConfigs.GetTablePrefix);

			return RunExecuteSql(sql, parms);
		}
		/// <summary>
		/// Copies the collection Components to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index.
		/// </summary>
		/// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param>
		/// <param name="index">The index of the array at which to begin inserting.</param>
		public void CopyTo(ModuleInfo[] array, int index) 
		{
			this.List.CopyTo(array, index);
		}
		/// <summary>
		/// Gets a value indicating whether the collection contains the specified <see cref="ModuleInfoCollection">ModuleInfoCollection</see>.
		/// </summary>
		/// <param name="value">The <see cref="ModuleInfoCollection">ModuleInfoCollection</see> to search for in the collection.</param>
		/// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
		public bool Contains(ModuleInfo value) 
		{
			return this.List.Contains(value);
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="ModuleInfoCollection">ModuleInfoCollection</see> class containing the specified array of <see cref="ModuleInfo">ModuleInfo</see> Components.
		/// </summary>
		/// <param name="value">An array of <see cref="ModuleInfo">ModuleInfo</see> Components with which to initialize the collection. </param>
		public ModuleInfoCollection(ModuleInfo[] value)
		{
			this.AddRange(value);
		}
		public int Add(ModuleInfo value) 
		{
			return this.List.Add(value);
		}
		public void Insert(int index, ModuleInfo value)	
		{
			List.Insert(index, value);
		}
		public void Remove(ModuleInfo value) 
		{
			List.Remove(value);
		}
Beispiel #10
0
        /// <summary>
        /// 更新模块
        /// </summary>
        /// <param name="moduleInfo">模块对象</param>
		public static void UpdateModule(ModuleInfo moduleInfo)
		{
			Space.Data.DbProvider.GetInstance().UpdateModule(moduleInfo);
		}
		/// <summary>
		/// Gets the index in the collection of the specified <see cref="ModuleInfoCollection">ModuleInfoCollection</see>, if it exists in the collection.
		/// </summary>
		/// <param name="value">The <see cref="ModuleInfoCollection">ModuleInfoCollection</see> to locate in the collection.</param>
		/// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
		public int IndexOf(ModuleInfo value) 
		{
			return this.List.IndexOf(value);
		}
Beispiel #12
0
		/// <summary>
		/// 添加本地模块
		/// </summary>
		/// <param name="moduleUrl">模块地址</param>
		/// <param name="userId">用户Id</param>
		/// <param name="tabId">标签Id</param>
		/// <param name="col">列Id</param>
		public static void AddLocalModule(string moduleUrl, int userId, int tabId, int col)
		{
			TabInfo tab = Spaces.GetTabById(tabId, userId);
			if (tab == null || tab.UserID != userId)
				return;

            int moduledef = 0;
			if (moduleUrl.StartsWith("builtin_"))
				moduledef = Spaces.GetModuleDefIdByUrl(moduleUrl);

            ModuleType mt = Utilities.ModuleValidate.ValidateModuleType(moduleUrl);
			if (moduledef > 0)
				mt = ModuleType.Local;

			if (mt == ModuleType.Remote || mt == ModuleType.Error)
				return;

            ModuleInfo moduleinfo = new ModuleInfo();
			moduleinfo.ModuleID = Spaces.GetNewModuleId(userId);
			moduleinfo.DisplayOrder = 0;
			moduleinfo.ModuleDefID = moduledef;
			moduleinfo.ModuleType = mt;
			moduleinfo.ModuleUrl = moduleUrl;
			moduleinfo.PaneName = "pane" + col;
			moduleinfo.TabID = tabId;
			moduleinfo.Uid = userId;
			moduleinfo.Val = 6;

			Spaces.AddModule(moduleinfo);
		}
Beispiel #13
0
        /// <summary>
        /// 添加模块
        /// </summary>
        /// <param name="moduleinfo">模块对象</param>
		public static void AddModule(ModuleInfo moduleinfo)
		{
			Space.Data.DbProvider.GetInstance().AddModule(moduleinfo);
		}
Beispiel #14
0
		/// <summary>
		/// 设置模块实例
		/// </summary>
		/// <param name="moduleInfo">模块对象</param>
		/// <returns>模块基类</returns>
		public static ModuleBase SetModuleBase(ModuleInfo moduleInfo)
		{
			ModuleBase desktopModule = new ModuleBase();
			if (moduleInfo.ModuleDefID > 0)
			{
				// 重构,是否需要缓存?
				ModuleDefInfo moduleDef = Spaces.GetModuleDefById(moduleInfo.ModuleDefID);
				try
				{
					Type type = Type.GetType(moduleDef.BussinessController, false, true);
					desktopModule = (ModuleBase)Activator.CreateInstance(type);
				}
				catch(Exception ex)
				{
					string a = ex.Message;
				}
				desktopModule.ModuleDef = moduleDef;//貌似不需要,重构?

			}
			desktopModule.Module = moduleInfo;
			desktopModule.ModuleID = moduleInfo.ModuleID;
			if (moduleInfo.ModuleType == ModuleType.Local)
			{
				string path = BaseConfigs.GetForumPath + "space/modules/" + moduleInfo.ModuleUrl;
				string modulefilepath = Utils.GetMapPath(path);
				try
				{

					desktopModule.UserPrefCollection = ModuleXmlHelper.LoadUserPrefs(modulefilepath);
					desktopModule.ModulePref = ModuleXmlHelper.LoadModulePref(modulefilepath);
					desktopModule.ModuleContent = ModuleXmlHelper.LoadContent(modulefilepath);
				}
				catch (Exception ex)
				{
                    desktopModule.UserPrefCollection = new UserPrefCollection<UserPref>();
					desktopModule.ModulePref = new ModulePref();
					desktopModule.ModuleContent = new ModuleContent();
					desktopModule.ModuleContent.ContentHtml = ex.Message;
					desktopModule.ModuleContent.Type = ModuleContentType.HtmlInline;
				}
				if (desktopModule.UserPrefCollection == null)
                    desktopModule.UserPrefCollection = new UserPrefCollection<UserPref>();
				if (desktopModule.ModulePref == null)
					desktopModule.ModulePref = new ModulePref();

				if (desktopModule.ModuleContent == null)
				{
					desktopModule.ModuleContent = new ModuleContent();
					desktopModule.ModuleContent.ContentHtml = "模块" + path + "不存在";
					desktopModule.ModuleContent.Type = ModuleContentType.HtmlInline;
				}
			}	
			return desktopModule;
		}
Beispiel #15
0
		private void AddModuleAction()
		{
			int tabid = DNTRequest.GetQueryInt("t", 0);
			int tabModuleCount = Spaces.GetModulesCountByTabId(tabid, this.userid);

			if (tabModuleCount > 20)
				return;
			string url = Utils.UrlDecode(DNTRequest.GetQueryString("x"));
            Random random = new Random();
            int col = random.Next(1, 5);//DNTRequest.GetQueryInt("col", 1);

			TabInfo tab = Spaces.GetTabById(tabid, this.userid);
			if (tab == null || tab.UserID != this.userid)
			{
				return;
			}
			int moduledef = 0;
			if (url.StartsWith("builtin_"))
			{
				moduledef = Spaces.GetModuleDefIdByUrl(url);
			}
			ModuleType mt = Utilities.ModuleValidate.ValidateModuleType(url);
			if (moduledef > 0)
			{
				mt = ModuleType.Local;
			}
			ModuleInfo moduleinfo = new ModuleInfo();
			moduleinfo.ModuleID = Spaces.GetNewModuleId(this.userid);
			moduleinfo.DisplayOrder = 0;
			moduleinfo.ModuleDefID = moduledef;
			moduleinfo.ModuleType = mt;
			moduleinfo.ModuleUrl = url;
			moduleinfo.PaneName = "pane" + col;
			moduleinfo.TabID = tabid;
			moduleinfo.Uid = this.userid;
			moduleinfo.Val = 6;

			Spaces.AddModule(moduleinfo);

		}
Beispiel #16
0
		private static ModuleInfo GetModuleEntity(IDataReader reader)
		{
			ModuleInfo mi = new ModuleInfo();
			mi.ModuleID = TypeConverter.ObjectToInt(reader["moduleid"]);
			mi.TabID = TypeConverter.ObjectToInt(reader["tabid"]);
			mi.Uid = TypeConverter.ObjectToInt(reader["uid"], -1);
			mi.ModuleDefID = TypeConverter.ObjectToInt(reader["moduledefid"]);
			mi.PaneName = reader["panename"].ToString();
			mi.DisplayOrder = TypeConverter.ObjectToInt(reader["displayorder"]);
			mi.UserPref = reader["userpref"].ToString();
			mi.Val = TypeConverter.ObjectToInt(reader["val"]);
			mi.ModuleUrl = reader["moduleurl"].ToString();
			int moduletype = TypeConverter.ObjectToInt(reader["moduletype"], 4);
			if (moduletype < 1 || moduletype > 4)
				moduletype = 4;

            mi.ModuleType = (ModuleType)moduletype;
			return mi;
		}